Skip to content

Commit 3945149

Browse files
committed
Release 1.0.4
1 parent 1150f2c commit 3945149

File tree

8 files changed

+98
-51
lines changed

8 files changed

+98
-51
lines changed

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
## 1.0.3
2+
3+
* 属性中适配 DateTime 实例
4+
15
## 1.0.2
26

37
* 新增 profilePushId 和 profileUnsetPushId 接口
48

5-
69
## 1.0.0
710

811
* 事件追踪
912
* 用户属性修改
1013
* App激活
1114
* 用户登陆
12-
* 其他
15+
* 其他

example/ios/Flutter/.last_build_id

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
40ab8879ed4b816959a627e9de50322e

example/ios/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Uncomment this line to define a global platform for your project
2-
# platform :ios, '9.0'
2+
platform :ios, '9.0'
33

44
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
55
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

example/ios/Podfile.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ PODS:
33
- sensors_analytics_flutter_plugin (1.0.2):
44
- Flutter
55
- SensorsAnalyticsSDK
6-
- SensorsAnalyticsSDK (2.1.2):
7-
- SensorsAnalyticsSDK/core (= 2.1.2)
8-
- SensorsAnalyticsSDK/core (2.1.2)
6+
- SensorsAnalyticsSDK (2.2.4):
7+
- SensorsAnalyticsSDK/Core (= 2.2.4)
8+
- SensorsAnalyticsSDK/Core (2.2.4)
99

1010
DEPENDENCIES:
1111
- Flutter (from `Flutter`)
@@ -24,8 +24,8 @@ EXTERNAL SOURCES:
2424
SPEC CHECKSUMS:
2525
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
2626
sensors_analytics_flutter_plugin: 67005f4a6591e48b68618f18dd5a68e842598056
27-
SensorsAnalyticsSDK: dd96a4b07d9e0ad35b80a2120e583b1a0153282d
27+
SensorsAnalyticsSDK: d898a6b6427dc842fa8c54c4cfb17dcc8a7e2220
2828

29-
PODFILE CHECKSUM: f32fb4e7c14f8b3ca19a369d7be425dd9241af27
29+
PODFILE CHECKSUM: 8685ee79ad9489b94b9f1ac3974f4638bb57b02e
3030

3131
COCOAPODS: 1.9.3

