@snowplow/react-native-tracker 1.3.0 → 2.0.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 (240) hide show
  1. package/.editorconfig +15 -0
  2. package/.eslintignore +6 -0
  3. package/.gitattributes +3 -0
  4. package/.github/ISSUE_TEMPLATE/bug_report.md +29 -0
  5. package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  6. package/.github/actions/setup/action.yml +28 -0
  7. package/.github/workflows/build.yml +150 -0
  8. package/.github/workflows/deploy.yml +98 -0
  9. package/.github/workflows/e2e-android.yml +121 -0
  10. package/.github/workflows/e2e-ios.yml +90 -0
  11. package/.github/workflows/snyk.yml +21 -0
  12. package/.gitignore +70 -0
  13. package/.npmignore +60 -0
  14. package/.nvmrc +1 -0
  15. package/.watchmanconfig +1 -0
  16. package/.yarnrc +3 -0
  17. package/CHANGELOG +166 -0
  18. package/CONTRIBUTING.md +80 -0
  19. package/LICENSE +1 -1
  20. package/README.md +24 -111
  21. package/android/build.gradle +93 -37
  22. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  23. package/android/gradle/wrapper/gradle-wrapper.properties +1 -2
  24. package/android/gradle.properties +5 -2
  25. package/android/gradlew +172 -110
  26. package/android/gradlew.bat +24 -19
  27. package/android/src/main/AndroidManifest.xml +1 -3
  28. package/android/src/main/AndroidManifestNew.xml +2 -0
  29. package/android/src/main/java/com/snowplow/reactnativetracker/ReactNativeTrackerModule.kt +704 -0
  30. package/android/src/main/java/com/snowplow/reactnativetracker/ReactNativeTrackerPackage.kt +17 -0
  31. package/android/src/main/java/com/snowplow/reactnativetracker/util/ConfigUtil.kt +271 -0
  32. package/android/src/main/java/com/snowplow/reactnativetracker/util/EventUtil.kt +213 -0
  33. package/android/src/main/java/com/snowplow/reactnativetracker/util/TrackerVersion.kt +5 -0
  34. package/babel.config.js +3 -0
  35. package/example/.watchmanconfig +1 -0
  36. package/example/Gemfile +6 -0
  37. package/example/android/app/build.gradle +129 -0
  38. package/example/android/app/debug.keystore +0 -0
  39. package/example/android/app/proguard-rules.pro +10 -0
  40. package/example/android/app/src/androidTest/java/com/reactnativetrackerexample/DetoxTest.java +36 -0
  41. package/example/android/app/src/androidTest/java/com/reactnativetrackerexample/DetoxTestAppJUnitRunner.java +21 -0
  42. package/example/android/app/src/debug/AndroidManifest.xml +13 -0
  43. package/example/android/app/src/debug/java/com/reactnativetrackerexample/ReactNativeFlipper.java +75 -0
  44. package/example/android/app/src/main/AndroidManifest.xml +26 -0
  45. package/example/android/app/src/main/java/com/reactnativetrackerexample/MainActivity.java +32 -0
  46. package/example/android/app/src/main/java/com/reactnativetrackerexample/MainApplication.java +62 -0
  47. package/example/android/app/src/main/res/drawable/rn_edit_text_material.xml +36 -0
  48. package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  49. package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  50. package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  51. package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  52. package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  53. package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  54. package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  55. package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  56. package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  57. package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  58. package/example/android/app/src/main/res/values/strings.xml +3 -0
  59. package/example/android/app/src/main/res/values/styles.xml +9 -0
  60. package/example/android/app/src/release/java/com/reactnativetrackerexample/ReactNativeFlipper.java +20 -0
  61. package/example/android/build.gradle +31 -0
  62. package/example/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  63. package/example/android/gradle/wrapper/gradle-wrapper.properties +6 -0
  64. package/example/android/gradle.properties +44 -0
  65. package/example/android/gradlew +244 -0
  66. package/example/android/gradlew.bat +92 -0
  67. package/example/android/settings.gradle +4 -0
  68. package/example/app.json +4 -0
  69. package/example/babel.config.js +17 -0
  70. package/example/detox.config.js +92 -0
  71. package/example/e2e/config.json +10 -0
  72. package/example/e2e/emitEvents.e2e.detox.js +108 -0
  73. package/example/e2e/environment.js +23 -0
  74. package/example/e2e/helpers/microCommands.js +153 -0
  75. package/example/e2e/helpers/microHelpers.js +346 -0
  76. package/example/e2e/helpers/microHelpers.test.js +308 -0
  77. package/example/e2e/helpers/schemas.js +62 -0
  78. package/example/e2e/jest.config.js +16 -0
  79. package/example/e2e/setup.js +4 -0
  80. package/example/e2e/testEvents.micro.test.js +300 -0
  81. package/example/index.js +5 -0
  82. package/example/ios/.xcode.env +11 -0
  83. package/example/ios/Podfile +64 -0
  84. package/example/ios/Podfile.lock +737 -0
  85. package/example/ios/ReactNativeTrackerExample/AppDelegate.h +6 -0
  86. package/example/ios/ReactNativeTrackerExample/AppDelegate.mm +26 -0
  87. package/example/ios/ReactNativeTrackerExample/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
  88. package/example/ios/ReactNativeTrackerExample/Images.xcassets/Contents.json +6 -0
  89. package/example/ios/ReactNativeTrackerExample/Info.plist +55 -0
  90. package/example/ios/ReactNativeTrackerExample/LaunchScreen.storyboard +47 -0
  91. package/example/ios/ReactNativeTrackerExample/main.m +10 -0
  92. package/example/ios/ReactNativeTrackerExample-Bridging-Header.h +3 -0
  93. package/example/ios/ReactNativeTrackerExample.xcodeproj/project.pbxproj +722 -0
  94. package/{ios/RNSnowplowTracker.xcodeproj/xcshareddata/xcschemes/RNSnowplowTracker.xcscheme → example/ios/ReactNativeTrackerExample.xcodeproj/xcshareddata/xcschemes/ReactNativeTrackerExample.xcscheme} +29 -21
  95. package/example/ios/ReactNativeTrackerExample.xcworkspace/contents.xcworkspacedata +10 -0
  96. package/example/ios/ReactNativeTrackerExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  97. package/example/ios/ReactNativeTrackerExampleTests/Info.plist +24 -0
  98. package/example/ios/ReactNativeTrackerExampleTests/ReactNativeTrackerExampleTests.m +66 -0
  99. package/example/metro.config.js +45 -0
  100. package/example/package.json +54 -0
  101. package/example/react-native.config.js +10 -0
  102. package/example/src/App.js +557 -0
  103. package/example/tsconfig.json +5 -0
  104. package/example/yarn.lock +7379 -0
  105. package/ios/ReactNativeTracker-Bridging-Header.h +2 -0
  106. package/ios/ReactNativeTracker.mm +165 -0
  107. package/ios/ReactNativeTracker.swift +757 -0
  108. package/ios/{RNSnowplowTracker.xcodeproj → ReactNativeTracker.xcodeproj}/project.pbxproj +55 -79
  109. package/ios/Util/ConfigUtils.swift +206 -0
  110. package/ios/Util/TrackerVersion.swift +3 -0
  111. package/ios/Util/Utilities.swift +37 -0
  112. package/lefthook.yml +11 -0
  113. package/lib/commonjs/api.js +475 -0
  114. package/lib/commonjs/api.js.map +1 -0
  115. package/lib/commonjs/configurations.js +209 -0
  116. package/lib/commonjs/configurations.js.map +1 -0
  117. package/lib/commonjs/constants.js +85 -0
  118. package/lib/commonjs/constants.js.map +1 -0
  119. package/lib/commonjs/events.js +256 -0
  120. package/lib/commonjs/events.js.map +1 -0
  121. package/lib/commonjs/index.js +141 -0
  122. package/lib/commonjs/index.js.map +1 -0
  123. package/lib/commonjs/jsCore.js +393 -0
  124. package/lib/commonjs/jsCore.js.map +1 -0
  125. package/lib/commonjs/native.js +29 -0
  126. package/lib/commonjs/native.js.map +1 -0
  127. package/lib/commonjs/subject.js +248 -0
  128. package/lib/commonjs/subject.js.map +1 -0
  129. package/lib/commonjs/tracker.js +221 -0
  130. package/lib/commonjs/tracker.js.map +1 -0
  131. package/lib/commonjs/types.js +2 -0
  132. package/lib/commonjs/types.js.map +1 -0
  133. package/lib/commonjs/utils.js +85 -0
  134. package/lib/commonjs/utils.js.map +1 -0
  135. package/lib/commonjs/webViewInterface.js +79 -0
  136. package/lib/commonjs/webViewInterface.js.map +1 -0
  137. package/lib/module/api.js +439 -0
  138. package/lib/module/api.js.map +1 -0
  139. package/lib/module/configurations.js +197 -0
  140. package/lib/module/configurations.js.map +1 -0
  141. package/lib/module/constants.js +80 -0
  142. package/lib/module/constants.js.map +1 -0
  143. package/lib/module/events.js +240 -0
  144. package/lib/module/events.js.map +1 -0
  145. package/lib/module/index.js +129 -0
  146. package/lib/module/index.js.map +1 -0
  147. package/lib/module/jsCore.js +390 -0
  148. package/lib/module/jsCore.js.map +1 -0
  149. package/lib/module/native.js +25 -0
  150. package/lib/module/native.js.map +1 -0
  151. package/lib/module/subject.js +235 -0
  152. package/lib/module/subject.js.map +1 -0
  153. package/lib/module/tracker.js +209 -0
  154. package/lib/module/tracker.js.map +1 -0
  155. package/lib/module/types.js +2 -0
  156. package/lib/module/types.js.map +1 -0
  157. package/lib/module/utils.js +79 -0
  158. package/lib/module/utils.js.map +1 -0
  159. package/lib/module/webViewInterface.js +75 -0
  160. package/lib/module/webViewInterface.js.map +1 -0
  161. package/lib/typescript/__tests__/api.test.d.ts +2 -0
  162. package/lib/typescript/__tests__/api.test.d.ts.map +1 -0
  163. package/lib/typescript/__tests__/configurations.test.d.ts +2 -0
  164. package/lib/typescript/__tests__/configurations.test.d.ts.map +1 -0
  165. package/lib/typescript/__tests__/events.test.d.ts +2 -0
  166. package/lib/typescript/__tests__/events.test.d.ts.map +1 -0
  167. package/lib/typescript/__tests__/index.test.d.ts +2 -0
  168. package/lib/typescript/__tests__/index.test.d.ts.map +1 -0
  169. package/lib/typescript/__tests__/jsCore.test.d.ts +2 -0
  170. package/lib/typescript/__tests__/jsCore.test.d.ts.map +1 -0
  171. package/lib/typescript/__tests__/utils.test.d.ts +2 -0
  172. package/lib/typescript/__tests__/utils.test.d.ts.map +1 -0
  173. package/lib/typescript/api.d.ts +226 -0
  174. package/lib/typescript/api.d.ts.map +1 -0
  175. package/lib/typescript/configurations.d.ts +73 -0
  176. package/lib/typescript/configurations.d.ts.map +1 -0
  177. package/lib/typescript/constants.d.ts +59 -0
  178. package/lib/typescript/constants.d.ts.map +1 -0
  179. package/lib/typescript/events.d.ts +101 -0
  180. package/lib/typescript/events.d.ts.map +1 -0
  181. package/lib/typescript/index.d.ts +27 -0
  182. package/lib/typescript/index.d.ts.map +1 -0
  183. package/lib/typescript/jsCore.d.ts +140 -0
  184. package/lib/typescript/jsCore.d.ts.map +1 -0
  185. package/lib/typescript/native.d.ts +4 -0
  186. package/lib/typescript/native.d.ts.map +1 -0
  187. package/lib/typescript/subject.d.ts +91 -0
  188. package/lib/typescript/subject.d.ts.map +1 -0
  189. package/lib/typescript/tracker.d.ts +93 -0
  190. package/lib/typescript/tracker.d.ts.map +1 -0
  191. package/{dist/index.d.ts → lib/typescript/types.d.ts} +188 -75
  192. package/lib/typescript/types.d.ts.map +1 -0
  193. package/lib/typescript/utils.d.ts +35 -0
  194. package/lib/typescript/utils.d.ts.map +1 -0
  195. package/lib/typescript/webViewInterface.d.ts +15 -0
  196. package/lib/typescript/webViewInterface.d.ts.map +1 -0
  197. package/package.json +138 -51
  198. package/scripts/bootstrap.js +29 -0
  199. package/snowplow-react-native-tracker.podspec +42 -0
  200. package/src/__mocks__/react-native.js +7 -0
  201. package/src/__tests__/api.test.ts +34 -0
  202. package/src/__tests__/configurations.test.ts +620 -0
  203. package/src/__tests__/events.test.ts +749 -0
  204. package/src/__tests__/index.test.ts +27 -0
  205. package/src/__tests__/jsCore.test.ts +169 -0
  206. package/src/__tests__/utils.test.ts +23 -0
  207. package/src/api.ts +535 -0
  208. package/src/configurations.ts +337 -0
  209. package/src/constants.ts +102 -0
  210. package/src/events.ts +330 -0
  211. package/src/index.ts +189 -0
  212. package/src/jsCore.ts +553 -0
  213. package/src/native.ts +34 -0
  214. package/src/subject.ts +315 -0
  215. package/src/tracker.ts +330 -0
  216. package/src/types.ts +1087 -0
  217. package/src/utils.ts +78 -0
  218. package/src/webViewInterface.ts +105 -0
  219. package/tsconfig.build.json +5 -0
  220. package/tsconfig.json +28 -0
  221. package/turbo.json +34 -0
  222. package/yarn.lock +9333 -0
  223. package/RNSnowplowTracker.podspec +0 -24
  224. package/android/src/main/java/com/snowplowanalytics/react/tracker/RNSnowplowTrackerModule.java +0 -750
  225. package/android/src/main/java/com/snowplowanalytics/react/tracker/RNSnowplowTrackerPackage.java +0 -29
  226. package/android/src/main/java/com/snowplowanalytics/react/util/ConfigUtil.java +0 -351
  227. package/android/src/main/java/com/snowplowanalytics/react/util/EventUtil.java +0 -339
  228. package/android/src/main/java/com/snowplowanalytics/react/util/TrackerVersion.java +0 -7
  229. package/dist/index.js +0 -1650
  230. package/dist/index.js.map +0 -1
  231. package/ios/RNSnowplowTracker.h +0 -34
  232. package/ios/RNSnowplowTracker.m +0 -911
  233. package/ios/Util/NSDictionary+RNSP_TypeMethods.h +0 -33
  234. package/ios/Util/NSDictionary+RNSP_TypeMethods.m +0 -40
  235. package/ios/Util/RNConfigUtils.h +0 -44
  236. package/ios/Util/RNConfigUtils.m +0 -209
  237. package/ios/Util/RNTrackerVersion.h +0 -27
  238. package/ios/Util/RNTrackerVersion.m +0 -27
  239. package/ios/Util/RNUtilities.h +0 -32
  240. package/ios/Util/RNUtilities.m +0 -68
