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