@snowplow/react-native-tracker 1.4.0 → 2.0.0
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/.editorconfig +15 -0
- package/.eslintignore +6 -0
- package/.gitattributes +3 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +29 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- package/.github/actions/setup/action.yml +28 -0
- package/.github/workflows/build.yml +150 -0
- package/.github/workflows/deploy.yml +98 -0
- package/.github/workflows/e2e-android.yml +121 -0
- package/.github/workflows/e2e-ios.yml +90 -0
- package/.github/workflows/snyk.yml +21 -0
- package/.gitignore +70 -0
- package/.npmignore +60 -0
- package/.nvmrc +1 -0
- package/.watchmanconfig +1 -0
- package/.yarnrc +3 -0
- package/CHANGELOG +166 -0
- package/CONTRIBUTING.md +80 -0
- package/README.md +23 -110
- package/android/build.gradle +93 -37
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +1 -2
- package/android/gradle.properties +5 -2
- package/android/gradlew +172 -110
- package/android/gradlew.bat +24 -19
- package/android/src/main/AndroidManifest.xml +1 -3
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/snowplow/reactnativetracker/ReactNativeTrackerModule.kt +704 -0
- package/android/src/main/java/com/snowplow/reactnativetracker/ReactNativeTrackerPackage.kt +17 -0
- package/android/src/main/java/com/snowplow/reactnativetracker/util/ConfigUtil.kt +271 -0
- package/android/src/main/java/com/snowplow/reactnativetracker/util/EventUtil.kt +213 -0
- package/android/src/main/java/com/snowplow/reactnativetracker/util/TrackerVersion.kt +5 -0
- package/babel.config.js +3 -0
- package/example/.watchmanconfig +1 -0
- package/example/Gemfile +6 -0
- package/example/android/app/build.gradle +129 -0
- package/example/android/app/debug.keystore +0 -0
- package/example/android/app/proguard-rules.pro +10 -0
- package/example/android/app/src/androidTest/java/com/reactnativetrackerexample/DetoxTest.java +36 -0
- package/example/android/app/src/androidTest/java/com/reactnativetrackerexample/DetoxTestAppJUnitRunner.java +21 -0
- package/example/android/app/src/debug/AndroidManifest.xml +13 -0
- package/example/android/app/src/debug/java/com/reactnativetrackerexample/ReactNativeFlipper.java +75 -0
- package/example/android/app/src/main/AndroidManifest.xml +26 -0
- package/example/android/app/src/main/java/com/reactnativetrackerexample/MainActivity.java +32 -0
- package/example/android/app/src/main/java/com/reactnativetrackerexample/MainApplication.java +62 -0
- package/example/android/app/src/main/res/drawable/rn_edit_text_material.xml +36 -0
- package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/values/strings.xml +3 -0
- package/example/android/app/src/main/res/values/styles.xml +9 -0
- package/example/android/app/src/release/java/com/reactnativetrackerexample/ReactNativeFlipper.java +20 -0
- package/example/android/build.gradle +31 -0
- package/example/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/example/android/gradle/wrapper/gradle-wrapper.properties +6 -0
- package/example/android/gradle.properties +44 -0
- package/example/android/gradlew +244 -0
- package/example/android/gradlew.bat +92 -0
- package/example/android/settings.gradle +4 -0
- package/example/app.json +4 -0
- package/example/babel.config.js +17 -0
- package/example/detox.config.js +92 -0
- package/example/e2e/config.json +10 -0
- package/example/e2e/emitEvents.e2e.detox.js +108 -0
- package/example/e2e/environment.js +23 -0
- package/example/e2e/helpers/microCommands.js +153 -0
- package/example/e2e/helpers/microHelpers.js +346 -0
- package/example/e2e/helpers/microHelpers.test.js +308 -0
- package/example/e2e/helpers/schemas.js +62 -0
- package/example/e2e/jest.config.js +16 -0
- package/example/e2e/setup.js +4 -0
- package/example/e2e/testEvents.micro.test.js +300 -0
- package/example/index.js +5 -0
- package/example/ios/.xcode.env +11 -0
- package/example/ios/Podfile +64 -0
- package/example/ios/Podfile.lock +737 -0
- package/example/ios/ReactNativeTrackerExample/AppDelegate.h +6 -0
- package/example/ios/ReactNativeTrackerExample/AppDelegate.mm +26 -0
- package/example/ios/ReactNativeTrackerExample/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
- package/example/ios/ReactNativeTrackerExample/Images.xcassets/Contents.json +6 -0
- package/example/ios/ReactNativeTrackerExample/Info.plist +55 -0
- package/example/ios/ReactNativeTrackerExample/LaunchScreen.storyboard +47 -0
- package/example/ios/ReactNativeTrackerExample/main.m +10 -0
- package/example/ios/ReactNativeTrackerExample-Bridging-Header.h +3 -0
- package/example/ios/ReactNativeTrackerExample.xcodeproj/project.pbxproj +722 -0
- package/{ios/RNSnowplowTracker.xcodeproj/xcshareddata/xcschemes/RNSnowplowTracker.xcscheme → example/ios/ReactNativeTrackerExample.xcodeproj/xcshareddata/xcschemes/ReactNativeTrackerExample.xcscheme} +29 -21
- package/example/ios/ReactNativeTrackerExample.xcworkspace/contents.xcworkspacedata +10 -0
- package/example/ios/ReactNativeTrackerExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/example/ios/ReactNativeTrackerExampleTests/Info.plist +24 -0
- package/example/ios/ReactNativeTrackerExampleTests/ReactNativeTrackerExampleTests.m +66 -0
- package/example/metro.config.js +45 -0
- package/example/package.json +54 -0
- package/example/react-native.config.js +10 -0
- package/example/src/App.js +557 -0
- package/example/tsconfig.json +5 -0
- package/example/yarn.lock +7379 -0
- package/ios/ReactNativeTracker-Bridging-Header.h +2 -0
- package/ios/ReactNativeTracker.mm +165 -0
- package/ios/ReactNativeTracker.swift +757 -0
- package/ios/{RNSnowplowTracker.xcodeproj → ReactNativeTracker.xcodeproj}/project.pbxproj +55 -79
- package/ios/Util/ConfigUtils.swift +206 -0
- package/ios/Util/TrackerVersion.swift +3 -0
- package/ios/Util/Utilities.swift +37 -0
- package/lefthook.yml +11 -0
- package/lib/commonjs/api.js +475 -0
- package/lib/commonjs/api.js.map +1 -0
- package/lib/commonjs/configurations.js +209 -0
- package/lib/commonjs/configurations.js.map +1 -0
- package/lib/commonjs/constants.js +85 -0
- package/lib/commonjs/constants.js.map +1 -0
- package/lib/commonjs/events.js +256 -0
- package/lib/commonjs/events.js.map +1 -0
- package/lib/commonjs/index.js +141 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/jsCore.js +393 -0
- package/lib/commonjs/jsCore.js.map +1 -0
- package/lib/commonjs/native.js +29 -0
- package/lib/commonjs/native.js.map +1 -0
- package/lib/commonjs/subject.js +248 -0
- package/lib/commonjs/subject.js.map +1 -0
- package/lib/commonjs/tracker.js +221 -0
- package/lib/commonjs/tracker.js.map +1 -0
- package/lib/commonjs/types.js +2 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/utils.js +85 -0
- package/lib/commonjs/utils.js.map +1 -0
- package/lib/commonjs/webViewInterface.js +79 -0
- package/lib/commonjs/webViewInterface.js.map +1 -0
- package/lib/module/api.js +439 -0
- package/lib/module/api.js.map +1 -0
- package/lib/module/configurations.js +197 -0
- package/lib/module/configurations.js.map +1 -0
- package/lib/module/constants.js +80 -0
- package/lib/module/constants.js.map +1 -0
- package/lib/module/events.js +240 -0
- package/lib/module/events.js.map +1 -0
- package/lib/module/index.js +129 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/jsCore.js +390 -0
- package/lib/module/jsCore.js.map +1 -0
- package/lib/module/native.js +25 -0
- package/lib/module/native.js.map +1 -0
- package/lib/module/subject.js +235 -0
- package/lib/module/subject.js.map +1 -0
- package/lib/module/tracker.js +209 -0
- package/lib/module/tracker.js.map +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/utils.js +79 -0
- package/lib/module/utils.js.map +1 -0
- package/lib/module/webViewInterface.js +75 -0
- package/lib/module/webViewInterface.js.map +1 -0
- package/lib/typescript/__tests__/api.test.d.ts +2 -0
- package/lib/typescript/__tests__/api.test.d.ts.map +1 -0
- package/lib/typescript/__tests__/configurations.test.d.ts +2 -0
- package/lib/typescript/__tests__/configurations.test.d.ts.map +1 -0
- package/lib/typescript/__tests__/events.test.d.ts +2 -0
- package/lib/typescript/__tests__/events.test.d.ts.map +1 -0
- package/lib/typescript/__tests__/index.test.d.ts +2 -0
- package/lib/typescript/__tests__/index.test.d.ts.map +1 -0
- package/lib/typescript/__tests__/jsCore.test.d.ts +2 -0
- package/lib/typescript/__tests__/jsCore.test.d.ts.map +1 -0
- package/lib/typescript/__tests__/utils.test.d.ts +2 -0
- package/lib/typescript/__tests__/utils.test.d.ts.map +1 -0
- package/lib/typescript/api.d.ts +226 -0
- package/lib/typescript/api.d.ts.map +1 -0
- package/lib/typescript/configurations.d.ts +73 -0
- package/lib/typescript/configurations.d.ts.map +1 -0
- package/lib/typescript/constants.d.ts +59 -0
- package/lib/typescript/constants.d.ts.map +1 -0
- package/lib/typescript/events.d.ts +101 -0
- package/lib/typescript/events.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +27 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/jsCore.d.ts +140 -0
- package/lib/typescript/jsCore.d.ts.map +1 -0
- package/lib/typescript/native.d.ts +4 -0
- package/lib/typescript/native.d.ts.map +1 -0
- package/lib/typescript/subject.d.ts +91 -0
- package/lib/typescript/subject.d.ts.map +1 -0
- package/lib/typescript/tracker.d.ts +93 -0
- package/lib/typescript/tracker.d.ts.map +1 -0
- package/{dist/index.d.ts → lib/typescript/types.d.ts} +188 -75
- package/lib/typescript/types.d.ts.map +1 -0
- package/lib/typescript/utils.d.ts +35 -0
- package/lib/typescript/utils.d.ts.map +1 -0
- package/lib/typescript/webViewInterface.d.ts +15 -0
- package/lib/typescript/webViewInterface.d.ts.map +1 -0
- package/package.json +134 -52
- package/scripts/bootstrap.js +29 -0
- package/snowplow-react-native-tracker.podspec +42 -0
- package/src/__mocks__/react-native.js +7 -0
- package/src/__tests__/api.test.ts +34 -0
- package/src/__tests__/configurations.test.ts +620 -0
- package/src/__tests__/events.test.ts +749 -0
- package/src/__tests__/index.test.ts +27 -0
- package/src/__tests__/jsCore.test.ts +169 -0
- package/src/__tests__/utils.test.ts +23 -0
- package/src/api.ts +535 -0
- package/src/configurations.ts +337 -0
- package/src/constants.ts +102 -0
- package/src/events.ts +330 -0
- package/src/index.ts +189 -0
- package/src/jsCore.ts +553 -0
- package/src/native.ts +34 -0
- package/src/subject.ts +315 -0
- package/src/tracker.ts +330 -0
- package/src/types.ts +1087 -0
- package/src/utils.ts +78 -0
- package/src/webViewInterface.ts +105 -0
- package/tsconfig.build.json +5 -0
- package/tsconfig.json +28 -0
- package/turbo.json +34 -0
- package/yarn.lock +9333 -0
- package/RNSnowplowTracker.podspec +0 -24
- package/android/src/main/java/com/snowplowanalytics/react/tracker/RNSnowplowTrackerModule.java +0 -750
- package/android/src/main/java/com/snowplowanalytics/react/tracker/RNSnowplowTrackerPackage.java +0 -29
- package/android/src/main/java/com/snowplowanalytics/react/util/ConfigUtil.java +0 -351
- package/android/src/main/java/com/snowplowanalytics/react/util/EventUtil.java +0 -339
- package/android/src/main/java/com/snowplowanalytics/react/util/TrackerVersion.java +0 -7
- package/dist/index.js +0 -2026
- package/dist/index.js.map +0 -1
- package/ios/RNSnowplowTracker.h +0 -34
- package/ios/RNSnowplowTracker.m +0 -911
- package/ios/Util/NSDictionary+RNSP_TypeMethods.h +0 -33
- package/ios/Util/NSDictionary+RNSP_TypeMethods.m +0 -40
- package/ios/Util/RNConfigUtils.h +0 -44
- package/ios/Util/RNConfigUtils.m +0 -209
- package/ios/Util/RNTrackerVersion.h +0 -27
- package/ios/Util/RNTrackerVersion.m +0 -27
- package/ios/Util/RNUtilities.h +0 -32
- package/ios/Util/RNUtilities.m +0 -68
|
@@ -0,0 +1,308 @@
|
|
|
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
|
+
const Micro = require('./microHelpers.js');
|
|
15
|
+
|
|
16
|
+
describe('tests helper functions of helpers.js', () => {
|
|
17
|
+
it('tests compare with null, numbers, strings, booleans', () => {
|
|
18
|
+
// null
|
|
19
|
+
expect(Micro.compare(null, null)).toBe(true);
|
|
20
|
+
expect(Micro.compare(null, [])).toBe(false);
|
|
21
|
+
expect(Micro.compare('not null', null)).toBe(false);
|
|
22
|
+
|
|
23
|
+
// numbers
|
|
24
|
+
expect(Micro.compare(1, 1)).toBe(true);
|
|
25
|
+
expect(Micro.compare(2.3, 0)).toBe(false);
|
|
26
|
+
|
|
27
|
+
// strings
|
|
28
|
+
expect(Micro.compare('a', 'a')).toBe(true);
|
|
29
|
+
expect(Micro.compare('a', 'ab')).toBe(false);
|
|
30
|
+
expect(Micro.compare('', 'b')).toBe(false);
|
|
31
|
+
|
|
32
|
+
// booleans
|
|
33
|
+
expect(Micro.compare(false, false)).toBe(true);
|
|
34
|
+
expect(Micro.compare(true, false)).toBe(false);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('tests compare with arrays', () => {
|
|
38
|
+
// arrays and nested arrays
|
|
39
|
+
expect(Micro.compare([], [])).toBe(true);
|
|
40
|
+
|
|
41
|
+
expect(Micro.compare([], [1, 2])).toBe(true);
|
|
42
|
+
|
|
43
|
+
expect(Micro.compare([1, 2], [])).toBe(false);
|
|
44
|
+
|
|
45
|
+
expect(Micro.compare([1, 2], [2])).toBe(false);
|
|
46
|
+
|
|
47
|
+
expect(Micro.compare([1, 2], [2, 1])).toBe(true);
|
|
48
|
+
|
|
49
|
+
expect(Micro.compare([1, 2, 3], [4, 2, 5, 3, 1, 6])).toBe(true);
|
|
50
|
+
|
|
51
|
+
expect(Micro.compare([1, [2, 3], 4], [5, 4, [3, 2, 0], 0, 1])).toBe(true);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('tests compare with objects', () => {
|
|
55
|
+
expect(Micro.compare({}, {})).toBe(true);
|
|
56
|
+
|
|
57
|
+
expect(Micro.compare({}, {a: 1})).toBe(true);
|
|
58
|
+
|
|
59
|
+
expect(Micro.compare({a: 1}, {})).toBe(false);
|
|
60
|
+
|
|
61
|
+
expect(
|
|
62
|
+
Micro.compare(
|
|
63
|
+
{
|
|
64
|
+
a: 1,
|
|
65
|
+
b: 2,
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
a: 1,
|
|
69
|
+
b: 3,
|
|
70
|
+
},
|
|
71
|
+
),
|
|
72
|
+
).toBe(false);
|
|
73
|
+
|
|
74
|
+
expect(
|
|
75
|
+
Micro.compare(
|
|
76
|
+
{
|
|
77
|
+
a: 1,
|
|
78
|
+
b: 2,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
b: 2,
|
|
82
|
+
c: 3,
|
|
83
|
+
a: 1,
|
|
84
|
+
},
|
|
85
|
+
),
|
|
86
|
+
).toBe(true);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('tests compare with arrays of objects', () => {
|
|
90
|
+
// expected, actual
|
|
91
|
+
let exp, act;
|
|
92
|
+
|
|
93
|
+
exp = [
|
|
94
|
+
{
|
|
95
|
+
a: 1,
|
|
96
|
+
b: 2,
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
c: 3,
|
|
100
|
+
},
|
|
101
|
+
];
|
|
102
|
+
act = [
|
|
103
|
+
{
|
|
104
|
+
c: 3,
|
|
105
|
+
e: 5,
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
b: 2,
|
|
109
|
+
a: 1,
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
d: 4,
|
|
113
|
+
},
|
|
114
|
+
];
|
|
115
|
+
expect(Micro.compare(exp, act)).toBe(true);
|
|
116
|
+
|
|
117
|
+
exp = [
|
|
118
|
+
{
|
|
119
|
+
a: 1,
|
|
120
|
+
b: 2,
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
c: 3,
|
|
124
|
+
},
|
|
125
|
+
];
|
|
126
|
+
act = [
|
|
127
|
+
{
|
|
128
|
+
c: 3,
|
|
129
|
+
e: 5,
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
b: 2,
|
|
133
|
+
a: 2,
|
|
134
|
+
},
|
|
135
|
+
];
|
|
136
|
+
expect(Micro.compare(exp, act)).toBe(false);
|
|
137
|
+
|
|
138
|
+
exp = [
|
|
139
|
+
{
|
|
140
|
+
a: 1,
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
c: [
|
|
144
|
+
{
|
|
145
|
+
d: 4,
|
|
146
|
+
e: {
|
|
147
|
+
f: 6,
|
|
148
|
+
g: [1, 2],
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
],
|
|
152
|
+
},
|
|
153
|
+
];
|
|
154
|
+
act = [
|
|
155
|
+
{
|
|
156
|
+
z: 10,
|
|
157
|
+
c: [
|
|
158
|
+
{
|
|
159
|
+
e: {
|
|
160
|
+
g: [3, 2, 1],
|
|
161
|
+
f: 6,
|
|
162
|
+
i: 2,
|
|
163
|
+
},
|
|
164
|
+
d: 4,
|
|
165
|
+
h: 7,
|
|
166
|
+
},
|
|
167
|
+
],
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
a: 1,
|
|
171
|
+
},
|
|
172
|
+
];
|
|
173
|
+
expect(Micro.compare(exp, act)).toBe(true);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it('tests compare with nested objects', () => {
|
|
177
|
+
// expected, actual
|
|
178
|
+
let exp, act_1, act_2;
|
|
179
|
+
|
|
180
|
+
exp = {
|
|
181
|
+
a: {
|
|
182
|
+
b: {
|
|
183
|
+
c: [1, 2],
|
|
184
|
+
d: 'test',
|
|
185
|
+
e: 5,
|
|
186
|
+
},
|
|
187
|
+
f: 1,
|
|
188
|
+
},
|
|
189
|
+
aa: [
|
|
190
|
+
{},
|
|
191
|
+
{
|
|
192
|
+
bb: 1,
|
|
193
|
+
cc: {
|
|
194
|
+
dd: {
|
|
195
|
+
ee: {
|
|
196
|
+
ff: 0,
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
[
|
|
202
|
+
[0, 1],
|
|
203
|
+
{
|
|
204
|
+
aaa: 'bbb',
|
|
205
|
+
ccc: [
|
|
206
|
+
{
|
|
207
|
+
ddd: 3.14,
|
|
208
|
+
},
|
|
209
|
+
],
|
|
210
|
+
},
|
|
211
|
+
0,
|
|
212
|
+
],
|
|
213
|
+
true,
|
|
214
|
+
],
|
|
215
|
+
last: 'thing',
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
// "innocent" diffs
|
|
219
|
+
act_1 = {
|
|
220
|
+
diff1: 0,
|
|
221
|
+
a: {
|
|
222
|
+
b: {
|
|
223
|
+
c: [1, 2],
|
|
224
|
+
diff2: 0,
|
|
225
|
+
d: 'test',
|
|
226
|
+
e: 5,
|
|
227
|
+
},
|
|
228
|
+
diff3: [0, 0, 0],
|
|
229
|
+
f: 1,
|
|
230
|
+
},
|
|
231
|
+
aa: [
|
|
232
|
+
{},
|
|
233
|
+
['diff41', 'diff42'],
|
|
234
|
+
{
|
|
235
|
+
bb: 1,
|
|
236
|
+
cc: {
|
|
237
|
+
dd: {
|
|
238
|
+
ee: {
|
|
239
|
+
ff: 0,
|
|
240
|
+
diff6: 0,
|
|
241
|
+
},
|
|
242
|
+
diff7: {},
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
diff8: 0,
|
|
246
|
+
},
|
|
247
|
+
[
|
|
248
|
+
[0, 1],
|
|
249
|
+
['diff9'],
|
|
250
|
+
{
|
|
251
|
+
aaa: 'bbb',
|
|
252
|
+
ccc: [
|
|
253
|
+
{
|
|
254
|
+
ddd: 3.14,
|
|
255
|
+
},
|
|
256
|
+
],
|
|
257
|
+
},
|
|
258
|
+
0,
|
|
259
|
+
],
|
|
260
|
+
true,
|
|
261
|
+
],
|
|
262
|
+
last: 'thing',
|
|
263
|
+
diff0: 'last',
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
// pi
|
|
267
|
+
act_2 = {
|
|
268
|
+
a: {
|
|
269
|
+
b: {
|
|
270
|
+
c: [1, 2],
|
|
271
|
+
d: 'test',
|
|
272
|
+
e: 5,
|
|
273
|
+
},
|
|
274
|
+
f: 1,
|
|
275
|
+
},
|
|
276
|
+
aa: [
|
|
277
|
+
{},
|
|
278
|
+
{
|
|
279
|
+
bb: 1,
|
|
280
|
+
cc: {
|
|
281
|
+
dd: {
|
|
282
|
+
ee: {
|
|
283
|
+
ff: 0,
|
|
284
|
+
},
|
|
285
|
+
},
|
|
286
|
+
},
|
|
287
|
+
},
|
|
288
|
+
[
|
|
289
|
+
[0, 1],
|
|
290
|
+
{
|
|
291
|
+
aaa: 'bbb',
|
|
292
|
+
ccc: [
|
|
293
|
+
{
|
|
294
|
+
ddd: 3.1415, // only diff with exp
|
|
295
|
+
},
|
|
296
|
+
],
|
|
297
|
+
},
|
|
298
|
+
0,
|
|
299
|
+
],
|
|
300
|
+
true,
|
|
301
|
+
],
|
|
302
|
+
last: 'thing',
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
expect(Micro.compare(exp, act_1)).toBe(true);
|
|
306
|
+
expect(Micro.compare(exp, act_2)).toBe(false);
|
|
307
|
+
});
|
|
308
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
// Self-describing schemas
|
|
15
|
+
const appInstall =
|
|
16
|
+
'iglu:com.snowplowanalytics.mobile/application_install/jsonschema/1-0-0';
|
|
17
|
+
const screenView =
|
|
18
|
+
'iglu:com.snowplowanalytics.mobile/screen_view/jsonschema/1-0-0';
|
|
19
|
+
const adImpression =
|
|
20
|
+
'iglu:com.snowplowanalytics.snowplow/ad_impression/jsonschema/1-0-0';
|
|
21
|
+
const linkClick =
|
|
22
|
+
'iglu:com.snowplowanalytics.snowplow/link_click/jsonschema/1-0-1';
|
|
23
|
+
const consentWithdrawn =
|
|
24
|
+
'iglu:com.snowplowanalytics.snowplow/consent_withdrawn/jsonschema/1-0-0';
|
|
25
|
+
const consentGranted =
|
|
26
|
+
'iglu:com.snowplowanalytics.snowplow/consent_granted/jsonschema/1-0-0';
|
|
27
|
+
const consentDoc =
|
|
28
|
+
'iglu:com.snowplowanalytics.snowplow/consent_document/jsonschema/1-0-0';
|
|
29
|
+
const timing = 'iglu:com.snowplowanalytics.snowplow/timing/jsonschema/1-0-0';
|
|
30
|
+
const deepLink =
|
|
31
|
+
'iglu:com.snowplowanalytics.mobile/deep_link_received/jsonschema/1-0-0';
|
|
32
|
+
const messageNotification =
|
|
33
|
+
'iglu:com.snowplowanalytics.mobile/message_notification/jsonschema/1-0-0';
|
|
34
|
+
|
|
35
|
+
// Context schemas
|
|
36
|
+
const mobileApplicationContext =
|
|
37
|
+
'iglu:com.snowplowanalytics.mobile/application/jsonschema/1-0-0';
|
|
38
|
+
const mobileContext =
|
|
39
|
+
'iglu:com.snowplowanalytics.snowplow/mobile_context/jsonschema/1-0-3';
|
|
40
|
+
const mobileScreenContext =
|
|
41
|
+
'iglu:com.snowplowanalytics.mobile/screen/jsonschema/1-0-0';
|
|
42
|
+
const clientSessionContext =
|
|
43
|
+
'iglu:com.snowplowanalytics.snowplow/client_session/jsonschema/1-0-2';
|
|
44
|
+
const gdprContext = 'iglu:com.snowplowanalytics.snowplow/gdpr/jsonschema/1-0-0';
|
|
45
|
+
|
|
46
|
+
module.exports = {
|
|
47
|
+
appInstall,
|
|
48
|
+
screenView,
|
|
49
|
+
adImpression,
|
|
50
|
+
linkClick,
|
|
51
|
+
consentWithdrawn,
|
|
52
|
+
consentGranted,
|
|
53
|
+
consentDoc,
|
|
54
|
+
timing,
|
|
55
|
+
mobileApplicationContext,
|
|
56
|
+
mobileContext,
|
|
57
|
+
mobileScreenContext,
|
|
58
|
+
clientSessionContext,
|
|
59
|
+
gdprContext,
|
|
60
|
+
deepLink,
|
|
61
|
+
messageNotification,
|
|
62
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** @type {import('jest').Config} */
|
|
2
|
+
module.exports = {
|
|
3
|
+
maxWorkers: 1,
|
|
4
|
+
globalSetup: "detox/runners/jest/globalSetup",
|
|
5
|
+
globalTeardown: "detox/runners/jest/globalTeardown",
|
|
6
|
+
testEnvironment: "detox/runners/jest/testEnvironment",
|
|
7
|
+
setupFilesAfterEnv: ["./setup.js"],
|
|
8
|
+
testRunner: "jest-circus/runner",
|
|
9
|
+
testTimeout: 300000,
|
|
10
|
+
testRegex: "\\.e2e.detox\\.js$",
|
|
11
|
+
transform: {
|
|
12
|
+
"\\.tsx?$": "ts-jest"
|
|
13
|
+
},
|
|
14
|
+
reporters: ["detox/runners/jest/reporter"],
|
|
15
|
+
verbose: true
|
|
16
|
+
};
|
|
@@ -0,0 +1,300 @@
|
|
|
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
|
+
const commands = require('./helpers/microCommands.js');
|
|
15
|
+
const schemas = require('./helpers/schemas.js');
|
|
16
|
+
|
|
17
|
+
test('no bad events', async () => {
|
|
18
|
+
await commands.assertNoBadEvents();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test('number of screen_view events', async () => {
|
|
22
|
+
await commands.eventsWithSchema(schemas.screenView, 9);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test('number of structured events', async () => {
|
|
26
|
+
await commands.eventsWithEventType('struct', 6);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('number of page_view events', async () => {
|
|
30
|
+
await commands.eventsWithEventType('page_view', 4);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('screen_view with adImpression context', async () => {
|
|
34
|
+
await commands.eventsWithProperties(
|
|
35
|
+
{
|
|
36
|
+
schema: schemas.screenView,
|
|
37
|
+
values: {
|
|
38
|
+
name: 'withContext and screenId',
|
|
39
|
+
},
|
|
40
|
+
contexts: [
|
|
41
|
+
{
|
|
42
|
+
schema: schemas.adImpression,
|
|
43
|
+
data: {
|
|
44
|
+
impressionId: 'test_imp_id',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
1
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test('self-describing ad_impression event', async () => {
|
|
54
|
+
await commands.eventsWithProperties(
|
|
55
|
+
{
|
|
56
|
+
schema: schemas.linkClick,
|
|
57
|
+
values: {
|
|
58
|
+
targetUrl: 'test.test',
|
|
59
|
+
},
|
|
60
|
+
contexts: [
|
|
61
|
+
{ schema: schemas.mobileApplicationContext },
|
|
62
|
+
{ schema: schemas.mobileContext },
|
|
63
|
+
{ schema: schemas.mobileScreenContext },
|
|
64
|
+
{ schema: schemas.clientSessionContext },
|
|
65
|
+
{ schema: schemas.gdprContext },
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
1
|
|
69
|
+
);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test('consentWithdrawn event', async () => {
|
|
73
|
+
await commands.eventsWithProperties(
|
|
74
|
+
{
|
|
75
|
+
schema: schemas.consentWithdrawn,
|
|
76
|
+
values: {
|
|
77
|
+
all: true,
|
|
78
|
+
},
|
|
79
|
+
contexts: [
|
|
80
|
+
{
|
|
81
|
+
schema: schemas.consentDoc,
|
|
82
|
+
data: {
|
|
83
|
+
id: '0987',
|
|
84
|
+
version: '0.2.0',
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
},
|
|
89
|
+
1
|
|
90
|
+
);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test('consentGranted event', async () => {
|
|
94
|
+
await commands.eventsWithProperties(
|
|
95
|
+
{
|
|
96
|
+
schema: schemas.consentGranted,
|
|
97
|
+
values: {
|
|
98
|
+
expiry: '2022-01-01T00:00:00Z',
|
|
99
|
+
},
|
|
100
|
+
contexts: [
|
|
101
|
+
{
|
|
102
|
+
schema: schemas.consentDoc,
|
|
103
|
+
data: {
|
|
104
|
+
id: '0123',
|
|
105
|
+
version: '0.1.0',
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
},
|
|
110
|
+
1
|
|
111
|
+
);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test('timing event', async () => {
|
|
115
|
+
await commands.eventsWithProperties(
|
|
116
|
+
{
|
|
117
|
+
schema: schemas.timing,
|
|
118
|
+
values: {
|
|
119
|
+
variable: 'testTimingVariable',
|
|
120
|
+
category: 'testTimingCategory',
|
|
121
|
+
timing: 10,
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
1
|
|
125
|
+
);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
test('transaction item event', async () => {
|
|
129
|
+
await commands.eventsWithProperties(
|
|
130
|
+
{
|
|
131
|
+
parameters: {
|
|
132
|
+
event: 'transaction_item',
|
|
133
|
+
ti_orderid: '0000',
|
|
134
|
+
ti_sku: '123',
|
|
135
|
+
ti_price: 5,
|
|
136
|
+
ti_quantity: 2,
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
1
|
|
140
|
+
);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test('ecommerce transaction event', async () => {
|
|
144
|
+
await commands.eventsWithProperties(
|
|
145
|
+
{
|
|
146
|
+
parameters: {
|
|
147
|
+
event: 'transaction',
|
|
148
|
+
tr_orderid: '0000',
|
|
149
|
+
tr_total: 10,
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
1
|
|
153
|
+
);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
test('deep link event', async () => {
|
|
157
|
+
await commands.eventsWithProperties(
|
|
158
|
+
{
|
|
159
|
+
schema: schemas.deepLink,
|
|
160
|
+
values: {
|
|
161
|
+
url: 'https://deeplink.com',
|
|
162
|
+
referrer: 'http://refr.com',
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
1
|
|
166
|
+
);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
test('message notification event', async () => {
|
|
170
|
+
await commands.eventsWithProperties(
|
|
171
|
+
{
|
|
172
|
+
schema: schemas.messageNotification,
|
|
173
|
+
values: {
|
|
174
|
+
title: 'title1',
|
|
175
|
+
body: 'body1',
|
|
176
|
+
trigger: 'push',
|
|
177
|
+
action: 'action1',
|
|
178
|
+
attachments: [
|
|
179
|
+
{
|
|
180
|
+
identifier: 'att_id1',
|
|
181
|
+
type: 'att_type1',
|
|
182
|
+
url: 'http://att.url.1',
|
|
183
|
+
},
|
|
184
|
+
],
|
|
185
|
+
bodyLocArgs: ['bodyArg1', 'bodyArg2'],
|
|
186
|
+
bodyLocKey: 'bodyKey1',
|
|
187
|
+
category: 'category1',
|
|
188
|
+
contentAvailable: true,
|
|
189
|
+
group: 'group1',
|
|
190
|
+
icon: 'icon1',
|
|
191
|
+
notificationCount: 3,
|
|
192
|
+
notificationTimestamp: '2022-02-02T15:17:42.767Z',
|
|
193
|
+
sound: 'sound1',
|
|
194
|
+
subtitle: 'subtitle1',
|
|
195
|
+
tag: 'tag1',
|
|
196
|
+
threadIdentifier: 'threadIdentifier1',
|
|
197
|
+
titleLocArgs: ['titleArg1', 'titleArg2'],
|
|
198
|
+
titleLocKey: 'titleKey1',
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
1
|
|
202
|
+
);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
test('common in all first tracker events', async () => {
|
|
206
|
+
await commands.eventsWithProperties(
|
|
207
|
+
{
|
|
208
|
+
parameters: {
|
|
209
|
+
app_id: 'DemoAppId',
|
|
210
|
+
platform: 'iot',
|
|
211
|
+
name_tracker: 'sp1',
|
|
212
|
+
},
|
|
213
|
+
header: 'test: works',
|
|
214
|
+
contexts: [
|
|
215
|
+
{ schema: schemas.mobileApplicationContext },
|
|
216
|
+
{ schema: schemas.mobileContext },
|
|
217
|
+
{ schema: schemas.mobileScreenContext },
|
|
218
|
+
{ schema: schemas.clientSessionContext },
|
|
219
|
+
{
|
|
220
|
+
schema: schemas.gdprContext,
|
|
221
|
+
data: {
|
|
222
|
+
basisForProcessing: 'consent',
|
|
223
|
+
documentDescription: 'test gdpr document',
|
|
224
|
+
documentId: 'docId',
|
|
225
|
+
documentVersion: '0.0.1',
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
schema: schemas.adImpression,
|
|
230
|
+
data: { impressionId: 'test_global_contexts_0' },
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
schema: schemas.adImpression,
|
|
234
|
+
data: { impressionId: 'test_global_contexts_1' },
|
|
235
|
+
},
|
|
236
|
+
],
|
|
237
|
+
},
|
|
238
|
+
23
|
|
239
|
+
);
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
test('events after resetting the Subject', async () => {
|
|
243
|
+
await commands.eventsWithProperties(
|
|
244
|
+
{
|
|
245
|
+
parameters: {
|
|
246
|
+
user_id: 'nextTester',
|
|
247
|
+
dvce_screenwidth: 300,
|
|
248
|
+
dvce_screenheight: 300,
|
|
249
|
+
br_lang: 'es',
|
|
250
|
+
os_timezone: 'Europe/London',
|
|
251
|
+
},
|
|
252
|
+
schema: schemas.screenView,
|
|
253
|
+
values: {
|
|
254
|
+
name: 'afterSetSubjectTestSV',
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
1
|
|
258
|
+
);
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
test('second tracker events', async () => {
|
|
262
|
+
await commands.eventsWithProperties(
|
|
263
|
+
{
|
|
264
|
+
parameters: {
|
|
265
|
+
name_tracker: 'sp2',
|
|
266
|
+
},
|
|
267
|
+
contexts: [
|
|
268
|
+
{ schema: schemas.mobileApplicationContext },
|
|
269
|
+
{ schema: schemas.mobileContext },
|
|
270
|
+
{ schema: schemas.mobileScreenContext },
|
|
271
|
+
{ schema: schemas.clientSessionContext },
|
|
272
|
+
],
|
|
273
|
+
},
|
|
274
|
+
2
|
|
275
|
+
);
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
test('anonymous tracker events', async () => {
|
|
279
|
+
await commands.eventsWithProperties(
|
|
280
|
+
{
|
|
281
|
+
parameters: {
|
|
282
|
+
name_tracker: 'sp_anon',
|
|
283
|
+
network_userid: '00000000-0000-0000-0000-000000000000',
|
|
284
|
+
},
|
|
285
|
+
event: {
|
|
286
|
+
contexts: {
|
|
287
|
+
data: [
|
|
288
|
+
{
|
|
289
|
+
schema: schemas.clientSessionContext,
|
|
290
|
+
data: {
|
|
291
|
+
userId: '00000000-0000-0000-0000-000000000000',
|
|
292
|
+
},
|
|
293
|
+
},
|
|
294
|
+
],
|
|
295
|
+
},
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
2
|
|
299
|
+
);
|
|
300
|
+
});
|
package/example/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# This `.xcode.env` file is versioned and is used to source the environment
|
|
2
|
+
# used when running script phases inside Xcode.
|
|
3
|
+
# To customize your local environment, you can create an `.xcode.env.local`
|
|
4
|
+
# file that is not versioned.
|
|
5
|
+
|
|
6
|
+
# NODE_BINARY variable contains the PATH to the node executable.
|
|
7
|
+
#
|
|
8
|
+
# Customize the NODE_BINARY variable here.
|
|
9
|
+
# For example, to use nvm with brew, add the following line
|
|
10
|
+
# . "$(brew --prefix nvm)/nvm.sh" --no-use
|
|
11
|
+
export NODE_BINARY=$(command -v node)
|