@snowplow/react-native-tracker 2.1.1 → 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 -180
- 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 -175
- 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
package/src/configurations.ts
DELETED
|
@@ -1,325 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
import { isObject } from './utils';
|
|
4
|
-
import { isValidSD } from './events';
|
|
5
|
-
import { logMessages } from './constants';
|
|
6
|
-
import type {
|
|
7
|
-
NetworkConfiguration,
|
|
8
|
-
TrackerConfiguration,
|
|
9
|
-
SessionConfiguration,
|
|
10
|
-
EmitterConfiguration,
|
|
11
|
-
SubjectConfiguration,
|
|
12
|
-
GdprConfiguration,
|
|
13
|
-
GCConfiguration,
|
|
14
|
-
GlobalContext,
|
|
15
|
-
InitTrackerConfiguration,
|
|
16
|
-
} from './types';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Configuration properties
|
|
20
|
-
*/
|
|
21
|
-
const networkProps = ['endpoint', 'method', 'customPostPath', 'requestHeaders'];
|
|
22
|
-
const trackerProps = [
|
|
23
|
-
'appId',
|
|
24
|
-
'devicePlatform',
|
|
25
|
-
'base64Encoding',
|
|
26
|
-
'logLevel',
|
|
27
|
-
'applicationContext',
|
|
28
|
-
'platformContext',
|
|
29
|
-
'geoLocationContext',
|
|
30
|
-
'sessionContext',
|
|
31
|
-
'deepLinkContext',
|
|
32
|
-
'screenContext',
|
|
33
|
-
'screenViewAutotracking',
|
|
34
|
-
'screenEngagementAutotracking',
|
|
35
|
-
'lifecycleAutotracking',
|
|
36
|
-
'installAutotracking',
|
|
37
|
-
'exceptionAutotracking',
|
|
38
|
-
'diagnosticAutotracking',
|
|
39
|
-
'userAnonymisation',
|
|
40
|
-
];
|
|
41
|
-
const sessionProps = ['foregroundTimeout', 'backgroundTimeout'];
|
|
42
|
-
const emitterProps = [
|
|
43
|
-
'bufferOption',
|
|
44
|
-
'emitRange',
|
|
45
|
-
'threadPoolSize',
|
|
46
|
-
'byteLimitPost',
|
|
47
|
-
'byteLimitGet',
|
|
48
|
-
'serverAnonymisation',
|
|
49
|
-
];
|
|
50
|
-
const subjectProps = [
|
|
51
|
-
'userId',
|
|
52
|
-
'networkUserId',
|
|
53
|
-
'domainUserId',
|
|
54
|
-
'useragent',
|
|
55
|
-
'ipAddress',
|
|
56
|
-
'timezone',
|
|
57
|
-
'language',
|
|
58
|
-
'screenResolution',
|
|
59
|
-
'screenViewport',
|
|
60
|
-
'colorDepth',
|
|
61
|
-
];
|
|
62
|
-
const gdprProps = [
|
|
63
|
-
'basisForProcessing',
|
|
64
|
-
'documentId',
|
|
65
|
-
'documentVersion',
|
|
66
|
-
'documentDescription',
|
|
67
|
-
];
|
|
68
|
-
const gcProps = ['tag', 'globalContexts'];
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Validates whether an object is of valid configuration given its default keys
|
|
72
|
-
*
|
|
73
|
-
* @param config {Object} - the object to validate
|
|
74
|
-
* @param defaultKeys {Array} - the default keys to validate against
|
|
75
|
-
* @returns - boolean
|
|
76
|
-
*/
|
|
77
|
-
function isValidConfig<Type extends Record<string, any>>(
|
|
78
|
-
config: Type,
|
|
79
|
-
defaultKeys: Array<string>
|
|
80
|
-
): config is Type {
|
|
81
|
-
return Object.keys(config).every((key) => defaultKeys.includes(key));
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Validates the networkConfig
|
|
86
|
-
*
|
|
87
|
-
* @param config {Object} - the config to validate
|
|
88
|
-
* @returns - boolean
|
|
89
|
-
*/
|
|
90
|
-
function isValidNetworkConf(config: NetworkConfiguration): boolean {
|
|
91
|
-
if (
|
|
92
|
-
!isObject(config) ||
|
|
93
|
-
!isValidConfig(config, networkProps) ||
|
|
94
|
-
typeof config.endpoint !== 'string' ||
|
|
95
|
-
!config.endpoint
|
|
96
|
-
) {
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
|
-
return true;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Validates the trackerConfig
|
|
104
|
-
*
|
|
105
|
-
* @param config {Object} - the config to validate
|
|
106
|
-
* @returns - boolean
|
|
107
|
-
*/
|
|
108
|
-
function isValidTrackerConf(config: TrackerConfiguration): boolean {
|
|
109
|
-
if (!isObject(config) || !isValidConfig(config, trackerProps)) {
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
return true;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Validates the sessionConfig
|
|
117
|
-
*
|
|
118
|
-
* @param config {Object} - the config to validate
|
|
119
|
-
* @returns - boolean
|
|
120
|
-
*/
|
|
121
|
-
function isValidSessionConf(config: SessionConfiguration): boolean {
|
|
122
|
-
if (
|
|
123
|
-
!isObject(config) ||
|
|
124
|
-
!isValidConfig(config, sessionProps) ||
|
|
125
|
-
!sessionProps.every((key) =>
|
|
126
|
-
Object.keys(config as SessionConfiguration).includes(key)
|
|
127
|
-
)
|
|
128
|
-
) {
|
|
129
|
-
return false;
|
|
130
|
-
}
|
|
131
|
-
return true;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Validates the emitterConfig
|
|
136
|
-
*
|
|
137
|
-
* @param config {Object} - the config to validate
|
|
138
|
-
* @returns - boolean
|
|
139
|
-
*/
|
|
140
|
-
function isValidEmitterConf(config: EmitterConfiguration): boolean {
|
|
141
|
-
if (!isObject(config) || !isValidConfig(config, emitterProps)) {
|
|
142
|
-
return false;
|
|
143
|
-
}
|
|
144
|
-
return true;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Validates whether an object is of ScreenSize type
|
|
149
|
-
*
|
|
150
|
-
* @param arr {Object} - the object to validate
|
|
151
|
-
* @returns - boolean
|
|
152
|
-
*/
|
|
153
|
-
function isScreenSize<Type>(arr: Type): boolean {
|
|
154
|
-
return (
|
|
155
|
-
Array.isArray(arr) &&
|
|
156
|
-
arr.length === 2 &&
|
|
157
|
-
arr.every(<Type>(n: Type) => typeof n === 'number')
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Validates the subjectConfig
|
|
163
|
-
*
|
|
164
|
-
* @param config {Object} - the config to validate
|
|
165
|
-
* @returns - boolean
|
|
166
|
-
*/
|
|
167
|
-
function isValidSubjectConf(config: SubjectConfiguration): boolean {
|
|
168
|
-
if (!isObject(config) || !isValidConfig(config, subjectProps)) {
|
|
169
|
-
return false;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// validating ScreenSize here to simplify array handling in bridge
|
|
173
|
-
if (
|
|
174
|
-
Object.prototype.hasOwnProperty.call(config, 'screenResolution') &&
|
|
175
|
-
config.screenResolution !== null &&
|
|
176
|
-
!isScreenSize(config.screenResolution as unknown)
|
|
177
|
-
) {
|
|
178
|
-
return false;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
if (
|
|
182
|
-
Object.prototype.hasOwnProperty.call(config, 'screenViewport') &&
|
|
183
|
-
config.screenViewport !== null &&
|
|
184
|
-
!isScreenSize(config.screenViewport as unknown)
|
|
185
|
-
) {
|
|
186
|
-
return false;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return true;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Validates the gdprConfig
|
|
194
|
-
*
|
|
195
|
-
* @param config {Object} - the config to validate
|
|
196
|
-
* @returns - boolean
|
|
197
|
-
*/
|
|
198
|
-
function isValidGdprConf(config: GdprConfiguration): boolean {
|
|
199
|
-
if (
|
|
200
|
-
!isObject(config) ||
|
|
201
|
-
!isValidConfig(config, gdprProps) ||
|
|
202
|
-
!gdprProps.every((key) =>
|
|
203
|
-
Object.keys(config as GdprConfiguration).includes(key)
|
|
204
|
-
) ||
|
|
205
|
-
![
|
|
206
|
-
'consent',
|
|
207
|
-
'contract',
|
|
208
|
-
'legal_obligation',
|
|
209
|
-
'legitimate_interests',
|
|
210
|
-
'public_task',
|
|
211
|
-
'vital_interests',
|
|
212
|
-
].includes(config.basisForProcessing)
|
|
213
|
-
) {
|
|
214
|
-
return false;
|
|
215
|
-
}
|
|
216
|
-
return true;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Validates whether an object is of GlobalContext type
|
|
221
|
-
*
|
|
222
|
-
* @param gc {Object} - the object to validate
|
|
223
|
-
* @returns - boolean
|
|
224
|
-
*/
|
|
225
|
-
function isValidGC(gc: GlobalContext): boolean {
|
|
226
|
-
return (
|
|
227
|
-
isObject(gc) &&
|
|
228
|
-
isValidConfig(gc, gcProps) &&
|
|
229
|
-
typeof gc.tag === 'string' &&
|
|
230
|
-
Array.isArray(gc.globalContexts) &&
|
|
231
|
-
gc.globalContexts.every((c) => isValidSD(c))
|
|
232
|
-
);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Validates the GCConfig (global contexts)
|
|
237
|
-
*
|
|
238
|
-
* @param config {Object} - the config to validate
|
|
239
|
-
* @returns - boolean
|
|
240
|
-
*/
|
|
241
|
-
function isValidGCConf(config: GCConfiguration): boolean {
|
|
242
|
-
if (!Array.isArray(config)) {
|
|
243
|
-
return false;
|
|
244
|
-
}
|
|
245
|
-
if (!config.every((gc) => isValidGC(gc as GlobalContext))) {
|
|
246
|
-
return false;
|
|
247
|
-
}
|
|
248
|
-
return true;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* Validates the initTrackerConfiguration
|
|
253
|
-
*
|
|
254
|
-
* @param init {Object} - the config to validate
|
|
255
|
-
* @returns - boolean promise
|
|
256
|
-
*/
|
|
257
|
-
function initValidate(init: InitTrackerConfiguration): Promise<boolean> {
|
|
258
|
-
if (typeof init.namespace !== 'string' || !init.namespace) {
|
|
259
|
-
return Promise.reject(new Error(logMessages.namespace));
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
if (
|
|
263
|
-
!Object.prototype.hasOwnProperty.call(init, 'networkConfig') ||
|
|
264
|
-
!isValidNetworkConf(init.networkConfig as NetworkConfiguration)
|
|
265
|
-
) {
|
|
266
|
-
return Promise.reject(new Error(logMessages.network));
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
if (
|
|
270
|
-
Object.prototype.hasOwnProperty.call(init, 'trackerConfig') &&
|
|
271
|
-
!isValidTrackerConf(init.trackerConfig as TrackerConfiguration)
|
|
272
|
-
) {
|
|
273
|
-
return Promise.reject(new Error(logMessages.tracker));
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
if (
|
|
277
|
-
Object.prototype.hasOwnProperty.call(init, 'sessionConfig') &&
|
|
278
|
-
!isValidSessionConf(init.sessionConfig as SessionConfiguration)
|
|
279
|
-
) {
|
|
280
|
-
return Promise.reject(new Error(logMessages.session));
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
if (
|
|
284
|
-
Object.prototype.hasOwnProperty.call(init, 'emitterConfig') &&
|
|
285
|
-
!isValidEmitterConf(init.emitterConfig as EmitterConfiguration)
|
|
286
|
-
) {
|
|
287
|
-
return Promise.reject(new Error(logMessages.emitter));
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
if (
|
|
291
|
-
Object.prototype.hasOwnProperty.call(init, 'subjectConfig') &&
|
|
292
|
-
!isValidSubjectConf(init.subjectConfig as SubjectConfiguration)
|
|
293
|
-
) {
|
|
294
|
-
return Promise.reject(new Error(logMessages.subject));
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
if (
|
|
298
|
-
Object.prototype.hasOwnProperty.call(init, 'gdprConfig') &&
|
|
299
|
-
!isValidGdprConf(init.gdprConfig as GdprConfiguration)
|
|
300
|
-
) {
|
|
301
|
-
return Promise.reject(new Error(logMessages.gdpr));
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
if (
|
|
305
|
-
Object.prototype.hasOwnProperty.call(init, 'gcConfig') &&
|
|
306
|
-
!isValidGCConf(init.gcConfig as GCConfiguration)
|
|
307
|
-
) {
|
|
308
|
-
return Promise.reject(new Error(logMessages.gc));
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
return Promise.resolve(true);
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
export {
|
|
315
|
-
isValidNetworkConf,
|
|
316
|
-
isValidTrackerConf,
|
|
317
|
-
isValidSessionConf,
|
|
318
|
-
isValidEmitterConf,
|
|
319
|
-
isValidSubjectConf,
|
|
320
|
-
isValidGdprConf,
|
|
321
|
-
isValidGCConf,
|
|
322
|
-
isValidGC,
|
|
323
|
-
isScreenSize,
|
|
324
|
-
initValidate,
|
|
325
|
-
};
|
package/src/constants.ts
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const logMessages = {
|
|
4
|
-
// configuration errors
|
|
5
|
-
namespace: 'namespace parameter is required to be set',
|
|
6
|
-
endpoint: 'endpoint parameter is required to be set',
|
|
7
|
-
network: 'networkConfig is invalid',
|
|
8
|
-
tracker: 'trackerConfig is invalid',
|
|
9
|
-
session: 'sessionConfig is invalid',
|
|
10
|
-
emitter: 'emitterConfig is invalid',
|
|
11
|
-
subject: 'subjectConfig is invalid',
|
|
12
|
-
gdpr: 'gdprConfig is invalid',
|
|
13
|
-
gc: 'gcConfig is invalid',
|
|
14
|
-
|
|
15
|
-
// event errors
|
|
16
|
-
context: 'invalid contexts parameter',
|
|
17
|
-
selfDesc:
|
|
18
|
-
'selfDescribing event requires schema and data parameters to be set',
|
|
19
|
-
evType: 'event argument can only be an object',
|
|
20
|
-
screenViewReq: 'screenView event requires name as string parameter to be set',
|
|
21
|
-
listItemViewReq:
|
|
22
|
-
'listItemView event requires index asn integer parameter to be set',
|
|
23
|
-
structuredReq:
|
|
24
|
-
'structured event requires category and action parameters to be set',
|
|
25
|
-
pageviewReq: 'pageView event requires pageUrl parameter to be set',
|
|
26
|
-
timingReq:
|
|
27
|
-
'timing event requires category, variable and timing parameters to be set',
|
|
28
|
-
consentGReq:
|
|
29
|
-
'consentGranted event requires expiry, documentId and version parameters to be set',
|
|
30
|
-
consentWReq:
|
|
31
|
-
'consentWithdrawn event requires all, documentId and version parameters to be set',
|
|
32
|
-
ecomReq:
|
|
33
|
-
'ecommerceTransaction event requires orderId, totalValue to be set and items to be an array of valid ecommerceItems',
|
|
34
|
-
deepLinkReq: 'deepLinkReceived event requires the url parameter to be set',
|
|
35
|
-
messageNotificationReq:
|
|
36
|
-
'messageNotification event requires title, body, and trigger parameters to be set',
|
|
37
|
-
|
|
38
|
-
// global contexts errors
|
|
39
|
-
gcTagType: 'tag argument is required to be a string',
|
|
40
|
-
gcType: 'global context argument is invalid',
|
|
41
|
-
|
|
42
|
-
// api error prefix
|
|
43
|
-
createTracker: 'createTracker:',
|
|
44
|
-
removeTracker: 'removeTracker: trackerNamespace can only be a string',
|
|
45
|
-
|
|
46
|
-
// methods
|
|
47
|
-
trackSelfDesc: 'trackSelfDescribingEvent:',
|
|
48
|
-
trackScreenView: 'trackScreenViewEvent:',
|
|
49
|
-
trackScrollChanged: 'trackScrollChangedEvent:',
|
|
50
|
-
trackListItemView: 'trackListItemViewEvent:',
|
|
51
|
-
trackStructured: 'trackStructuredEvent:',
|
|
52
|
-
trackPageView: 'trackPageViewEvent:',
|
|
53
|
-
trackTiming: 'trackTimingEvent:',
|
|
54
|
-
trackConsentGranted: 'trackConsentGranted:',
|
|
55
|
-
trackConsentWithdrawn: 'trackConsentWithdrawn:',
|
|
56
|
-
trackEcommerceTransaction: 'trackEcommerceTransaction:',
|
|
57
|
-
trackDeepLinkReceived: 'trackDeepLinkReceivedEvent:',
|
|
58
|
-
trackMessageNotification: 'trackMessageNotificationEvent:',
|
|
59
|
-
removeGlobalContexts: 'removeGlobalContexts:',
|
|
60
|
-
addGlobalContexts: 'addGlobalContexts:',
|
|
61
|
-
|
|
62
|
-
// setters
|
|
63
|
-
setUserId: 'setUserId: userId can only be a string or null',
|
|
64
|
-
setNetworkUserId:
|
|
65
|
-
'setNetworkUserId: networkUserId can only be a string(UUID) or null',
|
|
66
|
-
setDomainUserId:
|
|
67
|
-
'setDomainUserId: domainUserId can only be a string(UUID) or null',
|
|
68
|
-
setIpAddress: 'setIpAddress: ipAddress can only be a string or null',
|
|
69
|
-
setUseragent: 'setUseragent: useragent can only be a string or null',
|
|
70
|
-
setTimezone: 'setTimezone: timezone can only be a string or null',
|
|
71
|
-
setLanguage: 'setLanguage: language can only be a string or null',
|
|
72
|
-
setScreenResolution:
|
|
73
|
-
'setScreenResolution: screenResolution can only be of ScreenSize type or null',
|
|
74
|
-
setScreenViewport:
|
|
75
|
-
'setScreenViewport: screenViewport can only be of ScreenSize type or null',
|
|
76
|
-
setColorDepth:
|
|
77
|
-
'setColorDepth: colorDepth can only be a number(integer) or null',
|
|
78
|
-
setSubjectData: 'setSubjectData:',
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
const schemas = {
|
|
82
|
-
payloadData:
|
|
83
|
-
'iglu:com.snowplowanalytics.snowplow/payload_data/jsonschema/1-0-4',
|
|
84
|
-
timingSchema: 'iglu:com.snowplowanalytics.snowplow/timing/jsonschema/1-0-0',
|
|
85
|
-
deepLinkReceivedSchema:
|
|
86
|
-
'iglu:com.snowplowanalytics.mobile/deep_link_received/jsonschema/1-0-0',
|
|
87
|
-
messageNotificationSchema:
|
|
88
|
-
'iglu:com.snowplowanalytics.mobile/message_notification/jsonschema/1-0-0',
|
|
89
|
-
screenViewSchema:
|
|
90
|
-
'iglu:com.snowplowanalytics.mobile/screen_view/jsonschema/1-0-0',
|
|
91
|
-
scrollChangedSchema:
|
|
92
|
-
'iglu:com.snowplowanalytics.mobile/scroll_changed/jsonschema/1-0-0',
|
|
93
|
-
listItemViewSchema:
|
|
94
|
-
'iglu:com.snowplowanalytics.mobile/list_item_view/jsonschema/1-0-0',
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
export { logMessages, schemas };
|