Skip to content

Commit 9a28636

Browse files
committed
Merge branch 'release/0.3.0'
2 parents da0e152 + c4119e6 commit 9a28636

30 files changed

+487
-78
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.3.0
2+
* Enable screen and application context on mobile (#27)
3+
* Add anonymous tracking features (#16)
4+
15
# 0.2.0
26
* Configure custom POST path (#15)
37
* Upgrade underlying mobile native trackers to version 4 (#17)

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ This will add a line with the dependency like this to your `pubspec.yaml`:
4747

4848
```yml
4949
dependencies:
50-
snowplow_tracker: ^0.2.0
50+
snowplow_tracker: ^0.3.0
5151
```
5252
5353
Import the package into your Dart code:
@@ -157,7 +157,7 @@ The project is located in the `example` subfolder.
157157
Running the example app on Android/iOS:
158158

159159
1. Change into the project folder and `cd example`
160-
2. Run the integration tests (replace the Snowplow Micro URI with your IP address and set your iPhone or Android simulator name or remove to use default):
160+
2. Run the app (replace the Snowplow Micro URI with your IP address and set your iPhone or Android simulator name or remove to use default):
161161

162162
```bash
163163
flutter run --dart-define=ENDPOINT=http://192.168.100.127:9090 -d "iPhone 13 Pro"
@@ -167,13 +167,13 @@ To run the example app on Web:
167167

168168
1. [Download ChromeDriver](https://chromedriver.chromium.org/downloads) and launch it using `chromedriver --port=4444`
169169
2. Change into the project folder and `cd example`
170-
3. Run the integration tests (replace the Snowplow Micro URI with your IP address):
170+
3. Run the app (replace the Snowplow Micro URI with your IP address):
171171

172172
```bash
173173
flutter run --dart-define=ENDPOINT=http://0.0.0.0:9090 -d Chrome
174174
```
175175

176-
Alternatively, you may also run the integration tests from Visual Studio Code using the "Run Example App" target (update your IP address in launch.json).
176+
Alternatively, if you use Visual Studio Code you may also run the example app using the "Run Example App" target (update your IP address in .vscode/launch.json).
177177

178178
## Testing
179179

android/src/main/kotlin/com/snowplowanalytics/snowplow_tracker/SnowplowTrackerController.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ object SnowplowTrackerController {
3939
val gdprConfigReader = messageReader.gdprConfig
4040
gdprConfigReader?.let { controllers.add(it.toConfiguration()) }
4141

42+
val emitterConfigReader = messageReader.emitterConfig
43+
emitterConfigReader?.let { controllers.add(it.toConfiguration()) }
44+
4245
Snowplow.createTracker(
4346
context,
4447
messageReader.namespace,

android/src/main/kotlin/com/snowplowanalytics/snowplow_tracker/TrackerVersion.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
package com.snowplowanalytics.snowplow_tracker
1313

1414
object TrackerVersion {
15-
val TRACKER_VERSION = "flutter-0.2.0"
15+
val TRACKER_VERSION = "flutter-0.3.0"
1616
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright (c) 2022 Snowplow Analytics Ltd. All rights reserved.
2+
//
3+
// This program is licensed to you under the Apache License Version 2.0,
4+
// and you may not use this file except in compliance with the Apache License Version 2.0.
5+
// You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
6+
//
7+
// Unless required by applicable law or agreed to in writing,
8+
// software distributed under the Apache License Version 2.0 is distributed on an
9+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
11+
12+
package com.snowplowanalytics.snowplow_tracker.readers.configurations
13+
14+
import com.snowplowanalytics.snowplow.configuration.EmitterConfiguration
15+
16+
class EmitterConfigurationReader(values: Map<String, Any>) {
17+
private val valuesDefault = values.withDefault { null }
18+
19+
val serverAnonymisation: Boolean? by valuesDefault
20+
21+
fun toConfiguration(): EmitterConfiguration {
22+
val emitterConfig = EmitterConfiguration()
23+
24+
serverAnonymisation?.let { emitterConfig.serverAnonymisation(it) }
25+
26+
return emitterConfig
27+
}
28+
}

android/src/main/kotlin/com/snowplowanalytics/snowplow_tracker/readers/configurations/TrackerConfigurationReader.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ class TrackerConfigurationReader(values: Map<String, Any>) {
2525
val platformContext: Boolean? by valuesDefault
2626
val geoLocationContext: Boolean? by valuesDefault
2727
val sessionContext: Boolean? by valuesDefault
28+
val userAnonymisation: Boolean? by valuesDefault
29+
val screenContext: Boolean? by valuesDefault
30+
val applicationContext: Boolean? by valuesDefault
31+
2832

2933
fun toConfiguration(context: Context): TrackerConfiguration {
3034
val trackerConfig = DefaultTrackerConfiguration.toConfiguration(appId, context)
@@ -45,6 +49,9 @@ class TrackerConfigurationReader(values: Map<String, Any>) {
4549
platformContext?.let { trackerConfig.platformContext(it) }
4650
geoLocationContext?.let { trackerConfig.geoLocationContext(it) }
4751
sessionContext?.let { trackerConfig.sessionContext(it) }
52+
userAnonymisation?.let { trackerConfig.userAnonymisation(it) }
53+
screenContext?.let { trackerConfig.screenContext(it) }
54+
applicationContext?.let { trackerConfig.applicationContext(it) }
4855

4956
return trackerConfig
5057
}
@@ -54,9 +61,7 @@ object DefaultTrackerConfiguration {
5461
fun toConfiguration(appId: String?, context: Context): TrackerConfiguration {
5562
val trackerConfig = TrackerConfiguration(appId ?: context.getPackageName())
5663
.trackerVersionSuffix(TrackerVersion.TRACKER_VERSION)
57-
58-
trackerConfig.applicationContext(false)
59-
trackerConfig.screenContext(false)
64+
6065
trackerConfig.screenViewAutotracking(false)
6166
trackerConfig.lifecycleAutotracking(false)
6267
trackerConfig.installAutotracking(false)

android/src/main/kotlin/com/snowplowanalytics/snowplow_tracker/readers/messages/CreateTrackerMessageReader.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,9 @@ class CreateTrackerMessageReader(val values: Map<String, Any>) {
3333
GdprConfigurationReader(it as Map<String, Any>)
3434
}
3535
}
36+
val emitterConfig: EmitterConfigurationReader? by lazy {
37+
values.get("emitterConfig")?.let {
38+
EmitterConfigurationReader(it as Map<String, Any>)
39+
}
40+
}
3641
}

dartdoc_options.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ dartdoc:
1515
"Sessions and data model":
1616
markdown: doc/05-sessions.md
1717
name: Sessions and data model
18-
categoryOrder: ["Getting started", "Initialization and configuration", "Tracking events", "Adding data to your events", "Sessions and data model"]
18+
"Anonymous tracking":
19+
markdown: doc/06-anonymous-tracking.md
20+
name: Anonymous tracking
21+
categoryOrder: ["Getting started", "Initialization and configuration", "Tracking events", "Adding data to your events", "Sessions and data model", "Anonymous tracking"]
1922
showUndocumentedCategories: true
2023
errors:
2124
- unresolved-doc-reference

doc/01-getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ This will add a line with the dependency like to your pubspec.yaml:
1616

1717
```yml
1818
dependencies:
19-
snowplow_tracker: ^0.2.0
19+
snowplow_tracker: ^0.3.0
2020
```
2121
2222
Import the package into your Dart code:

doc/02-configuration.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ The only required attributes of the `Snowplow.createTracker` method are `namespa
2525
| `trackerConfig` | `TrackerConfiguration?` | Configuration of the tracker and the core tracker properties. |
2626
| `gdprConfig` | `GdprConfiguration?` | Determines the GDPR context that will be attached to all events sent by the tracker. |
2727
| `subjectConfig` | `SubjectConfiguration?` | Subject information about tracked user and device that is added to events. |
28+
| `emitterConfig` | `EmitterConfiguration?` | Configuration for how the events are sent. |
2829

2930
Setting a custom POST path can be useful in avoiding adblockers; it replaces the default "com.snowplowanalytics/snowplow/tp2". Your event collector must also be configured to accept the custom path.
3031

@@ -37,16 +38,28 @@ Setting a custom POST path can be useful in avoiding adblockers; it replaces the
3738
| `appId` | `String?` | Identifier of the app. |||| null on Web, bundle identifier on iOS/Android |
3839
| `devicePlatform` | `DevicePlatform?` | The device platform the tracker runs on. Available options are provided by the `DevicePlatform` enum. |||| "web" on Web, "mob" on iOS/Android |
3940
| `base64Encoding` | `bool?` | Indicates whether payload JSON data should be base64 encoded. |||| true |
40-
| `platformContext` | `bool?` | Indicates whether platform context should be attached to tracked events. ||| | true |
41-
| `geoLocationContext` | `bool?` | Indicates whether geo-location context should be attached to tracked events. |||| false |
42-
| `sessionContext` | `bool?` | Indicates whether session context should be attached to tracked events. |||| true |
43-
| `webPageContext` | `bool?` | Indicates whether context about current web page should be attached to tracked events. | | || true |
41+
| `platformContext` | `bool?` | Indicates whether [platform](http://iglucentral.com/schemas/com.snowplowanalytics.snowplow/mobile_context/jsonschema/1-0-2) (mobile) context should be attached to tracked events. ||| | true |
42+
| `geoLocationContext` | `bool?` | Indicates whether [geo-location](http://iglucentral.com/schemas/com.snowplowanalytics.snowplow/geolocation_context/jsonschema/1-1-0) context should be attached to tracked events. |||| false |
43+
| `sessionContext` | `bool?` | Indicates whether [session](http://iglucentral.com/schemas/com.snowplowanalytics.snowplow/client_session/jsonschema/1-0-2) context should be attached to tracked events. |||| true |
44+
| `webPageContext` | `bool?` | Indicates whether context about current [web page](http://iglucentral.com/schemas/com.snowplowanalytics.snowplow/web_page/jsonschema/1-0-0) should be attached to tracked events. | | || true |
45+
| `screenContext` | `bool?` | Indicates whether [screen](http://iglucentral.com/schemas/com.snowplowanalytics.mobile/screen/jsonschema/1-0-0) context should be attached to tracked events. ||| | true |
46+
| `applicationContext` | `bool?` | Indicates whether [application](http://iglucentral.com/schemas/com.snowplowanalytics.mobile/application/jsonschema/1-0-0) context should be attached to tracked events. ||| | true |
4447
| `webActivityTracking` | WebActivityTracking?` | Enables activity tracking using page views and pings on the Web. | | || true |
48+
| `userAnonymisation` | `bool?` | Anonymises certain user identifiers. |||| false |
4549

4650
The optional `WebActivityTracking` property configures page tracking on Web. Initializing the configuration will inform `SnowplowObserver` observers (see section on auto-tracking in "Tracking events") to auto track `PageViewEvent` events instead of `ScreenView` events on navigation changes. Further, setting the `minimumVisitLength` and `heartbeatDelay` properties of the `WebActivityTracking` instance will enable activity tracking using 'page ping' events on Web.
4751

4852
Activity tracking monitors whether a user continues to engage with a page over time, and record how he / she digests content on the page over time. That is accomplished using 'page ping' events. If activity tracking is enabled, the web page is monitored to see if a user is engaging with it. (E.g. is the tab in focus, does the mouse move over the page, does the user scroll etc.) If any of these things occur in a set period of time (`minimumVisitLength` seconds from page load and every `heartbeatDelay` seconds after that), a page ping event fires, and records the maximum scroll left / right and up / down in the last ping period. If there is no activity in the page (e.g. because the user is on a different tab in his / her browser), no page ping fires.
4953

54+
See the separate page for information about anonymous tracking.
55+
56+
## Configuration of emitter properties: `EmitterConfiguration`
57+
This Configuration class was added in v0.3.0. Currently, the only property is `serverAnonymisation`.
58+
59+
| Attribute | Type | Description | Android | iOS | Web | Default |
60+
|-----------|-----------|------------------------|---------|-----|-----|-----------------------------------------------|
61+
| `serverAnonymisation` | `bool?` | Prevents tracking of server-side user identifiers. |||| false |
62+
5063
## Configuration of subject information: `SubjectConfiguration`
5164

5265
Subject information are persistent and global information about the tracked device or user. They apply to all events and are assigned as event properties.

0 commit comments

Comments
 (0)