Commit 9c9ee2d80dd6bd78b72f8dad8aee8bd97aa49ec9
1 parent
1d68c048
feat(purchase): add currency code and actual price
Showing
2 changed files
with
16 additions
and
4 deletions
| 1 | -import 'dart:math'; | ||
| 2 | - | ||
| 3 | -import 'package:doublefeel_flutter/core/constants/membership.dart'; | ||
| 4 | -import 'package:doublefeel_flutter/core/logging/app_logger.dart'; | ||
| 5 | import 'package:doublefeel_flutter/core/network/api/pay_api.dart'; | 1 | import 'package:doublefeel_flutter/core/network/api/pay_api.dart'; |
| 6 | import 'package:doublefeel_flutter/core/network/api/vip_api.dart'; | 2 | import 'package:doublefeel_flutter/core/network/api/vip_api.dart'; |
| 7 | import 'package:doublefeel_flutter/core/result/app_result.dart'; | 3 | import 'package:doublefeel_flutter/core/result/app_result.dart'; |
| @@ -92,6 +88,12 @@ class MembershipOfferController extends GetxController { | @@ -92,6 +88,12 @@ class MembershipOfferController extends GetxController { | ||
| 92 | trackMap['product_type'] = yearlyProduct.value?.appleId; | 88 | trackMap['product_type'] = yearlyProduct.value?.appleId; |
| 93 | trackMap['price'] = yearlyProduct.value?.price; | 89 | trackMap['price'] = yearlyProduct.value?.price; |
| 94 | 90 | ||
| 91 | + final appleInfo = yearlyProductAppleInfo.value; | ||
| 92 | + trackMap['currency_code'] = appleInfo?.currencyCode ?? ''; | ||
| 93 | + | ||
| 94 | + var actualPrice = appleInfo?.price ?? 0; | ||
| 95 | + trackMap['actual_price'] = actualPrice > 0 ? actualPrice : (appleInfo?.originPrice ?? 0); | ||
| 96 | + | ||
| 95 | ta.track( | 97 | ta.track( |
| 96 | 'success_doublefeel_pay_order', | 98 | 'success_doublefeel_pay_order', |
| 97 | properties: trackMap, | 99 | properties: trackMap, |
| @@ -31,6 +31,7 @@ class PurchasePlan { | @@ -31,6 +31,7 @@ class PurchasePlan { | ||
| 31 | this.product, | 31 | this.product, |
| 32 | this.appleProductId, | 32 | this.appleProductId, |
| 33 | this.actualPrice, | 33 | this.actualPrice, |
| 34 | + this.appleProductInfo, | ||
| 34 | }); | 35 | }); |
| 35 | 36 | ||
| 36 | final String title; | 37 | final String title; |
| @@ -42,6 +43,8 @@ class PurchasePlan { | @@ -42,6 +43,8 @@ class PurchasePlan { | ||
| 42 | 43 | ||
| 43 | /// Real product price in cents, based on the Chinese price baseline. | 44 | /// Real product price in cents, based on the Chinese price baseline. |
| 44 | final int? actualPrice; | 45 | final int? actualPrice; |
| 46 | + | ||
| 47 | + final AppleProductInfo? appleProductInfo; | ||
| 45 | } | 48 | } |
| 46 | 49 | ||
| 47 | class PurchaseController extends GetxController { | 50 | class PurchaseController extends GetxController { |
| @@ -349,6 +352,7 @@ class PurchaseController extends GetxController { | @@ -349,6 +352,7 @@ class PurchaseController extends GetxController { | ||
| 349 | product: product, | 352 | product: product, |
| 350 | appleProductId: product.appleId, | 353 | appleProductId: product.appleId, |
| 351 | actualPrice: appleInfo == null ? null : _actualPrice(appleInfo), | 354 | actualPrice: appleInfo == null ? null : _actualPrice(appleInfo), |
| 355 | + appleProductInfo: appleInfo, | ||
| 352 | ); | 356 | ); |
| 353 | } | 357 | } |
| 354 | 358 | ||
| @@ -441,12 +445,18 @@ class PurchaseController extends GetxController { | @@ -441,12 +445,18 @@ class PurchaseController extends GetxController { | ||
| 441 | 445 | ||
| 442 | void _trackSuccessPayOrder() { | 446 | void _trackSuccessPayOrder() { |
| 443 | final plan = _selectedPlan; | 447 | final plan = _selectedPlan; |
| 448 | + final appleInfo = plan?.appleProductInfo; | ||
| 449 | + final actualPrice = appleInfo?.price ?? 0; | ||
| 444 | ta.track( | 450 | ta.track( |
| 445 | 'success_doublefeel_pay_order', | 451 | 'success_doublefeel_pay_order', |
| 446 | properties: { | 452 | properties: { |
| 447 | ..._baseAnalyticsProperties, | 453 | ..._baseAnalyticsProperties, |
| 448 | 'product_type': plan?.product?.appleId, | 454 | 'product_type': plan?.product?.appleId, |
| 449 | 'price': plan?.product?.price, | 455 | 'price': plan?.product?.price, |
| 456 | + 'currency_code': appleInfo?.currencyCode ?? '', | ||
| 457 | + 'actual_price': actualPrice > 0 | ||
| 458 | + ? actualPrice | ||
| 459 | + : (appleInfo?.originPrice ?? 0), | ||
| 450 | }, | 460 | }, |
| 451 | ); | 461 | ); |
| 452 | } | 462 | } |
-
Please register or login to post a comment