@snowplow/react-native-tracker 2.1.2 → 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.
- package/LICENSE +29 -203
- package/README.md +59 -143
- package/dist/index.cjs.d.ts +499 -0
- package/dist/index.cjs.js +2656 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.cjs.min.d.ts +499 -0
- package/dist/index.cjs.min.js +63 -0
- package/dist/index.cjs.min.js.map +1 -0
- package/dist/index.module.d.ts +499 -0
- package/dist/index.module.js +250 -0
- package/dist/index.module.js.map +1 -0
- package/package.json +48 -158
- package/.editorconfig +0 -15
- package/.eslintignore +0 -6
- package/.gitattributes +0 -3
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -29
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- package/.github/actions/setup/action.yml +0 -28
- package/.github/workflows/build.yml +0 -155
- package/.github/workflows/deploy.yml +0 -97
- package/.github/workflows/e2e-android.yml +0 -121
- package/.github/workflows/e2e-ios.yml +0 -95
- package/.github/workflows/snyk.yml +0 -21
- package/.gitignore +0 -70
- package/.npmignore +0 -60
- package/.nvmrc +0 -1
- package/.watchmanconfig +0 -1
- package/.yarnrc +0 -3
- package/CHANGELOG +0 -184
- package/CONTRIBUTING.md +0 -80
- package/android/build.gradle +0 -110
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +0 -5
- package/android/gradle.properties +0 -5
- package/android/gradlew +0 -234
- package/android/gradlew.bat +0 -89
- package/android/src/main/AndroidManifest.xml +0 -3
- package/android/src/main/AndroidManifestNew.xml +0 -2
- package/android/src/main/java/com/snowplow/reactnativetracker/ReactNativeTrackerModule.kt +0 -744
- package/android/src/main/java/com/snowplow/reactnativetracker/ReactNativeTrackerPackage.kt +0 -17
- package/android/src/main/java/com/snowplow/reactnativetracker/util/ConfigUtil.kt +0 -274
- package/android/src/main/java/com/snowplow/reactnativetracker/util/EventUtil.kt +0 -233
- package/android/src/main/java/com/snowplow/reactnativetracker/util/TrackerVersion.kt +0 -5
- package/babel.config.js +0 -3
- package/example/.watchmanconfig +0 -1
- package/example/Gemfile +0 -6
- package/example/android/app/build.gradle +0 -129
- package/example/android/app/debug.keystore +0 -0
- package/example/android/app/proguard-rules.pro +0 -10
- package/example/android/app/src/androidTest/java/com/reactnativetrackerexample/DetoxTest.java +0 -36
- package/example/android/app/src/androidTest/java/com/reactnativetrackerexample/DetoxTestAppJUnitRunner.java +0 -21
- package/example/android/app/src/debug/AndroidManifest.xml +0 -13
- package/example/android/app/src/debug/java/com/reactnativetrackerexample/ReactNativeFlipper.java +0 -75
- package/example/android/app/src/main/AndroidManifest.xml +0 -26
- package/example/android/app/src/main/java/com/reactnativetrackerexample/MainActivity.java +0 -32
- package/example/android/app/src/main/java/com/reactnativetrackerexample/MainApplication.java +0 -62
- package/example/android/app/src/main/res/drawable/rn_edit_text_material.xml +0 -36
- package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/values/strings.xml +0 -3
- package/example/android/app/src/main/res/values/styles.xml +0 -9
- package/example/android/app/src/release/java/com/reactnativetrackerexample/ReactNativeFlipper.java +0 -20
- package/example/android/build.gradle +0 -31
- package/example/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/example/android/gradle/wrapper/gradle-wrapper.properties +0 -6
- package/example/android/gradle.properties +0 -44
- package/example/android/gradlew +0 -244
- package/example/android/gradlew.bat +0 -92
- package/example/android/settings.gradle +0 -4
- package/example/app.json +0 -4
- package/example/babel.config.js +0 -17
- package/example/detox.config.js +0 -92
- package/example/e2e/config.json +0 -10
- package/example/e2e/emitEvents.e2e.detox.js +0 -95
- package/example/e2e/environment.js +0 -23
- package/example/e2e/helpers/microCommands.js +0 -140
- package/example/e2e/helpers/microHelpers.js +0 -333
- package/example/e2e/helpers/microHelpers.test.js +0 -295
- package/example/e2e/helpers/schemas.js +0 -49
- package/example/e2e/jest.config.js +0 -16
- package/example/e2e/setup.js +0 -4
- package/example/e2e/testEvents.micro.test.js +0 -287
- package/example/index.js +0 -5
- package/example/ios/.xcode.env +0 -11
- package/example/ios/Podfile +0 -62
- package/example/ios/Podfile.lock +0 -730
- package/example/ios/ReactNativeTrackerExample/AppDelegate.h +0 -6
- package/example/ios/ReactNativeTrackerExample/AppDelegate.mm +0 -26
- package/example/ios/ReactNativeTrackerExample/Images.xcassets/AppIcon.appiconset/Contents.json +0 -53
- package/example/ios/ReactNativeTrackerExample/Images.xcassets/Contents.json +0 -6
- package/example/ios/ReactNativeTrackerExample/Info.plist +0 -55
- package/example/ios/ReactNativeTrackerExample/LaunchScreen.storyboard +0 -47
- package/example/ios/ReactNativeTrackerExample/PrivacyInfo.xcprivacy +0 -37
- package/example/ios/ReactNativeTrackerExample/main.m +0 -10
- package/example/ios/ReactNativeTrackerExample-Bridging-Header.h +0 -3
- package/example/ios/ReactNativeTrackerExample.xcodeproj/project.pbxproj +0 -739
- package/example/ios/ReactNativeTrackerExample.xcodeproj/xcshareddata/xcschemes/ReactNativeTrackerExample.xcscheme +0 -88
- package/example/ios/ReactNativeTrackerExample.xcworkspace/contents.xcworkspacedata +0 -10
- package/example/ios/ReactNativeTrackerExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/example/ios/ReactNativeTrackerExampleTests/Info.plist +0 -24
- package/example/ios/ReactNativeTrackerExampleTests/ReactNativeTrackerExampleTests.m +0 -66
- package/example/metro.config.js +0 -45
- package/example/package.json +0 -54
- package/example/react-native.config.js +0 -10
- package/example/src/App.js +0 -566
- package/example/tsconfig.json +0 -5
- package/example/yarn.lock +0 -7703
- package/ios/ReactNativeTracker-Bridging-Header.h +0 -2
- package/ios/ReactNativeTracker.mm +0 -171
- package/ios/ReactNativeTracker.swift +0 -822
- package/ios/ReactNativeTracker.xcodeproj/project.pbxproj +0 -301
- package/ios/Util/ConfigUtils.swift +0 -209
- package/ios/Util/TrackerVersion.swift +0 -3
- package/ios/Util/Utilities.swift +0 -37
- package/lefthook.yml +0 -11
- package/lib/commonjs/api.js +0 -490
- package/lib/commonjs/api.js.map +0 -1
- package/lib/commonjs/configurations.js +0 -196
- package/lib/commonjs/configurations.js.map +0 -1
- package/lib/commonjs/constants.js +0 -77
- package/lib/commonjs/constants.js.map +0 -1
- package/lib/commonjs/events.js +0 -277
- package/lib/commonjs/events.js.map +0 -1
- package/lib/commonjs/index.js +0 -132
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/jsCore.js +0 -427
- package/lib/commonjs/jsCore.js.map +0 -1
- package/lib/commonjs/native.js +0 -16
- package/lib/commonjs/native.js.map +0 -1
- package/lib/commonjs/subject.js +0 -235
- package/lib/commonjs/subject.js.map +0 -1
- package/lib/commonjs/tracker.js +0 -248
- package/lib/commonjs/tracker.js.map +0 -1
- package/lib/commonjs/types.js +0 -2
- package/lib/commonjs/types.js.map +0 -1
- package/lib/commonjs/utils.js +0 -72
- package/lib/commonjs/utils.js.map +0 -1
- package/lib/commonjs/webViewInterface.js +0 -66
- package/lib/commonjs/webViewInterface.js.map +0 -1
- package/lib/module/api.js +0 -452
- package/lib/module/api.js.map +0 -1
- package/lib/module/configurations.js +0 -184
- package/lib/module/configurations.js.map +0 -1
- package/lib/module/constants.js +0 -72
- package/lib/module/constants.js.map +0 -1
- package/lib/module/events.js +0 -259
- package/lib/module/events.js.map +0 -1
- package/lib/module/index.js +0 -120
- package/lib/module/index.js.map +0 -1
- package/lib/module/jsCore.js +0 -424
- package/lib/module/jsCore.js.map +0 -1
- package/lib/module/native.js +0 -12
- package/lib/module/native.js.map +0 -1
- package/lib/module/subject.js +0 -222
- package/lib/module/subject.js.map +0 -1
- package/lib/module/tracker.js +0 -234
- package/lib/module/tracker.js.map +0 -1
- package/lib/module/types.js +0 -2
- package/lib/module/types.js.map +0 -1
- package/lib/module/utils.js +0 -66
- package/lib/module/utils.js.map +0 -1
- package/lib/module/webViewInterface.js +0 -62
- package/lib/module/webViewInterface.js.map +0 -1
- package/lib/typescript/__tests__/api.test.d.ts +0 -2
- package/lib/typescript/__tests__/api.test.d.ts.map +0 -1
- package/lib/typescript/__tests__/configurations.test.d.ts +0 -2
- package/lib/typescript/__tests__/configurations.test.d.ts.map +0 -1
- package/lib/typescript/__tests__/events.test.d.ts +0 -2
- package/lib/typescript/__tests__/events.test.d.ts.map +0 -1
- package/lib/typescript/__tests__/index.test.d.ts +0 -2
- package/lib/typescript/__tests__/index.test.d.ts.map +0 -1
- package/lib/typescript/__tests__/jsCore.test.d.ts +0 -2
- package/lib/typescript/__tests__/jsCore.test.d.ts.map +0 -1
- package/lib/typescript/__tests__/utils.test.d.ts +0 -2
- package/lib/typescript/__tests__/utils.test.d.ts.map +0 -1
- package/lib/typescript/api.d.ts +0 -240
- package/lib/typescript/api.d.ts.map +0 -1
- package/lib/typescript/configurations.d.ts +0 -73
- package/lib/typescript/configurations.d.ts.map +0 -1
- package/lib/typescript/constants.d.ts +0 -64
- package/lib/typescript/constants.d.ts.map +0 -1
- package/lib/typescript/events.d.ts +0 -115
- package/lib/typescript/events.d.ts.map +0 -1
- package/lib/typescript/index.d.ts +0 -27
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/jsCore.d.ts +0 -152
- package/lib/typescript/jsCore.d.ts.map +0 -1
- package/lib/typescript/native.d.ts +0 -4
- package/lib/typescript/native.d.ts.map +0 -1
- package/lib/typescript/subject.d.ts +0 -91
- package/lib/typescript/subject.d.ts.map +0 -1
- package/lib/typescript/tracker.d.ts +0 -111
- package/lib/typescript/tracker.d.ts.map +0 -1
- package/lib/typescript/types.d.ts +0 -981
- package/lib/typescript/types.d.ts.map +0 -1
- package/lib/typescript/utils.d.ts +0 -35
- package/lib/typescript/utils.d.ts.map +0 -1
- package/lib/typescript/webViewInterface.d.ts +0 -15
- package/lib/typescript/webViewInterface.d.ts.map +0 -1
- package/scripts/bootstrap.js +0 -29
- package/snowplow-react-native-tracker.podspec +0 -42
- package/src/__mocks__/react-native.js +0 -7
- package/src/__tests__/api.test.ts +0 -21
- package/src/__tests__/configurations.test.ts +0 -608
- package/src/__tests__/events.test.ts +0 -736
- package/src/__tests__/index.test.ts +0 -14
- package/src/__tests__/jsCore.test.ts +0 -199
- package/src/__tests__/utils.test.ts +0 -10
- package/src/api.ts +0 -556
- package/src/configurations.ts +0 -325
- package/src/constants.ts +0 -97
- package/src/events.ts +0 -355
- package/src/index.ts +0 -184
- package/src/jsCore.ts +0 -603
- package/src/native.ts +0 -21
- package/src/subject.ts +0 -302
- package/src/tracker.ts +0 -377
- package/src/types.ts +0 -1162
- package/src/utils.ts +0 -65
- package/src/webViewInterface.ts +0 -92
- package/tsconfig.build.json +0 -5
- package/tsconfig.json +0 -28
- package/turbo.json +0 -34
- package/yarn.lock +0 -9398
package/src/subject.ts
DELETED
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
import { RNSnowplowTracker } from './native';
|
|
4
|
-
import { logMessages } from './constants';
|
|
5
|
-
import { isScreenSize, isValidSubjectConf } from './configurations';
|
|
6
|
-
import type { ScreenSize, SubjectConfiguration } from './types';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Sets the userId of the tracker subject
|
|
10
|
-
*
|
|
11
|
-
* @param namespace {string} - the tracker namespace
|
|
12
|
-
* @param newUid {string | null} - the new userId
|
|
13
|
-
* @returns - Promise
|
|
14
|
-
*/
|
|
15
|
-
function setUserId(namespace: string, newUid: string | null): Promise<void> {
|
|
16
|
-
if (!(newUid === null || typeof newUid === 'string')) {
|
|
17
|
-
return Promise.reject(new Error(logMessages.setUserId));
|
|
18
|
-
}
|
|
19
|
-
return <Promise<void>>Promise.resolve(
|
|
20
|
-
RNSnowplowTracker.setUserId({
|
|
21
|
-
tracker: namespace,
|
|
22
|
-
userId: newUid,
|
|
23
|
-
})
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Sets the networkUserId of the tracker subject
|
|
29
|
-
*
|
|
30
|
-
* @param namespace {string} - the tracker namespace
|
|
31
|
-
* @param newNuid {string | null} - the new networkUserId
|
|
32
|
-
* @returns - Promise
|
|
33
|
-
*/
|
|
34
|
-
function setNetworkUserId(
|
|
35
|
-
namespace: string,
|
|
36
|
-
newNuid: string | null
|
|
37
|
-
): Promise<void> {
|
|
38
|
-
if (!(newNuid === null || typeof newNuid === 'string')) {
|
|
39
|
-
return Promise.reject(new Error(logMessages.setNetworkUserId));
|
|
40
|
-
}
|
|
41
|
-
return <Promise<void>>Promise.resolve(
|
|
42
|
-
RNSnowplowTracker.setNetworkUserId({
|
|
43
|
-
tracker: namespace,
|
|
44
|
-
networkUserId: newNuid,
|
|
45
|
-
})
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Sets the domainUserId of the tracker subject
|
|
51
|
-
*
|
|
52
|
-
* @param namespace {string} - the tracker namespace
|
|
53
|
-
* @param newDuid {string | null} - the new domainUserId
|
|
54
|
-
* @returns - Promise
|
|
55
|
-
*/
|
|
56
|
-
function setDomainUserId(
|
|
57
|
-
namespace: string,
|
|
58
|
-
newDuid: string | null
|
|
59
|
-
): Promise<void> {
|
|
60
|
-
if (!(newDuid === null || typeof newDuid === 'string')) {
|
|
61
|
-
return Promise.reject(new Error(logMessages.setDomainUserId));
|
|
62
|
-
}
|
|
63
|
-
return <Promise<void>>Promise.resolve(
|
|
64
|
-
RNSnowplowTracker.setDomainUserId({
|
|
65
|
-
tracker: namespace,
|
|
66
|
-
domainUserId: newDuid,
|
|
67
|
-
})
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Sets the ipAddress of the tracker subject
|
|
73
|
-
*
|
|
74
|
-
* @param namespace {string} - the tracker namespace
|
|
75
|
-
* @param newIp {string | null} - the new ipAddress
|
|
76
|
-
* @returns - Promise
|
|
77
|
-
*/
|
|
78
|
-
function setIpAddress(namespace: string, newIp: string | null): Promise<void> {
|
|
79
|
-
if (!(newIp === null || typeof newIp === 'string')) {
|
|
80
|
-
return Promise.reject(new Error(logMessages.setIpAddress));
|
|
81
|
-
}
|
|
82
|
-
return <Promise<void>>Promise.resolve(
|
|
83
|
-
RNSnowplowTracker.setIpAddress({
|
|
84
|
-
tracker: namespace,
|
|
85
|
-
ipAddress: newIp,
|
|
86
|
-
})
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Sets the useragent of the tracker subject
|
|
92
|
-
*
|
|
93
|
-
* @param namespace {string} - the tracker namespace
|
|
94
|
-
* @param newUagent {string | null} - the new useragent
|
|
95
|
-
* @returns - Promise
|
|
96
|
-
*/
|
|
97
|
-
function setUseragent(
|
|
98
|
-
namespace: string,
|
|
99
|
-
newUagent: string | null
|
|
100
|
-
): Promise<void> {
|
|
101
|
-
if (!(newUagent === null || typeof newUagent === 'string')) {
|
|
102
|
-
return Promise.reject(new Error(logMessages.setUseragent));
|
|
103
|
-
}
|
|
104
|
-
return <Promise<void>>Promise.resolve(
|
|
105
|
-
RNSnowplowTracker.setUseragent({
|
|
106
|
-
tracker: namespace,
|
|
107
|
-
useragent: newUagent,
|
|
108
|
-
})
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Sets the timezone of the tracker subject
|
|
114
|
-
*
|
|
115
|
-
* @param namespace {string} - the tracker namespace
|
|
116
|
-
* @param newTz {string | null} - the new timezone
|
|
117
|
-
* @returns - Promise
|
|
118
|
-
*/
|
|
119
|
-
function setTimezone(namespace: string, newTz: string | null): Promise<void> {
|
|
120
|
-
if (!(newTz === null || typeof newTz === 'string')) {
|
|
121
|
-
return Promise.reject(new Error(logMessages.setTimezone));
|
|
122
|
-
}
|
|
123
|
-
return <Promise<void>>Promise.resolve(
|
|
124
|
-
RNSnowplowTracker.setTimezone({
|
|
125
|
-
tracker: namespace,
|
|
126
|
-
timezone: newTz,
|
|
127
|
-
})
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Sets the language of the tracker subject
|
|
133
|
-
*
|
|
134
|
-
* @param namespace {string} - the tracker namespace
|
|
135
|
-
* @param newLang {string | null} - the new language
|
|
136
|
-
* @returns - Promise
|
|
137
|
-
*/
|
|
138
|
-
function setLanguage(namespace: string, newLang: string | null): Promise<void> {
|
|
139
|
-
if (!(newLang === null || typeof newLang === 'string')) {
|
|
140
|
-
return Promise.reject(new Error(logMessages.setLanguage));
|
|
141
|
-
}
|
|
142
|
-
return <Promise<void>>Promise.resolve(
|
|
143
|
-
RNSnowplowTracker.setLanguage({
|
|
144
|
-
tracker: namespace,
|
|
145
|
-
language: newLang,
|
|
146
|
-
})
|
|
147
|
-
);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Sets the screenResolution of the tracker subject
|
|
152
|
-
*
|
|
153
|
-
* @param namespace {string} - the tracker namespace
|
|
154
|
-
* @param newRes {ScreenSize | null} - the new screenResolution
|
|
155
|
-
* @returns - Promise
|
|
156
|
-
*/
|
|
157
|
-
function setScreenResolution(
|
|
158
|
-
namespace: string,
|
|
159
|
-
newRes: ScreenSize | null
|
|
160
|
-
): Promise<void> {
|
|
161
|
-
if (!(newRes === null || isScreenSize(newRes))) {
|
|
162
|
-
return Promise.reject(new Error(logMessages.setScreenResolution));
|
|
163
|
-
}
|
|
164
|
-
return <Promise<void>>Promise.resolve(
|
|
165
|
-
RNSnowplowTracker.setScreenResolution({
|
|
166
|
-
tracker: namespace,
|
|
167
|
-
screenResolution: newRes,
|
|
168
|
-
})
|
|
169
|
-
);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Sets the screenViewport of the tracker subject
|
|
174
|
-
*
|
|
175
|
-
* @param namespace {string} - the tracker namespace
|
|
176
|
-
* @param newView {ScreenSize | null} - the new screenViewport
|
|
177
|
-
* @returns - Promise
|
|
178
|
-
*/
|
|
179
|
-
function setScreenViewport(
|
|
180
|
-
namespace: string,
|
|
181
|
-
newView: ScreenSize | null
|
|
182
|
-
): Promise<void> {
|
|
183
|
-
if (!(newView === null || isScreenSize(newView))) {
|
|
184
|
-
return Promise.reject(new Error(logMessages.setScreenViewport));
|
|
185
|
-
}
|
|
186
|
-
return <Promise<void>>Promise.resolve(
|
|
187
|
-
RNSnowplowTracker.setScreenViewport({
|
|
188
|
-
tracker: namespace,
|
|
189
|
-
screenViewport: newView,
|
|
190
|
-
})
|
|
191
|
-
);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Sets the colorDepth of the tracker subject
|
|
196
|
-
*
|
|
197
|
-
* @param namespace {string} - the tracker namespace
|
|
198
|
-
* @param newColorD {number | null} - the new colorDepth
|
|
199
|
-
* @returns - Promise
|
|
200
|
-
*/
|
|
201
|
-
function setColorDepth(
|
|
202
|
-
namespace: string,
|
|
203
|
-
newColorD: number | null
|
|
204
|
-
): Promise<void> {
|
|
205
|
-
if (!(newColorD === null || typeof newColorD === 'number')) {
|
|
206
|
-
return Promise.reject(new Error(logMessages.setColorDepth));
|
|
207
|
-
}
|
|
208
|
-
return <Promise<void>>Promise.resolve(
|
|
209
|
-
RNSnowplowTracker.setColorDepth({
|
|
210
|
-
tracker: namespace,
|
|
211
|
-
colorDepth: newColorD,
|
|
212
|
-
})
|
|
213
|
-
);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
const setterMap = {
|
|
217
|
-
userId: setUserId,
|
|
218
|
-
networkUserId: setNetworkUserId,
|
|
219
|
-
domainUserId: setDomainUserId,
|
|
220
|
-
ipAddress: setIpAddress,
|
|
221
|
-
useragent: setUseragent,
|
|
222
|
-
timezone: setTimezone,
|
|
223
|
-
language: setLanguage,
|
|
224
|
-
screenResolution: setScreenResolution,
|
|
225
|
-
screenViewport: setScreenViewport,
|
|
226
|
-
colorDepth: setColorDepth,
|
|
227
|
-
} as Record<
|
|
228
|
-
keyof SubjectConfiguration,
|
|
229
|
-
<Type>(namespace: string, x: Type | null) => Promise<void>
|
|
230
|
-
>;
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* Sets the tracker subject
|
|
234
|
-
*
|
|
235
|
-
* @param namespace {string} - the tracker namespace
|
|
236
|
-
* @param config {SubjectConfiguration} - the new subject data
|
|
237
|
-
* @returns - Promise
|
|
238
|
-
*/
|
|
239
|
-
function setSubjectData(
|
|
240
|
-
namespace: string,
|
|
241
|
-
config: SubjectConfiguration
|
|
242
|
-
): Promise<void> {
|
|
243
|
-
if (!isValidSubjectConf(config)) {
|
|
244
|
-
return Promise.reject(
|
|
245
|
-
new Error(`${logMessages.setSubjectData} ${logMessages.subject}`)
|
|
246
|
-
);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
const promises = Object.keys(config)
|
|
250
|
-
.map((k) => {
|
|
251
|
-
const fun = setterMap[k];
|
|
252
|
-
return fun ? fun(namespace, config[k]) : undefined;
|
|
253
|
-
})
|
|
254
|
-
.filter((f) => f !== undefined);
|
|
255
|
-
|
|
256
|
-
// to use Promise.all (Promise.allSettled not supported in all RN versions)
|
|
257
|
-
const safePromises = promises.map((p) =>
|
|
258
|
-
(p as Promise<void>)
|
|
259
|
-
.then(
|
|
260
|
-
(x) =>
|
|
261
|
-
Object.assign({
|
|
262
|
-
status: 'fulfilled',
|
|
263
|
-
value: x,
|
|
264
|
-
}) as PromiseFulfilledResult<void>
|
|
265
|
-
)
|
|
266
|
-
.catch(
|
|
267
|
-
(err) =>
|
|
268
|
-
Object.assign({
|
|
269
|
-
status: 'rejected',
|
|
270
|
-
reason: err.message as string,
|
|
271
|
-
}) as PromiseRejectedResult
|
|
272
|
-
)
|
|
273
|
-
);
|
|
274
|
-
|
|
275
|
-
return <Promise<void>>Promise.all(safePromises).then((outcomes) => {
|
|
276
|
-
const anyReasons = outcomes.filter(
|
|
277
|
-
(res) => res.status === 'rejected'
|
|
278
|
-
) as PromiseRejectedResult[];
|
|
279
|
-
if (anyReasons.length > 0) {
|
|
280
|
-
const allReasons = anyReasons.reduce(
|
|
281
|
-
(acc, curr) => acc + ':' + curr.reason,
|
|
282
|
-
logMessages.setSubjectData
|
|
283
|
-
);
|
|
284
|
-
throw new Error(allReasons);
|
|
285
|
-
}
|
|
286
|
-
return true;
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
export {
|
|
291
|
-
setUserId,
|
|
292
|
-
setNetworkUserId,
|
|
293
|
-
setDomainUserId,
|
|
294
|
-
setIpAddress,
|
|
295
|
-
setUseragent,
|
|
296
|
-
setTimezone,
|
|
297
|
-
setLanguage,
|
|
298
|
-
setScreenResolution,
|
|
299
|
-
setScreenViewport,
|
|
300
|
-
setColorDepth,
|
|
301
|
-
setSubjectData,
|
|
302
|
-
};
|
package/src/tracker.ts
DELETED
|
@@ -1,377 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
import { RNSnowplowTracker } from './native';
|
|
4
|
-
import { logMessages } from './constants';
|
|
5
|
-
import {
|
|
6
|
-
validateContexts,
|
|
7
|
-
validateSelfDesc,
|
|
8
|
-
validateScreenView,
|
|
9
|
-
validateScrollChanged,
|
|
10
|
-
validateListItemView,
|
|
11
|
-
validateStructured,
|
|
12
|
-
validatePageView,
|
|
13
|
-
validateTiming,
|
|
14
|
-
validateConsentGranted,
|
|
15
|
-
validateConsentWithdrawn,
|
|
16
|
-
validateEcommerceTransaction,
|
|
17
|
-
validateDeepLinkReceived,
|
|
18
|
-
validateMessageNotification,
|
|
19
|
-
} from './events';
|
|
20
|
-
import type {
|
|
21
|
-
SelfDescribing,
|
|
22
|
-
EventContext,
|
|
23
|
-
ScreenViewProps,
|
|
24
|
-
StructuredProps,
|
|
25
|
-
PageViewProps,
|
|
26
|
-
TimingProps,
|
|
27
|
-
ConsentGrantedProps,
|
|
28
|
-
ConsentWithdrawnProps,
|
|
29
|
-
EcommerceTransactionProps,
|
|
30
|
-
DeepLinkReceivedProps,
|
|
31
|
-
MessageNotificationProps,
|
|
32
|
-
ScrollChangedProps,
|
|
33
|
-
ListItemViewProps,
|
|
34
|
-
} from './types';
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Tracks a self-describing event
|
|
38
|
-
*
|
|
39
|
-
* @param namespace {string} - the tracker namespace
|
|
40
|
-
* @param argmap {Object} - the event data
|
|
41
|
-
* @param contexts {Array}- the event contexts
|
|
42
|
-
* @returns {Promise}
|
|
43
|
-
*/
|
|
44
|
-
function trackSelfDescribingEvent(
|
|
45
|
-
namespace: string | null,
|
|
46
|
-
argmap: SelfDescribing,
|
|
47
|
-
contexts: EventContext[] = []
|
|
48
|
-
): Promise<void> {
|
|
49
|
-
return <Promise<void>>validateSelfDesc(argmap)
|
|
50
|
-
.then(() => validateContexts(contexts))
|
|
51
|
-
.then(
|
|
52
|
-
() => <Promise<void>>RNSnowplowTracker.trackSelfDescribingEvent({
|
|
53
|
-
tracker: namespace,
|
|
54
|
-
eventData: argmap,
|
|
55
|
-
contexts: contexts,
|
|
56
|
-
})
|
|
57
|
-
)
|
|
58
|
-
.catch((error) => {
|
|
59
|
-
throw new Error(`${logMessages.trackSelfDesc} ${error.message}`);
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Tracks a screen-view event
|
|
65
|
-
*
|
|
66
|
-
* @param namespace {string} - the tracker namespace
|
|
67
|
-
* @param argmap {Object} - the event data
|
|
68
|
-
* @param contexts {Array}- the event contexts
|
|
69
|
-
* @returns {Promise}
|
|
70
|
-
*/
|
|
71
|
-
function trackScreenViewEvent(
|
|
72
|
-
namespace: string | null,
|
|
73
|
-
argmap: ScreenViewProps,
|
|
74
|
-
contexts: EventContext[] = []
|
|
75
|
-
): Promise<void> {
|
|
76
|
-
return <Promise<void>>validateScreenView(argmap)
|
|
77
|
-
.then(() => validateContexts(contexts))
|
|
78
|
-
.then(
|
|
79
|
-
() => <Promise<void>>RNSnowplowTracker.trackScreenViewEvent({
|
|
80
|
-
tracker: namespace,
|
|
81
|
-
eventData: argmap,
|
|
82
|
-
contexts: contexts,
|
|
83
|
-
})
|
|
84
|
-
)
|
|
85
|
-
.catch((error) => {
|
|
86
|
-
throw new Error(`${logMessages.trackScreenView} ${error.message}`);
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Tracks a scroll-changed event
|
|
92
|
-
*
|
|
93
|
-
* @param namespace {string} - the tracker namespace
|
|
94
|
-
* @param argmap {Object} - the event data
|
|
95
|
-
* @param contexts {Array}- the event contexts
|
|
96
|
-
* @returns {Promise}
|
|
97
|
-
*/
|
|
98
|
-
function trackScrollChangedEvent(
|
|
99
|
-
namespace: string | null,
|
|
100
|
-
argmap: ScrollChangedProps,
|
|
101
|
-
contexts: EventContext[] = []
|
|
102
|
-
): Promise<void> {
|
|
103
|
-
return <Promise<void>>validateScrollChanged(argmap)
|
|
104
|
-
.then(() => validateContexts(contexts))
|
|
105
|
-
.then(
|
|
106
|
-
() => <Promise<void>>RNSnowplowTracker.trackScrollChangedEvent({
|
|
107
|
-
tracker: namespace,
|
|
108
|
-
eventData: argmap,
|
|
109
|
-
contexts: contexts,
|
|
110
|
-
})
|
|
111
|
-
)
|
|
112
|
-
.catch((error) => {
|
|
113
|
-
throw new Error(`${logMessages.trackScrollChanged} ${error.message}`);
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Tracks a list item view event
|
|
119
|
-
*
|
|
120
|
-
* @param namespace {string} - the tracker namespace
|
|
121
|
-
* @param argmap {Object} - the event data
|
|
122
|
-
* @param contexts {Array}- the event contexts
|
|
123
|
-
* @returns {Promise}
|
|
124
|
-
*/
|
|
125
|
-
function trackListItemViewEvent(
|
|
126
|
-
namespace: string | null,
|
|
127
|
-
argmap: ListItemViewProps,
|
|
128
|
-
contexts: EventContext[] = []
|
|
129
|
-
): Promise<void> {
|
|
130
|
-
return <Promise<void>>validateListItemView(argmap)
|
|
131
|
-
.then(() => validateContexts(contexts))
|
|
132
|
-
.then(
|
|
133
|
-
() => <Promise<void>>RNSnowplowTracker.trackListItemViewEvent({
|
|
134
|
-
tracker: namespace,
|
|
135
|
-
eventData: argmap,
|
|
136
|
-
contexts: contexts,
|
|
137
|
-
})
|
|
138
|
-
)
|
|
139
|
-
.catch((error) => {
|
|
140
|
-
throw new Error(`${logMessages.trackListItemView} ${error.message}`);
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Tracks a structured event
|
|
146
|
-
*
|
|
147
|
-
* @param namespace {string} - the tracker namespace
|
|
148
|
-
* @param argmap {Object} - the event data
|
|
149
|
-
* @param contexts {Array}- the event contexts
|
|
150
|
-
* @returns {Promise}
|
|
151
|
-
*/
|
|
152
|
-
function trackStructuredEvent(
|
|
153
|
-
namespace: string | null,
|
|
154
|
-
argmap: StructuredProps,
|
|
155
|
-
contexts: EventContext[] = []
|
|
156
|
-
): Promise<void> {
|
|
157
|
-
return <Promise<void>>validateStructured(argmap)
|
|
158
|
-
.then(() => validateContexts(contexts))
|
|
159
|
-
.then(
|
|
160
|
-
() => <Promise<void>>RNSnowplowTracker.trackStructuredEvent({
|
|
161
|
-
tracker: namespace,
|
|
162
|
-
eventData: argmap,
|
|
163
|
-
contexts: contexts,
|
|
164
|
-
})
|
|
165
|
-
)
|
|
166
|
-
.catch((error) => {
|
|
167
|
-
throw new Error(`${logMessages.trackStructured} ${error.message}`);
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Tracks a page-view event
|
|
173
|
-
*
|
|
174
|
-
* @param namespace {string} - the tracker namespace
|
|
175
|
-
* @param argmap {Object} - the event data
|
|
176
|
-
* @param contexts {Array}- the event contexts
|
|
177
|
-
* @returns {Promise}
|
|
178
|
-
*/
|
|
179
|
-
function trackPageViewEvent(
|
|
180
|
-
namespace: string | null,
|
|
181
|
-
argmap: PageViewProps,
|
|
182
|
-
contexts: EventContext[] = []
|
|
183
|
-
): Promise<void> {
|
|
184
|
-
return <Promise<void>>validatePageView(argmap)
|
|
185
|
-
.then(() => validateContexts(contexts))
|
|
186
|
-
.then(
|
|
187
|
-
() => <Promise<void>>RNSnowplowTracker.trackPageViewEvent({
|
|
188
|
-
tracker: namespace,
|
|
189
|
-
eventData: argmap,
|
|
190
|
-
contexts: contexts,
|
|
191
|
-
})
|
|
192
|
-
)
|
|
193
|
-
.catch((error) => {
|
|
194
|
-
throw new Error(`${logMessages.trackPageView} ${error.message}`);
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Tracks a timing event
|
|
200
|
-
*
|
|
201
|
-
* @param namespace {string} - the tracker namespace
|
|
202
|
-
* @param argmap {Object} - the event data
|
|
203
|
-
* @param contexts {Array}- the event contexts
|
|
204
|
-
* @returns {Promise}
|
|
205
|
-
*/
|
|
206
|
-
function trackTimingEvent(
|
|
207
|
-
namespace: string | null,
|
|
208
|
-
argmap: TimingProps,
|
|
209
|
-
contexts: EventContext[] = []
|
|
210
|
-
): Promise<void> {
|
|
211
|
-
return <Promise<void>>validateTiming(argmap)
|
|
212
|
-
.then(() => validateContexts(contexts))
|
|
213
|
-
.then(
|
|
214
|
-
() => <Promise<void>>RNSnowplowTracker.trackTimingEvent({
|
|
215
|
-
tracker: namespace,
|
|
216
|
-
eventData: argmap,
|
|
217
|
-
contexts: contexts,
|
|
218
|
-
})
|
|
219
|
-
)
|
|
220
|
-
.catch((error) => {
|
|
221
|
-
throw new Error(`${logMessages.trackTiming} ${error.message}`);
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Tracks a consent-granted event
|
|
227
|
-
*
|
|
228
|
-
* @param namespace {string} - the tracker namespace
|
|
229
|
-
* @param argmap {Object} - the event data
|
|
230
|
-
* @param contexts {Array}- the event contexts
|
|
231
|
-
* @returns {Promise}
|
|
232
|
-
*/
|
|
233
|
-
function trackConsentGrantedEvent(
|
|
234
|
-
namespace: string | null,
|
|
235
|
-
argmap: ConsentGrantedProps,
|
|
236
|
-
contexts: EventContext[] = []
|
|
237
|
-
): Promise<void> {
|
|
238
|
-
return <Promise<void>>validateConsentGranted(argmap)
|
|
239
|
-
.then(() => validateContexts(contexts))
|
|
240
|
-
.then(
|
|
241
|
-
() => <Promise<void>>RNSnowplowTracker.trackConsentGrantedEvent({
|
|
242
|
-
tracker: namespace,
|
|
243
|
-
eventData: argmap,
|
|
244
|
-
contexts: contexts,
|
|
245
|
-
})
|
|
246
|
-
)
|
|
247
|
-
.catch((error) => {
|
|
248
|
-
throw new Error(`${logMessages.trackConsentGranted} ${error.message}`);
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* Tracks a consent-withdrawn event
|
|
254
|
-
*
|
|
255
|
-
* @param namespace {string} - the tracker namespace
|
|
256
|
-
* @param argmap {Object} - the event data
|
|
257
|
-
* @param contexts {Array}- the event contexts
|
|
258
|
-
* @returns {Promise}
|
|
259
|
-
*/
|
|
260
|
-
function trackConsentWithdrawnEvent(
|
|
261
|
-
namespace: string | null,
|
|
262
|
-
argmap: ConsentWithdrawnProps,
|
|
263
|
-
contexts: EventContext[] = []
|
|
264
|
-
): Promise<void> {
|
|
265
|
-
return <Promise<void>>validateConsentWithdrawn(argmap)
|
|
266
|
-
.then(() => validateContexts(contexts))
|
|
267
|
-
.then(
|
|
268
|
-
() => <Promise<void>>RNSnowplowTracker.trackConsentWithdrawnEvent({
|
|
269
|
-
tracker: namespace,
|
|
270
|
-
eventData: argmap,
|
|
271
|
-
contexts: contexts,
|
|
272
|
-
})
|
|
273
|
-
)
|
|
274
|
-
.catch((error) => {
|
|
275
|
-
throw new Error(`${logMessages.trackConsentWithdrawn} ${error.message}`);
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* Tracks an ecommerce-transaction event
|
|
281
|
-
*
|
|
282
|
-
* @param namespace {string} - the tracker namespace
|
|
283
|
-
* @param argmap {Object} - the event data
|
|
284
|
-
* @param contexts {Array}- the event contexts
|
|
285
|
-
* @returns {Promise}
|
|
286
|
-
*/
|
|
287
|
-
function trackEcommerceTransactionEvent(
|
|
288
|
-
namespace: string | null,
|
|
289
|
-
argmap: EcommerceTransactionProps,
|
|
290
|
-
contexts: EventContext[] = []
|
|
291
|
-
): Promise<void> {
|
|
292
|
-
return <Promise<void>>validateEcommerceTransaction(argmap)
|
|
293
|
-
.then(() => validateContexts(contexts))
|
|
294
|
-
.then(
|
|
295
|
-
() => <Promise<void>>RNSnowplowTracker.trackEcommerceTransactionEvent({
|
|
296
|
-
tracker: namespace,
|
|
297
|
-
eventData: argmap,
|
|
298
|
-
contexts: contexts,
|
|
299
|
-
})
|
|
300
|
-
)
|
|
301
|
-
.catch((error) => {
|
|
302
|
-
throw new Error(
|
|
303
|
-
`${logMessages.trackEcommerceTransaction} ${error.message}`
|
|
304
|
-
);
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
/**
|
|
309
|
-
* Tracks a deep link received event
|
|
310
|
-
*
|
|
311
|
-
* @param namespace {string} - the tracker namespace
|
|
312
|
-
* @param argmap {Object} - the event data
|
|
313
|
-
* @param contexts {Array}- the event contexts
|
|
314
|
-
* @returns {Promise}
|
|
315
|
-
*/
|
|
316
|
-
function trackDeepLinkReceivedEvent(
|
|
317
|
-
namespace: string | null,
|
|
318
|
-
argmap: DeepLinkReceivedProps,
|
|
319
|
-
contexts: EventContext[] = []
|
|
320
|
-
): Promise<void> {
|
|
321
|
-
return <Promise<void>>validateDeepLinkReceived(argmap)
|
|
322
|
-
.then(() => validateContexts(contexts))
|
|
323
|
-
.then(
|
|
324
|
-
() => <Promise<void>>RNSnowplowTracker.trackDeepLinkReceivedEvent({
|
|
325
|
-
tracker: namespace,
|
|
326
|
-
eventData: argmap,
|
|
327
|
-
contexts: contexts,
|
|
328
|
-
})
|
|
329
|
-
)
|
|
330
|
-
.catch((error) => {
|
|
331
|
-
throw new Error(`${logMessages.trackDeepLinkReceived} ${error.message}`);
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
/**
|
|
336
|
-
* Tracks a message notification event
|
|
337
|
-
*
|
|
338
|
-
* @param namespace {string} - the tracker namespace
|
|
339
|
-
* @param argmap {Object} - the event data
|
|
340
|
-
* @param contexts {Array}- the event contexts
|
|
341
|
-
* @returns {Promise}
|
|
342
|
-
*/
|
|
343
|
-
function trackMessageNotificationEvent(
|
|
344
|
-
namespace: string | null,
|
|
345
|
-
argmap: MessageNotificationProps,
|
|
346
|
-
contexts: EventContext[] = []
|
|
347
|
-
): Promise<void> {
|
|
348
|
-
return <Promise<void>>validateMessageNotification(argmap)
|
|
349
|
-
.then(() => validateContexts(contexts))
|
|
350
|
-
.then(
|
|
351
|
-
() => <Promise<void>>RNSnowplowTracker.trackMessageNotificationEvent({
|
|
352
|
-
tracker: namespace,
|
|
353
|
-
eventData: argmap,
|
|
354
|
-
contexts: contexts,
|
|
355
|
-
})
|
|
356
|
-
)
|
|
357
|
-
.catch((error) => {
|
|
358
|
-
throw new Error(
|
|
359
|
-
`${logMessages.trackMessageNotification} ${error.message}`
|
|
360
|
-
);
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
export {
|
|
365
|
-
trackSelfDescribingEvent,
|
|
366
|
-
trackScreenViewEvent,
|
|
367
|
-
trackScrollChangedEvent,
|
|
368
|
-
trackListItemViewEvent,
|
|
369
|
-
trackStructuredEvent,
|
|
370
|
-
trackPageViewEvent,
|
|
371
|
-
trackTimingEvent,
|
|
372
|
-
trackConsentGrantedEvent,
|
|
373
|
-
trackConsentWithdrawnEvent,
|
|
374
|
-
trackEcommerceTransactionEvent,
|
|
375
|
-
trackDeepLinkReceivedEvent,
|
|
376
|
-
trackMessageNotificationEvent,
|
|
377
|
-
};
|