@@ -6,7 +6,7 @@ import 'package:flutter/services.dart';
66// This is the official Flutter Plugin for Sensors Analytics.
77class SensorsAnalyticsFlutterPlugin {
88 static const MethodChannel _channel =
9- const MethodChannel ('sensors_analytics_flutter_plugin' );
9+ const MethodChannel ('sensors_analytics_flutter_plugin' );
1010
1111 static Future <String > get getDistinctId async {
1212 return await _channel.invokeMethod ('getDistinctId' );
@@ -23,6 +23,7 @@ class SensorsAnalyticsFlutterPlugin {
2323 /// SensorsAnalyticsFlutterPlugin.track('eventname',{'key1':'value1','key2':'value2'});
2424 ///
2525 static void track (String eventName, Map <String , dynamic >? properties) {
26+ properties = properties == null ? null : {...properties};
2627 _convertDateTime (properties);
2728 List <dynamic > params = [eventName, properties];
2829 _channel.invokeMethod ('track' , params);
@@ -38,8 +39,9 @@ class SensorsAnalyticsFlutterPlugin {
3839 /// 使用示例:
3940 /// SensorsAnalyticsFlutterPlugin.trackInstallation('AppInstall',{'key1':'value1','key2':'value2'});
4041 ///
41- static void trackInstallation (String eventName,
42- Map <String , dynamic >? properties) {
42+ static void trackInstallation (
43+ String eventName, Map <String , dynamic >? properties) {
44+ properties = properties == null ? null : {...properties};
4345 _convertDateTime (properties);
4446 List <dynamic > params = [eventName, properties];
4547 _channel.invokeMethod ('trackInstallation' , params);
@@ -89,7 +91,9 @@ class SensorsAnalyticsFlutterPlugin {
8991 /// 使用示例:(计时器事件名称 viewTimer )
9092 /// SensorsAnalyticsFlutterPlugin.trackTimerEnd('viewTimer',{});
9193 ///
92- static void trackTimerEnd (String eventName, Map <String , dynamic >? properties) {
94+ static void trackTimerEnd (
95+ String eventName, Map <String , dynamic >? properties) {
96+ properties = properties == null ? null : {...properties};
9397 _convertDateTime (properties);
9498 List <dynamic > params = [eventName, properties];
9599 _channel.invokeMethod ('trackTimerEnd' , params);
@@ -141,6 +145,7 @@ class SensorsAnalyticsFlutterPlugin {
141145 /// SensorsAnalyticsFlutterPlugin.trackViewScreen('urlForView',{'key1':'value1','key2':'value2'});
142146 ///
143147 static void trackViewScreen (String url, Map <String , dynamic >? properties) {
148+ properties = properties == null ? null : {...properties};
144149 _convertDateTime (properties);
145150 List <dynamic > params = [url, properties];
146151 _channel.invokeMethod ('trackViewScreen' , params);
@@ -156,6 +161,9 @@ class SensorsAnalyticsFlutterPlugin {
156161 /// SensorsAnalyticsFlutterPlugin.profileSet({'key1':'value1','key2':'value2'});
157162 ///
158163 static void profileSet (Map <String , dynamic > profileProperties) {
164+ if (profileProperties != null ) {
165+ profileProperties = {...profileProperties};
166+ }
159167 _convertDateTime (profileProperties);
160168 List <dynamic > params = [profileProperties];
161169 _channel.invokeMethod ('profileSet' , params);
@@ -171,6 +179,9 @@ class SensorsAnalyticsFlutterPlugin {
171179 /// SensorsAnalyticsFlutterPlugin.profileSetOnce({'key1':'value1','key2':'value2'});
172180 ///
173181 static void profileSetOnce (Map <String , dynamic > profileProperties) {
182+ if (profileProperties != null ) {
183+ profileProperties = {...profileProperties};
184+ }
174185 _convertDateTime (profileProperties);
175186 List <dynamic > params = [profileProperties];
176187 _channel.invokeMethod ('profileSetOnce' , params);
@@ -252,6 +263,9 @@ class SensorsAnalyticsFlutterPlugin {
252263 /// SensorsAnalyticsFlutterPlugin.registerSuperProperties({'key1':'value1','key2':'value2'});
253264 ///
254265 static void registerSuperProperties (Map <String , dynamic > superProperties) {
266+ if (superProperties != null ) {
267+ superProperties = {...superProperties};
268+ }
255269 _convertDateTime (superProperties);
256270 List <dynamic > params = [superProperties];
257271 _channel.invokeMethod ('registerSuperProperties' , params);
@@ -446,6 +460,8 @@ class SensorsAnalyticsFlutterPlugin {
446460 /// [disableCallback] 是否关闭这次渠道匹配的回调请求
447461 static void trackAppInstall (
448462 [Map <String , dynamic >? properties, bool disableCallback = false ]) {
463+ properties = properties == null ? null : {...properties};
464+ _convertDateTime (properties);
449465 _channel.invokeMethod ("trackAppInstall" , [properties, disableCallback]);
450466 }
451467
@@ -481,6 +497,8 @@ class SensorsAnalyticsFlutterPlugin {
481497 /// [properties] item 相关属性
482498 static void itemSet (String itemType, String itemId,
483499 [Map <String , dynamic >? properties]) {
500+ properties = properties == null ? null : {...properties};
501+ _convertDateTime (properties);
484502 _channel.invokeMethod ("itemSet" , [itemType, itemId, properties]);
485503 }
486504
0 commit comments