You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Clickstream Flutter SDK can help you easily collect and report events from your mobile app to AWS. This SDK is part of an AWS solution - [Clickstream Analytics on AWS](https://github.com/awslabs/clickstream-analytics-on-aws), which provisions data pipeline to ingest and process event data into AWS services such as S3, Redshift.
@@ -90,14 +89,30 @@ Current login user's attributes will be cached in disk, so the next time app lau
90
89
91
90
#### Add global attribute
92
91
93
-
```dart
94
-
analytics.addGlobalAttributes({
95
-
"_traffic_source_medium": "Search engine",
96
-
"_traffic_source_name": "Summer promotion",
97
-
"level": 10
98
-
});
99
-
100
-
// delete global attribute
92
+
1. Add global attributes when initializing the SDK
93
+
94
+
```dart
95
+
analytics.init({
96
+
appId: "your appId",
97
+
endpoint: "https://example.com/collect",
98
+
globalAttributes: {
99
+
"_traffic_source_medium": "Search engine",
100
+
"_traffic_source_name": "Summer promotion",
101
+
}
102
+
});
103
+
```
104
+
105
+
2. Add global attributes after initializing the SDK
106
+
```dart
107
+
analytics.addGlobalAttributes({
108
+
"_traffic_source_medium": "Search engine",
109
+
"_traffic_source_name": "Summer promotion",
110
+
"level": 10
111
+
});
112
+
```
113
+
114
+
#### Delete global attribute
115
+
```
101
116
analytics.deleteGlobalAttributes(["level"]);
102
117
```
103
118
@@ -123,13 +138,30 @@ var itemBook = ClickstreamItem(
123
138
analytics.record(
124
139
name: "view_item",
125
140
attributes: {
126
-
"currency": 'USD',
127
-
"event_category": 'recommended'
141
+
"currency": "USD",
142
+
"event_category": "recommended"
128
143
},
129
144
items: [itemBook]
130
145
);
131
146
```
132
147
148
+
#### Record Screen View events manually
149
+
150
+
By default, SDK will automatically track the preset `_screen_view` event when Android Activity triggers `onResume` or iOS ViewController triggers `viewDidAppear`.
151
+
152
+
You can also manually record screen view events whether automatic screen view tracking is enabled, add the following code to record a screen view event with two attributes.
153
+
154
+
*`screenName` Required. Your screen's name.
155
+
*`screenUniqueId` Optional. Set the id of your Widget. If you do not set, the SDK will set a default value based on the hashcode of the current Activity or ViewController.
156
+
157
+
```dart
158
+
analytics.recordScreenView(
159
+
screenName: 'Main',
160
+
screenUniqueId: '123adf',
161
+
attributes: { ... }
162
+
);
163
+
```
164
+
133
165
#### Other configurations
134
166
135
167
In addition to the required `appId` and `endpoint`, you can configure other information to get more customized usage:
@@ -146,7 +178,10 @@ analytics.init(
146
178
isTrackUserEngagementEvents: true,
147
179
isTrackAppExceptionEvents: false,
148
180
authCookie: "your auth cookie",
149
-
sessionTimeoutDuration: 1800000
181
+
sessionTimeoutDuration: 1800000,
182
+
globalAttributes: {
183
+
"_traffic_source_medium": "Search engine",
184
+
},
150
185
);
151
186
```
152
187
@@ -162,6 +197,7 @@ Here is an explanation of each option:
162
197
-**isTrackAppExceptionEvents**: whether auto track exception event in app, default is `false`
163
198
-**authCookie**: your auth cookie for AWS application load balancer auth cookie.
164
199
-**sessionTimeoutDuration**: the duration for session timeout millisecond, default is 1800000
200
+
-**globalAttributes**: the global attributes when initializing the SDK.
0 commit comments