Skip to content

Commit 85f0473

Browse files
author
Zuoweixiang
committed
添加注释
1 parent 3d6a722 commit 85f0473

File tree

1 file changed

+137
-0
lines changed

1 file changed

+137
-0
lines changed

lib/sensors_analytics_flutter_plugin.dart

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,79 +11,216 @@ class SensorsAnalyticsFlutterPlugin {
1111
return await _channel.invokeMethod('getDistinctId');
1212
}
1313

14+
///
15+
/// track
16+
/// 事件追踪
17+
///
18+
/// @param eventName String 事件名.
19+
/// @param properties Map<String,dynamic> 事件属性.
20+
///
21+
/// 使用示例:
22+
/// SensorsAnalyticsFlutterPlugin.track('eventname',{'key1':'value1','key2':'value2'});
23+
///
1424
static void track(String eventName ,Map<String,dynamic> properties ) {
1525
assert(eventName != null);
1626
List<dynamic> params = [eventName,properties];
1727
_channel.invokeMethod('track',params);
1828
}
1929

30+
///
31+
/// trackInstallation
32+
/// App 激活事件追踪
33+
///
34+
/// @param eventName String 通常为'AppInstall'.
35+
/// @param properties Map<String,dynamic> App 激活事件的属性.
36+
///
37+
/// 使用示例:
38+
/// SensorsAnalyticsFlutterPlugin.trackInstallation('AppInstall',{'key1':'value1','key2':'value2'});
39+
///
2040
static void trackInstallation(String eventName ,Map<String,dynamic> properties ) {
2141
assert(eventName != null);
2242
List<dynamic> params = [eventName,properties];
2343
_channel.invokeMethod('trackInstallation',params);
2444
}
2545

46+
///
47+
/// trackTimerStart
48+
/// 开始计时
49+
///
50+
/// 初始化事件的计时器,默认计时单位为秒(计时开始).
51+
/// @param eventName 事件的名称.
52+
///
53+
/// 使用示例:(计时器事件名称 viewTimer )
54+
/// SensorsAnalyticsFlutterPlugin.trackTimerStart('viewTimer');
55+
///
2656
static void trackTimerStart(String eventName) {
2757
assert(eventName != null);
2858
List<String> params = [eventName];
2959
_channel.invokeMethod('trackTimerStart',params);
3060
}
3161

62+
///
63+
/// trackTimerEnd
64+
/// 计时结束
65+
///
66+
/// 初始化事件的计时器,默认计时单位为秒(计时开始).
67+
/// @param eventName 事件的名称.
68+
/// @param properties Map<String,dynamic> 事件属性.
69+
///
70+
/// 使用示例:(计时器事件名称 viewTimer )
71+
/// SensorsAnalyticsFlutterPlugin.trackTimerEnd('viewTimer',{});
72+
///
3273
static void trackTimerEnd(String eventName ,Map<String,dynamic> properties ) {
3374
assert(eventName != null);
3475
List<dynamic> params = [eventName,properties];
3576
_channel.invokeMethod('trackTimerEnd',params);
3677
}
3778

79+
80+
///
81+
/// clearTrackTimer
82+
/// 清除所有事件计时器
83+
///
84+
/// 使用示例:
85+
/// SensorsAnalyticsFlutterPlugin.clearTrackTimer();
86+
///
3887
static void clearTrackTimer() {
3988
_channel.invokeMethod('clearTrackTimer');
4089
}
4190

91+
///
92+
/// login.
93+
/// 用户登陆
94+
/// @param loginId 用户登录 ID.
95+
///
96+
/// 使用示例:
97+
/// SensorsAnalyticsFlutterPlugin.login('login_id');
98+
///
4299
static void login(String loginId){
43100
assert(loginId != null);
44101
List<String> params = [loginId];
45102
_channel.invokeMethod('login',params);
46103
}
47104

105+
///
106+
/// logout
107+
/// 用户登出
108+
///
109+
/// 使用示例:
110+
/// SensorsAnalyticsFlutterPlugin.logout();
111+
///
48112
static void logout(){
49113
_channel.invokeMethod('logout');
50114
}
51115