@@ -0,0 +1,308 @@
1
+ /*
2
+ * Copyright (c) 2020-2023 Snowplow Analytics Ltd. All rights reserved.
3
+ *
4
+ * This program is licensed to you under the Apache License Version 2.0,
5
+ * and you may not use this file except in compliance with the Apache License Version 2.0.
6
+ * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
7
+ *
8
+ * Unless required by applicable law or agreed to in writing,
9
+ * software distributed under the Apache License Version 2.0 is distributed on an
10
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
12
+ */
13
+
14
+ const Micro = require('./microHelpers.js');
15
+
16
+ describe('tests helper functions of helpers.js', () => {
17
+ it('tests compare with null, numbers, strings, booleans', () => {
18
+ // null
19
+ expect(Micro.compare(null, null)).toBe(true);
20
+ expect(Micro.compare(null, [])).toBe(false);
21
+ expect(Micro.compare('not null', null)).toBe(false);
22
+
23
+ // numbers
24
+ expect(Micro.compare(1, 1)).toBe(true);
25
+ expect(Micro.compare(2.3, 0)).toBe(false);
26
+
27
+ // strings
28
+ expect(Micro.compare('a', 'a')).toBe(true);
29
+ expect(Micro.compare('a', 'ab')).toBe(false);
30
+ expect(Micro.compare('', 'b')).toBe(false);
31
+
32
+ // booleans
33
+ expect(Micro.compare(false, false)).toBe(true);
34
+ expect(Micro.compare(true, false)).toBe(false);
35
+ });
36
+
37
+ it('tests compare with arrays', () => {
38
+ // arrays and nested arrays
39
+ expect(Micro.compare([], [])).toBe(true);
40
+
41
+ expect(Micro.compare([], [1, 2])).toBe(true);
42
+
43
+ expect(Micro.compare([1, 2], [])).toBe(false);
44
+
45
+ expect(Micro.compare([1, 2], [2])).toBe(false);
46
+
47
+ expect(Micro.compare([1, 2], [2, 1])).toBe(true);
48
+
49
+ expect(Micro.compare([1, 2, 3], [4, 2, 5, 3, 1, 6])).toBe(true);
50
+
51
+ expect(Micro.compare([1, [2, 3], 4], [5, 4, [3, 2, 0], 0, 1])).toBe(true);
52
+ });
53
+
54
+ it('tests compare with objects', () => {
55
+ expect(Micro.compare({}, {})).toBe(true);
56
+
57
+ expect(Micro.compare({}, {a: 1})).toBe(true);
58
+
59
+ expect(Micro.compare({a: 1}, {})).toBe(false);
60
+
61
+ expect(
62
+ Micro.compare(
63
+ {
64
+ a: 1,
65
+ b: 2,
66
+ },
67
+ {
68
+ a: 1,
69
+ b: 3,
70
+ },
71
+ ),
72
+ ).toBe(false);
73
+
74
+ expect(
75
+ Micro.compare(
76
+ {
77
+ a: 1,
78
+ b: 2,
79
+ },
80
+ {
81
+ b: 2,
82
+ c: 3,
83
+ a: 1,
84
+ },
85
+ ),
86
+ ).toBe(true);
87
+ });
88
+
89
+ it('tests compare with arrays of objects', () => {
90
+ // expected, actual
91
+ let exp, act;
92
+
93
+ exp = [
94
+ {
95
+ a: 1,
96
+ b: 2,
97
+ },
98
+ {
99
+ c: 3,
100
+ },
101
+ ];
102
+ act = [
103
+ {
104
+ c: 3,
105
+ e: 5,
106
+ },
107
+ {
108
+ b: 2,
109
+ a: 1,
110
+ },
111
+ {
112
+ d: 4,
113
+ },
114
+ ];
115
+ expect(Micro.compare(exp, act)).toBe(true);
116
+
117
+ exp = [
118
+ {
119
+ a: 1,
120
+ b: 2,
121
+ },
122
+ {
123
+ c: 3,
124
+ },
125
+ ];
126
+ act = [
127
+ {
128
+ c: 3,
129
+ e: 5,
130
+ },
131
+ {
132
+ b: 2,
133
+ a: 2,
134
+ },
135
+ ];
136
+ expect(Micro.compare(exp, act)).toBe(false);
137
+
138
+ exp = [
139
+ {
140
+ a: 1,
141
+ },
142
+ {
143
+ c: [
144
+ {
145
+ d: 4,
146
+ e: {
147
+ f: 6,
148
+ g: [1, 2],
149
+ },
150
+ },
151
+ ],
152
+ },
153
+ ];
154
+ act = [
155
+ {
156
+ z: 10,
157
+ c: [
158
+ {
159
+ e: {
160
+ g: [3, 2, 1],
161
+ f: 6,
162
+ i: 2,
163
+ },
164
+ d: 4,
165
+ h: 7,
166
+ },
167
+ ],
168
+ },
169
+ {
170
+ a: 1,
171
+ },
172
+ ];
173
+ expect(Micro.compare(exp, act)).toBe(true);
174
+ });
175
+
176
+ it('tests compare with nested objects', () => {
177
+ // expected, actual
178
+ let exp, act_1, act_2;
179
+
180
+ exp = {
181
+ a: {
182
+ b: {
183
+ c: [1, 2],
184
+ d: 'test',
185
+ e: 5,
186
+ },
187
+ f: 1,
188
+ },
189
+ aa: [
190
+ {},
191
+ {
192
+ bb: 1,
193
+ cc: {
194
+ dd: {
195
+ ee: {
196
+ ff: 0,
197
+ },
198
+ },
199
+ },
200
+ },
201
+ [
202
+ [0, 1],
203
+ {
204
+ aaa: 'bbb',
205
+ ccc: [
206
+ {
207
+ ddd: 3.14,
208
+ },
209
+ ],
210
+ },
211
+ 0,
212
+ ],
213
+ true,
214
+ ],
215
+ last: 'thing',
216
+ };
217
+
218
+ // "innocent" diffs
219
+ act_1 = {
220
+ diff1: 0,
221
+ a: {
222
+ b: {
223
+ c: [1, 2],
224
+ diff2: 0,
225
+ d: 'test',
226
+ e: 5,
227
+ },
228
+ diff3: [0, 0, 0],
229
+ f: 1,
230
+ },
231
+ aa: [
232
+ {},
233
+ ['diff41', 'diff42'],
234
+ {
235
+ bb: 1,
236
+ cc: {
237
+ dd: {
238
+ ee: {
239
+ ff: 0,
240
+ diff6: 0,
241
+ },
242
+ diff7: {},
243
+ },
244
+ },
245
+ diff8: 0,
246
+ },
247
+ [
248
+ [0, 1],
249
+ ['diff9'],
250
+ {
251
+ aaa: 'bbb',
252
+ ccc: [
253
+ {
254
+ ddd: 3.14,
255
+ },
256
+ ],
257
+ },
258
+ 0,
259
+ ],
260
+ true,
261
+ ],
262
+ last: 'thing',
263
+ diff0: 'last',
264
+ };
265
+
266
+ // pi
267
+ act_2 = {
268
+ a: {
269
+ b: {
270
+ c: [1, 2],
271
+ d: 'test',
272
+ e: 5,
273
+ },
274
+ f: 1,
275
+ },
276
+ aa: [
277
+ {},
278
+ {
279
+ bb: 1,
280
+ cc: {
281
+ dd: {
282
+ ee: {
283
+ ff: 0,
284
+ },
285
+ },
286
+ },
287
+ },
288
+ [
289
+ [0, 1],
290
+ {
291
+ aaa: 'bbb',
292
+ ccc: [
293
+ {
294
+ ddd: 3.1415, // only diff with exp
295
+ },
296
+ ],
297
+ },
298
+ 0,
299
+ ],
300
+ true,
301
+ ],
302
+ last: 'thing',
303
+ };
304
+
305
+ expect(Micro.compare(exp, act_1)).toBe(true);
306
+ expect(Micro.compare(exp, act_2)).toBe(false);
307
+ });
308
+ });
@@ -0,0 +1,62 @@
1
+ /*
2
+ * Copyright (c) 2020-2023 Snowplow Analytics Ltd. All rights reserved.
3
+ *
4
+ * This program is licensed to you under the Apache License Version 2.0,
5
+ * and you may not use this file except in compliance with the Apache License Version 2.0.
6
+ * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
7
+ *
8
+ * Unless required by applicable law or agreed to in writing,
9
+ * software distributed under the Apache License Version 2.0 is distributed on an
10
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
12
+ */
13
+
14
+ // Self-describing schemas
15
+ const appInstall =
16
+ 'iglu:com.snowplowanalytics.mobile/application_install/jsonschema/1-0-0';
17
+ const screenView =
18
+ 'iglu:com.snowplowanalytics.mobile/screen_view/jsonschema/1-0-0';
19
+ const adImpression =
20
+ 'iglu:com.snowplowanalytics.snowplow/ad_impression/jsonschema/1-0-0';
21
+ const linkClick =
22
+ 'iglu:com.snowplowanalytics.snowplow/link_click/jsonschema/1-0-1';
23
+ const consentWithdrawn =
24
+ 'iglu:com.snowplowanalytics.snowplow/consent_withdrawn/jsonschema/1-0-0';
25
+ const consentGranted =
26
+ 'iglu:com.snowplowanalytics.snowplow/consent_granted/jsonschema/1-0-0';
27
+ const consentDoc =
28
+ 'iglu:com.snowplowanalytics.snowplow/consent_document/jsonschema/1-0-0';
29
+ const timing = 'iglu:com.snowplowanalytics.snowplow/timing/jsonschema/1-0-0';
30
+ const deepLink =
31
+ 'iglu:com.snowplowanalytics.mobile/deep_link_received/jsonschema/1-0-0';
32
+ const messageNotification =
33
+ 'iglu:com.snowplowanalytics.mobile/message_notification/jsonschema/1-0-0';
34
+
35
+ // Context schemas
36
+ const mobileApplicationContext =
37
+ 'iglu:com.snowplowanalytics.mobile/application/jsonschema/1-0-0';
38
+ const mobileContext =
39
+ 'iglu:com.snowplowanalytics.snowplow/mobile_context/jsonschema/1-0-3';
40
+ const mobileScreenContext =
41
+ 'iglu:com.snowplowanalytics.mobile/screen/jsonschema/1-0-0';
42
+ const clientSessionContext =
43
+ 'iglu:com.snowplowanalytics.snowplow/client_session/jsonschema/1-0-2';
44
+ const gdprContext = 'iglu:com.snowplowanalytics.snowplow/gdpr/jsonschema/1-0-0';
45
+
46
+ module.exports = {
47
+ appInstall,
48
+ screenView,
49
+ adImpression,
50
+ linkClick,
51
+ consentWithdrawn,
52
+ consentGranted,
53
+ consentDoc,
54
+ timing,
55
+ mobileApplicationContext,
56
+ mobileContext,
57
+ mobileScreenContext,
58
+ clientSessionContext,
59
+ gdprContext,
60
+ deepLink,
61
+ messageNotification,
62
+ };
@@ -0,0 +1,16 @@
1
+ /** @type {import('jest').Config} */
2
+ module.exports = {
3
+ maxWorkers: 1,
4
+ globalSetup: "detox/runners/jest/globalSetup",
5
+ globalTeardown: "detox/runners/jest/globalTeardown",
6
+ testEnvironment: "detox/runners/jest/testEnvironment",
7
+ setupFilesAfterEnv: ["./setup.js"],
8
+ testRunner: "jest-circus/runner",
9
+ testTimeout: 300000,
10
+ testRegex: "\\.e2e.detox\\.js$",
11
+ transform: {
12
+ "\\.tsx?$": "ts-jest"
13
+ },
14
+ reporters: ["detox/runners/jest/reporter"],
15
+ verbose: true
16
+ };
@@ -0,0 +1,4 @@
1
+ beforeAll(async () => {
2
+ // https://github.com/wix/Detox/blob/master/docs/APIRef.DeviceObjectAPI.md
3
+ await device.launchApp({delete: true});
4
+ });
@@ -0,0 +1,300 @@
1
+ /*
2
+ * Copyright (c) 2020-2023 Snowplow Analytics Ltd. All rights reserved.
3
+ *
4
+ * This program is licensed to you under the Apache License Version 2.0,
5
+ * and you may not use this file except in compliance with the Apache License Version 2.0.
6
+ * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
7
+ *
8
+ * Unless required by applicable law or agreed to in writing,
9
+ * software distributed under the Apache License Version 2.0 is distributed on an
10
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
12
+ */
13
+
14
+ const commands = require('./helpers/microCommands.js');
15
+ const schemas = require('./helpers/schemas.js');
16
+
17
+ test('no bad events', async () => {
18
+ await commands.assertNoBadEvents();
19
+ });
20
+
21
+ test('number of screen_view events', async () => {
22
+ await commands.eventsWithSchema(schemas.screenView, 9);
23
+ });
24
+
25
+ test('number of structured events', async () => {
26
+ await commands.eventsWithEventType('struct', 6);
27
+ });
28
+
29
+ test('number of page_view events', async () => {
30
+ await commands.eventsWithEventType('page_view', 4);
31
+ });
32
+
33
+ test('screen_view with adImpression context', async () => {
34
+ await commands.eventsWithProperties(
35
+ {
36
+ schema: schemas.screenView,
37
+ values: {
38
+ name: 'withContext and screenId',
39
+ },
40
+ contexts: [
41
+ {
42
+ schema: schemas.adImpression,
43
+ data: {
44
+ impressionId: 'test_imp_id',
45
+ },
46
+ },
47
+ ],
48
+ },
49
+ 1
50
+ );
51
+ });
52
+
53
+ test('self-describing ad_impression event', async () => {
54
+ await commands.eventsWithProperties(
55
+ {
56
+ schema: schemas.linkClick,
57
+ values: {
58
+ targetUrl: 'test.test',
59
+ },
60
+ contexts: [
61
+ { schema: schemas.mobileApplicationContext },
62
+ { schema: schemas.mobileContext },
63
+ { schema: schemas.mobileScreenContext },
64
+ { schema: schemas.clientSessionContext },
65
+ { schema: schemas.gdprContext },
66
+ ],
67
+ },
68
+ 1
69
+ );
70
+ });
71
+
72
+ test('consentWithdrawn event', async () => {
73
+ await commands.eventsWithProperties(
74
+ {
75
+ schema: schemas.consentWithdrawn,
76
+ values: {
77
+ all: true,
78
+ },
79
+ contexts: [
80
+ {
81
+ schema: schemas.consentDoc,
82
+ data: {
83
+ id: '0987',
84
+ version: '0.2.0',
85
+ },
86
+ },
87
+ ],
88
+ },
89
+ 1
90
+ );
91
+ });
92
+
93
+ test('consentGranted event', async () => {
94
+ await commands.eventsWithProperties(
95
+ {
96
+ schema: schemas.consentGranted,
97
+ values: {
98
+ expiry: '2022-01-01T00:00:00Z',
99
+ },
100
+ contexts: [
101
+ {
102
+ schema: schemas.consentDoc,
103
+ data: {
104
+ id: '0123',
105
+ version: '0.1.0',
106
+ },
107
+ },
108
+ ],
109
+ },
110
+ 1
111
+ );
112
+ });
113
+
114
+ test('timing event', async () => {
115
+ await commands.eventsWithProperties(
116
+ {
117
+ schema: schemas.timing,
118
+ values: {
119
+ variable: 'testTimingVariable',
120
+ category: 'testTimingCategory',
121
+ timing: 10,
122
+ },
123
+ },
124
+ 1
125
+ );
126
+ });
127
+
128
+ test('transaction item event', async () => {
129
+ await commands.eventsWithProperties(
130
+ {
131
+ parameters: {
132
+ event: 'transaction_item',
133
+ ti_orderid: '0000',
134
+ ti_sku: '123',
135
+ ti_price: 5,
136
+ ti_quantity: 2,
137
+ },
138
+ },
139
+ 1
140
+ );
141
+ });
142
+
143
+ test('ecommerce transaction event', async () => {
144
+ await commands.eventsWithProperties(
145
+ {
146
+ parameters: {
147
+ event: 'transaction',
148
+ tr_orderid: '0000',
149
+ tr_total: 10,
150
+ },
151
+ },
152
+ 1
153
+ );
154
+ });
155
+
156
+ test('deep link event', async () => {
157
+ await commands.eventsWithProperties(
158
+ {
159
+ schema: schemas.deepLink,
160
+ values: {
161
+ url: 'https://deeplink.com',
162
+ referrer: 'http://refr.com',
163
+ },
164
+ },
165
+ 1
166
+ );
167
+ });
168
+
169
+ test('message notification event', async () => {
170
+ await commands.eventsWithProperties(
171
+ {
172
+ schema: schemas.messageNotification,
173
+ values: {
174
+ title: 'title1',
175
+ body: 'body1',
176
+ trigger: 'push',
177
+ action: 'action1',
178
+ attachments: [
179
+ {
180
+ identifier: 'att_id1',
181
+ type: 'att_type1',
182
+ url: 'http://att.url.1',
183
+ },
184
+ ],
185
+ bodyLocArgs: ['bodyArg1', 'bodyArg2'],
186
+ bodyLocKey: 'bodyKey1',
187
+ category: 'category1',
188
+ contentAvailable: true,
189
+ group: 'group1',
190
+ icon: 'icon1',
191
+ notificationCount: 3,
192
+ notificationTimestamp: '2022-02-02T15:17:42.767Z',
193
+ sound: 'sound1',
194
+ subtitle: 'subtitle1',
195
+ tag: 'tag1',
196
+ threadIdentifier: 'threadIdentifier1',
197
+ titleLocArgs: ['titleArg1', 'titleArg2'],
198
+ titleLocKey: 'titleKey1',
199
+ },
200
+ },
201
+ 1
202
+ );
203
+ });
204
+
205
+ test('common in all first tracker events', async () => {
206
+ await commands.eventsWithProperties(
207
+ {
208
+ parameters: {
209
+ app_id: 'DemoAppId',
210
+ platform: 'iot',
211
+ name_tracker: 'sp1',
212
+ },
213
+ header: 'test: works',
214
+ contexts: [
215
+ { schema: schemas.mobileApplicationContext },
216
+ { schema: schemas.mobileContext },
217
+ { schema: schemas.mobileScreenContext },
218
+ { schema: schemas.clientSessionContext },
219
+ {
220
+ schema: schemas.gdprContext,
221
+ data: {
222
+ basisForProcessing: 'consent',
223
+ documentDescription: 'test gdpr document',
224
+ documentId: 'docId',
225
+ documentVersion: '0.0.1',
226
+ },
227
+ },
228
+ {
229
+ schema: schemas.adImpression,
230
+ data: { impressionId: 'test_global_contexts_0' },
231
+ },
232
+ {
233
+ schema: schemas.adImpression,
234
+ data: { impressionId: 'test_global_contexts_1' },
235
+ },
236
+ ],
237
+ },
238
+ 23
239
+ );
240
+ });
241
+
242
+ test('events after resetting the Subject', async () => {
243
+ await commands.eventsWithProperties(
244
+ {
245
+ parameters: {
246
+ user_id: 'nextTester',
247
+ dvce_screenwidth: 300,
248
+ dvce_screenheight: 300,
249
+ br_lang: 'es',
250
+ os_timezone: 'Europe/London',
251
+ },
252
+ schema: schemas.screenView,
253
+ values: {
254
+ name: 'afterSetSubjectTestSV',
255
+ },
256
+ },
257
+ 1
258
+ );
259
+ });
260
+
261
+ test('second tracker events', async () => {
262
+ await commands.eventsWithProperties(
263
+ {
264
+ parameters: {
265
+ name_tracker: 'sp2',
266
+ },
267
+ contexts: [
268
+ { schema: schemas.mobileApplicationContext },
269
+ { schema: schemas.mobileContext },
270
+ { schema: schemas.mobileScreenContext },
271
+ { schema: schemas.clientSessionContext },
272
+ ],
273
+ },
274
+ 2
275
+ );
276
+ });
277
+
278
+ test('anonymous tracker events', async () => {
279
+ await commands.eventsWithProperties(
280
+ {
281
+ parameters: {
282
+ name_tracker: 'sp_anon',
283
+ network_userid: '00000000-0000-0000-0000-000000000000',
284
+ },
285
+ event: {
286
+ contexts: {
287
+ data: [
288
+ {
289
+ schema: schemas.clientSessionContext,
290
+ data: {
291
+ userId: '00000000-0000-0000-0000-000000000000',
292
+ },
293
+ },
294
+ ],
295
+ },
296
+ },
297
+ },
298
+ 2
299
+ );
300
+ });
@@ -0,0 +1,5 @@
1
+ import { AppRegistry } from 'react-native';
2
+ import App from './src/App';
3
+ import { name as appName } from './app.json';
4
+
5
+ AppRegistry.registerComponent(appName, () => App);
@@ -0,0 +1,11 @@
1
+ # This `.xcode.env` file is versioned and is used to source the environment
2
+ # used when running script phases inside Xcode.
3
+ # To customize your local environment, you can create an `.xcode.env.local`
4
+ # file that is not versioned.
5
+
6
+ # NODE_BINARY variable contains the PATH to the node executable.
7
+ #
8
+ # Customize the NODE_BINARY variable here.
9
+ # For example, to use nvm with brew, add the following line
10
+ # . "$(brew --prefix nvm)/nvm.sh" --no-use
11
+ export NODE_BINARY=$(command -v node)