example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
archiveVersion = 1;
44
classes = {
55
};
6-
objectVersion = 46;
6+
objectVersion = 50;
77
objects = {
88

99
/* Begin PBXBuildFile section */
@@ -70,7 +70,6 @@
7070
2363752114BFB379A3D29679 /* Pods-Runner.release.xcconfig */,
7171
4D3AFCAFD89DAB446AE6CB5F /* Pods-Runner.profile.xcconfig */,
7272
);
73-
name = Pods;
7473
path = Pods;
7574
sourceTree = "<group>";
7675
};
@@ -242,13 +241,12 @@
242241
buildActionMask = 2147483647;
243242
files = (
244243
);
245-
inputPaths = (
246-
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
247-
"${PODS_ROOT}/../Flutter/Flutter.framework",
244+
inputFileListPaths = (
245+
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
248246
);
249247
name = "[CP] Embed Pods Frameworks";
250-
outputPaths = (
251-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
248+
outputFileListPaths = (
249+
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
252250
);
253251
runOnlyForDeploymentPostprocessing = 0;
254252
shellPath = /bin/sh;
@@ -260,13 +258,12 @@
260258
buildActionMask = 2147483647;
261259
files = (
262260
);
263-
inputPaths = (
264-
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh",
265-
"${PODS_ROOT}/SensorsAnalyticsSDK/SensorsAnalyticsSDK/SensorsAnalyticsSDK.bundle",
261+
inputFileListPaths = (
262+
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
266263
);
267264
name = "[CP] Copy Pods Resources";
268-
outputPaths = (
269-
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/SensorsAnalyticsSDK.bundle",
265+
outputFileListPaths = (
266+
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
270267
);
271268
runOnlyForDeploymentPostprocessing = 0;
272269
shellPath = /bin/sh;
@@ -332,7 +329,6 @@
332329
/* Begin XCBuildConfiguration section */
333330
249021D3217E4FDB00AE95B9 /* Profile */ = {
334331
isa = XCBuildConfiguration;
335-
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
336332
buildSettings = {
337333
ALWAYS_SEARCH_USER_PATHS = NO;
338334
CLANG_ANALYZER_NONNULL = YES;
@@ -372,7 +368,7 @@
372368
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
373369
GCC_WARN_UNUSED_FUNCTION = YES;
374370
GCC_WARN_UNUSED_VARIABLE = YES;
375-
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
371+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
376372
MTL_ENABLE_DEBUG_INFO = NO;
377373
SDKROOT = iphoneos;
378374
SUPPORTED_PLATFORMS = iphoneos;
@@ -393,7 +389,10 @@
393389
"$(PROJECT_DIR)/Flutter",
394390
);
395391
INFOPLIST_FILE = Runner/Info.plist;
396-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
392+
LD_RUNPATH_SEARCH_PATHS = (
393+
"$(inherited)",
394+
"@executable_path/Frameworks",
395+
);
397396
LIBRARY_SEARCH_PATHS = (
398397
"$(inherited)",
399398
"$(PROJECT_DIR)/Flutter",
@@ -406,7 +405,6 @@
406405
};
407406
97C147031CF9000F007C117D /* Debug */ = {
408407
isa = XCBuildConfiguration;
409-
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
410408
buildSettings = {
411409
ALWAYS_SEARCH_USER_PATHS = NO;
412410
CLANG_ANALYZER_NONNULL = YES;
@@ -452,7 +450,7 @@
452450
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
453451
GCC_WARN_UNUSED_FUNCTION = YES;
454452
GCC_WARN_UNUSED_VARIABLE = YES;
455-
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
453+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
456454
MTL_ENABLE_DEBUG_INFO = YES;
457455
ONLY_ACTIVE_ARCH = YES;
458456
SDKROOT = iphoneos;
@@ -462,7 +460,6 @@
462460
};
463461
97C147041CF9000F007C117D /* Release */ = {
464462
isa = XCBuildConfiguration;
465-
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
466463
buildSettings = {
467464
ALWAYS_SEARCH_USER_PATHS = NO;
468465
CLANG_ANALYZER_NONNULL = YES;
@@ -502,7 +499,7 @@
502499
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
503500
GCC_WARN_UNUSED_FUNCTION = YES;
504501
GCC_WARN_UNUSED_VARIABLE = YES;
505-
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
502+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
506503
MTL_ENABLE_DEBUG_INFO = NO;
507504
SDKROOT = iphoneos;
508505
SUPPORTED_PLATFORMS = iphoneos;
@@ -523,7 +520,10 @@
523520
"$(PROJECT_DIR)/Flutter",
524521
);
525522
INFOPLIST_FILE = Runner/Info.plist;
526-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
523+
LD_RUNPATH_SEARCH_PATHS = (
524+
"$(inherited)",
525+
"@executable_path/Frameworks",
526+
);
527527
LIBRARY_SEARCH_PATHS = (
528528
"$(inherited)",
529529
"$(PROJECT_DIR)/Flutter",
@@ -546,7 +546,10 @@
546546
"$(PROJECT_DIR)/Flutter",
547547
);
548548
INFOPLIST_FILE = Runner/Info.plist;
549-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
549+
LD_RUNPATH_SEARCH_PATHS = (
550+
"$(inherited)",
551+
"@executable_path/Frameworks",
552+
);
550553
LIBRARY_SEARCH_PATHS = (
551554
"$(inherited)",
552555
"$(PROJECT_DIR)/Flutter",

example/lib/main.dart

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import 'package:flutter/material.dart';
21
import 'dart:async';
32

3+
import 'package:flutter/material.dart';
44
import 'package:flutter/services.dart';
55
import 'package:sensors_analytics_flutter_plugin/sensors_analytics_flutter_plugin.dart';
66

@@ -23,14 +23,13 @@ class _MyAppState extends State<MyApp> {
2323

2424
// Platform messages are asynchronous, so we initialize in an async method.
2525
Future<void> initPlatformState() async {
26-
String distinctId="";
26+
String distinctId = "";
2727

2828
// Platform messages may fail, so we use a try/catch PlatformException.
2929
try {
3030
distinctId = await SensorsAnalyticsFlutterPlugin.getDistinctId;
3131
} on PlatformException {
3232
distinctId = 'Failed to get distinctId.';
33-
3433
}
3534

3635
// If the widget was removed from the tree while the asynchronous platform
@@ -40,7 +39,6 @@ class _MyAppState extends State<MyApp> {
4039

4140
setState(() {
4241
_distinctId = distinctId;
43-
4442
});
4543
}
4644

@@ -54,51 +52,72 @@ class _MyAppState extends State<MyApp> {
5452
body: ListView(
5553
children: <Widget>[
5654
ListTile(
57-
title: Text(_distinctId??""),
58-
onTap: (){},
55+
title: Text(_distinctId ?? ""),
56+
onTap: () {},
5957
),
6058
ListTile(
61-
title: Text('This is the official Flutter Plugin for Sensors Analytics.'),
62-
onTap: (){},
59+
title: Text(
60+
'This is the official Flutter Plugin for Sensors Analytics.'),
61+
onTap: () {},
6362
),
6463
ListTile(
6564
leading: Icon(Icons.account_circle),
6665
title: Text('注册成功/登录成功时调用 login '),
67-
onTap: (){ SensorsAnalyticsFlutterPlugin.login('传入你们服务端分配给用户的登录 ID');},
66+
onTap: () {
67+
SensorsAnalyticsFlutterPlugin.login('传入你们服务端分配给用户的登录 ID');
68+
},
6869
),
6970
ListTile(
7071
leading: Icon(Icons.event),
7172
title: Text('触发激活事件 trackInstallation '),
72-
onTap: (){ SensorsAnalyticsFlutterPlugin.trackInstallation('AppInstall',{});},
73+
onTap: () {
74+
SensorsAnalyticsFlutterPlugin.trackInstallation(
75+
'AppInstall', <String, dynamic>{
76+
"a_time": DateTime.now(),
77+
"product_name": "Apple 12 max pro"
78+
});
79+
},
7380
),
7481
ListTile(
7582
leading: Icon(Icons.event),
7683
title: Text('追踪事件 track'),
77-
onTap: (){
78-
print("======触发事件2");
79-
SensorsAnalyticsFlutterPlugin.track('ViewProduct',parameters ?? <String, dynamic>{});
80-
},
84+
onTap: () {
85+
print("======触发事件233");
86+
SensorsAnalyticsFlutterPlugin.track(
87+
'ViewProduct', <String, dynamic>{
88+
"a_time": DateTime.now(),
89+
"product_name": "Apple 12 max pro"
90+
});
91+
},
8192
),
8293
ListTile(
8394
leading: Icon(Icons.assessment),
8495
title: Text('设置用户属性 profileSet2'),
85-
onTap: (){ SensorsAnalyticsFlutterPlugin.profileSet({'Age':18,'Sex':'Male'});},
96+
onTap: () {
97+
SensorsAnalyticsFlutterPlugin.profileSet(
98+
{'Age': 18, 'Sex': 'Male', "a_time": DateTime.now()});
99+
},
86100
),
87101
ListTile(
88102
leading: Icon(Icons.assessment),
89103
title: Text('设置用户推送 ID 到用户表'),
90-
onTap: (){ SensorsAnalyticsFlutterPlugin.profilePushId("jgId", "12312312312");},
104+
onTap: () {
105+
SensorsAnalyticsFlutterPlugin.profilePushId(
106+
"jgId", "12312312312");
107+
},
91108
),
92109
ListTile(
93110
leading: Icon(Icons.assessment),
94111
title: Text('删除用户设置的 pushId'),
95-
onTap: (){ SensorsAnalyticsFlutterPlugin.profileUnsetPushId("jgId");},
112+
onTap: () {
113+
SensorsAnalyticsFlutterPlugin.profileUnsetPushId("jgId");
114+
},
96115
),
97116
ListTile(
98-
title: Text('https://github.com/sensorsdata/sensors_analytics_flutter_plugin'),
99-
onTap: (){},
117+
title: Text(
118+
'https://github.com/sensorsdata/sensors_analytics_flutter_plugin'),
119+
onTap: () {},
100120
)
101-
102121
],
103122
),
104123
),

lib/sensors_analytics_flutter_plugin.dart

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class SensorsAnalyticsFlutterPlugin {
2323
///
2424
static void track(String eventName, Map<String, dynamic> properties) {
2525
assert(eventName != null);
26+
_convertDateTime(properties);
2627
List<dynamic> params = [eventName, properties];
2728
_channel.invokeMethod('track', params);
2829
}
@@ -40,6 +41,7 @@ class SensorsAnalyticsFlutterPlugin {
4041
static void trackInstallation(
4142
String eventName, Map<String, dynamic> properties) {
4243
assert(eventName != null);
44+
_convertDateTime(properties);
4345
List<dynamic> params = [eventName, properties];
4446
_channel.invokeMethod('trackInstallation', params);
4547
}
@@ -73,6 +75,7 @@ class SensorsAnalyticsFlutterPlugin {
7375
///
7476
static void trackTimerEnd(String eventName, Map<String, dynamic> properties) {
7577
assert(eventName != null);
78+
_convertDateTime(properties);
7679
List<dynamic> params = [eventName, properties];
7780
_channel.invokeMethod('trackTimerEnd', params);
7881
}
@@ -125,6 +128,7 @@ class SensorsAnalyticsFlutterPlugin {
125128
///
126129
static void trackViewScreen(String url, Map<String, dynamic> properties) {
127130
assert(url != null);
131+
_convertDateTime(properties);
128132
List<dynamic> params = [url, properties];
129133
_channel.invokeMethod('trackViewScreen', params);
130134
}
@@ -139,6 +143,7 @@ class SensorsAnalyticsFlutterPlugin {
139143
/// SensorsAnalyticsFlutterPlugin.profileSet({'key1':'value1','key2':'value2'});
140144
///
141145
static void profileSet(Map<String, dynamic> profileProperties) {
146+
_convertDateTime(profileProperties);
142147
List<dynamic> params = [profileProperties];
143148
_channel.invokeMethod('profileSet', params);
144149
}
@@ -153,6 +158,7 @@ class SensorsAnalyticsFlutterPlugin {
153158
/// SensorsAnalyticsFlutterPlugin.profileSetOnce({'key1':'value1','key2':'value2'});
154159
///
155160
static void profileSetOnce(Map<String, dynamic> profileProperties) {
161+
_convertDateTime(profileProperties);
156162
List<dynamic> params = [profileProperties];
157163
_channel.invokeMethod('profileSetOnce', params);
158164
}
@@ -233,6 +239,7 @@ class SensorsAnalyticsFlutterPlugin {
233239
/// SensorsAnalyticsFlutterPlugin.registerSuperProperties({'key1':'value1','key2':'value2'});
234240
///
235241
static void registerSuperProperties(Map<String, dynamic> superProperties) {
242+
_convertDateTime(superProperties);
236243
List<dynamic> params = [superProperties];
237244
_channel.invokeMethod('registerSuperProperties', params);
238245
}
@@ -281,4 +288,18 @@ class SensorsAnalyticsFlutterPlugin {
281288
static void profileUnsetPushId(String pushTypeKey) {
282289
_channel.invokeMethod("profileUnsetPushId", [pushTypeKey]);
283290
}
291+
292+
/// 如果 map 中的 value 字段是 DateTime 类型,将其转换成
293+
static void _convertDateTime(Map<String, dynamic> map){
294+
if(map != null){
295+
map.updateAll((key, value){
296+
if(value is DateTime){
297+
String timeString = value.toLocal().toString();
298+
int lastDotIndex = timeString.lastIndexOf(".");
299+
return timeString.substring(0, lastDotIndex);
300+
}
301+
return value;
302+
});
303+
}
304+
}
284305
}

0 commit comments

Comments
 (0)