@snowplow/react-native-tracker 2.0.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/build.yml +10 -5
- package/.github/workflows/deploy.yml +9 -10
- package/.github/workflows/e2e-android.yml +2 -2
- package/.github/workflows/e2e-ios.yml +6 -1
- package/.github/workflows/snyk.yml +1 -1
- package/CHANGELOG +14 -0
- package/CONTRIBUTING.md +2 -2
- package/LICENSE +1 -1
- package/README.md +2 -2
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/snowplow/reactnativetracker/ReactNativeTrackerModule.kt +50 -10
- package/android/src/main/java/com/snowplow/reactnativetracker/util/ConfigUtil.kt +5 -2
- package/android/src/main/java/com/snowplow/reactnativetracker/util/EventUtil.kt +20 -0
- package/android/src/main/java/com/snowplow/reactnativetracker/util/TrackerVersion.kt +1 -1
- package/example/Gemfile +1 -1
- package/example/e2e/emitEvents.e2e.detox.js +0 -13
- package/example/e2e/helpers/microCommands.js +0 -13
- package/example/e2e/helpers/microHelpers.js +0 -13
- package/example/e2e/helpers/microHelpers.test.js +0 -13
- package/example/e2e/helpers/schemas.js +0 -13
- package/example/e2e/testEvents.micro.test.js +1 -14
- package/example/ios/Podfile +0 -2
- package/example/ios/Podfile.lock +194 -201
- package/example/ios/ReactNativeTrackerExample/PrivacyInfo.xcprivacy +37 -0
- package/example/ios/ReactNativeTrackerExample.xcodeproj/project.pbxproj +17 -0
- package/example/package.json +13 -13
- package/example/src/App.js +9 -0
- package/example/yarn.lock +1599 -1275
- package/ios/ReactNativeTracker.mm +10 -0
- package/ios/ReactNativeTracker.swift +71 -6
- package/ios/Util/ConfigUtils.swift +5 -2
- package/ios/Util/TrackerVersion.swift +1 -1
- package/lib/commonjs/api.js +28 -13
- package/lib/commonjs/api.js.map +1 -1
- package/lib/commonjs/configurations.js +1 -14
- package/lib/commonjs/configurations.js.map +1 -1
- package/lib/commonjs/constants.js +6 -14
- package/lib/commonjs/constants.js.map +1 -1
- package/lib/commonjs/events.js +34 -13
- package/lib/commonjs/events.js.map +1 -1
- package/lib/commonjs/index.js +4 -13
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/jsCore.js +49 -15
- package/lib/commonjs/jsCore.js.map +1 -1
- package/lib/commonjs/native.js +0 -13
- package/lib/commonjs/native.js.map +1 -1
- package/lib/commonjs/subject.js +0 -13
- package/lib/commonjs/subject.js.map +1 -1
- package/lib/commonjs/tracker.js +40 -13
- package/lib/commonjs/tracker.js.map +1 -1
- package/lib/commonjs/utils.js +0 -13
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/webViewInterface.js +0 -13
- package/lib/commonjs/webViewInterface.js.map +1 -1
- package/lib/module/api.js +27 -14
- package/lib/module/api.js.map +1 -1
- package/lib/module/configurations.js +1 -14
- package/lib/module/configurations.js.map +1 -1
- package/lib/module/constants.js +6 -14
- package/lib/module/constants.js.map +1 -1
- package/lib/module/events.js +33 -14
- package/lib/module/events.js.map +1 -1
- package/lib/module/index.js +4 -13
- package/lib/module/index.js.map +1 -1
- package/lib/module/jsCore.js +49 -15
- package/lib/module/jsCore.js.map +1 -1
- package/lib/module/native.js +0 -13
- package/lib/module/native.js.map +1 -1
- package/lib/module/subject.js +0 -13
- package/lib/module/subject.js.map +1 -1
- package/lib/module/tracker.js +40 -15
- package/lib/module/tracker.js.map +1 -1
- package/lib/module/utils.js +0 -13
- package/lib/module/utils.js.map +1 -1
- package/lib/module/webViewInterface.js +0 -13
- package/lib/module/webViewInterface.js.map +1 -1
- package/lib/typescript/api.d.ts +16 -2
- package/lib/typescript/api.d.ts.map +1 -1
- package/lib/typescript/configurations.d.ts.map +1 -1
- package/lib/typescript/constants.d.ts +5 -0
- package/lib/typescript/constants.d.ts.map +1 -1
- package/lib/typescript/events.d.ts +16 -2
- package/lib/typescript/events.d.ts.map +1 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/jsCore.d.ts +13 -1
- package/lib/typescript/jsCore.d.ts.map +1 -1
- package/lib/typescript/native.d.ts.map +1 -1
- package/lib/typescript/subject.d.ts.map +1 -1
- package/lib/typescript/tracker.d.ts +20 -2
- package/lib/typescript/tracker.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +83 -5
- package/lib/typescript/types.d.ts.map +1 -1
- package/lib/typescript/utils.d.ts.map +1 -1
- package/lib/typescript/webViewInterface.d.ts.map +1 -1
- package/package.json +22 -22
- package/snowplow-react-native-tracker.podspec +1 -1
- package/src/__tests__/api.test.ts +0 -13
- package/src/__tests__/configurations.test.ts +3 -15
- package/src/__tests__/events.test.ts +0 -13
- package/src/__tests__/index.test.ts +0 -13
- package/src/__tests__/jsCore.test.ts +43 -13
- package/src/__tests__/utils.test.ts +0 -13
- package/src/api.ts +34 -13
- package/src/configurations.ts +1 -13
- package/src/constants.ts +8 -13
- package/src/events.ts +38 -13
- package/src/index.ts +8 -13
- package/src/jsCore.ts +65 -15
- package/src/native.ts +0 -13
- package/src/subject.ts +0 -13
- package/src/tracker.ts +60 -13
- package/src/types.ts +93 -18
- package/src/utils.ts +0 -13
- package/src/webViewInterface.ts +0 -13
- package/yarn.lock +1600 -1535
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@snowplow/react-native-tracker",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "A library for tracking Snowplow events in React Native",
|
|
5
5
|
"homepage": "https://docs.snowplowanalytics.com/docs/collecting-data/collecting-from-own-applications/react-native-tracker/",
|
|
6
6
|
"main": "lib/commonjs/index",
|
|
@@ -64,33 +64,33 @@
|
|
|
64
64
|
"registry": "https://registry.npmjs.org/"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@snowplow/tracker-core": "3.
|
|
67
|
+
"@snowplow/tracker-core": "3.24.1",
|
|
68
68
|
"uuid": "^3.4.0"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@evilmartians/lefthook": "^1.
|
|
72
|
-
"@react-native-community/eslint-config": "^3.0
|
|
73
|
-
"@release-it/conventional-changelog": "^
|
|
74
|
-
"@types/jest": "^
|
|
75
|
-
"@types/react": "~
|
|
76
|
-
"@types/react-native": "0.
|
|
71
|
+
"@evilmartians/lefthook": "^1.6.18",
|
|
72
|
+
"@react-native-community/eslint-config": "^3.2.0",
|
|
73
|
+
"@release-it/conventional-changelog": "^7.0.2",
|
|
74
|
+
"@types/jest": "^29.5.12",
|
|
75
|
+
"@types/react": "~18.3.3",
|
|
76
|
+
"@types/react-native": "0.71.3",
|
|
77
77
|
"@types/uuid": "~3.4.6",
|
|
78
|
-
"del-cli": "^5.
|
|
79
|
-
"eslint": "^8.
|
|
80
|
-
"eslint-config-prettier": "^8.
|
|
81
|
-
"eslint-plugin-prettier": "^4.
|
|
82
|
-
"jest": "^
|
|
83
|
-
"pod-install": "^0.
|
|
84
|
-
"prettier": "^2.
|
|
85
|
-
"react": "18.
|
|
86
|
-
"react-native": "0.72.
|
|
78
|
+
"del-cli": "^5.1.0",
|
|
79
|
+
"eslint": "^8.57.0",
|
|
80
|
+
"eslint-config-prettier": "^8.10.0",
|
|
81
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
82
|
+
"jest": "^29.7.0",
|
|
83
|
+
"pod-install": "^0.2.2",
|
|
84
|
+
"prettier": "^2.8.8",
|
|
85
|
+
"react": "18.3.1",
|
|
86
|
+
"react-native": "0.72.15",
|
|
87
87
|
"react-native-builder-bob": "^0.21.3",
|
|
88
|
-
"release-it": "^
|
|
89
|
-
"turbo": "^1.
|
|
90
|
-
"typescript": "
|
|
88
|
+
"release-it": "^16.3.0",
|
|
89
|
+
"turbo": "^1.13.4",
|
|
90
|
+
"typescript": "~5.1.6"
|
|
91
91
|
},
|
|
92
92
|
"resolutions": {
|
|
93
|
-
"@types/react": "
|
|
93
|
+
"@types/react": "18.3.3"
|
|
94
94
|
},
|
|
95
95
|
"peerDependencies": {
|
|
96
96
|
"react": "*",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"engines": {
|
|
100
100
|
"node": ">= 16.0.0"
|
|
101
101
|
},
|
|
102
|
-
"packageManager": "
|
|
102
|
+
"packageManager": "yarn@1.22.22",
|
|
103
103
|
"jest": {
|
|
104
104
|
"preset": "react-native",
|
|
105
105
|
"modulePathIgnorePatterns": [
|
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2020-2023 Snowplow Analytics Ltd. All rights reserved.
|
|
3
|
-
*
|
|
4
|
-
* This program is licensed to you under the Apache License Version 2.0,
|
|
5
|
-
* and you may not use this file except in compliance with the Apache License Version 2.0.
|
|
6
|
-
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
|
|
7
|
-
*
|
|
8
|
-
* Unless required by applicable law or agreed to in writing,
|
|
9
|
-
* software distributed under the Apache License Version 2.0 is distributed on an
|
|
10
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
1
|
import * as c from '../configurations';
|
|
15
2
|
import * as api from '../api';
|
|
16
3
|
|
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2020-2023 Snowplow Analytics Ltd. All rights reserved.
|
|
3
|
-
*
|
|
4
|
-
* This program is licensed to you under the Apache License Version 2.0,
|
|
5
|
-
* and you may not use this file except in compliance with the Apache License Version 2.0.
|
|
6
|
-
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
|
|
7
|
-
*
|
|
8
|
-
* Unless required by applicable law or agreed to in writing,
|
|
9
|
-
* software distributed under the Apache License Version 2.0 is distributed on an
|
|
10
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
1
|
import * as c from '../configurations';
|
|
15
2
|
import { logMessages } from '../constants';
|
|
16
3
|
|
|
@@ -252,7 +239,8 @@ describe('test initValidate resolves', () => {
|
|
|
252
239
|
deepLinkContext: true,
|
|
253
240
|
screenContext: true,
|
|
254
241
|
screenViewAutotracking: false,
|
|
255
|
-
|
|
242
|
+
screenEngagementAutotracking: true,
|
|
243
|
+
lifecycleAutotracking: true,
|
|
256
244
|
installAutotracking: true,
|
|
257
245
|
exceptionAutotracking: true,
|
|
258
246
|
diagnosticAutotracking: false,
|
|
@@ -389,7 +377,7 @@ describe('test isValidEmitterConf', () => {
|
|
|
389
377
|
|
|
390
378
|
test('invalid - invalid props', () => {
|
|
391
379
|
const testConf = {
|
|
392
|
-
bufferOption: '
|
|
380
|
+
bufferOption: 'small',
|
|
393
381
|
invalid: true,
|
|
394
382
|
} as any;
|
|
395
383
|
expect(c.isValidEmitterConf(testConf)).toBe(false);
|
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2020-2023 Snowplow Analytics Ltd. All rights reserved.
|
|
3
|
-
*
|
|
4
|
-
* This program is licensed to you under the Apache License Version 2.0,
|
|
5
|
-
* and you may not use this file except in compliance with the Apache License Version 2.0.
|
|
6
|
-
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
|
|
7
|
-
*
|
|
8
|
-
* Unless required by applicable law or agreed to in writing,
|
|
9
|
-
* software distributed under the Apache License Version 2.0 is distributed on an
|
|
10
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
1
|
import * as e from '../events';
|
|
15
2
|
import { logMessages } from '../constants';
|
|
16
3
|
|
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2020-2023 Snowplow Analytics Ltd. All rights reserved.
|
|
3
|
-
*
|
|
4
|
-
* This program is licensed to you under the Apache License Version 2.0,
|
|
5
|
-
* and you may not use this file except in compliance with the Apache License Version 2.0.
|
|
6
|
-
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
|
|
7
|
-
*
|
|
8
|
-
* Unless required by applicable law or agreed to in writing,
|
|
9
|
-
* software distributed under the Apache License Version 2.0 is distributed on an
|
|
10
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
1
|
import * as main from '../index';
|
|
15
2
|
import * as api from '../api';
|
|
16
3
|
|
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2020-2023 Snowplow Analytics Ltd. All rights reserved.
|
|
3
|
-
*
|
|
4
|
-
* This program is licensed to you under the Apache License Version 2.0,
|
|
5
|
-
* and you may not use this file except in compliance with the Apache License Version 2.0.
|
|
6
|
-
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
|
|
7
|
-
*
|
|
8
|
-
* Unless required by applicable law or agreed to in writing,
|
|
9
|
-
* software distributed under the Apache License Version 2.0 is distributed on an
|
|
10
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
1
|
import type { Payload } from '@snowplow/tracker-core';
|
|
15
2
|
import type { InitTrackerConfiguration } from '../types';
|
|
16
3
|
import { JSSnowplowTracker } from '../jsCore';
|
|
@@ -85,6 +72,49 @@ describe('test jsCore', () => {
|
|
|
85
72
|
expect(trackedPayloads[0]?.ue_pr ?? '').toContain('"name":"screen"');
|
|
86
73
|
});
|
|
87
74
|
|
|
75
|
+
test('tracks scroll changed event with default tracker', async () => {
|
|
76
|
+
const trackedPayloads = await createTracker(
|
|
77
|
+
{
|
|
78
|
+
namespace: 'ns',
|
|
79
|
+
networkConfig: { endpoint: 'http://localhost' },
|
|
80
|
+
},
|
|
81
|
+
async () => {
|
|
82
|
+
await JSSnowplowTracker.trackScrollChangedEvent({
|
|
83
|
+
tracker: null,
|
|
84
|
+
eventData: { viewHeight: 100, contentHeight: 200, yOffset: 50 },
|
|
85
|
+
contexts: [],
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
expect(trackedPayloads.length).toBe(1);
|
|
91
|
+
expect(trackedPayloads[0]?.tna).toEqual('ns');
|
|
92
|
+
expect(trackedPayloads[0]?.ue_pr ?? '').toContain('"view_height":100');
|
|
93
|
+
expect(trackedPayloads[0]?.ue_pr ?? '').toContain('"content_height":200');
|
|
94
|
+
expect(trackedPayloads[0]?.ue_pr ?? '').toContain('"y_offset":50');
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test('tracks list item view event with default tracker', async () => {
|
|
98
|
+
const trackedPayloads = await createTracker(
|
|
99
|
+
{
|
|
100
|
+
namespace: 'ns',
|
|
101
|
+
networkConfig: { endpoint: 'http://localhost' },
|
|
102
|
+
},
|
|
103
|
+
async () => {
|
|
104
|
+
await JSSnowplowTracker.trackListItemViewEvent({
|
|
105
|
+
tracker: null,
|
|
106
|
+
eventData: { index: 2, itemsCount: 10 },
|
|
107
|
+
contexts: [],
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
expect(trackedPayloads.length).toBe(1);
|
|
113
|
+
expect(trackedPayloads[0]?.tna).toEqual('ns');
|
|
114
|
+
expect(trackedPayloads[0]?.ue_pr ?? '').toContain('"index":2');
|
|
115
|
+
expect(trackedPayloads[0]?.ue_pr ?? '').toContain('"items_count":10');
|
|
116
|
+
});
|
|
117
|
+
|
|
88
118
|
test('works with multiple trackers', async () => {
|
|
89
119
|
const tracker1Payloads = await createTracker({
|
|
90
120
|
namespace: 'ns1',
|
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2020-2023 Snowplow Analytics Ltd. All rights reserved.
|
|
3
|
-
*
|
|
4
|
-
* This program is licensed to you under the Apache License Version 2.0,
|
|
5
|
-
* and you may not use this file except in compliance with the Apache License Version 2.0.
|
|
6
|
-
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
|
|
7
|
-
*
|
|
8
|
-
* Unless required by applicable law or agreed to in writing,
|
|
9
|
-
* software distributed under the Apache License Version 2.0 is distributed on an
|
|
10
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
1
|
import * as u from '../utils';
|
|
15
2
|
|
|
16
3
|
describe('test isObject', () => {
|
package/src/api.ts
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2020-2023 Snowplow Analytics Ltd. All rights reserved.
|
|
3
|
-
*
|
|
4
|
-
* This program is licensed to you under the Apache License Version 2.0,
|
|
5
|
-
* and you may not use this file except in compliance with the Apache License Version 2.0.
|
|
6
|
-
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
|
|
7
|
-
*
|
|
8
|
-
* Unless required by applicable law or agreed to in writing,
|
|
9
|
-
* software distributed under the Apache License Version 2.0 is distributed on an
|
|
10
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
1
|
'use strict';
|
|
15
2
|
|
|
16
3
|
import { RNSnowplowTracker } from './native';
|
|
@@ -35,6 +22,8 @@ import type {
|
|
|
35
22
|
ScreenSize,
|
|
36
23
|
DeepLinkReceivedProps,
|
|
37
24
|
MessageNotificationProps,
|
|
25
|
+
ScrollChangedProps,
|
|
26
|
+
ListItemViewProps,
|
|
38
27
|
} from './types';
|
|
39
28
|
|
|
40
29
|
/**
|
|
@@ -109,6 +98,36 @@ function trackScreenViewEvent(namespace: string) {
|
|
|
109
98
|
};
|
|
110
99
|
}
|
|
111
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Returns a function to track a ScrollChanged event by a tracker
|
|
103
|
+
*
|
|
104
|
+
* @param namespace {string} - The tracker namespace
|
|
105
|
+
* @returns - A function to track a ScrollChanged event
|
|
106
|
+
*/
|
|
107
|
+
function trackScrollChangedEvent(namespace: string) {
|
|
108
|
+
return function (
|
|
109
|
+
argmap: ScrollChangedProps,
|
|
110
|
+
contexts: EventContext[] = []
|
|
111
|
+
): Promise<void> {
|
|
112
|
+
return tracker.trackScrollChangedEvent(namespace, argmap, contexts);
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Returns a function to track a ListItemView event by a tracker
|
|
118
|
+
*
|
|
119
|
+
* @param namespace {string} - The tracker namespace
|
|
120
|
+
* @returns - A function to track a ListItemView event
|
|
121
|
+
*/
|
|
122
|
+
function trackListItemViewEvent(namespace: string) {
|
|
123
|
+
return function (
|
|
124
|
+
argmap: ListItemViewProps,
|
|
125
|
+
contexts: EventContext[] = []
|
|
126
|
+
): Promise<void> {
|
|
127
|
+
return tracker.trackListItemViewEvent(namespace, argmap, contexts);
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
112
131
|
/**
|
|
113
132
|
* Returns a function to track a Structured event by a tracker
|
|
114
133
|
*
|
|
@@ -505,6 +524,8 @@ export {
|
|
|
505
524
|
removeAllTrackers,
|
|
506
525
|
trackSelfDescribingEvent,
|
|
507
526
|
trackScreenViewEvent,
|
|
527
|
+
trackScrollChangedEvent,
|
|
528
|
+
trackListItemViewEvent,
|
|
508
529
|
trackStructuredEvent,
|
|
509
530
|
trackPageViewEvent,
|
|
510
531
|
trackTimingEvent,
|
package/src/configurations.ts
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2020-2023 Snowplow Analytics Ltd. All rights reserved.
|
|
3
|
-
*
|
|
4
|
-
* This program is licensed to you under the Apache License Version 2.0,
|
|
5
|
-
* and you may not use this file except in compliance with the Apache License Version 2.0.
|
|
6
|
-
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
|
|
7
|
-
*
|
|
8
|
-
* Unless required by applicable law or agreed to in writing,
|
|
9
|
-
* software distributed under the Apache License Version 2.0 is distributed on an
|
|
10
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
1
|
'use strict';
|
|
15
2
|
|
|
16
3
|
import { isObject } from './utils';
|
|
@@ -44,6 +31,7 @@ const trackerProps = [
|
|
|
44
31
|
'deepLinkContext',
|
|
45
32
|
'screenContext',
|
|
46
33
|
'screenViewAutotracking',
|
|
34
|
+
'screenEngagementAutotracking',
|
|
47
35
|
'lifecycleAutotracking',
|
|
48
36
|
'installAutotracking',
|
|
49
37
|
'exceptionAutotracking',
|
package/src/constants.ts
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2020-2023 Snowplow Analytics Ltd. All rights reserved.
|
|
3
|
-
*
|
|
4
|
-
* This program is licensed to you under the Apache License Version 2.0,
|
|
5
|
-
* and you may not use this file except in compliance with the Apache License Version 2.0.
|
|
6
|
-
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
|
|
7
|
-
*
|
|
8
|
-
* Unless required by applicable law or agreed to in writing,
|
|
9
|
-
* software distributed under the Apache License Version 2.0 is distributed on an
|
|
10
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
1
|
'use strict';
|
|
15
2
|
|
|
16
3
|
const logMessages = {
|
|
@@ -31,6 +18,8 @@ const logMessages = {
|
|
|
31
18
|
'selfDescribing event requires schema and data parameters to be set',
|
|
32
19
|
evType: 'event argument can only be an object',
|
|
33
20
|
screenViewReq: 'screenView event requires name as string parameter to be set',
|
|
21
|
+
listItemViewReq:
|
|
22
|
+
'listItemView event requires index asn integer parameter to be set',
|
|
34
23
|
structuredReq:
|
|
35
24
|
'structured event requires category and action parameters to be set',
|
|
36
25
|
pageviewReq: 'pageView event requires pageUrl parameter to be set',
|
|
@@ -57,6 +46,8 @@ const logMessages = {
|
|
|
57
46
|
// methods
|
|
58
47
|
trackSelfDesc: 'trackSelfDescribingEvent:',
|
|
59
48
|
trackScreenView: 'trackScreenViewEvent:',
|
|
49
|
+
trackScrollChanged: 'trackScrollChangedEvent:',
|
|
50
|
+
trackListItemView: 'trackListItemViewEvent:',
|
|
60
51
|
trackStructured: 'trackStructuredEvent:',
|
|
61
52
|
trackPageView: 'trackPageViewEvent:',
|
|
62
53
|
trackTiming: 'trackTimingEvent:',
|
|
@@ -97,6 +88,10 @@ const schemas = {
|
|
|
97
88
|
'iglu:com.snowplowanalytics.mobile/message_notification/jsonschema/1-0-0',
|
|
98
89
|
screenViewSchema:
|
|
99
90
|
'iglu:com.snowplowanalytics.mobile/screen_view/jsonschema/1-0-0',
|
|
91
|
+
scrollChangedSchema:
|
|
92
|
+
'iglu:com.snowplowanalytics.mobile/scroll_changed/jsonschema/1-0-0',
|
|
93
|
+
listItemViewSchema:
|
|
94
|
+
'iglu:com.snowplowanalytics.mobile/list_item_view/jsonschema/1-0-0',
|
|
100
95
|
};
|
|
101
96
|
|
|
102
97
|
export { logMessages, schemas };
|
package/src/events.ts
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2020-2023 Snowplow Analytics Ltd. All rights reserved.
|
|
3
|
-
*
|
|
4
|
-
* This program is licensed to you under the Apache License Version 2.0,
|
|
5
|
-
* and you may not use this file except in compliance with the Apache License Version 2.0.
|
|
6
|
-
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
|
|
7
|
-
*
|
|
8
|
-
* Unless required by applicable law or agreed to in writing,
|
|
9
|
-
* software distributed under the Apache License Version 2.0 is distributed on an
|
|
10
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
1
|
'use strict';
|
|
15
2
|
|
|
16
3
|
import { isObject } from './utils';
|
|
@@ -28,6 +15,8 @@ import type {
|
|
|
28
15
|
EcommerceTransactionProps,
|
|
29
16
|
DeepLinkReceivedProps,
|
|
30
17
|
MessageNotificationProps,
|
|
18
|
+
ScrollChangedProps,
|
|
19
|
+
ListItemViewProps,
|
|
31
20
|
} from './types';
|
|
32
21
|
|
|
33
22
|
/**
|
|
@@ -93,6 +82,40 @@ function validateScreenView(argmap: ScreenViewProps): Promise<boolean> {
|
|
|
93
82
|
return Promise.resolve(true);
|
|
94
83
|
}
|
|
95
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Validates a scroll changed event
|
|
87
|
+
*
|
|
88
|
+
* @param argmap {Object} - the object to validate
|
|
89
|
+
* @returns - boolean promise
|
|
90
|
+
*/
|
|
91
|
+
function validateScrollChanged(argmap: ScrollChangedProps): Promise<boolean> {
|
|
92
|
+
// validate type
|
|
93
|
+
if (!isObject(argmap)) {
|
|
94
|
+
return Promise.reject(new Error(logMessages.evType));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return Promise.resolve(true);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Validates a list item view event
|
|
102
|
+
*
|
|
103
|
+
* @param argmap {Object} - the object to validate
|
|
104
|
+
* @returns - boolean promise
|
|
105
|
+
*/
|
|
106
|
+
function validateListItemView(argmap: ListItemViewProps): Promise<boolean> {
|
|
107
|
+
// validate type
|
|
108
|
+
if (!isObject(argmap)) {
|
|
109
|
+
return Promise.reject(new Error(logMessages.evType));
|
|
110
|
+
}
|
|
111
|
+
// validate required props
|
|
112
|
+
if (typeof argmap.index !== 'number') {
|
|
113
|
+
return Promise.reject(new Error(logMessages.listItemViewReq));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return Promise.resolve(true);
|
|
117
|
+
}
|
|
118
|
+
|
|
96
119
|
/**
|
|
97
120
|
* Validates a structured event
|
|
98
121
|
*
|
|
@@ -317,6 +340,8 @@ export {
|
|
|
317
340
|
validateContexts,
|
|
318
341
|
validateSelfDesc,
|
|
319
342
|
validateScreenView,
|
|
343
|
+
validateScrollChanged,
|
|
344
|
+
validateListItemView,
|
|
320
345
|
validateStructured,
|
|
321
346
|
validatePageView,
|
|
322
347
|
validateTiming,
|
package/src/index.ts
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2020-2023 Snowplow Analytics Ltd. All rights reserved.
|
|
3
|
-
*
|
|
4
|
-
* This program is licensed to you under the Apache License Version 2.0,
|
|
5
|
-
* and you may not use this file except in compliance with the Apache License Version 2.0.
|
|
6
|
-
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
|
|
7
|
-
*
|
|
8
|
-
* Unless required by applicable law or agreed to in writing,
|
|
9
|
-
* software distributed under the Apache License Version 2.0 is distributed on an
|
|
10
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
1
|
'use strict';
|
|
15
2
|
|
|
16
3
|
import * as api from './api';
|
|
@@ -55,6 +42,12 @@ function createTracker(
|
|
|
55
42
|
api.trackSelfDescribingEvent(namespace)
|
|
56
43
|
);
|
|
57
44
|
const trackScreenViewEvent = mkMethod(api.trackScreenViewEvent(namespace));
|
|
45
|
+
const trackScrollChangedEvent = mkMethod(
|
|
46
|
+
api.trackScrollChangedEvent(namespace)
|
|
47
|
+
);
|
|
48
|
+
const trackListItemViewEvent = mkMethod(
|
|
49
|
+
api.trackListItemViewEvent(namespace)
|
|
50
|
+
);
|
|
58
51
|
const trackStructuredEvent = mkMethod(api.trackStructuredEvent(namespace));
|
|
59
52
|
const trackPageViewEvent = mkMethod(api.trackPageViewEvent(namespace));
|
|
60
53
|
const trackTimingEvent = mkMethod(api.trackTimingEvent(namespace));
|
|
@@ -100,6 +93,8 @@ function createTracker(
|
|
|
100
93
|
return Object.freeze({
|
|
101
94
|
trackSelfDescribingEvent,
|
|
102
95
|
trackScreenViewEvent,
|
|
96
|
+
trackScrollChangedEvent,
|
|
97
|
+
trackListItemViewEvent,
|
|
103
98
|
trackStructuredEvent,
|
|
104
99
|
trackPageViewEvent,
|
|
105
100
|
trackTimingEvent,
|
package/src/jsCore.ts
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2020-2023 Snowplow Analytics Ltd. All rights reserved.
|
|
3
|
-
*
|
|
4
|
-
* This program is licensed to you under the Apache License Version 2.0,
|
|
5
|
-
* and you may not use this file except in compliance with the Apache License Version 2.0.
|
|
6
|
-
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
|
|
7
|
-
*
|
|
8
|
-
* Unless required by applicable law or agreed to in writing,
|
|
9
|
-
* software distributed under the Apache License Version 2.0 is distributed on an
|
|
10
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
1
|
'use strict';
|
|
15
2
|
|
|
16
3
|
import type {
|
|
@@ -28,6 +15,8 @@ import type {
|
|
|
28
15
|
DeepLinkReceivedProps,
|
|
29
16
|
MessageNotificationProps,
|
|
30
17
|
NetworkConfiguration,
|
|
18
|
+
ScrollChangedProps,
|
|
19
|
+
ListItemViewProps,
|
|
31
20
|
} from './types';
|
|
32
21
|
|
|
33
22
|
import {
|
|
@@ -48,7 +37,7 @@ import { schemas } from './constants';
|
|
|
48
37
|
import { v4 as uuid } from 'uuid';
|
|
49
38
|
|
|
50
39
|
// Tracker version added to the events
|
|
51
|
-
const trackerVersion = 'rn-2.
|
|
40
|
+
const trackerVersion = 'rn-2.1.1';
|
|
52
41
|
|
|
53
42
|
interface Tracker extends TrackerCore {
|
|
54
43
|
setDomainUserId: (duid: string | undefined) => void;
|
|
@@ -60,7 +49,7 @@ let trackers: { [namespace: string]: Tracker } = {};
|
|
|
60
49
|
function preparePayload(payload: Payload): Record<string, string> {
|
|
61
50
|
const stringifiedPayload: Record<string, string> = {};
|
|
62
51
|
|
|
63
|
-
payload
|
|
52
|
+
payload.stm = new Date().getTime().toString();
|
|
64
53
|
|
|
65
54
|
for (const key in payload) {
|
|
66
55
|
if (Object.prototype.hasOwnProperty.call(payload, key)) {
|
|
@@ -265,6 +254,65 @@ function trackScreenViewEvent(details: {
|
|
|
265
254
|
});
|
|
266
255
|
}
|
|
267
256
|
|
|
257
|
+
function trackScrollChangedEvent(details: {
|
|
258
|
+
tracker: string | null;
|
|
259
|
+
eventData: ScrollChangedProps;
|
|
260
|
+
contexts: EventContext[];
|
|
261
|
+
}): Promise<void> {
|
|
262
|
+
const data: Record<string, number> = {};
|
|
263
|
+
|
|
264
|
+
if (details.eventData.yOffset != null) {
|
|
265
|
+
data.y_offset = details.eventData.yOffset;
|
|
266
|
+
}
|
|
267
|
+
if (details.eventData.xOffset != null) {
|
|
268
|
+
data.x_offset = details.eventData.xOffset;
|
|
269
|
+
}
|
|
270
|
+
if (details.eventData.viewHeight != null) {
|
|
271
|
+
data.view_height = details.eventData.viewHeight;
|
|
272
|
+
}
|
|
273
|
+
if (details.eventData.viewWidth != null) {
|
|
274
|
+
data.view_width = details.eventData.viewWidth;
|
|
275
|
+
}
|
|
276
|
+
if (details.eventData.contentHeight != null) {
|
|
277
|
+
data.content_height = details.eventData.contentHeight;
|
|
278
|
+
}
|
|
279
|
+
if (details.eventData.contentWidth != null) {
|
|
280
|
+
data.content_width = details.eventData.contentWidth;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
return trackSelfDescribingEvent({
|
|
284
|
+
tracker: details.tracker,
|
|
285
|
+
eventData: {
|
|
286
|
+
schema: schemas.scrollChangedSchema,
|
|
287
|
+
data: data,
|
|
288
|
+
},
|
|
289
|
+
contexts: details.contexts,
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function trackListItemViewEvent(details: {
|
|
294
|
+
tracker: string | null;
|
|
295
|
+
eventData: ListItemViewProps;
|
|
296
|
+
contexts: EventContext[];
|
|
297
|
+
}): Promise<void> {
|
|
298
|
+
const data: Record<string, number> = {
|
|
299
|
+
index: details.eventData.index,
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
if (details.eventData.itemsCount != null) {
|
|
303
|
+
data.items_count = details.eventData.itemsCount;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
return trackSelfDescribingEvent({
|
|
307
|
+
tracker: details.tracker,
|
|
308
|
+
eventData: {
|
|
309
|
+
schema: schemas.listItemViewSchema,
|
|
310
|
+
data: data,
|
|
311
|
+
},
|
|
312
|
+
contexts: details.contexts,
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
|
|
268
316
|
function trackPageViewEvent(details: {
|
|
269
317
|
tracker: string | null;
|
|
270
318
|
eventData: PageViewProps;
|
|
@@ -523,6 +571,8 @@ const JSSnowplowTracker = Object.freeze({
|
|
|
523
571
|
trackSelfDescribingEvent,
|
|
524
572
|
trackStructuredEvent,
|
|
525
573
|
trackScreenViewEvent,
|
|
574
|
+
trackScrollChangedEvent,
|
|
575
|
+
trackListItemViewEvent,
|
|
526
576
|
trackPageViewEvent,
|
|
527
577
|
trackTimingEvent,
|
|
528
578
|
trackConsentGrantedEvent,
|
package/src/native.ts
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2020-2023 Snowplow Analytics Ltd. All rights reserved.
|
|
3
|
-
*
|
|
4
|
-
* This program is licensed to you under the Apache License Version 2.0,
|
|
5
|
-
* and you may not use this file except in compliance with the Apache License Version 2.0.
|
|
6
|
-
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
|
|
7
|
-
*
|
|
8
|
-
* Unless required by applicable law or agreed to in writing,
|
|
9
|
-
* software distributed under the Apache License Version 2.0 is distributed on an
|
|
10
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
1
|
'use strict';
|
|
15
2
|
|
|
16
3
|
import { NativeModules } from 'react-native';
|
package/src/subject.ts
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2020-2023 Snowplow Analytics Ltd. All rights reserved.
|
|
3
|
-
*
|
|
4
|
-
* This program is licensed to you under the Apache License Version 2.0,
|
|
5
|
-
* and you may not use this file except in compliance with the Apache License Version 2.0.
|
|
6
|
-
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
|
|
7
|
-
*
|
|
8
|
-
* Unless required by applicable law or agreed to in writing,
|
|
9
|
-
* software distributed under the Apache License Version 2.0 is distributed on an
|
|
10
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
1
|
'use strict';
|
|
15
2
|
|
|
16
3
|
import { RNSnowplowTracker } from './native';
|