@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,566 +0,0 @@
1
- /**
2
- * Sample React Native App
3
- * https://github.com/facebook/react-native
4
- *
5
- * @format
6
- * @flow strict-local
7
- */
8
-
9
- import React from 'react';
10
- import {
11
- SafeAreaView,
12
- ScrollView,
13
- StatusBar,
14
- StyleSheet,
15
- Text,
16
- useColorScheme,
17
- View,
18
- Button,
19
- Dimensions,
20
- } from 'react-native';
21
- import { WebView } from 'react-native-webview';
22
-
23
- import { Colors, Header } from 'react-native/Libraries/NewAppScreen';
24
-
25
- import {
26
- createTracker,
27
- removeTracker,
28
- getWebViewCallback,
29
- } from '@snowplow/react-native-tracker';
30
-
31
- /**
32
- * URI of the Snowplow collector (e.g., Micro, Mini, or BDP) to send events to
33
- */
34
- const collectorEndpoint = 'placeholder';
35
-
36
- /**
37
- * URI of a website to load in the webview component
38
- */
39
- const webViewEndpoint = '';
40
-
41
- const Section = ({ children, title }) => {
42
- const isDarkMode = useColorScheme() === 'dark';
43
- return (
44
- <View style={styles.sectionContainer}>
45
- <Text
46
- style={[
47
- styles.sectionTitle,
48
- {
49
- color: isDarkMode ? Colors.white : Colors.black,
50
- },
51
- ]}
52
- >
53
- {title}
54
- </Text>
55
- <Text
56
- style={[
57
- styles.sectionDescription,
58
- {
59
- color: isDarkMode ? Colors.light : Colors.dark,
60
- },
61
- ]}
62
- >
63
- {children}
64
- </Text>
65
- </View>
66
- );
67
- };
68
-
69
- const App = () => {
70
- const isDarkMode = useColorScheme() === 'dark';
71
-
72
- const backgroundStyle = {
73
- backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
74
- };
75
-
76
- const tracker = createTracker(
77
- 'sp1',
78
- {
79
- endpoint: collectorEndpoint,
80
- requestHeaders: {
81
- test: 'works',
82
- },
83
- },
84
- {
85
- trackerConfig: {
86
- appId: 'DemoAppId',
87
- base64Encoding: false,
88
- devicePlatform: 'iot',
89
- installAutotracking: false,
90
- },
91
- sessionConfig: {
92
- foregroundTimeout: 5,
93
- backgroundTimeout: 10,
94
- },
95
- subjectConfig: {
96
- userId: 'tester',
97
- screenViewport: [200, 200],
98
- language: 'fr',
99
- },
100
- gdprConfig: {
101
- basisForProcessing: 'consent',
102
- documentId: 'docId',
103
- documentVersion: '0.0.1',
104
- documentDescription: 'test gdpr document',
105
- },
106
- gcConfig: [
107
- {
108
- tag: 'testTag',
109
- globalContexts: [
110
- {
111
- schema:
112
- 'iglu:com.snowplowanalytics.snowplow/ad_impression/jsonschema/1-0-0',
113
- data: { impressionId: 'test_global_contexts_0' },
114
- },
115
- {
116
- schema:
117
- 'iglu:com.snowplowanalytics.snowplow/ad_impression/jsonschema/1-0-0',
118
- data: { impressionId: 'test_global_contexts_1' },
119
- },
120
- ],
121
- },
122
- ],
123
- }
124
- );
125
-
126
- const secTracker = createTracker(
127
- 'sp2',
128
- {
129
- endpoint: collectorEndpoint,
130
- },
131
- {
132
- trackerConfig: {
133
- screenViewAutotracking: false, // for tests predictability
134
- installAutotracking: false,
135
- },
136
- }
137
- );
138
-
139
- const anonymousTracker = createTracker(
140
- 'sp_anon',
141
- {
142
- endpoint: collectorEndpoint,
143
- },
144
- {
145
- trackerConfig: {
146
- screenViewAutotracking: false, // for tests predictability
147
- installAutotracking: false,
148
- userAnonymisation: true,
149
- },
150
- emitterConfig: {
151
- serverAnonymisation: true,
152
- },
153
- }
154
- );
155
-
156
- const onPressTrackScreenViewEvent = () => {
157
- tracker.trackScreenViewEvent({ name: 'onlyRequired' });
158
- tracker.trackScrollChangedEvent({
159
- yOffset: 20,
160
- contentHeight: 100,
161
- viewHeight: 50,
162
- });
163
- tracker.trackListItemViewEvent({
164
- index: 1,
165
- itemsCount: 10,
166
- });
167
- tracker.trackScreenViewEvent({
168
- name: 'allPopulated',
169
- type: 'allPopulated',
170
- transitionType: 'test',
171
- });
172
- tracker.trackScreenViewEvent({
173
- name: 'allOptionalsNull',
174
- type: null,
175
- transitionType: null,
176
- });
177
- tracker.trackScreenViewEvent({
178
- name: 'allOptionalsUndefined',
179
- type: undefined,
180
- transitionType: undefined,
181
- });
182
- tracker.trackScreenViewEvent(
183
- {
184
- name: 'withContext and screenId',
185
- id: '5d79770b-015b-4af8-8c91-b2ed6faf4b1e',
186
- },
187
- [
188
- {
189
- schema:
190
- 'iglu:com.snowplowanalytics.snowplow/ad_impression/jsonschema/1-0-0',
191
- data: { impressionId: 'test_imp_id' },
192
- },
193
- ]
194
- );
195
- tracker.trackScreenViewEvent({ name: 'withEmptyArrayContext' }, []);
196
- };
197
-
198
- const onPressTrackSelfDescribingEvent = () => {
199
- tracker.trackSelfDescribingEvent({
200
- schema: 'iglu:com.snowplowanalytics.snowplow/link_click/jsonschema/1-0-1',
201
- data: { targetUrl: 'test.test' },
202
- });
203
- tracker.trackTimingEvent({
204
- category: 'testTimingCategory',
205
- variable: 'testTimingVariable',
206
- timing: 10,
207
- });
208
- tracker.trackConsentGrantedEvent({
209
- expiry: '2022-01-01T00:00:00Z',
210
- documentId: '0123',
211
- version: '0.1.0',
212
- });
213
- tracker.trackConsentWithdrawnEvent({
214
- all: true,
215
- documentId: '0987',
216
- version: '0.2.0',
217
- });
218
- tracker.trackEcommerceTransactionEvent(
219
- {
220
- orderId: '0000',
221
- totalValue: 10,
222
- items: [
223
- {
224
- sku: '123',
225
- price: 5,
226
- quantity: 2,
227
- },
228
- ],
229
- },
230
- []
231
- );
232
- };
233
-
234
- const onPressTrackStructuredEvent = () => {
235
- tracker.trackStructuredEvent({
236
- category: 'SeTest',
237
- action: 'allPopulated',
238
- label: 'valueIsFloat',
239
- property: 'property',
240
- value: 50.1,
241
- });
242
- tracker.trackStructuredEvent({
243
- category: 'SeTest',
244
- action: 'allPopulated',
245
- label: 'valueIsNullAndSoIsProperty',
246
- property: null,
247
- value: null,
248
- });
249
-
250
- tracker.trackStructuredEvent({
251
- category: 'SeTest',
252
- action: 'allPopulated',
253
- label: 'valueIsUndefined',
254
- property: 'property',
255
- value: undefined,
256
- });
257
- tracker.trackStructuredEvent({
258
- category: 'SeTest',
259
- action: 'onlyRequired',
260
- });
261
- };
262
-
263
- const onPressTrackPageViewEvent = () => {
264
- tracker.trackPageViewEvent({
265
- pageUrl: 'https://allpopulated.com',
266
- pageTitle: 'some title',
267
- referrer: 'http://refr.com',
268
- });
269
- tracker.trackPageViewEvent({ pageUrl: 'https://onlyrequired.com' });
270
- tracker.trackPageViewEvent({
271
- pageUrl: 'https://alloptionalsnull.com',
272
- pageTitle: null,
273
- referrer: null,
274
- });
275
- tracker.trackPageViewEvent({
276
- pageUrl: 'https://alloptionalsundefined.com',
277
- pageTitle: undefined,
278
- referrer: undefined,
279
- });
280
- };
281
-
282
- const onPressTrackDeepLinkReceivedEvent = () => {
283
- tracker.trackDeepLinkReceivedEvent({
284
- url: 'https://deeplink.com',
285
- referrer: 'http://refr.com',
286
- });
287
- };
288
-
289
- const onPressTrackMessageNotificationEvent = () => {
290
- tracker.trackMessageNotificationEvent({
291
- title: 'title1',
292
- body: 'body1',
293
- trigger: 'push',
294
- action: 'action1',
295
- attachments: [
296
- {
297
- identifier: 'att_id1',
298
- type: 'att_type1',
299
- url: 'http://att.url.1',
300
- },
301
- ],
302
- bodyLocArgs: ['bodyArg1', 'bodyArg2'],
303
- bodyLocKey: 'bodyKey1',
304
- category: 'category1',
305
- contentAvailable: true,
306
- group: 'group1',
307
- icon: 'icon1',
308
- notificationCount: 3,
309
- notificationTimestamp: '2022-02-02T15:17:42.767Z',
310
- sound: 'sound1',
311
- subtitle: 'subtitle1',
312
- tag: 'tag1',
313
- threadIdentifier: 'threadIdentifier1',
314
- titleLocArgs: ['titleArg1', 'titleArg2'],
315
- titleLocKey: 'titleKey1',
316
- });
317
- };
318
-
319
- const onPressShowMeSomeWarnings = () => {
320
- tracker.trackSelfDescribingEvent({});
321
- tracker.trackStructuredEvent({});
322
- tracker.trackPageViewEvent({});
323
- tracker.trackScreenViewEvent({});
324
- };
325
-
326
- const onPressTestSetSubject = async () => {
327
- try {
328
- await tracker.setSubjectData({
329
- userId: 'nextTester',
330
- domainUserId: '5d79770b-015b-4af8-8c91-b2ed6faf4b1e',
331
- language: 'es',
332
- colorDepth: 50,
333
- timezone: 'Europe/London',
334
- screenResolution: [300, 300],
335
- });
336
- await tracker.trackScreenViewEvent({ name: 'afterSetSubjectTestSV' });
337
- } catch (e) {
338
- console.log(e.message);
339
- }
340
- };
341
-
342
- const onPressTestSecondTracker = () => {
343
- secTracker.trackScreenViewEvent({ name: 'fromSecondTracker' });
344
- secTracker.trackStructuredEvent({
345
- category: 'SecTracker',
346
- action: 'trackStructured',
347
- });
348
- };
349
-
350
- const onPressTestAnonymousTracker = () => {
351
- anonymousTracker.trackScreenViewEvent({ name: 'fromAnonymousTracker' });
352
- anonymousTracker.trackStructuredEvent({
353
- category: 'AnonymousTracker',
354
- action: 'trackAnonymous',
355
- });
356
- };
357
-
358
- const onPressPlayGC = async () => {
359
- try {
360
- await tracker.removeGlobalContexts('testTag');
361
- await tracker.addGlobalContexts({
362
- tag: 'testTagReloaded',
363
- globalContexts: [
364
- {
365
- schema:
366
- 'iglu:com.snowplowanalytics.snowplow/ad_impression/jsonschema/1-0-0',
367
- data: { impressionId: 'test_global_contexts_Reloaded' },
368
- },
369
- ],
370
- });
371
- await tracker.trackPageViewEvent({ pageUrl: 'afterGCChange.test' });
372
- } catch (e) {
373
- console.log(e.message);
374
- }
375
- };
376
-
377
- const onPressRemoveSecTracker = () => {
378
- removeTracker('sp2');
379
- // removeAllTrackers();
380
- };
381
-
382
- const onPressLogSessionData = async () => {
383
- try {
384
- const sessionUserId = await tracker.getSessionUserId();
385
- const sessionId = await tracker.getSessionId();
386
- const sessionIdx = await tracker.getSessionIndex();
387
- const isInBg = await tracker.getIsInBackground();
388
- const bgIndex = await tracker.getBackgroundIndex();
389
- const fgIndex = await tracker.getForegroundIndex();
390
-
391
- const sessionData = {
392
- userId: sessionUserId,
393
- sessionId: sessionId,
394
- sessionIndex: sessionIdx,
395
- isInBackground: isInBg,
396
- backgroundIndex: bgIndex,
397
- foregroundIndex: fgIndex,
398
- };
399
- console.log(
400
- 'SnowplowTracker: Session Data: ' + JSON.stringify(sessionData)
401
- );
402
- } catch (e) {
403
- console.log(e.message);
404
- }
405
- };
406
-
407
- return (
408
- <SafeAreaView style={backgroundStyle}>
409
- <StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} />
410
- <ScrollView
411
- testID="scrollView"
412
- contentInsetAdjustmentBehavior="automatic"
413
- style={backgroundStyle}
414
- >
415
- <Header />
416
- <View
417
- style={{
418
- backgroundColor: isDarkMode ? Colors.black : Colors.white,
419
- }}
420
- >
421
- <Section title="Screen Views">
422
- <Button
423
- onPress={onPressTrackScreenViewEvent}
424
- title="Track some Screen View Events"
425
- color="#841584"
426
- accessibilityLabel="testScreenView"
427
- />
428
- </Section>
429
- <Section title="Self-Describing Events">
430
- <Button
431
- onPress={onPressTrackSelfDescribingEvent}
432
- title="Track some Self-Describing Events"
433
- color="#841584"
434
- accessibilityLabel="testSelfDesc"
435
- />
436
- </Section>
437
- <Section title="Structured Events">
438
- <Button
439
- onPress={onPressTrackStructuredEvent}
440
- title="Track some Structured Events"
441
- color="#841584"
442
- accessibilityLabel="testStruct"
443
- />
444
- </Section>
445
- <Section title="Page Views">
446
- <Button
447
- onPress={onPressTrackPageViewEvent}
448
- title="Track some Page View Events"
449
- color="#841584"
450
- accessibilityLabel="testPageView"
451
- />
452
- </Section>
453
- <Section title="Deep Link">
454
- <Button
455
- onPress={onPressTrackDeepLinkReceivedEvent}
456
- title="Track a Deep Link Received Event"
457
- color="#841584"
458
- accessibilityLabel="testDeepLinkReceived"
459
- />
460
- </Section>
461
- <Section title="Message Notification">
462
- <Button
463
- onPress={onPressTrackMessageNotificationEvent}
464
- title="Track a Message Notification Event"
465
- color="#841584"
466
- accessibilityLabel="testMessageNotification"
467
- />
468
- </Section>
469
- <Section title="Second tracker">
470
- <Button
471
- onPress={onPressTestSecondTracker}
472
- title="Track events with second tracker"
473
- color="#841584"
474
- accessibilityLabel="testSecTracker"
475
- />
476
- </Section>
477
- <Section title="Anonymous tracker">
478
- <Button
479
- onPress={onPressTestAnonymousTracker}
480
- title="Track events with anonymous tracking"
481
- color="#841584"
482
- accessibilityLabel="testAnonymousTracker"
483
- />
484
- </Section>
485
- <Section title="Warnings">
486
- <Button
487
- onPress={onPressShowMeSomeWarnings}
488
- title="Show me some warnings"
489
- color="#f6bd3b"
490
- accessibilityLabel="testWrongInputs"
491
- />
492
- </Section>
493
- <Section title="Set the Subject">
494
- <Button
495
- onPress={onPressTestSetSubject}
496
- title="Set the Subject again"
497
- color="#228B22"
498
- accessibilityLabel="testSetSubject"
499
- />
500
- </Section>
501
- <Section title="SessionData">
502
- <Button
503
- onPress={onPressLogSessionData}
504
- title="Show me session data"
505
- color="#f6bd3b"
506
- accessibilityLabel="testSessionData"
507
- />
508
- </Section>
509
-
510
- <Section title="GC">
511
- <Button
512
- onPress={onPressPlayGC}
513
- title="Remove and Add Global Contexts"
514
- color="#228B22"
515
- accessibilityLabel="testGC"
516
- />
517
- </Section>
518
- <Section title="Removals">
519
- <Button
520
- onPress={onPressRemoveSecTracker}
521
- title="Remove Tracker"
522
- color="#AA2222"
523
- accessibilityLabel="testRemove"
524
- />
525
- </Section>
526
- <Section title="Web view">
527
- {webViewEndpoint ? (
528
- <WebView
529
- onMessage={getWebViewCallback()}
530
- source={{ uri: webViewEndpoint }}
531
- style={{
532
- height: 400,
533
- width:
534
- Dimensions.get('window').width -
535
- styles.sectionContainer.paddingHorizontal,
536
- }}
537
- />
538
- ) : null}
539
- </Section>
540
- </View>
541
- </ScrollView>
542
- </SafeAreaView>
543
- );
544
- };
545
-
546
- const styles = StyleSheet.create({
547
- sectionContainer: {
548
- marginTop: 32,
549
- marginBottom: 16,
550
- paddingHorizontal: 24,
551
- },
552
- sectionTitle: {
553
- fontSize: 24,
554
- fontWeight: '600',
555
- },
556
- sectionDescription: {
557
- marginTop: 8,
558
- fontSize: 18,
559
- fontWeight: '400',
560
- },
561
- highlight: {
562
- fontWeight: '700',
563
- },
564
- });
565
-
566
- export default App;
@@ -1,5 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "verbatimModuleSyntax": false
4
- }
5
- }