@snowplow/react-native-tracker 2.1.2 → 4.0.2-dev.1

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