@@ -5,7 +5,7 @@ import 'package:flutter/services.dart';
55
66// This is the official Flutter Plugin for Sensors Analytics.
77class SensorsAnalyticsFlutterPlugin {
8- static const String FLUTTER_PLUGIN_VERSION = "2.0.3 " ;
8+ static const String FLUTTER_PLUGIN_VERSION = "2.0.4 " ;
99 static bool hasAddedFlutterPluginVersion = false ;
1010
1111 static const MethodChannel _channel =
@@ -26,7 +26,7 @@ class SensorsAnalyticsFlutterPlugin {
2626 /// SensorsAnalyticsFlutterPlugin.track('eventname',{'key1':'value1','key2':'value2'});
2727 ///
2828 static void track (String eventName, Map <String , dynamic >? properties) {
29- properties = properties == null ? null : {...properties};
29+ properties = properties == null ? {} : {...properties};
3030 _convertDateTime (properties);
3131 _setupLibPluginVersion (properties);
3232 List <dynamic > params = [eventName, properties];
@@ -97,8 +97,9 @@ class SensorsAnalyticsFlutterPlugin {
9797 ///
9898 static void trackTimerEnd (
9999 String eventName, Map <String , dynamic >? properties) {
100- properties = properties == null ? null : {...properties};
100+ properties = properties == null ? {} : {...properties};
101101 _convertDateTime (properties);
102+ _setupLibPluginVersion (properties);
102103 List <dynamic > params = [eventName, properties];
103104 _channel.invokeMethod ('trackTimerEnd' , params);
104105 }
@@ -122,8 +123,11 @@ class SensorsAnalyticsFlutterPlugin {
122123 /// 使用示例:
123124 /// SensorsAnalyticsFlutterPlugin.login('login_id');
124125 ///
125- static void login (String loginId) {
126- List <String > params = [loginId];
126+ static void login (String loginId, [Map <String , dynamic >? properties]) {
127+ properties = properties == null ? {} : {...properties};
128+ _convertDateTime (properties);
129+ _setupLibPluginVersion (properties);
130+ List <dynamic > params = [loginId, properties];
127131 _channel.invokeMethod ('login' , params);
128132 }
129133
@@ -149,8 +153,9 @@ class SensorsAnalyticsFlutterPlugin {
149153 /// SensorsAnalyticsFlutterPlugin.trackViewScreen('urlForView',{'key1':'value1','key2':'value2'});
150154 ///
151155 static void trackViewScreen (String url, Map <String , dynamic >? properties) {
152- properties = properties == null ? null : {...properties};
156+ properties = properties == null ? {} : {...properties};
153157 _convertDateTime (properties);
158+ _setupLibPluginVersion (properties);
154159 List <dynamic > params = [url, properties];
155160 _channel.invokeMethod ('trackViewScreen' , params);
156161 }
@@ -530,7 +535,11 @@ class SensorsAnalyticsFlutterPlugin {
530535 if (properties == null ) {
531536 properties = {};
532537 }
533- List <String >? values = properties[r"$lib_plugin_version" ];
538+ dynamic tmp = properties[r"$lib_plugin_version" ];
539+ if ((tmp is ! List <String >) && (tmp is ! List <String ?>)) {
540+ properties.remove (r"$lib_plugin_version" );
541+ }
542+ dynamic values = properties[r"$lib_plugin_version" ];
534543 values = values == null ? [] : [...values];
535544 values.add ("flutter_plugin:$FLUTTER_PLUGIN_VERSION " );
536545 properties[r"$lib_plugin_version" ] = values;
0 commit comments