@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
package/src/api.ts DELETED
@@ -1,556 +0,0 @@
1
- 'use strict';
2
-
3
- import { RNSnowplowTracker } from './native';
4
- import { initValidate, isValidGC } from './configurations';
5
- import { logMessages } from './constants';
6
- import * as tracker from './tracker';
7
- import * as subject from './subject';
8
-
9
- import type {
10
- InitTrackerConfiguration,
11
- SubjectConfiguration,
12
- SelfDescribing,
13
- EventContext,
14
- ScreenViewProps,
15
- StructuredProps,
16
- PageViewProps,
17
- TimingProps,
18
- ConsentGrantedProps,
19
- ConsentWithdrawnProps,
20
- EcommerceTransactionProps,
21
- GlobalContext,
22
- ScreenSize,
23
- DeepLinkReceivedProps,
24
- MessageNotificationProps,
25
- ScrollChangedProps,
26
- ListItemViewProps,
27
- } from './types';
28
-
29
- /**
30
- * Create a tracker from specified initial configuration.
31
- *
32
- * @param initConfig {Object} - The initial tracker configuration
33
- * @returns - A promise fullfilled if the tracker is initialized
34
- */
35
- function createTracker(initConfig: InitTrackerConfiguration): Promise<void> {
36
- return <Promise<void>>initValidate(initConfig)
37
- .then(() => <Promise<void>>RNSnowplowTracker.createTracker(initConfig))
38
- .catch((error) => {
39
- throw new Error(`${logMessages.createTracker} ${error.message}.`);
40
- });
41
- }
42
-
43
- /**
44
- * Removes the tracker with given namespace
45
- *
46
- * @param trackerNamespace {string} - The tracker namespace
47
- * @returns - A boolean promise
48
- */
49
- function removeTracker(trackerNamespace: string): Promise<boolean> {
50
- if (typeof trackerNamespace !== 'string') {
51
- return Promise.reject(new Error(logMessages.removeTracker));
52
- }
53
- return <Promise<boolean>>(
54
- Promise.resolve(
55
- RNSnowplowTracker.removeTracker({ tracker: trackerNamespace })
56
- )
57
- );
58
- }
59
-
60
- /**
61
- * Removes all existing trackers
62
- *
63
- * @returns - A void promise
64
- */
65
- function removeAllTrackers(): Promise<boolean> {
66
- return <Promise<boolean>>(
67
- Promise.resolve(RNSnowplowTracker.removeAllTrackers())
68
- );
69
- }
70
-
71
- /**
72
- * Returns a function to track a SelfDescribing event by a tracker
73
- *
74
- * @param namespace {string} - The tracker namespace
75
- * @returns - A function to track a SelfDescribing event
76
- */
77
- function trackSelfDescribingEvent(namespace: string) {
78
- return function (
79
- argmap: SelfDescribing,
80
- contexts: EventContext[] = []
81
- ): Promise<void> {
82
- return tracker.trackSelfDescribingEvent(namespace, argmap, contexts);
83
- };
84
- }
85
-
86
- /**
87
- * Returns a function to track a ScreenView event by a tracker
88
- *
89
- * @param namespace {string} - The tracker namespace
90
- * @returns - A function to track a ScreenView event
91
- */
92
- function trackScreenViewEvent(namespace: string) {
93
- return function (
94
- argmap: ScreenViewProps,
95
- contexts: EventContext[] = []
96
- ): Promise<void> {
97
- return tracker.trackScreenViewEvent(namespace, argmap, contexts);
98
- };
99
- }
100
-
101
- /**
102
- * Returns a function to track a ScrollChanged event by a tracker
103
- *
104
- * @param namespace {string} - The tracker namespace
105
- * @returns - A function to track a ScrollChanged event
106
- */
107
- function trackScrollChangedEvent(namespace: string) {
108
- return function (
109
- argmap: ScrollChangedProps,
110
- contexts: EventContext[] = []
111
- ): Promise<void> {
112
- return tracker.trackScrollChangedEvent(namespace, argmap, contexts);
113
- };
114
- }
115
-
116
- /**
117
- * Returns a function to track a ListItemView event by a tracker
118
- *
119
- * @param namespace {string} - The tracker namespace
120
- * @returns - A function to track a ListItemView event
121
- */
122
- function trackListItemViewEvent(namespace: string) {
123
- return function (
124
- argmap: ListItemViewProps,
125
- contexts: EventContext[] = []
126
- ): Promise<void> {
127
- return tracker.trackListItemViewEvent(namespace, argmap, contexts);
128
- };
129
- }
130
-
131
- /**
132
- * Returns a function to track a Structured event by a tracker
133
- *
134
- * @param namespace {string} - The tracker namespace
135
- * @returns - A function to track a Structured event
136
- */
137
- function trackStructuredEvent(namespace: string) {
138
- return function (
139
- argmap: StructuredProps,
140
- contexts: EventContext[] = []
141
- ): Promise<void> {
142
- return tracker.trackStructuredEvent(namespace, argmap, contexts);
143
- };
144
- }
145
-
146
- /**
147
- * Returns a function to track a PageView event by a tracker
148
- *
149
- * @param namespace {string} - The tracker namespace
150
- * @returns - A function to track a PageView event
151
- */
152
- function trackPageViewEvent(namespace: string) {
153
- return function (
154
- argmap: PageViewProps,
155
- contexts: EventContext[] = []
156
- ): Promise<void> {
157
- return tracker.trackPageViewEvent(namespace, argmap, contexts);
158
- };
159
- }
160
-
161
- /**
162
- * Returns a function to track a Timing event by a tracker
163
- *
164
- * @param namespace {string} - The tracker namespace
165
- * @returns - A function to track a Timing event
166
- */
167
- function trackTimingEvent(namespace: string) {
168
- return function (
169
- argmap: TimingProps,
170
- contexts: EventContext[] = []
171
- ): Promise<void> {
172
- return tracker.trackTimingEvent(namespace, argmap, contexts);
173
- };
174
- }
175
-
176
- /**
177
- * Returns a function to track a ConsentGranted event by a tracker
178
- *
179
- * @param namespace {string} - The tracker namespace
180
- * @returns - A function to track a ConsentGranted event
181
- */
182
- function trackConsentGrantedEvent(namespace: string) {
183
- return function (
184
- argmap: ConsentGrantedProps,
185
- contexts: EventContext[] = []
186
- ): Promise<void> {
187
- return tracker.trackConsentGrantedEvent(namespace, argmap, contexts);
188
- };
189
- }
190
-
191
- /**
192
- * Returns a function to track a ConsentWithdrawn event by a tracker
193
- *
194
- * @param namespace {string} - The tracker namespace
195
- * @returns - A function to track a ConsentWithdrawn event
196
- */
197
- function trackConsentWithdrawnEvent(namespace: string) {
198
- return function (
199
- argmap: ConsentWithdrawnProps,
200
- contexts: EventContext[] = []
201
- ): Promise<void> {
202
- return tracker.trackConsentWithdrawnEvent(namespace, argmap, contexts);
203
- };
204
- }
205
-
206
- /**
207
- * Returns a function to track an EcommerceTransaction event by a tracker
208
- *
209
- * @param namespace {string} - The tracker namespace
210
- * @returns - A function to track an EcommerceTransaction event
211
- */
212
- function trackEcommerceTransactionEvent(namespace: string) {
213
- return function (
214
- argmap: EcommerceTransactionProps,
215
- contexts: EventContext[] = []
216
- ): Promise<void> {
217
- return tracker.trackEcommerceTransactionEvent(namespace, argmap, contexts);
218
- };
219
- }
220
-
221
- /**
222
- * Returns a function to track an DeepLinkReceived event by a tracker
223
- *
224
- * @param namespace {string} - The tracker namespace
225
- * @returns - A function to track an DeepLinkReceived event
226
- */
227
- function trackDeepLinkReceivedEvent(namespace: string) {
228
- return function (
229
- argmap: DeepLinkReceivedProps,
230
- contexts: EventContext[] = []
231
- ): Promise<void> {
232
- return tracker.trackDeepLinkReceivedEvent(namespace, argmap, contexts);
233
- };
234
- }
235
-
236
- /**
237
- * Returns a function to track an MessageNotification event by a tracker
238
- *
239
- * @param namespace {string} - The tracker namespace
240
- * @returns - A function to track an MessageNotification event
241
- */
242
- function trackMessageNotificationEvent(namespace: string) {
243
- return function (
244
- argmap: MessageNotificationProps,
245
- contexts: EventContext[] = []
246
- ): Promise<void> {
247
- return tracker.trackMessageNotificationEvent(namespace, argmap, contexts);
248
- };
249
- }
250
-
251
- /**
252
- * Returns a function to remove global contexts by a tracker
253
- *
254
- * @param namespace {string} - The tracker namespace
255
- * @returns - A function to remove global contexts
256
- */
257
- function removeGlobalContexts(namespace: string) {
258
- return function (tag: string): Promise<void> {
259
- if (typeof tag !== 'string') {
260
- return Promise.reject(
261
- new Error(
262
- `${logMessages.removeGlobalContexts} ${logMessages.gcTagType}`
263
- )
264
- );
265
- }
266
- return Promise.resolve(
267
- RNSnowplowTracker.removeGlobalContexts({
268
- tracker: namespace,
269
- removeTag: tag,
270
- })
271
- );
272
- };
273
- }
274
-
275
- /**
276
- * Returns a function to add global contexts by a tracker
277
- *
278
- * @param namespace {string} - The tracker namespace
279
- * @returns - A function to add global contexts
280
- */
281
- function addGlobalContexts(namespace: string) {
282
- return function (gc: GlobalContext): Promise<void> {
283
- if (!isValidGC(gc)) {
284
- return Promise.reject(
285
- new Error(`${logMessages.addGlobalContexts} ${logMessages.gcType}`)
286
- );
287
- }
288
- return Promise.resolve(
289
- RNSnowplowTracker.addGlobalContexts({
290
- tracker: namespace,
291
- addGlobalContext: gc,
292
- })
293
- );
294
- };
295
- }
296
-
297
- /**
298
- * Returns a function to set the subject userId
299
- *
300
- * @param namespace {string} - The tracker namespace
301
- * @returns - A function to set the userId
302
- */
303
- function setUserId(namespace: string) {
304
- return function (newUid: string | null): Promise<void> {
305
- return subject.setUserId(namespace, newUid);
306
- };
307
- }
308
-
309
- /**
310
- * Returns a function to set the subject networkUserId
311
- *
312
- * @param namespace {string} - The tracker namespace
313
- * @returns - A function to set the networkUserId
314
- */
315
- function setNetworkUserId(namespace: string) {
316
- return function (newNuid: string | null): Promise<void> {
317
- return subject.setNetworkUserId(namespace, newNuid);
318
- };
319
- }
320
-
321
- /**
322
- * Returns a function to set the subject domainUserId
323
- *
324
- * @param namespace {string} - The tracker namespace
325
- * @returns - A function to set the domainUserId
326
- */
327
- function setDomainUserId(namespace: string) {
328
- return function (newDuid: string | null): Promise<void> {
329
- return subject.setDomainUserId(namespace, newDuid);
330
- };
331
- }
332
-
333
- /**
334
- * Returns a function to set the subject ipAddress
335
- *
336
- * @param namespace {string} - The tracker namespace
337
- * @returns - A function to set the ipAddress
338
- */
339
- function setIpAddress(namespace: string) {
340
- return function (newIp: string | null): Promise<void> {
341
- return subject.setIpAddress(namespace, newIp);
342
- };
343
- }
344
-
345
- /**
346
- * Returns a function to set the subject useragent
347
- *
348
- * @param namespace {string} - The tracker namespace
349
- * @returns - A function to set the useragent
350
- */
351
- function setUseragent(namespace: string) {
352
- return function (newUagent: string | null): Promise<void> {
353
- return subject.setUseragent(namespace, newUagent);
354
- };
355
- }
356
-
357
- /**
358
- * Returns a function to set the subject timezone
359
- *
360
- * @param namespace {string} - The tracker namespace
361
- * @returns - A function to set the timezone
362
- */
363
- function setTimezone(namespace: string) {
364
- return function (newTz: string | null): Promise<void> {
365
- return subject.setTimezone(namespace, newTz);
366
- };
367
- }
368
-
369
- /**
370
- * Returns a function to set the subject language
371
- *
372
- * @param namespace {string} - The tracker namespace
373
- * @returns - A function to set the language
374
- */
375
- function setLanguage(namespace: string) {
376
- return function (newLang: string | null): Promise<void> {
377
- return subject.setLanguage(namespace, newLang);
378
- };
379
- }
380
-
381
- /**
382
- * Returns a function to set the subject screenResolution
383
- *
384
- * @param namespace {string} - The tracker namespace
385
- * @returns - A function to set the screenResolution
386
- */
387
- function setScreenResolution(namespace: string) {
388
- return function (newRes: ScreenSize | null): Promise<void> {
389
- return subject.setScreenResolution(namespace, newRes);
390
- };
391
- }
392
-
393
- /**
394
- * Returns a function to set the subject screenViewport
395
- *
396
- * @param namespace {string} - The tracker namespace
397
- * @returns - A function to set the screenViewport
398
- */
399
- function setScreenViewport(namespace: string) {
400
- return function (newView: ScreenSize | null): Promise<void> {
401
- return subject.setScreenViewport(namespace, newView);
402
- };
403
- }
404
-
405
- /**
406
- * Returns a function to set the subject colorDepth
407
- *
408
- * @param namespace {string} - The tracker namespace
409
- * @returns - A function to set the colorDepth
410
- */
411
- function setColorDepth(namespace: string) {
412
- return function (newColorD: number | null): Promise<void> {
413
- return subject.setColorDepth(namespace, newColorD);
414
- };
415
- }
416
-
417
- /**
418
- * Returns a function to set subject data
419
- *
420
- * @param namespace {string} - The tracker namespace
421
- * @returns - A function to set subject data
422
- */
423
- function setSubjectData(namespace: string) {
424
- return function (config: SubjectConfiguration): Promise<void> {
425
- return subject.setSubjectData(namespace, config);
426
- };
427
- }
428
-
429
- /**
430
- * Returns a function to get the current session userId
431
- *
432
- * @param namespace {string} - The tracker namespace
433
- * @returns - A function to get the session userId
434
- */
435
- function getSessionUserId(namespace: string) {
436
- return function (): Promise<string> {
437
- return <Promise<string>>(
438
- Promise.resolve(
439
- RNSnowplowTracker.getSessionUserId({ tracker: namespace })
440
- )
441
- );
442
- };
443
- }
444
-
445
- /**
446
- * Returns a function to get the current sessionId
447
- *
448
- * @param namespace {string} - The tracker namespace
449
- * @returns - A function to get the sessionId
450
- */
451
- function getSessionId(namespace: string) {
452
- return function (): Promise<string> {
453
- return <Promise<string>>(
454
- Promise.resolve(RNSnowplowTracker.getSessionId({ tracker: namespace }))
455
- );
456
- };
457
- }
458
-
459
- /**
460
- * Returns a function to get the current session index
461
- *
462
- * @param namespace {string} - The tracker namespace
463
- * @returns - A function to get the session index
464
- */
465
- function getSessionIndex(namespace: string) {
466
- return function (): Promise<number> {
467
- return <Promise<number>>(
468
- Promise.resolve(RNSnowplowTracker.getSessionIndex({ tracker: namespace }))
469
- );
470
- };
471
- }
472
-
473
- /**
474
- * Returns a function to get whether the app is in background
475
- *
476
- * @param namespace {string} - The tracker namespace
477
- * @returns - A function to get whether the app isInBackground
478
- */
479
- function getIsInBackground(namespace: string) {
480
- return function (): Promise<boolean> {
481
- return <Promise<boolean>>(
482
- Promise.resolve(
483
- RNSnowplowTracker.getIsInBackground({ tracker: namespace })
484
- )
485
- );
486
- };
487
- }
488
-
489
- /**
490
- * Returns a function to get the background index
491
- *
492
- * @param namespace {string} - The tracker namespace
493
- * @returns - A function to get the backgroundIndex
494
- */
495
- function getBackgroundIndex(namespace: string) {
496
- return function (): Promise<number> {
497
- return <Promise<number>>(
498
- Promise.resolve(
499
- RNSnowplowTracker.getBackgroundIndex({ tracker: namespace })
500
- )
501
- );
502
- };
503
- }
504
-
505
- /**
506
- * Returns a function to get the foreground index
507
- *
508
- * @param namespace {string} - The tracker namespace
509
- * @returns - A function to get the foregroundIndex
510
- */
511
- function getForegroundIndex(namespace: string) {
512
- return function (): Promise<number> {
513
- return <Promise<number>>(
514
- Promise.resolve(
515
- RNSnowplowTracker.getForegroundIndex({ tracker: namespace })
516
- )
517
- );
518
- };
519
- }
520
-
521
- export {
522
- createTracker,
523
- removeTracker,
524
- removeAllTrackers,
525
- trackSelfDescribingEvent,
526
- trackScreenViewEvent,
527
- trackScrollChangedEvent,
528
- trackListItemViewEvent,
529
- trackStructuredEvent,
530
- trackPageViewEvent,
531
- trackTimingEvent,
532
- trackConsentGrantedEvent,
533
- trackConsentWithdrawnEvent,
534
- trackEcommerceTransactionEvent,
535
- trackDeepLinkReceivedEvent,
536
- trackMessageNotificationEvent,
537
- removeGlobalContexts,
538
- addGlobalContexts,
539
- setUserId,
540
- setNetworkUserId,
541
- setDomainUserId,
542
- setIpAddress,
543
- setUseragent,
544
- setTimezone,
545
- setLanguage,
546
- setScreenResolution,
547
- setScreenViewport,
548
- setColorDepth,
549
- setSubjectData,
550
- getSessionUserId,
551
- getSessionId,
552
- getSessionIndex,
553
- getIsInBackground,
554
- getBackgroundIndex,
555
- getForegroundIndex,
556
- };