@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
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
- };