Showing
4 changed files
with
31 additions
and
2 deletions
| @@ -3,6 +3,7 @@ import 'dart:convert'; | @@ -3,6 +3,7 @@ import 'dart:convert'; | ||
| 3 | import 'package:doublefeel_flutter/core/config/app_environment_config.dart'; | 3 | import 'package:doublefeel_flutter/core/config/app_environment_config.dart'; |
| 4 | import 'package:doublefeel_flutter/core/constants/app_const.dart'; | 4 | import 'package:doublefeel_flutter/core/constants/app_const.dart'; |
| 5 | import 'package:doublefeel_flutter/core/logging/app_logger.dart'; | 5 | import 'package:doublefeel_flutter/core/logging/app_logger.dart'; |
| 6 | +import 'package:doublefeel_flutter/core/services/thinking_data_service.dart'; | ||
| 6 | import 'package:doublefeel_flutter/data/models/local/user_preferences.dart'; | 7 | import 'package:doublefeel_flutter/data/models/local/user_preferences.dart'; |
| 7 | import 'package:doublefeel_flutter/l10n/gen/app_localizations.dart'; | 8 | import 'package:doublefeel_flutter/l10n/gen/app_localizations.dart'; |
| 8 | import 'package:doublefeel_flutter/pigeon/platform_api.g.dart'; | 9 | import 'package:doublefeel_flutter/pigeon/platform_api.g.dart'; |
| @@ -119,6 +120,12 @@ class LoginController extends GetxController { | @@ -119,6 +120,12 @@ class LoginController extends GetxController { | ||
| 119 | super.onClose(); | 120 | super.onClose(); |
| 120 | } | 121 | } |
| 121 | 122 | ||
| 123 | + @override | ||
| 124 | + void onReady() { | ||
| 125 | + super.onReady(); | ||
| 126 | + ta.track('enter_doublefeel_welcome_page'); | ||
| 127 | + } | ||
| 128 | + | ||
| 122 | String get cleanPhone => phoneInput.value.replaceAll(' ', ''); | 129 | String get cleanPhone => phoneInput.value.replaceAll(' ', ''); |
| 123 | 130 | ||
| 124 | bool get canRequestCode => | 131 | bool get canRequestCode => |
| 1 | import 'dart:math' as math; | 1 | import 'dart:math' as math; |
| 2 | 2 | ||
| 3 | import 'package:doublefeel_flutter/core/config/app_environment_config.dart'; | 3 | import 'package:doublefeel_flutter/core/config/app_environment_config.dart'; |
| 4 | +import 'package:doublefeel_flutter/core/services/thinking_data_service.dart'; | ||
| 4 | import 'package:doublefeel_flutter/core/theme/app_theme.dart'; | 5 | import 'package:doublefeel_flutter/core/theme/app_theme.dart'; |
| 5 | import 'package:doublefeel_flutter/data/local/local_storage.dart'; | 6 | import 'package:doublefeel_flutter/data/local/local_storage.dart'; |
| 6 | import 'package:doublefeel_flutter/l10n/l10n_extensions.dart'; | 7 | import 'package:doublefeel_flutter/l10n/l10n_extensions.dart'; |
| 1 | +import 'package:get/get.dart'; | ||
| 2 | +import 'package:thinking_analytics/td_analytics.dart'; | ||
| 3 | + | ||
| 1 | import '../config/app_environment_config.dart'; | 4 | import '../config/app_environment_config.dart'; |
| 2 | import '../constants/app_const.dart'; | 5 | import '../constants/app_const.dart'; |
| 3 | import '../logging/app_logger.dart'; | 6 | import '../logging/app_logger.dart'; |
| @@ -13,17 +16,35 @@ class ThinkingDataService { | @@ -13,17 +16,35 @@ class ThinkingDataService { | ||
| 13 | 'ThinkingData init appId=${_environment.thinkingDataAppId} ' | 16 | 'ThinkingData init appId=${_environment.thinkingDataAppId} ' |
| 14 | 'url=${AppConst.thinkingDataServerUrl}', | 17 | 'url=${AppConst.thinkingDataServerUrl}', |
| 15 | ); | 18 | ); |
| 19 | + TDAnalytics.init( | ||
| 20 | + _environment.thinkingDataAppId, AppConst.thinkingDataServerUrl); | ||
| 16 | } | 21 | } |
| 17 | 22 | ||
| 18 | - void login(int userId) { | 23 | + void login(String userId) { |
| 19 | AppLogger.i('ThinkingData login $userId'); | 24 | AppLogger.i('ThinkingData login $userId'); |
| 25 | + TDAnalytics.login(userId); | ||
| 20 | } | 26 | } |
| 21 | 27 | ||
| 22 | void logout() { | 28 | void logout() { |
| 23 | AppLogger.i('ThinkingData logout'); | 29 | AppLogger.i('ThinkingData logout'); |
| 30 | + TDAnalytics.logout(); | ||
| 24 | } | 31 | } |
| 25 | 32 | ||
| 26 | void userSet(Map<String, Object?> properties) { | 33 | void userSet(Map<String, Object?> properties) { |
| 27 | AppLogger.i('ThinkingData userSet $properties'); | 34 | AppLogger.i('ThinkingData userSet $properties'); |
| 35 | + TDAnalytics.setSuperProperties(properties); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + void timeEvent(String s) { | ||
| 39 | + TDAnalytics.timeEvent(s); | ||
| 28 | } | 40 | } |
| 41 | + | ||
| 42 | + void track(String s, {Map<String, dynamic>? properties}) { | ||
| 43 | + TDAnalytics.track(s, properties: properties); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + static ThinkingDataService get instance => Get.find<ThinkingDataService>(); | ||
| 29 | } | 47 | } |
| 48 | + | ||
| 49 | +/// Global shorthand to access [ThinkingDataService] | ||
| 50 | +ThinkingDataService get ta => Get.find<ThinkingDataService>(); |
| @@ -48,7 +48,7 @@ class UserStateService { | @@ -48,7 +48,7 @@ class UserStateService { | ||
| 48 | void _trackLogin() { | 48 | void _trackLogin() { |
| 49 | final uid = _userPrefs.preferences.value.meUserInfo?.id ?? 0; | 49 | final uid = _userPrefs.preferences.value.meUserInfo?.id ?? 0; |
| 50 | if (uid > 0) { | 50 | if (uid > 0) { |
| 51 | - _thinkingDataService.login(uid); | 51 | + _thinkingDataService.login(uid.toString()); |
| 52 | } | 52 | } |
| 53 | } | 53 | } |
| 54 | 54 |
-
Please register or login to post a comment