@snowplow/react-native-tracker 2.1.2 → 4.0.2-dev.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/LICENSE +29 -203
- package/README.md +59 -143
- package/dist/index.cjs.d.ts +499 -0
- package/dist/index.cjs.js +2656 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.cjs.min.d.ts +499 -0
- package/dist/index.cjs.min.js +63 -0
- package/dist/index.cjs.min.js.map +1 -0
- package/dist/index.module.d.ts +499 -0
- package/dist/index.module.js +250 -0
- package/dist/index.module.js.map +1 -0
- package/package.json +48 -158
- package/.editorconfig +0 -15
- package/.eslintignore +0 -6
- package/.gitattributes +0 -3
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -29
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- package/.github/actions/setup/action.yml +0 -28
- package/.github/workflows/build.yml +0 -155
- package/.github/workflows/deploy.yml +0 -97
- package/.github/workflows/e2e-android.yml +0 -121
- package/.github/workflows/e2e-ios.yml +0 -95
- package/.github/workflows/snyk.yml +0 -21
- package/.gitignore +0 -70
- package/.npmignore +0 -60
- package/.nvmrc +0 -1
- package/.watchmanconfig +0 -1
- package/.yarnrc +0 -3
- package/CHANGELOG +0 -184
- package/CONTRIBUTING.md +0 -80
- package/android/build.gradle +0 -110
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +0 -5
- package/android/gradle.properties +0 -5
- package/android/gradlew +0 -234
- package/android/gradlew.bat +0 -89
- package/android/src/main/AndroidManifest.xml +0 -3
- package/android/src/main/AndroidManifestNew.xml +0 -2
- package/android/src/main/java/com/snowplow/reactnativetracker/ReactNativeTrackerModule.kt +0 -744
- package/android/src/main/java/com/snowplow/reactnativetracker/ReactNativeTrackerPackage.kt +0 -17
- package/android/src/main/java/com/snowplow/reactnativetracker/util/ConfigUtil.kt +0 -274
- package/android/src/main/java/com/snowplow/reactnativetracker/util/EventUtil.kt +0 -233
- package/android/src/main/java/com/snowplow/reactnativetracker/util/TrackerVersion.kt +0 -5
- package/babel.config.js +0 -3
- package/example/.watchmanconfig +0 -1
- package/example/Gemfile +0 -6
- package/example/android/app/build.gradle +0 -129
- package/example/android/app/debug.keystore +0 -0
- package/example/android/app/proguard-rules.pro +0 -10
- package/example/android/app/src/androidTest/java/com/reactnativetrackerexample/DetoxTest.java +0 -36
- package/example/android/app/src/androidTest/java/com/reactnativetrackerexample/DetoxTestAppJUnitRunner.java +0 -21
- package/example/android/app/src/debug/AndroidManifest.xml +0 -13
- package/example/android/app/src/debug/java/com/reactnativetrackerexample/ReactNativeFlipper.java +0 -75
- package/example/android/app/src/main/AndroidManifest.xml +0 -26
- package/example/android/app/src/main/java/com/reactnativetrackerexample/MainActivity.java +0 -32
- package/example/android/app/src/main/java/com/reactnativetrackerexample/MainApplication.java +0 -62
- package/example/android/app/src/main/res/drawable/rn_edit_text_material.xml +0 -36
- 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 +0 -3
- package/example/android/app/src/main/res/values/styles.xml +0 -9
- package/example/android/app/src/release/java/com/reactnativetrackerexample/ReactNativeFlipper.java +0 -20
- package/example/android/build.gradle +0 -31
- package/example/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/example/android/gradle/wrapper/gradle-wrapper.properties +0 -6
- package/example/android/gradle.properties +0 -44
- package/example/android/gradlew +0 -244
- package/example/android/gradlew.bat +0 -92
- package/example/android/settings.gradle +0 -4
- package/example/app.json +0 -4
- package/example/babel.config.js +0 -17
- package/example/detox.config.js +0 -92
- package/example/e2e/config.json +0 -10
- package/example/e2e/emitEvents.e2e.detox.js +0 -95
- package/example/e2e/environment.js +0 -23
- package/example/e2e/helpers/microCommands.js +0 -140
- package/example/e2e/helpers/microHelpers.js +0 -333
- package/example/e2e/helpers/microHelpers.test.js +0 -295
- package/example/e2e/helpers/schemas.js +0 -49
- package/example/e2e/jest.config.js +0 -16
- package/example/e2e/setup.js +0 -4
- package/example/e2e/testEvents.micro.test.js +0 -287
- package/example/index.js +0 -5
- package/example/ios/.xcode.env +0 -11
- package/example/ios/Podfile +0 -62
- package/example/ios/Podfile.lock +0 -730
- package/example/ios/ReactNativeTrackerExample/AppDelegate.h +0 -6
- package/example/ios/ReactNativeTrackerExample/AppDelegate.mm +0 -26
- package/example/ios/ReactNativeTrackerExample/Images.xcassets/AppIcon.appiconset/Contents.json +0 -53
- package/example/ios/ReactNativeTrackerExample/Images.xcassets/Contents.json +0 -6
- package/example/ios/ReactNativeTrackerExample/Info.plist +0 -55
- package/example/ios/ReactNativeTrackerExample/LaunchScreen.storyboard +0 -47
- package/example/ios/ReactNativeTrackerExample/PrivacyInfo.xcprivacy +0 -37
- package/example/ios/ReactNativeTrackerExample/main.m +0 -10
- package/example/ios/ReactNativeTrackerExample-Bridging-Header.h +0 -3
- package/example/ios/ReactNativeTrackerExample.xcodeproj/project.pbxproj +0 -739
- package/example/ios/ReactNativeTrackerExample.xcodeproj/xcshareddata/xcschemes/ReactNativeTrackerExample.xcscheme +0 -88
- package/example/ios/ReactNativeTrackerExample.xcworkspace/contents.xcworkspacedata +0 -10
- package/example/ios/ReactNativeTrackerExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/example/ios/ReactNativeTrackerExampleTests/Info.plist +0 -24
- package/example/ios/ReactNativeTrackerExampleTests/ReactNativeTrackerExampleTests.m +0 -66
- package/example/metro.config.js +0 -45
- package/example/package.json +0 -54
- package/example/react-native.config.js +0 -10
- package/example/src/App.js +0 -566
- package/example/tsconfig.json +0 -5
- package/example/yarn.lock +0 -7703
- package/ios/ReactNativeTracker-Bridging-Header.h +0 -2
- package/ios/ReactNativeTracker.mm +0 -171
- package/ios/ReactNativeTracker.swift +0 -822
- package/ios/ReactNativeTracker.xcodeproj/project.pbxproj +0 -301
- package/ios/Util/ConfigUtils.swift +0 -209
- package/ios/Util/TrackerVersion.swift +0 -3
- package/ios/Util/Utilities.swift +0 -37
- package/lefthook.yml +0 -11
- package/lib/commonjs/api.js +0 -490
- package/lib/commonjs/api.js.map +0 -1
- package/lib/commonjs/configurations.js +0 -196
- package/lib/commonjs/configurations.js.map +0 -1
- package/lib/commonjs/constants.js +0 -77
- package/lib/commonjs/constants.js.map +0 -1
- package/lib/commonjs/events.js +0 -277
- package/lib/commonjs/events.js.map +0 -1
- package/lib/commonjs/index.js +0 -132
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/jsCore.js +0 -427
- package/lib/commonjs/jsCore.js.map +0 -1
- package/lib/commonjs/native.js +0 -16
- package/lib/commonjs/native.js.map +0 -1
- package/lib/commonjs/subject.js +0 -235
- package/lib/commonjs/subject.js.map +0 -1
- package/lib/commonjs/tracker.js +0 -248
- package/lib/commonjs/tracker.js.map +0 -1
- package/lib/commonjs/types.js +0 -2
- package/lib/commonjs/types.js.map +0 -1
- package/lib/commonjs/utils.js +0 -72
- package/lib/commonjs/utils.js.map +0 -1
- package/lib/commonjs/webViewInterface.js +0 -66
- package/lib/commonjs/webViewInterface.js.map +0 -1
- package/lib/module/api.js +0 -452
- package/lib/module/api.js.map +0 -1
- package/lib/module/configurations.js +0 -184
- package/lib/module/configurations.js.map +0 -1
- package/lib/module/constants.js +0 -72
- package/lib/module/constants.js.map +0 -1
- package/lib/module/events.js +0 -259
- package/lib/module/events.js.map +0 -1
- package/lib/module/index.js +0 -120
- package/lib/module/index.js.map +0 -1
- package/lib/module/jsCore.js +0 -424
- package/lib/module/jsCore.js.map +0 -1
- package/lib/module/native.js +0 -12
- package/lib/module/native.js.map +0 -1
- package/lib/module/subject.js +0 -222
- package/lib/module/subject.js.map +0 -1
- package/lib/module/tracker.js +0 -234
- package/lib/module/tracker.js.map +0 -1
- package/lib/module/types.js +0 -2
- package/lib/module/types.js.map +0 -1
- package/lib/module/utils.js +0 -66
- package/lib/module/utils.js.map +0 -1
- package/lib/module/webViewInterface.js +0 -62
- package/lib/module/webViewInterface.js.map +0 -1
- package/lib/typescript/__tests__/api.test.d.ts +0 -2
- package/lib/typescript/__tests__/api.test.d.ts.map +0 -1
- package/lib/typescript/__tests__/configurations.test.d.ts +0 -2
- package/lib/typescript/__tests__/configurations.test.d.ts.map +0 -1
- package/lib/typescript/__tests__/events.test.d.ts +0 -2
- package/lib/typescript/__tests__/events.test.d.ts.map +0 -1
- package/lib/typescript/__tests__/index.test.d.ts +0 -2
- package/lib/typescript/__tests__/index.test.d.ts.map +0 -1
- package/lib/typescript/__tests__/jsCore.test.d.ts +0 -2
- package/lib/typescript/__tests__/jsCore.test.d.ts.map +0 -1
- package/lib/typescript/__tests__/utils.test.d.ts +0 -2
- package/lib/typescript/__tests__/utils.test.d.ts.map +0 -1
- package/lib/typescript/api.d.ts +0 -240
- package/lib/typescript/api.d.ts.map +0 -1
- package/lib/typescript/configurations.d.ts +0 -73
- package/lib/typescript/configurations.d.ts.map +0 -1
- package/lib/typescript/constants.d.ts +0 -64
- package/lib/typescript/constants.d.ts.map +0 -1
- package/lib/typescript/events.d.ts +0 -115
- package/lib/typescript/events.d.ts.map +0 -1
- package/lib/typescript/index.d.ts +0 -27
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/jsCore.d.ts +0 -152
- package/lib/typescript/jsCore.d.ts.map +0 -1
- package/lib/typescript/native.d.ts +0 -4
- package/lib/typescript/native.d.ts.map +0 -1
- package/lib/typescript/subject.d.ts +0 -91
- package/lib/typescript/subject.d.ts.map +0 -1
- package/lib/typescript/tracker.d.ts +0 -111
- package/lib/typescript/tracker.d.ts.map +0 -1
- package/lib/typescript/types.d.ts +0 -981
- package/lib/typescript/types.d.ts.map +0 -1
- package/lib/typescript/utils.d.ts +0 -35
- package/lib/typescript/utils.d.ts.map +0 -1
- package/lib/typescript/webViewInterface.d.ts +0 -15
- package/lib/typescript/webViewInterface.d.ts.map +0 -1
- package/scripts/bootstrap.js +0 -29
- package/snowplow-react-native-tracker.podspec +0 -42
- package/src/__mocks__/react-native.js +0 -7
- package/src/__tests__/api.test.ts +0 -21
- package/src/__tests__/configurations.test.ts +0 -608
- package/src/__tests__/events.test.ts +0 -736
- package/src/__tests__/index.test.ts +0 -14
- package/src/__tests__/jsCore.test.ts +0 -199
- package/src/__tests__/utils.test.ts +0 -10
- package/src/api.ts +0 -556
- package/src/configurations.ts +0 -325
- package/src/constants.ts +0 -97
- package/src/events.ts +0 -355
- package/src/index.ts +0 -184
- package/src/jsCore.ts +0 -603
- package/src/native.ts +0 -21
- package/src/subject.ts +0 -302
- package/src/tracker.ts +0 -377
- package/src/types.ts +0 -1162
- package/src/utils.ts +0 -65
- package/src/webViewInterface.ts +0 -92
- package/tsconfig.build.json +0 -5
- package/tsconfig.json +0 -28
- package/turbo.json +0 -34
- package/yarn.lock +0 -9398
|
@@ -1,608 +0,0 @@
|
|
|
1
|
-
import * as c from '../configurations';
|
|
2
|
-
import { logMessages } from '../constants';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* initValidate
|
|
6
|
-
*/
|
|
7
|
-
describe('test initValidate rejects', () => {
|
|
8
|
-
test('test missing namespace', async () => {
|
|
9
|
-
const testConfig = {
|
|
10
|
-
networkConfig: { endpoint: 'test' },
|
|
11
|
-
};
|
|
12
|
-
await expect(c.initValidate(testConfig as any)).rejects.toThrow(
|
|
13
|
-
logMessages.namespace
|
|
14
|
-
);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
test('test invalid namespace', async () => {
|
|
18
|
-
const testConfig = {
|
|
19
|
-
namespace: '',
|
|
20
|
-
networkConfig: { endpoint: 'test' },
|
|
21
|
-
};
|
|
22
|
-
await expect(c.initValidate(testConfig as any)).rejects.toThrow(
|
|
23
|
-
logMessages.namespace
|
|
24
|
-
);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
test('test missing endpoint', async () => {
|
|
28
|
-
const testConfig = {
|
|
29
|
-
namespace: 'sp1',
|
|
30
|
-
networkConfig: { method: 'get' },
|
|
31
|
-
};
|
|
32
|
-
await expect(c.initValidate(testConfig as any)).rejects.toThrow(
|
|
33
|
-
logMessages.network
|
|
34
|
-
);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
test('test invalid endpoint', async () => {
|
|
38
|
-
const testConfig = {
|
|
39
|
-
namespace: 'sp1',
|
|
40
|
-
networkConfig: { endpoint: '', method: 'get' },
|
|
41
|
-
};
|
|
42
|
-
await expect(c.initValidate(testConfig as any)).rejects.toThrow(
|
|
43
|
-
logMessages.network
|
|
44
|
-
);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
test('test invalid networkConfig', async () => {
|
|
48
|
-
const testConfig = {
|
|
49
|
-
namespace: 'sp1',
|
|
50
|
-
networkConfig: { endpoint: 'test', invalid: true },
|
|
51
|
-
};
|
|
52
|
-
await expect(c.initValidate(testConfig as any)).rejects.toThrow(
|
|
53
|
-
logMessages.network
|
|
54
|
-
);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
test('test invalid trackerConfig', async () => {
|
|
58
|
-
const testConfig = {
|
|
59
|
-
namespace: 'sp1',
|
|
60
|
-
networkConfig: { endpoint: 'test' },
|
|
61
|
-
trackerConfig: { invalid: true },
|
|
62
|
-
};
|
|
63
|
-
await expect(c.initValidate(testConfig as any)).rejects.toThrow(
|
|
64
|
-
logMessages.tracker
|
|
65
|
-
);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
test('test invalid sessionConfig', async () => {
|
|
69
|
-
const testConfig = {
|
|
70
|
-
namespace: 'sp1',
|
|
71
|
-
networkConfig: { endpoint: 'test' },
|
|
72
|
-
sessionConfig: { invalid: true },
|
|
73
|
-
};
|
|
74
|
-
await expect(c.initValidate(testConfig as any)).rejects.toThrow(
|
|
75
|
-
logMessages.session
|
|
76
|
-
);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
test('test invalid emitterConfig', async () => {
|
|
80
|
-
const testConfig = {
|
|
81
|
-
namespace: 'sp1',
|
|
82
|
-
networkConfig: { endpoint: 'test' },
|
|
83
|
-
emitterConfig: { invalid: true },
|
|
84
|
-
};
|
|
85
|
-
await expect(c.initValidate(testConfig as any)).rejects.toThrow(
|
|
86
|
-
logMessages.emitter
|
|
87
|
-
);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
test('test invalid subjectConfig', async () => {
|
|
91
|
-
const testConfig = {
|
|
92
|
-
namespace: 'sp1',
|
|
93
|
-
networkConfig: { endpoint: 'test' },
|
|
94
|
-
subjectConfig: { userId: 'tester', invalid: true },
|
|
95
|
-
};
|
|
96
|
-
await expect(c.initValidate(testConfig as any)).rejects.toThrow(
|
|
97
|
-
logMessages.subject
|
|
98
|
-
);
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
test('test invalid gdprConfig - extra', async () => {
|
|
102
|
-
const testConfig = {
|
|
103
|
-
namespace: 'sp1',
|
|
104
|
-
networkConfig: { endpoint: 'test' },
|
|
105
|
-
gdprConfig: {
|
|
106
|
-
basisForProcessing: 'consent',
|
|
107
|
-
documentId: '12345',
|
|
108
|
-
documentVersion: '1.0.0',
|
|
109
|
-
documentDescription: 'gdpr document description',
|
|
110
|
-
invalid: true,
|
|
111
|
-
},
|
|
112
|
-
};
|
|
113
|
-
await expect(c.initValidate(testConfig as any)).rejects.toThrow(
|
|
114
|
-
logMessages.gdpr
|
|
115
|
-
);
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
test('test invalid gdprConfig - missing', async () => {
|
|
119
|
-
const testConfig = {
|
|
120
|
-
namespace: 'sp1',
|
|
121
|
-
networkConfig: { endpoint: 'test' },
|
|
122
|
-
gdprConfig: {
|
|
123
|
-
basisForProcessing: 'consent',
|
|
124
|
-
documentId: '12345',
|
|
125
|
-
documentVersion: '1.0.0',
|
|
126
|
-
},
|
|
127
|
-
};
|
|
128
|
-
await expect(c.initValidate(testConfig as any)).rejects.toThrow(
|
|
129
|
-
logMessages.gdpr
|
|
130
|
-
);
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
test('test invalid gdprConfig - basis', async () => {
|
|
134
|
-
const testConfig = {
|
|
135
|
-
namespace: 'sp1',
|
|
136
|
-
networkConfig: { endpoint: 'test' },
|
|
137
|
-
gdprConfig: {
|
|
138
|
-
basisForProcessing: 'invalid',
|
|
139
|
-
documentId: '12345',
|
|
140
|
-
documentVersion: '1.0.0',
|
|
141
|
-
documentDescription: 'gdpr document description',
|
|
142
|
-
},
|
|
143
|
-
};
|
|
144
|
-
await expect(c.initValidate(testConfig as any)).rejects.toThrow(
|
|
145
|
-
logMessages.gdpr
|
|
146
|
-
);
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
// when initValidate resolves
|
|
151
|
-
describe('test initValidate resolves', () => {
|
|
152
|
-
test('test minimal required', async () => {
|
|
153
|
-
const testConfig = {
|
|
154
|
-
namespace: 'sp1',
|
|
155
|
-
networkConfig: { endpoint: 'test' },
|
|
156
|
-
};
|
|
157
|
-
await expect(c.initValidate(testConfig as any)).resolves.toBe(true);
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
test('test valid networkConfig', async () => {
|
|
161
|
-
const testConfig = {
|
|
162
|
-
namespace: 'sp1',
|
|
163
|
-
networkConfig: {
|
|
164
|
-
endpoint: 'test',
|
|
165
|
-
method: 'get',
|
|
166
|
-
customPostPath: 'custom/path',
|
|
167
|
-
requestHeaders: { the: 'header' },
|
|
168
|
-
},
|
|
169
|
-
};
|
|
170
|
-
await expect(c.initValidate(testConfig as any)).resolves.toBe(true);
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
test('test valid trackerConfig', async () => {
|
|
174
|
-
const testConfig = {
|
|
175
|
-
namespace: 'sp1',
|
|
176
|
-
networkConfig: { endpoint: 'test' },
|
|
177
|
-
trackerConfig: { base64Encoding: false },
|
|
178
|
-
};
|
|
179
|
-
await expect(c.initValidate(testConfig as any)).resolves.toBe(true);
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
test('test valid sessionConfig', async () => {
|
|
183
|
-
const testConfig = {
|
|
184
|
-
namespace: 'sp1',
|
|
185
|
-
networkConfig: { endpoint: 'test' },
|
|
186
|
-
sessionConfig: { foregroundTimeout: 100, backgroundTimeout: 100 },
|
|
187
|
-
};
|
|
188
|
-
await expect(c.initValidate(testConfig as any)).resolves.toBe(true);
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
test('test valid emitterConfig', async () => {
|
|
192
|
-
const testConfig = {
|
|
193
|
-
namespace: 'sp1',
|
|
194
|
-
networkConfig: { endpoint: 'test' },
|
|
195
|
-
emitterConfig: { byteLimitPost: 20000 },
|
|
196
|
-
};
|
|
197
|
-
await expect(c.initValidate(testConfig as any)).resolves.toBe(true);
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
test('test valid subjectConfig', async () => {
|
|
201
|
-
const testConfig = {
|
|
202
|
-
namespace: 'sp1',
|
|
203
|
-
networkConfig: { endpoint: 'test' },
|
|
204
|
-
subjectConfig: { userId: 'tester', language: 'javascript' },
|
|
205
|
-
};
|
|
206
|
-
await expect(c.initValidate(testConfig as any)).resolves.toBe(true);
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
test('test valid gdprConfig', async () => {
|
|
210
|
-
const testConfig = {
|
|
211
|
-
namespace: 'sp1',
|
|
212
|
-
networkConfig: { endpoint: 'test' },
|
|
213
|
-
gdprConfig: {
|
|
214
|
-
basisForProcessing: 'consent',
|
|
215
|
-
documentId: '12345',
|
|
216
|
-
documentVersion: '1.0.0',
|
|
217
|
-
documentDescription: 'gdpr document description',
|
|
218
|
-
},
|
|
219
|
-
};
|
|
220
|
-
await expect(c.initValidate(testConfig as any)).resolves.toBe(true);
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
test('test with all defaults', async () => {
|
|
224
|
-
const testConfig = {
|
|
225
|
-
namespace: 'sp1',
|
|
226
|
-
networkConfig: {
|
|
227
|
-
endpoint: 'test',
|
|
228
|
-
method: 'post',
|
|
229
|
-
customPostPath: 'com.snowplowanalytics.snowplow/tp2',
|
|
230
|
-
},
|
|
231
|
-
trackerConfig: {
|
|
232
|
-
devicePlatform: 'mob',
|
|
233
|
-
base64Encoding: true,
|
|
234
|
-
logLevel: 'off',
|
|
235
|
-
applicationContext: true,
|
|
236
|
-
platformContext: true,
|
|
237
|
-
geoLocationContext: false,
|
|
238
|
-
sessionContext: true,
|
|
239
|
-
deepLinkContext: true,
|
|
240
|
-
screenContext: true,
|
|
241
|
-
screenViewAutotracking: false,
|
|
242
|
-
screenEngagementAutotracking: true,
|
|
243
|
-
lifecycleAutotracking: true,
|
|
244
|
-
installAutotracking: true,
|
|
245
|
-
exceptionAutotracking: true,
|
|
246
|
-
diagnosticAutotracking: false,
|
|
247
|
-
userAnonymisation: false,
|
|
248
|
-
},
|
|
249
|
-
sessionConfig: {
|
|
250
|
-
foregroundTimeout: 30,
|
|
251
|
-
backgroundTimeout: 30,
|
|
252
|
-
},
|
|
253
|
-
emitterConfig: {
|
|
254
|
-
bufferOption: 'single',
|
|
255
|
-
emitRange: 150,
|
|
256
|
-
threadPoolSize: 15,
|
|
257
|
-
byteLimitPost: 40000,
|
|
258
|
-
byteLimitGet: 40000,
|
|
259
|
-
serverAnonymisation: false,
|
|
260
|
-
},
|
|
261
|
-
};
|
|
262
|
-
await expect(c.initValidate(testConfig as any)).resolves.toBe(true);
|
|
263
|
-
});
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
describe('test isValidNetworkConf', () => {
|
|
267
|
-
test('invalid - type', () => {
|
|
268
|
-
const testConf = undefined as any;
|
|
269
|
-
expect(c.isValidNetworkConf(testConf)).toBe(false);
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
test('invalid - invalid props', () => {
|
|
273
|
-
const testConf = {
|
|
274
|
-
endpoint: 'test',
|
|
275
|
-
invalid: true,
|
|
276
|
-
} as any;
|
|
277
|
-
expect(c.isValidNetworkConf(testConf)).toBe(false);
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
test('invalid - missing endpoint', () => {
|
|
281
|
-
const testConf = {
|
|
282
|
-
method: 'get',
|
|
283
|
-
} as any;
|
|
284
|
-
expect(c.isValidNetworkConf(testConf)).toBe(false);
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
test('invalid - empty endpoint', () => {
|
|
288
|
-
const testConf = {
|
|
289
|
-
endpoint: '',
|
|
290
|
-
method: 'get',
|
|
291
|
-
} as any;
|
|
292
|
-
expect(c.isValidNetworkConf(testConf)).toBe(false);
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
test('valid', () => {
|
|
296
|
-
const testConf = {
|
|
297
|
-
endpoint: '0.0.0.0:9090',
|
|
298
|
-
method: 'post',
|
|
299
|
-
customPostPath: 'com.snowplowanalytics.snowplow/tp2',
|
|
300
|
-
} as any;
|
|
301
|
-
expect(c.isValidNetworkConf(testConf)).toBe(true);
|
|
302
|
-
});
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
describe('test isValidTrackerConf', () => {
|
|
306
|
-
test('invalid - type', () => {
|
|
307
|
-
const testConf = undefined as any;
|
|
308
|
-
expect(c.isValidTrackerConf(testConf)).toBe(false);
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
test('invalid - invalid props', () => {
|
|
312
|
-
const testConf = {
|
|
313
|
-
appId: 'test',
|
|
314
|
-
invalid: true,
|
|
315
|
-
} as any;
|
|
316
|
-
expect(c.isValidTrackerConf(testConf)).toBe(false);
|
|
317
|
-
});
|
|
318
|
-
|
|
319
|
-
test('valid', () => {
|
|
320
|
-
const testConf = {
|
|
321
|
-
appId: 'test',
|
|
322
|
-
applicationContext: true,
|
|
323
|
-
base64Encoding: true,
|
|
324
|
-
devicePlatform: 'mob',
|
|
325
|
-
diagnosticAutotracking: false,
|
|
326
|
-
exceptionAutotracking: true,
|
|
327
|
-
geoLocationContext: false,
|
|
328
|
-
installAutotracking: true,
|
|
329
|
-
lifecycleAutotracking: false,
|
|
330
|
-
logLevel: 'off',
|
|
331
|
-
platformContext: true,
|
|
332
|
-
screenContext: true,
|
|
333
|
-
screenViewAutotracking: false,
|
|
334
|
-
sessionContext: true,
|
|
335
|
-
deepLinkContext: true,
|
|
336
|
-
userAnonymisation: false,
|
|
337
|
-
} as any;
|
|
338
|
-
expect(c.isValidTrackerConf(testConf)).toBe(true);
|
|
339
|
-
});
|
|
340
|
-
});
|
|
341
|
-
|
|
342
|
-
describe('test isValidSessionConf', () => {
|
|
343
|
-
test('invalid - type', () => {
|
|
344
|
-
const testConf = undefined as any;
|
|
345
|
-
expect(c.isValidSessionConf(testConf)).toBe(false);
|
|
346
|
-
});
|
|
347
|
-
|
|
348
|
-
test('invalid - invalid props', () => {
|
|
349
|
-
const testConf = {
|
|
350
|
-
backgroundTimeout: 30,
|
|
351
|
-
invalid: true,
|
|
352
|
-
} as any;
|
|
353
|
-
expect(c.isValidSessionConf(testConf)).toBe(false);
|
|
354
|
-
});
|
|
355
|
-
|
|
356
|
-
test('invalid - missing props', () => {
|
|
357
|
-
const testConf = {
|
|
358
|
-
backgroundTimeout: 30,
|
|
359
|
-
} as any;
|
|
360
|
-
expect(c.isValidSessionConf(testConf)).toBe(false);
|
|
361
|
-
});
|
|
362
|
-
|
|
363
|
-
test('valid', () => {
|
|
364
|
-
const testConf = {
|
|
365
|
-
foregroundTimeout: 30,
|
|
366
|
-
backgroundTimeout: 30,
|
|
367
|
-
};
|
|
368
|
-
expect(c.isValidSessionConf(testConf)).toBe(true);
|
|
369
|
-
});
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
describe('test isValidEmitterConf', () => {
|
|
373
|
-
test('invalid - type', () => {
|
|
374
|
-
const testConf = undefined as any;
|
|
375
|
-
expect(c.isValidEmitterConf(testConf)).toBe(false);
|
|
376
|
-
});
|
|
377
|
-
|
|
378
|
-
test('invalid - invalid props', () => {
|
|
379
|
-
const testConf = {
|
|
380
|
-
bufferOption: 'small',
|
|
381
|
-
invalid: true,
|
|
382
|
-
} as any;
|
|
383
|
-
expect(c.isValidEmitterConf(testConf)).toBe(false);
|
|
384
|
-
});
|
|
385
|
-
|
|
386
|
-
test('valid', () => {
|
|
387
|
-
const testConf = {
|
|
388
|
-
bufferOption: 'single',
|
|
389
|
-
byteLimitGet: 40000,
|
|
390
|
-
byteLimitPost: 40000,
|
|
391
|
-
emitRange: 150,
|
|
392
|
-
threadPoolSize: 15,
|
|
393
|
-
} as any;
|
|
394
|
-
expect(c.isValidEmitterConf(testConf)).toBe(true);
|
|
395
|
-
});
|
|
396
|
-
});
|
|
397
|
-
|
|
398
|
-
describe('test isScreenSize', () => {
|
|
399
|
-
test('invalid - type', () => {
|
|
400
|
-
const testSize = 'invalid' as any;
|
|
401
|
-
expect(c.isScreenSize(testSize)).toBe(false);
|
|
402
|
-
});
|
|
403
|
-
|
|
404
|
-
test('invalid - array size', () => {
|
|
405
|
-
const testSizeA = [] as any;
|
|
406
|
-
const testSizeB = [0, 1, 2] as any;
|
|
407
|
-
expect(c.isScreenSize(testSizeA)).toBe(false);
|
|
408
|
-
expect(c.isScreenSize(testSizeB)).toBe(false);
|
|
409
|
-
});
|
|
410
|
-
|
|
411
|
-
test('invalid - array elements not numbers', () => {
|
|
412
|
-
const testSize = ['a', 'b'] as any;
|
|
413
|
-
expect(c.isScreenSize(testSize)).toBe(false);
|
|
414
|
-
});
|
|
415
|
-
|
|
416
|
-
test('valid', () => {
|
|
417
|
-
const testSize = [10, 20] as any;
|
|
418
|
-
expect(c.isScreenSize(testSize)).toBe(true);
|
|
419
|
-
});
|
|
420
|
-
});
|
|
421
|
-
|
|
422
|
-
describe('test isValidSubjectConf', () => {
|
|
423
|
-
test('invalid - type', () => {
|
|
424
|
-
const testConf = null as any;
|
|
425
|
-
expect(c.isValidSubjectConf(testConf)).toBe(false);
|
|
426
|
-
});
|
|
427
|
-
|
|
428
|
-
test('invalid - invalid props', () => {
|
|
429
|
-
const testConf = {
|
|
430
|
-
userId: 'tester',
|
|
431
|
-
invalid: true,
|
|
432
|
-
} as any;
|
|
433
|
-
expect(c.isValidSubjectConf(testConf)).toBe(false);
|
|
434
|
-
});
|
|
435
|
-
|
|
436
|
-
test('invalid - invalid screenResolution', () => {
|
|
437
|
-
const testConf = {
|
|
438
|
-
userId: 'tester',
|
|
439
|
-
screenResolution: 10,
|
|
440
|
-
} as any;
|
|
441
|
-
expect(c.isValidSubjectConf(testConf)).toBe(false);
|
|
442
|
-
});
|
|
443
|
-
|
|
444
|
-
test('invalid - invalid screenViewport', () => {
|
|
445
|
-
const testConf = {
|
|
446
|
-
userId: 'tester',
|
|
447
|
-
screenViewport: [10, 20, 30],
|
|
448
|
-
} as any;
|
|
449
|
-
expect(c.isValidSubjectConf(testConf)).toBe(false);
|
|
450
|
-
});
|
|
451
|
-
|
|
452
|
-
test('valid screenViewport and screenResolution', () => {
|
|
453
|
-
const testConf = {
|
|
454
|
-
screenViewport: [10, 20],
|
|
455
|
-
screenResolution: [30, 40],
|
|
456
|
-
} as any;
|
|
457
|
-
expect(c.isValidSubjectConf(testConf)).toBe(true);
|
|
458
|
-
});
|
|
459
|
-
|
|
460
|
-
test('valid', () => {
|
|
461
|
-
const testConf = {
|
|
462
|
-
userId: 'tester',
|
|
463
|
-
networkUserId: '5d79770b-015b-4af8-8c91-b2ed6faf4b1e',
|
|
464
|
-
domainUserId: '5d79770b-015b-4af8-8c91-b2ed6faf4b1e',
|
|
465
|
-
useragent: 'agent string',
|
|
466
|
-
ipAddress: '0.0.0.0',
|
|
467
|
-
timezone: 'Europe/London',
|
|
468
|
-
language: 'en',
|
|
469
|
-
screenResolution: [123, 456],
|
|
470
|
-
screenViewport: [12, 34],
|
|
471
|
-
colorDepth: 0,
|
|
472
|
-
} as any;
|
|
473
|
-
expect(c.isValidSubjectConf(testConf)).toBe(true);
|
|
474
|
-
});
|
|
475
|
-
});
|
|
476
|
-
|
|
477
|
-
describe('test isValidGdprConf', () => {
|
|
478
|
-
test('invalid - type', () => {
|
|
479
|
-
const testConf = 'invalid' as any;
|
|
480
|
-
expect(c.isValidGdprConf(testConf)).toBe(false);
|
|
481
|
-
});
|
|
482
|
-
|
|
483
|
-
test('invalid prop', () => {
|
|
484
|
-
const testConf = {
|
|
485
|
-
basisForProcessing: 'consent',
|
|
486
|
-
documentId: '12345',
|
|
487
|
-
documentVersion: '1.0.0',
|
|
488
|
-
documentDescription: 'gdpr document description',
|
|
489
|
-
invalid: true,
|
|
490
|
-
} as any;
|
|
491
|
-
expect(c.isValidGdprConf(testConf)).toBe(false);
|
|
492
|
-
});
|
|
493
|
-
|
|
494
|
-
test('invalid prop - invalid basis', () => {
|
|
495
|
-
const testConf = {
|
|
496
|
-
basisForProcessing: 'invalid',
|
|
497
|
-
documentId: '12345',
|
|
498
|
-
documentVersion: '1.0.0',
|
|
499
|
-
documentDescription: 'gdpr document description',
|
|
500
|
-
} as any;
|
|
501
|
-
expect(c.isValidGdprConf(testConf)).toBe(false);
|
|
502
|
-
});
|
|
503
|
-
|
|
504
|
-
test('invalid - missing prop', () => {
|
|
505
|
-
const testConf = {
|
|
506
|
-
basisForProcessing: 'consent',
|
|
507
|
-
documentId: '12345',
|
|
508
|
-
documentVersion: '1.0.0',
|
|
509
|
-
} as any;
|
|
510
|
-
expect(c.isValidGdprConf(testConf)).toBe(false);
|
|
511
|
-
});
|
|
512
|
-
|
|
513
|
-
test('valid', () => {
|
|
514
|
-
const testConf = {
|
|
515
|
-
basisForProcessing: 'consent',
|
|
516
|
-
documentId: '12345',
|
|
517
|
-
documentVersion: '1.0.0',
|
|
518
|
-
documentDescription: 'gdpr document description',
|
|
519
|
-
} as any;
|
|
520
|
-
expect(c.isValidGdprConf(testConf)).toBe(true);
|
|
521
|
-
});
|
|
522
|
-
});
|
|
523
|
-
|
|
524
|
-
describe('test isValidGCConf', () => {
|
|
525
|
-
test('invalid - type', () => {
|
|
526
|
-
const testConf = { tag: 'invalid' } as any;
|
|
527
|
-
expect(c.isValidGCConf(testConf)).toBe(false);
|
|
528
|
-
});
|
|
529
|
-
|
|
530
|
-
test('valid - empty array', () => {
|
|
531
|
-
const testConf = [] as any;
|
|
532
|
-
expect(c.isValidGCConf(testConf)).toBe(true);
|
|
533
|
-
});
|
|
534
|
-
|
|
535
|
-
test('invalid prop - invalid tag', () => {
|
|
536
|
-
const testConf = [
|
|
537
|
-
{
|
|
538
|
-
tag: undefined,
|
|
539
|
-
globalContexts: [
|
|
540
|
-
{
|
|
541
|
-
schema: 'testSchema',
|
|
542
|
-
data: { test: 'data' },
|
|
543
|
-
},
|
|
544
|
-
],
|
|
545
|
-
},
|
|
546
|
-
] as any;
|
|
547
|
-
expect(c.isValidGCConf(testConf)).toBe(false);
|
|
548
|
-
});
|
|
549
|
-
|
|
550
|
-
test('invalid prop - invalid globalContexts type', () => {
|
|
551
|
-
const testConf = [
|
|
552
|
-
{
|
|
553
|
-
tag: undefined,
|
|
554
|
-
globalContexts: {
|
|
555
|
-
schema: 'testSchema',
|
|
556
|
-
data: { test: 'data' },
|
|
557
|
-
},
|
|
558
|
-
},
|
|
559
|
-
] as any;
|
|
560
|
-
expect(c.isValidGCConf(testConf)).toBe(false);
|
|
561
|
-
});
|
|
562
|
-
|
|
563
|
-
test('invalid prop - invalid globalContexts - invalid sdj', () => {
|
|
564
|
-
const testConf = [
|
|
565
|
-
{
|
|
566
|
-
tag: 'testGCTag',
|
|
567
|
-
globalContexts: [
|
|
568
|
-
{
|
|
569
|
-
data: { test: 'data' },
|
|
570
|
-
},
|
|
571
|
-
],
|
|
572
|
-
},
|
|
573
|
-
] as any;
|
|
574
|
-
expect(c.isValidGCConf(testConf)).toBe(false);
|
|
575
|
-
});
|
|
576
|
-
|
|
577
|
-
test('valid', () => {
|
|
578
|
-
const testConf = [
|
|
579
|
-
{
|
|
580
|
-
tag: 'testGCTag1',
|
|
581
|
-
globalContexts: [
|
|
582
|
-
{
|
|
583
|
-
schema: 'testSchema0',
|
|
584
|
-
data: { test: 'data' },
|
|
585
|
-
},
|
|
586
|
-
{
|
|
587
|
-
schema: 'testSchema1',
|
|
588
|
-
data: { test: 'data' },
|
|
589
|
-
},
|
|
590
|
-
],
|
|
591
|
-
},
|
|
592
|
-
{
|
|
593
|
-
tag: 'testGCTag2',
|
|
594
|
-
globalContexts: [
|
|
595
|
-
{
|
|
596
|
-
schema: 'testSchema2',
|
|
597
|
-
data: { test: 'data' },
|
|
598
|
-
},
|
|
599
|
-
{
|
|
600
|
-
schema: 'testSchema3',
|
|
601
|
-
data: { test: 'data' },
|
|
602
|
-
},
|
|
603
|
-
],
|
|
604
|
-
},
|
|
605
|
-
] as any;
|
|
606
|
-
expect(c.isValidGCConf(testConf)).toBe(true);
|
|
607
|
-
});
|
|
608
|
-
});
|