Commit 9c9ee2d80dd6bd78b72f8dad8aee8bd97aa49ec9

Authored by 刘宏哲
1 parent 1d68c048

feat(purchase): add currency code and actual price

import 'dart:math';
import 'package:doublefeel_flutter/core/constants/membership.dart';
import 'package:doublefeel_flutter/core/logging/app_logger.dart';
import 'package:doublefeel_flutter/core/network/api/pay_api.dart';
import 'package:doublefeel_flutter/core/network/api/vip_api.dart';
import 'package:doublefeel_flutter/core/result/app_result.dart';
... ... @@ -92,6 +88,12 @@ class MembershipOfferController extends GetxController {
trackMap['product_type'] = yearlyProduct.value?.appleId;
trackMap['price'] = yearlyProduct.value?.price;
final appleInfo = yearlyProductAppleInfo.value;
trackMap['currency_code'] = appleInfo?.currencyCode ?? '';
var actualPrice = appleInfo?.price ?? 0;
trackMap['actual_price'] = actualPrice > 0 ? actualPrice : (appleInfo?.originPrice ?? 0);
ta.track(
'success_doublefeel_pay_order',
properties: trackMap,
... ...
... ... @@ -31,6 +31,7 @@ class PurchasePlan {
this.product,
this.appleProductId,
this.actualPrice,
this.appleProductInfo,
});
final String title;
... ... @@ -42,6 +43,8 @@ class PurchasePlan {
/// Real product price in cents, based on the Chinese price baseline.
final int? actualPrice;
final AppleProductInfo? appleProductInfo;
}
class PurchaseController extends GetxController {
... ... @@ -349,6 +352,7 @@ class PurchaseController extends GetxController {
product: product,
appleProductId: product.appleId,
actualPrice: appleInfo == null ? null : _actualPrice(appleInfo),
appleProductInfo: appleInfo,
);
}
... ... @@ -441,12 +445,18 @@ class PurchaseController extends GetxController {
void _trackSuccessPayOrder() {
final plan = _selectedPlan;
final appleInfo = plan?.appleProductInfo;
final actualPrice = appleInfo?.price ?? 0;
ta.track(
'success_doublefeel_pay_order',
properties: {
..._baseAnalyticsProperties,
'product_type': plan?.product?.appleId,
'price': plan?.product?.price,
'currency_code': appleInfo?.currencyCode ?? '',
'actual_price': actualPrice > 0
? actualPrice
: (appleInfo?.originPrice ?? 0),
},
);
}
... ...