Skip to content

Commit a3d9e26

Browse files
author
weiqiangliu
committed
Release 2.0.1
1 parent 51e811a commit a3d9e26

File tree

8 files changed

+79
-37
lines changed

8 files changed

+79
-37
lines changed

.idea/libraries/Dart_SDK.xml

Lines changed: 20 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.0.1
2+
3+
* 修复 track 接口时传入 const map 报错
4+
15
## 2.0.0
26

37
* 支持 null safety

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
```yml
1818
dependencies:
1919
# 添加神策 flutter plugin
20-
sensors_analytics_flutter_plugin: ^2.0.0
20+
sensors_analytics_flutter_plugin: ^2.0.1
2121
```
2222
2323
执行 flutter packages get 命令安装插件

example/lib/main.dart

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ class _MyAppState extends State<MyApp> {
4444

4545
@override
4646
Widget build(BuildContext context) {
47-
4847
dynamic tmpResult;
4948

5049
return MaterialApp(
@@ -86,11 +85,15 @@ class _MyAppState extends State<MyApp> {
8685
title: Text('追踪事件 track'),
8786
onTap: () {
8887
print("======触发事件233");
88+
// SensorsAnalyticsFlutterPlugin.track(
89+
// 'ViewProduct', <String, dynamic>{
90+
// "a_time": DateTime.now(),
91+
// "product_name": "Apple 12 max pro"
92+
// });
93+
var map = const {};
94+
map = {};
8995
SensorsAnalyticsFlutterPlugin.track(
90-
'ViewProduct', <String, dynamic>{
91-
"a_time": DateTime.now(),
92-
"product_name": "Apple 12 max pro"
93-
});
96+
"hello", const <String, dynamic>{"address": "xxx road"});
9497
},
9598
),
9699
ListTile(
@@ -130,7 +133,9 @@ class _MyAppState extends State<MyApp> {
130133
ListTile(
131134
title: Text('set server url'),
132135
onTap: () async {
133-
SensorsAnalyticsFlutterPlugin.setServerUrl("https://newsdktest.datasink.sensorsdata.cn/sa?project=zhujiagui&token=5a394d2405c147ca", true);
136+
SensorsAnalyticsFlutterPlugin.setServerUrl(
137+
"https://newsdktest.datasink.sensorsdata.cn/sa?project=zhujiagui&token=5a394d2405c147ca",
138+
true);
134139
},
135140
),
136141
ListTile(
@@ -167,19 +172,20 @@ class _MyAppState extends State<MyApp> {
167172
title: Text('getFlushInterval'),
168173
onTap: () async {
169174
dynamic result =
170-
await SensorsAnalyticsFlutterPlugin.getFlushInterval();
175+
await SensorsAnalyticsFlutterPlugin.getFlushInterval();
171176
print("getFlushInterval===$result");
172177
},
173178
),
174179
ListTile(
175180
title: Text('setFlushBulkSize'),
176181
onTap: () async {
177-
SensorsAnalyticsFlutterPlugin.setFlushInterval(60*60*1000);
182+
SensorsAnalyticsFlutterPlugin.setFlushInterval(60 * 60 * 1000);
178183
SensorsAnalyticsFlutterPlugin.setFlushBulkSize(100);
179184
print("setFlushBulkSize===");
180-
dynamic result = await SensorsAnalyticsFlutterPlugin.getFlushBulkSize();
185+
dynamic result =
186+
await SensorsAnalyticsFlutterPlugin.getFlushBulkSize();
181187
print("getFlushBulkSize===$result");
182-
for(int index=0;index<=100;index++){
188+
for (int index = 0; index <= 100; index++) {
183189
SensorsAnalyticsFlutterPlugin.track(
184190
'ViewProduct2', <String, dynamic>{
185191
"a_time": DateTime.now(),
@@ -232,9 +238,8 @@ class _MyAppState extends State<MyApp> {
232238
ListTile(
233239
title: Text('trackTimerStart'),
234240
onTap: () async {
235-
tmpResult =
236-
await SensorsAnalyticsFlutterPlugin.trackTimerStart(
237-
"hello_event");
241+
tmpResult = await SensorsAnalyticsFlutterPlugin.trackTimerStart(
242+
"hello_event");
238243
print("trackTimerStart===$tmpResult");
239244
},
240245
),
@@ -262,8 +267,7 @@ class _MyAppState extends State<MyApp> {
262267
ListTile(
263268
title: Text('end timer'),
264269
onTap: () async {
265-
SensorsAnalyticsFlutterPlugin.trackTimerEnd(
266-
tmpResult, null);
270+
SensorsAnalyticsFlutterPlugin.trackTimerEnd(tmpResult, null);
267271
print("end timer===");
268272
},
269273
),
@@ -284,8 +288,8 @@ class _MyAppState extends State<MyApp> {
284288
ListTile(
285289
title: Text('setsuperproperties'),
286290
onTap: () async {
287-
SensorsAnalyticsFlutterPlugin.registerSuperProperties(
288-
{"age":100});
291+
SensorsAnalyticsFlutterPlugin.registerSuperProperties(
292+
{"age": 100});
289293
print("getSuperProperties===");
290294
},
291295
),
@@ -330,7 +334,7 @@ class _MyAppState extends State<MyApp> {
330334
ListTile(
331335
title: Text('enableDataCollect'),
332336
onTap: () async {
333-
SensorsAnalyticsFlutterPlugin.enableDataCollect();
337+
SensorsAnalyticsFlutterPlugin.enableDataCollect();
334338
print("enableDataCollect===");
335339
},
336340
),

ios/sensors_analytics_flutter_plugin.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
Pod::Spec.new do |s|
55
s.name = 'sensors_analytics_flutter_plugin'
6-
s.version = '2.0.0'
6+
s.version = '2.0.1'
77
s.summary = 'A new flutter plugin project.'
88
s.description = <<-DESC
99
A new flutter plugin project.

lib/sensors_analytics_flutter_plugin.dart

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import 'package:flutter/services.dart';
66
// This is the official Flutter Plugin for Sensors Analytics.
77
class 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

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: sensors_analytics_flutter_plugin
22
description: This is the official flutter plugin for Sensors Analytics,with this plugin you can easily collect your app data on Android and iOS.
3-
version: 2.0.0
3+
version: 2.0.1
44
homepage: "https://github.com/sensorsdata/sensors_analytics_flutter_plugin"
55

66
environment:

0 commit comments

Comments
 (0)