@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.
Files changed (232) hide show
  1. package/LICENSE +29 -203
  2. package/README.md +59 -143
  3. package/dist/index.cjs.d.ts +499 -0
  4. package/dist/index.cjs.js +2656 -0
  5. package/dist/index.cjs.js.map +1 -0
  6. package/dist/index.cjs.min.d.ts +499 -0
  7. package/dist/index.cjs.min.js +63 -0
  8. package/dist/index.cjs.min.js.map +1 -0
  9. package/dist/index.module.d.ts +499 -0
  10. package/dist/index.module.js +250 -0
  11. package/dist/index.module.js.map +1 -0
  12. package/package.json +48 -158
  13. package/.editorconfig +0 -15
  14. package/.eslintignore +0 -6
  15. package/.gitattributes +0 -3
  16. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -29
  17. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  18. package/.github/actions/setup/action.yml +0 -28
  19. package/.github/workflows/build.yml +0 -155
  20. package/.github/workflows/deploy.yml +0 -97
  21. package/.github/workflows/e2e-android.yml +0 -121
  22. package/.github/workflows/e2e-ios.yml +0 -95
  23. package/.github/workflows/snyk.yml +0 -21
  24. package/.gitignore +0 -70
  25. package/.npmignore +0 -60
  26. package/.nvmrc +0 -1
  27. package/.watchmanconfig +0 -1
  28. package/.yarnrc +0 -3
  29. package/CHANGELOG +0 -180
  30. package/CONTRIBUTING.md +0 -80
  31. package/android/build.gradle +0 -110
  32. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  33. package/android/gradle/wrapper/gradle-wrapper.properties +0 -5
  34. package/android/gradle.properties +0 -5
  35. package/android/gradlew +0 -234
  36. package/android/gradlew.bat +0 -89
  37. package/android/src/main/AndroidManifest.xml +0 -3
  38. package/android/src/main/AndroidManifestNew.xml +0 -2
  39. package/android/src/main/java/com/snowplow/reactnativetracker/ReactNativeTrackerModule.kt +0 -744
  40. package/android/src/main/java/com/snowplow/reactnativetracker/ReactNativeTrackerPackage.kt +0 -17
  41. package/android/src/main/java/com/snowplow/reactnativetracker/util/ConfigUtil.kt +0 -274
  42. package/android/src/main/java/com/snowplow/reactnativetracker/util/EventUtil.kt +0 -233
  43. package/android/src/main/java/com/snowplow/reactnativetracker/util/TrackerVersion.kt +0 -5
  44. package/babel.config.js +0 -3
  45. package/example/.watchmanconfig +0 -1
  46. package/example/Gemfile +0 -6
  47. package/example/android/app/build.gradle +0 -129
  48. package/example/android/app/debug.keystore +0 -0
  49. package/example/android/app/proguard-rules.pro +0 -10
  50. package/example/android/app/src/androidTest/java/com/reactnativetrackerexample/DetoxTest.java +0 -36
  51. package/example/android/app/src/androidTest/java/com/reactnativetrackerexample/DetoxTestAppJUnitRunner.java +0 -21
  52. package/example/android/app/src/debug/AndroidManifest.xml +0 -13
  53. package/example/android/app/src/debug/java/com/reactnativetrackerexample/ReactNativeFlipper.java +0 -75
  54. package/example/android/app/src/main/AndroidManifest.xml +0 -26
  55. package/example/android/app/src/main/java/com/reactnativetrackerexample/MainActivity.java +0 -32
  56. package/example/android/app/src/main/java/com/reactnativetrackerexample/MainApplication.java +0 -62
  57. package/example/android/app/src/main/res/drawable/rn_edit_text_material.xml +0 -36
  58. package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  59. package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  60. package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  61. package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  62. package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  63. package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  64. package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  65. package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  66. package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  67. package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  68. package/example/android/app/src/main/res/values/strings.xml +0 -3
  69. package/example/android/app/src/main/res/values/styles.xml +0 -9
  70. package/example/android/app/src/release/java/com/reactnativetrackerexample/ReactNativeFlipper.java +0 -20
  71. package/example/android/build.gradle +0 -31
  72. package/example/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  73. package/example/android/gradle/wrapper/gradle-wrapper.properties +0 -6
  74. package/example/android/gradle.properties +0 -44
  75. package/example/android/gradlew +0 -244
  76. package/example/android/gradlew.bat +0 -92
  77. package/example/android/settings.gradle +0 -4
  78. package/example/app.json +0 -4
  79. package/example/babel.config.js +0 -17
  80. package/example/detox.config.js +0 -92
  81. package/example/e2e/config.json +0 -10
  82. package/example/e2e/emitEvents.e2e.detox.js +0 -95
  83. package/example/e2e/environment.js +0 -23
  84. package/example/e2e/helpers/microCommands.js +0 -140
  85. package/example/e2e/helpers/microHelpers.js +0 -333
  86. package/example/e2e/helpers/microHelpers.test.js +0 -295
  87. package/example/e2e/helpers/schemas.js +0 -49
  88. package/example/e2e/jest.config.js +0 -16
  89. package/example/e2e/setup.js +0 -4
  90. package/example/e2e/testEvents.micro.test.js +0 -287
  91. package/example/index.js +0 -5
  92. package/example/ios/.xcode.env +0 -11
  93. package/example/ios/Podfile +0 -62
  94. package/example/ios/Podfile.lock +0 -730
  95. package/example/ios/ReactNativeTrackerExample/AppDelegate.h +0 -6
  96. package/example/ios/ReactNativeTrackerExample/AppDelegate.mm +0 -26
  97. package/example/ios/ReactNativeTrackerExample/Images.xcassets/AppIcon.appiconset/Contents.json +0 -53
  98. package/example/ios/ReactNativeTrackerExample/Images.xcassets/Contents.json +0 -6
  99. package/example/ios/ReactNativeTrackerExample/Info.plist +0 -55
  100. package/example/ios/ReactNativeTrackerExample/LaunchScreen.storyboard +0 -47
  101. package/example/ios/ReactNativeTrackerExample/PrivacyInfo.xcprivacy +0 -37
  102. package/example/ios/ReactNativeTrackerExample/main.m +0 -10
  103. package/example/ios/ReactNativeTrackerExample-Bridging-Header.h +0 -3
  104. package/example/ios/ReactNativeTrackerExample.xcodeproj/project.pbxproj +0 -739
  105. package/example/ios/ReactNativeTrackerExample.xcodeproj/xcshareddata/xcschemes/ReactNativeTrackerExample.xcscheme +0 -88
  106. package/example/ios/ReactNativeTrackerExample.xcworkspace/contents.xcworkspacedata +0 -10
  107. package/example/ios/ReactNativeTrackerExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  108. package/example/ios/ReactNativeTrackerExampleTests/Info.plist +0 -24
  109. package/example/ios/ReactNativeTrackerExampleTests/ReactNativeTrackerExampleTests.m +0 -66
  110. package/example/metro.config.js +0 -45
  111. package/example/package.json +0 -54
  112. package/example/react-native.config.js +0 -10
  113. package/example/src/App.js +0 -566
  114. package/example/tsconfig.json +0 -5
  115. package/example/yarn.lock +0 -7703
  116. package/ios/ReactNativeTracker-Bridging-Header.h +0 -2
  117. package/ios/ReactNativeTracker.mm +0 -175
  118. package/ios/ReactNativeTracker.swift +0 -822
  119. package/ios/ReactNativeTracker.xcodeproj/project.pbxproj +0 -301
  120. package/ios/Util/ConfigUtils.swift +0 -209
  121. package/ios/Util/TrackerVersion.swift +0 -3
  122. package/ios/Util/Utilities.swift +0 -37
  123. package/lefthook.yml +0 -11
  124. package/lib/commonjs/api.js +0 -490
  125. package/lib/commonjs/api.js.map +0 -1
  126. package/lib/commonjs/configurations.js +0 -196
  127. package/lib/commonjs/configurations.js.map +0 -1
  128. package/lib/commonjs/constants.js +0 -77
  129. package/lib/commonjs/constants.js.map +0 -1
  130. package/lib/commonjs/events.js +0 -277
  131. package/lib/commonjs/events.js.map +0 -1
  132. package/lib/commonjs/index.js +0 -132
  133. package/lib/commonjs/index.js.map +0 -1
  134. package/lib/commonjs/jsCore.js +0 -427
  135. package/lib/commonjs/jsCore.js.map +0 -1
  136. package/lib/commonjs/native.js +0 -16
  137. package/lib/commonjs/native.js.map +0 -1
  138. package/lib/commonjs/subject.js +0 -235
  139. package/lib/commonjs/subject.js.map +0 -1
  140. package/lib/commonjs/tracker.js +0 -248
  141. package/lib/commonjs/tracker.js.map +0 -1
  142. package/lib/commonjs/types.js +0 -2
  143. package/lib/commonjs/types.js.map +0 -1
  144. package/lib/commonjs/utils.js +0 -72
  145. package/lib/commonjs/utils.js.map +0 -1
  146. package/lib/commonjs/webViewInterface.js +0 -66
  147. package/lib/commonjs/webViewInterface.js.map +0 -1
  148. package/lib/module/api.js +0 -452
  149. package/lib/module/api.js.map +0 -1
  150. package/lib/module/configurations.js +0 -184
  151. package/lib/module/configurations.js.map +0 -1
  152. package/lib/module/constants.js +0 -72
  153. package/lib/module/constants.js.map +0 -1
  154. package/lib/module/events.js +0 -259
  155. package/lib/module/events.js.map +0 -1
  156. package/lib/module/index.js +0 -120
  157. package/lib/module/index.js.map +0 -1
  158. package/lib/module/jsCore.js +0 -424
  159. package/lib/module/jsCore.js.map +0 -1
  160. package/lib/module/native.js +0 -12
  161. package/lib/module/native.js.map +0 -1
  162. package/lib/module/subject.js +0 -222
  163. package/lib/module/subject.js.map +0 -1
  164. package/lib/module/tracker.js +0 -234
  165. package/lib/module/tracker.js.map +0 -1
  166. package/lib/module/types.js +0 -2
  167. package/lib/module/types.js.map +0 -1
  168. package/lib/module/utils.js +0 -66
  169. package/lib/module/utils.js.map +0 -1
  170. package/lib/module/webViewInterface.js +0 -62
  171. package/lib/module/webViewInterface.js.map +0 -1
  172. package/lib/typescript/__tests__/api.test.d.ts +0 -2
  173. package/lib/typescript/__tests__/api.test.d.ts.map +0 -1
  174. package/lib/typescript/__tests__/configurations.test.d.ts +0 -2
  175. package/lib/typescript/__tests__/configurations.test.d.ts.map +0 -1
  176. package/lib/typescript/__tests__/events.test.d.ts +0 -2
  177. package/lib/typescript/__tests__/events.test.d.ts.map +0 -1
  178. package/lib/typescript/__tests__/index.test.d.ts +0 -2
  179. package/lib/typescript/__tests__/index.test.d.ts.map +0 -1
  180. package/lib/typescript/__tests__/jsCore.test.d.ts +0 -2
  181. package/lib/typescript/__tests__/jsCore.test.d.ts.map +0 -1
  182. package/lib/typescript/__tests__/utils.test.d.ts +0 -2
  183. package/lib/typescript/__tests__/utils.test.d.ts.map +0 -1
  184. package/lib/typescript/api.d.ts +0 -240
  185. package/lib/typescript/api.d.ts.map +0 -1
  186. package/lib/typescript/configurations.d.ts +0 -73
  187. package/lib/typescript/configurations.d.ts.map +0 -1
  188. package/lib/typescript/constants.d.ts +0 -64
  189. package/lib/typescript/constants.d.ts.map +0 -1
  190. package/lib/typescript/events.d.ts +0 -115
  191. package/lib/typescript/events.d.ts.map +0 -1
  192. package/lib/typescript/index.d.ts +0 -27
  193. package/lib/typescript/index.d.ts.map +0 -1
  194. package/lib/typescript/jsCore.d.ts +0 -152
  195. package/lib/typescript/jsCore.d.ts.map +0 -1
  196. package/lib/typescript/native.d.ts +0 -4
  197. package/lib/typescript/native.d.ts.map +0 -1
  198. package/lib/typescript/subject.d.ts +0 -91
  199. package/lib/typescript/subject.d.ts.map +0 -1
  200. package/lib/typescript/tracker.d.ts +0 -111
  201. package/lib/typescript/tracker.d.ts.map +0 -1
  202. package/lib/typescript/types.d.ts +0 -981
  203. package/lib/typescript/types.d.ts.map +0 -1
  204. package/lib/typescript/utils.d.ts +0 -35
  205. package/lib/typescript/utils.d.ts.map +0 -1
  206. package/lib/typescript/webViewInterface.d.ts +0 -15
  207. package/lib/typescript/webViewInterface.d.ts.map +0 -1
  208. package/scripts/bootstrap.js +0 -29
  209. package/snowplow-react-native-tracker.podspec +0 -42
  210. package/src/__mocks__/react-native.js +0 -7
  211. package/src/__tests__/api.test.ts +0 -21
  212. package/src/__tests__/configurations.test.ts +0 -608
  213. package/src/__tests__/events.test.ts +0 -736
  214. package/src/__tests__/index.test.ts +0 -14
  215. package/src/__tests__/jsCore.test.ts +0 -199
  216. package/src/__tests__/utils.test.ts +0 -10
  217. package/src/api.ts +0 -556
  218. package/src/configurations.ts +0 -325
  219. package/src/constants.ts +0 -97
  220. package/src/events.ts +0 -355
  221. package/src/index.ts +0 -184
  222. package/src/jsCore.ts +0 -603
  223. package/src/native.ts +0 -21
  224. package/src/subject.ts +0 -302
  225. package/src/tracker.ts +0 -377
  226. package/src/types.ts +0 -1162
  227. package/src/utils.ts +0 -65
  228. package/src/webViewInterface.ts +0 -92
  229. package/tsconfig.build.json +0 -5
  230. package/tsconfig.json +0 -28
  231. package/turbo.json +0 -34
  232. package/yarn.lock +0 -9398
@@ -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 };