@snowplow/react-native-tracker 1.4.0 → 2.1.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 +155 -0
- package/.github/workflows/deploy.yml +97 -0
- package/.github/workflows/e2e-android.yml +121 -0
- package/.github/workflows/e2e-ios.yml +95 -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 +176 -0
- package/CONTRIBUTING.md +80 -0
- package/LICENSE +1 -1
- package/README.md +24 -111
- 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 +744 -0
- package/android/src/main/java/com/snowplow/reactnativetracker/ReactNativeTrackerPackage.kt +17 -0
- package/android/src/main/java/com/snowplow/reactnativetracker/util/ConfigUtil.kt +274 -0
- package/android/src/main/java/com/snowplow/reactnativetracker/util/EventUtil.kt +233 -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 +95 -0
- package/example/e2e/environment.js +23 -0
- package/example/e2e/helpers/microCommands.js +140 -0
- package/example/e2e/helpers/microHelpers.js +333 -0
- package/example/e2e/helpers/microHelpers.test.js +295 -0
- package/example/e2e/helpers/schemas.js +49 -0
- package/example/e2e/jest.config.js +16 -0
- package/example/e2e/setup.js +4 -0
- package/example/e2e/testEvents.micro.test.js +287 -0
- package/example/index.js +5 -0
- package/example/ios/.xcode.env +11 -0
- package/example/ios/Podfile +62 -0
- package/example/ios/Podfile.lock +730 -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 +566 -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 +175 -0
- package/ios/ReactNativeTracker.swift +822 -0
- package/ios/{RNSnowplowTracker.xcodeproj → ReactNativeTracker.xcodeproj}/project.pbxproj +55 -79
- package/ios/Util/ConfigUtils.swift +209 -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 +490 -0
- package/lib/commonjs/api.js.map +1 -0
- package/lib/commonjs/configurations.js +196 -0
- package/lib/commonjs/configurations.js.map +1 -0
- package/lib/commonjs/constants.js +77 -0
- package/lib/commonjs/constants.js.map +1 -0
- package/lib/commonjs/events.js +277 -0
- package/lib/commonjs/events.js.map +1 -0
- package/lib/commonjs/index.js +132 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/jsCore.js +427 -0
- package/lib/commonjs/jsCore.js.map +1 -0
- package/lib/commonjs/native.js +16 -0
- package/lib/commonjs/native.js.map +1 -0
- package/lib/commonjs/subject.js +235 -0
- package/lib/commonjs/subject.js.map +1 -0
- package/lib/commonjs/tracker.js +248 -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 +72 -0
- package/lib/commonjs/utils.js.map +1 -0
- package/lib/commonjs/webViewInterface.js +66 -0
- package/lib/commonjs/webViewInterface.js.map +1 -0
- package/lib/module/api.js +452 -0
- package/lib/module/api.js.map +1 -0
- package/lib/module/configurations.js +184 -0
- package/lib/module/configurations.js.map +1 -0
- package/lib/module/constants.js +72 -0
- package/lib/module/constants.js.map +1 -0
- package/lib/module/events.js +259 -0
- package/lib/module/events.js.map +1 -0
- package/lib/module/index.js +120 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/jsCore.js +424 -0
- package/lib/module/jsCore.js.map +1 -0
- package/lib/module/native.js +12 -0
- package/lib/module/native.js.map +1 -0
- package/lib/module/subject.js +222 -0
- package/lib/module/subject.js.map +1 -0
- package/lib/module/tracker.js +234 -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 +66 -0
- package/lib/module/utils.js.map +1 -0
- package/lib/module/webViewInterface.js +62 -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 +240 -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 +64 -0
- package/lib/typescript/constants.d.ts.map +1 -0
- package/lib/typescript/events.d.ts +115 -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 +152 -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 +111 -0
- package/lib/typescript/tracker.d.ts.map +1 -0
- package/{dist/index.d.ts → lib/typescript/types.d.ts} +264 -73
- 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 +135 -53
- 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 +21 -0
- package/src/__tests__/configurations.test.ts +608 -0
- package/src/__tests__/events.test.ts +736 -0
- package/src/__tests__/index.test.ts +14 -0
- package/src/__tests__/jsCore.test.ts +199 -0
- package/src/__tests__/utils.test.ts +10 -0
- package/src/api.ts +556 -0
- package/src/configurations.ts +325 -0
- package/src/constants.ts +97 -0
- package/src/events.ts +355 -0
- package/src/index.ts +184 -0
- package/src/jsCore.ts +603 -0
- package/src/native.ts +21 -0
- package/src/subject.ts +302 -0
- package/src/tracker.ts +377 -0
- package/src/types.ts +1162 -0
- package/src/utils.ts +65 -0
- package/src/webViewInterface.ts +92 -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,608 @@
|
|
|
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
|
+
});
|