116+
///
117+
/// trackViewScreen
118+
/// 页面浏览
119+
///
120+
/// @param url String 页面标示.
121+
/// @param properties Map<String,dynamic> 事件属性.
122+
///
123+
/// 使用示例:
124+
/// SensorsAnalyticsFlutterPlugin.trackViewScreen('urlForView',{'key1':'value1','key2':'value2'});
125+
///
52126
static void trackViewScreen(String url ,Map<String,dynamic> properties ) {
53127
assert(url != null);
54128
List<dynamic> params = [url,properties];
55129
_channel.invokeMethod('trackViewScreen',params);
56130
}
57131

132+
133+
///
134+
/// profileSet
135+
/// 设置用户属性值
136+
///
137+
/// @param profileProperties Map<String,dynamic> 用户属性.
138+
///
139+
/// 使用示例:
140+
/// SensorsAnalyticsFlutterPlugin.profileSet({'key1':'value1','key2':'value2'});
141+
///
58142
static void profileSet(Map<String,dynamic> profileProperties){
59143
List<dynamic> params = [profileProperties];
60144
_channel.invokeMethod('profileSet',params);
61145
}
62146

147+
///
148+
/// profileSetOnce
149+
/// 设置用户属性值,与 profileSet 不同的是:如果之前存在,则忽略,否则,新创建.
150+
///
151+
/// @param profileProperties Map<String,dynamic> 用户属性.
152+
///
153+
/// 使用示例:
154+
/// SensorsAnalyticsFlutterPlugin.profileSetOnce({'key1':'value1','key2':'value2'});
155+
///
63156
static void profileSetOnce(Map<String,dynamic> profileProperties){
64157
List<dynamic> params = [profileProperties];
65158
_channel.invokeMethod('profileSetOnce',params);
66159
}
67160

161+
///
162+
/// profileUnset
163+
/// 删除一个用户属性.
164+
///
165+
/// @param profilePropertity String 用户属性.
166+
///
167+
/// 使用示例:
168+
/// SensorsAnalyticsFlutterPlugin.profileUnset('key1');
169+
///
68170
static void profileUnset(String profilePropertity){
69171
List<dynamic> params = [profilePropertity];
70172
_channel.invokeMethod('profileUnset',params);
71173
}
72174

175+
///
176+
/// profileIncrement
177+
/// 给一个数值类型的Profile增加一个数值. 只能对数值型属性进行操作,若该属性未设置,则添加属性并设置默认值为0
178+
///
179+
/// @param profilePropertity String 用户属性.
180+
/// @param number 增加的数值,可以为负数
181+
///
182+
/// 使用示例:
183+
/// SensorsAnalyticsFlutterPlugin.profileIncrement('age',10);
184+
///
73185
static void profileIncrement(String profilePropertity, num number) {
74186
List<dynamic> params = [profilePropertity,number];
75187
_channel.invokeMethod('profileIncrement',params);
76188
}
77189

190+
///
191+
/// profileAppend
192+
/// 给一个 List 类型的 Profile 增加一些值
193+
///
194+
/// @param profilePropertity String 用户属性.
195+
/// @param content List<String> 增加的值,List 中元素必须为 String
196+
///
197+
/// 使用示例:
198+
/// SensorsAnalyticsFlutterPlugin.profileAppend('address',['Beijing','Shanghai']);
199+
///
78200
static void profileAppend(String profilePropertity, List<String> content) {
79201
List<dynamic> params = [profilePropertity,content];
80202
_channel.invokeMethod('profileAppend',params);
81203
}
82204

205+
206+
///
207+
/// profileDelete
208+
/// 删除当前用户的所有记录
209+
///
210+
/// 使用示例:
211+
/// SensorsAnalyticsFlutterPlugin.profileDelete();
212+
///
83213
static void profileDelete() {
84214
_channel.invokeMethod('profileDelete');
85215
}
86216

217+
///
218+
/// clearKeychainData
219+
/// 删除当前 keychain 记录 (仅 iOS 使用)
220+
///
221+
/// 使用示例:
222+
/// SensorsAnalyticsFlutterPlugin.clearKeychainData();
223+
///
87224
static void clearKeychainData() {
88225
_channel.invokeMethod('clearKeychainData');
89226
}

0 commit comments

Comments
 (0)