react-native-mparticle 2.7.12 → 2.8.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/SECURITY.md +9 -0
- package/android/build.gradle +65 -10
- package/android/src/main/AndroidManifestNew.xml +3 -0
- package/android/src/main/java/com/mparticle/react/MParticleModule.kt +976 -0
- package/android/src/main/java/com/mparticle/react/MParticlePackage.kt +68 -0
- package/android/src/main/java/com/mparticle/react/rokt/MPRoktModuleImpl.kt +251 -0
- package/android/src/main/java/com/mparticle/react/rokt/RoktLayoutViewManagerImpl.kt +79 -0
- package/android/src/newarch/java/com/mparticle/react/rokt/MPRoktModule.kt +130 -0
- package/android/src/newarch/java/com/mparticle/react/rokt/RoktLayoutViewManager.kt +22 -0
- package/android/src/oldarch/java/com/mparticle/react/NativeMPRoktSpec.kt +29 -0
- package/android/src/oldarch/java/com/mparticle/react/NativeMParticleSpec.kt +153 -0
- package/android/src/oldarch/java/com/mparticle/react/rokt/MPRoktModule.kt +79 -0
- package/android/src/oldarch/java/com/mparticle/react/rokt/RoktLayoutViewManager.kt +34 -0
- package/ios/RNMParticle/RNMPRokt.h +15 -0
- package/ios/RNMParticle/RNMPRokt.mm +247 -0
- package/ios/RNMParticle/RNMParticle.h +6 -1
- package/ios/RNMParticle/RNMParticle.mm +1199 -0
- package/ios/RNMParticle/RoktEventManager.h +16 -0
- package/ios/RNMParticle/RoktEventManager.m +174 -0
- package/ios/RNMParticle/RoktLayoutManager.m +22 -0
- package/ios/RNMParticle/RoktNativeLayoutComponentView.h +18 -0
- package/ios/RNMParticle/RoktNativeLayoutComponentView.mm +50 -0
- package/ios/RNMParticle.xcodeproj/project.pbxproj +29 -6
- package/js/codegenSpecs/NativeMParticle.ts +214 -0
- package/js/codegenSpecs/rokt/NativeMPRokt.ts +32 -0
- package/js/codegenSpecs/rokt/RoktLayoutNativeComponent.ts +29 -0
- package/js/index.tsx +940 -0
- package/js/rokt/rokt-layout-view.android.tsx +133 -0
- package/js/rokt/rokt-layout-view.ios.tsx +121 -0
- package/js/rokt/rokt-layout-view.tsx +15 -0
- package/js/rokt/rokt.ts +87 -0
- package/js/utils/architecture.ts +22 -0
- package/lib/codegenSpecs/NativeMParticle.d.ts +148 -0
- package/lib/codegenSpecs/NativeMParticle.js +5 -0
- package/lib/codegenSpecs/NativeMParticle.js.map +1 -0
- package/lib/codegenSpecs/rokt/NativeMPRokt.d.ts +24 -0
- package/lib/codegenSpecs/rokt/NativeMPRokt.js +5 -0
- package/lib/codegenSpecs/rokt/NativeMPRokt.js.map +1 -0
- package/lib/codegenSpecs/rokt/RoktLayoutNativeComponent.d.ts +18 -0
- package/lib/codegenSpecs/rokt/RoktLayoutNativeComponent.js +8 -0
- package/lib/codegenSpecs/rokt/RoktLayoutNativeComponent.js.map +1 -0
- package/lib/index.d.ts +410 -0
- package/lib/index.js +645 -0
- package/lib/index.js.map +1 -0
- package/lib/rokt/rokt-layout-view.android.d.ts +39 -0
- package/lib/rokt/rokt-layout-view.android.js +109 -0
- package/lib/rokt/rokt-layout-view.android.js.map +1 -0
- package/lib/rokt/rokt-layout-view.d.ts +5 -0
- package/lib/rokt/rokt-layout-view.ios.d.ts +32 -0
- package/lib/rokt/rokt-layout-view.ios.js +84 -0
- package/lib/rokt/rokt-layout-view.ios.js.map +1 -0
- package/lib/rokt/rokt-layout-view.js +12 -0
- package/lib/rokt/rokt-layout-view.js.map +1 -0
- package/lib/rokt/rokt.d.ts +40 -0
- package/lib/rokt/rokt.js +54 -0
- package/lib/rokt/rokt.js.map +1 -0
- package/lib/utils/architecture.d.ts +9 -0
- package/lib/utils/architecture.js +19 -0
- package/lib/utils/architecture.js.map +1 -0
- package/package.json +32 -10
- package/react-native-mparticle.podspec +7 -6
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -8
- package/.github/dependabot.yml +0 -12
- package/.github/workflows/daily.yml +0 -19
- package/.github/workflows/dependabot-automerge.yml +0 -12
- package/.github/workflows/pull-request.yml +0 -60
- package/.github/workflows/release.yml +0 -60
- package/.github/workflows/sonarcloud.yml +0 -16
- package/android/.classpath +0 -6
- package/android/.gradle/7.5.1/checksums/checksums.lock +0 -0
- package/android/.gradle/7.5.1/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/7.5.1/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.5.1/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.5.1/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/7.5.1/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.5.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.5.1/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.project +0 -34
- package/android/.settings/org.eclipse.buildship.core.prefs +0 -13
- package/android/.settings/org.eclipse.jdt.core.prefs +0 -4
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +0 -6
- package/android/gradle.properties +0 -53
- package/android/gradlew +0 -160
- package/android/gradlew.bat +0 -90
- package/android/libs/java-json.jar +0 -0
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-debug-sources.jar +0 -0
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-debug-sources.jar.md5 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-debug-sources.jar.sha1 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-debug-sources.jar.sha256 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-debug-sources.jar.sha512 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-debug.aar +0 -0
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-debug.aar.md5 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-debug.aar.sha1 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-debug.aar.sha256 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-debug.aar.sha512 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-release-sources.jar +0 -0
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-release-sources.jar.md5 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-release-sources.jar.sha1 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-release-sources.jar.sha256 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-release-sources.jar.sha512 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-release.aar +0 -0
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-release.aar.md5 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-release.aar.sha1 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-release.aar.sha256 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-release.aar.sha512 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5.module +0 -204
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5.module.md5 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5.module.sha1 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5.module.sha256 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5.module.sha512 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5.pom +0 -44
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5.pom.md5 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5.pom.sha1 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5.pom.sha256 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5.pom.sha512 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/maven-metadata.xml +0 -13
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/maven-metadata.xml.md5 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/maven-metadata.xml.sha1 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/maven-metadata.xml.sha256 +0 -1
- package/android/libs/react-native-android/com/facebook/react/hermes-engine/maven-metadata.xml.sha512 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-debug-sources.jar +0 -0
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-debug-sources.jar.md5 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-debug-sources.jar.sha1 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-debug-sources.jar.sha256 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-debug-sources.jar.sha512 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-debug.aar +0 -0
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-debug.aar.md5 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-debug.aar.sha1 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-debug.aar.sha256 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-debug.aar.sha512 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-release-sources.jar +0 -0
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-release-sources.jar.md5 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-release-sources.jar.sha1 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-release-sources.jar.sha256 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-release-sources.jar.sha512 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-release.aar +0 -0
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-release.aar.md5 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-release.aar.sha1 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-release.aar.sha256 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-release.aar.sha512 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5.module +0 -628
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5.module.md5 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5.module.sha1 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5.module.sha256 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5.module.sha512 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5.pom +0 -156
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5.pom.md5 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5.pom.sha1 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5.pom.sha256 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5.pom.sha512 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/maven-metadata.xml +0 -13
- package/android/libs/react-native-android/com/facebook/react/react-native/maven-metadata.xml.md5 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/maven-metadata.xml.sha1 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/maven-metadata.xml.sha256 +0 -1
- package/android/libs/react-native-android/com/facebook/react/react-native/maven-metadata.xml.sha512 +0 -1
- package/android/src/main/java/com/mparticle/react/MParticleModule.java +0 -987
- package/android/src/main/java/com/mparticle/react/MParticlePackage.java +0 -34
- package/android/src/test/java/com/mparticle/react/IdentityApiTest.java +0 -230
- package/android/src/test/java/com/mparticle/react/MParticleUserTest.java +0 -233
- package/android/src/test/java/com/mparticle/react/testutils/MockMParticleUser.java +0 -103
- package/android/src/test/java/com/mparticle/react/testutils/MockMap.java +0 -169
- package/android/src/test/java/com/mparticle/react/testutils/MockReadableArray.java +0 -53
- package/android/src/test/java/com/mparticle/react/testutils/MockWritableMap.java +0 -4
- package/android/src/test/java/com/mparticle/react/testutils/Mutable.java +0 -13
- package/ios/RNMParticle/RNMParticle.m +0 -671
- package/ios/RNMParticle.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/RNMParticle.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/RNMParticle.xcodeproj/project.xcworkspace/xcuserdata/bstalnaker.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/RNMParticle.xcodeproj/xcuserdata/bstalnaker.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +0 -6
- package/ios/RNMParticle.xcodeproj/xcuserdata/bstalnaker.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
- package/js/index.js +0 -697
- package/release.sh +0 -6
package/js/index.tsx
ADDED
|
@@ -0,0 +1,940 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import { Platform } from 'react-native';
|
|
4
|
+
import {
|
|
5
|
+
Rokt,
|
|
6
|
+
CacheConfig,
|
|
7
|
+
IRoktConfig,
|
|
8
|
+
ColorMode,
|
|
9
|
+
RoktEventManager,
|
|
10
|
+
} from './rokt/rokt';
|
|
11
|
+
import RoktLayoutView, { RoktLayoutViewProps } from './rokt/rokt-layout-view';
|
|
12
|
+
import type {
|
|
13
|
+
Spec as NativeMParticleInterface,
|
|
14
|
+
CallbackError,
|
|
15
|
+
UserAttributes as NativeUserAttributes,
|
|
16
|
+
} from './codegenSpecs/NativeMParticle';
|
|
17
|
+
import { getNativeModule } from './utils/architecture';
|
|
18
|
+
|
|
19
|
+
const MParticleModule: NativeMParticleInterface =
|
|
20
|
+
getNativeModule<NativeMParticleInterface>('RNMParticle');
|
|
21
|
+
|
|
22
|
+
// ******** Types ********
|
|
23
|
+
export interface UserAttributes extends NativeUserAttributes {
|
|
24
|
+
[key: string]: string | string[] | number | boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface UserIdentities {
|
|
28
|
+
[key: number]: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface CustomAttributes {
|
|
32
|
+
[key: string]: string | number | boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface MParticleErrorResponse {
|
|
36
|
+
httpCode: number;
|
|
37
|
+
message?: string; // iOS only
|
|
38
|
+
responseCode?: number; // iOS only
|
|
39
|
+
mpid?: string;
|
|
40
|
+
errors?: string; // Both platforms return error details as concatenated strings
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface AttributionResult {
|
|
44
|
+
[key: string]: any;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type CompletionCallback<T> = (result: T) => void;
|
|
48
|
+
export type ErrorCallback = (error: MParticleError | null) => void;
|
|
49
|
+
export type IdentityCallback = (
|
|
50
|
+
error: MParticleError | null,
|
|
51
|
+
userId: string | null,
|
|
52
|
+
previousUserId?: string | null // previousUserId is optional in some cases
|
|
53
|
+
) => void;
|
|
54
|
+
|
|
55
|
+
// ******** Constants ********
|
|
56
|
+
|
|
57
|
+
export const EventType = {
|
|
58
|
+
Navigation: 1,
|
|
59
|
+
Location: 2,
|
|
60
|
+
Search: 3,
|
|
61
|
+
Transaction: 4,
|
|
62
|
+
UserContent: 5,
|
|
63
|
+
UserPreference: 6,
|
|
64
|
+
Social: 7,
|
|
65
|
+
Other: 8,
|
|
66
|
+
Media: 9,
|
|
67
|
+
} as const;
|
|
68
|
+
|
|
69
|
+
export const UserAttributeType = {
|
|
70
|
+
FirstName: '$FirstName',
|
|
71
|
+
LastName: '$LastName',
|
|
72
|
+
Address: '$Address',
|
|
73
|
+
State: '$State',
|
|
74
|
+
City: '$City',
|
|
75
|
+
Zipcode: '$Zip',
|
|
76
|
+
Country: '$Country',
|
|
77
|
+
Age: '$Age',
|
|
78
|
+
Gender: '$Gender',
|
|
79
|
+
MobileNumber: '$Mobile',
|
|
80
|
+
} as const;
|
|
81
|
+
|
|
82
|
+
export const UserIdentityType = {
|
|
83
|
+
Other: 0,
|
|
84
|
+
CustomerId: 1,
|
|
85
|
+
Facebook: 2,
|
|
86
|
+
Twitter: 3,
|
|
87
|
+
Google: 4,
|
|
88
|
+
Microsoft: 5,
|
|
89
|
+
Yahoo: 6,
|
|
90
|
+
Email: 7,
|
|
91
|
+
Alias: 8,
|
|
92
|
+
FacebookCustomAudienceId: 9,
|
|
93
|
+
Other2: 10,
|
|
94
|
+
Other3: 11,
|
|
95
|
+
Other4: 12,
|
|
96
|
+
Other5: 13,
|
|
97
|
+
Other6: 14,
|
|
98
|
+
Other7: 15,
|
|
99
|
+
Other8: 16,
|
|
100
|
+
Other9: 17,
|
|
101
|
+
Other10: 18,
|
|
102
|
+
MobileNumber: 19,
|
|
103
|
+
PhoneNumber2: 20,
|
|
104
|
+
PhoneNumber3: 21,
|
|
105
|
+
IOSAdvertiserId: 22,
|
|
106
|
+
IOSVendorId: 23,
|
|
107
|
+
PushToken: 24,
|
|
108
|
+
DeviceApplicationStamp: 25,
|
|
109
|
+
} as const;
|
|
110
|
+
|
|
111
|
+
export const ProductActionType = {
|
|
112
|
+
AddToCart: 1,
|
|
113
|
+
RemoveFromCart: 2,
|
|
114
|
+
Checkout: 3,
|
|
115
|
+
CheckoutOption: 4,
|
|
116
|
+
Click: 5,
|
|
117
|
+
ViewDetail: 6,
|
|
118
|
+
Purchase: 7,
|
|
119
|
+
Refund: 8,
|
|
120
|
+
AddToWishlist: 9,
|
|
121
|
+
RemoveFromWishlist: 10,
|
|
122
|
+
} as const;
|
|
123
|
+
|
|
124
|
+
export const PromotionActionType = {
|
|
125
|
+
View: 0,
|
|
126
|
+
Click: 1,
|
|
127
|
+
} as const;
|
|
128
|
+
|
|
129
|
+
export const ATTAuthStatus = {
|
|
130
|
+
NotDetermined: 0,
|
|
131
|
+
Restricted: 1,
|
|
132
|
+
Denied: 2,
|
|
133
|
+
Authorized: 3,
|
|
134
|
+
} as const;
|
|
135
|
+
|
|
136
|
+
// ******** Main API ********
|
|
137
|
+
|
|
138
|
+
export const upload = (): void => {
|
|
139
|
+
MParticleModule.upload();
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export const setUploadInterval = (uploadInterval: number): void => {
|
|
143
|
+
MParticleModule.setUploadInterval(uploadInterval);
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export const logEvent = (
|
|
147
|
+
eventName: string,
|
|
148
|
+
type: number = EventType.Other,
|
|
149
|
+
attributes: CustomAttributes | null = null
|
|
150
|
+
): void => {
|
|
151
|
+
MParticleModule.logEvent(eventName, type, attributes);
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export const logMPEvent = (event: Event): void => {
|
|
155
|
+
MParticleModule.logMPEvent(event);
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export const logCommerceEvent = (commerceEvent: CommerceEvent): void => {
|
|
159
|
+
MParticleModule.logCommerceEvent(commerceEvent);
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
export const logScreenEvent = (
|
|
163
|
+
screenName: string,
|
|
164
|
+
attributes: CustomAttributes | null = null,
|
|
165
|
+
shouldUploadEvent = true
|
|
166
|
+
): void => {
|
|
167
|
+
MParticleModule.logScreenEvent(screenName, attributes, shouldUploadEvent);
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
// ATT Status methods - iOS only, will be no-op on Android
|
|
171
|
+
export const setATTStatus = (status: number): void => {
|
|
172
|
+
if (Platform.OS === 'ios') {
|
|
173
|
+
MParticleModule.setATTStatus(status);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
export const setATTStatusWithCustomTimestamp = (
|
|
178
|
+
status: number,
|
|
179
|
+
timestamp: number
|
|
180
|
+
): void => {
|
|
181
|
+
if (Platform.OS === 'ios') {
|
|
182
|
+
MParticleModule.setATTStatusWithCustomTimestamp(status, timestamp);
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
export const setOptOut = (optOut: boolean): void => {
|
|
187
|
+
MParticleModule.setOptOut(optOut);
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
export const getOptOut = (completion: CompletionCallback<boolean>): void => {
|
|
191
|
+
MParticleModule.getOptOut(completion);
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
export const addGDPRConsentState = (
|
|
195
|
+
newConsentState: GDPRConsent,
|
|
196
|
+
purpose: string
|
|
197
|
+
): void => {
|
|
198
|
+
MParticleModule.addGDPRConsentState(newConsentState, purpose);
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
export const removeGDPRConsentStateWithPurpose = (purpose: string): void => {
|
|
202
|
+
MParticleModule.removeGDPRConsentStateWithPurpose(purpose);
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
export const setCCPAConsentState = (newConsentState: CCPAConsent): void => {
|
|
206
|
+
MParticleModule.setCCPAConsentState(newConsentState);
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
export const removeCCPAConsentState = (): void => {
|
|
210
|
+
MParticleModule.removeCCPAConsentState();
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
export const isKitActive = (
|
|
214
|
+
kitId: number,
|
|
215
|
+
completion: CompletionCallback<boolean>
|
|
216
|
+
): void => {
|
|
217
|
+
MParticleModule.isKitActive(kitId, completion);
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
export const getAttributions = (
|
|
221
|
+
completion: CompletionCallback<AttributionResult>
|
|
222
|
+
): void => {
|
|
223
|
+
MParticleModule.getAttributions(completion);
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
export const logPushRegistration = (
|
|
227
|
+
registrationField1: string,
|
|
228
|
+
registrationField2: string
|
|
229
|
+
): void => {
|
|
230
|
+
MParticleModule.logPushRegistration(registrationField1, registrationField2);
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
export const getSession = (
|
|
234
|
+
completion: CompletionCallback<string | null>
|
|
235
|
+
): void => {
|
|
236
|
+
MParticleModule.getSession(completion);
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
export const setLocation = (latitude: number, longitude: number): void => {
|
|
240
|
+
MParticleModule.setLocation(latitude, longitude);
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
// ******** Identity ********
|
|
244
|
+
export class User {
|
|
245
|
+
readonly userId: string;
|
|
246
|
+
|
|
247
|
+
constructor(userId: string) {
|
|
248
|
+
this.userId = userId;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
getMpid(): string {
|
|
252
|
+
return this.userId;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
setUserAttribute(
|
|
256
|
+
key: string,
|
|
257
|
+
value: string | string[] | number | boolean
|
|
258
|
+
): void {
|
|
259
|
+
if (value && value.constructor === Array) {
|
|
260
|
+
MParticleModule.setUserAttributeArray(this.userId, key, value);
|
|
261
|
+
} else {
|
|
262
|
+
MParticleModule.setUserAttribute(this.userId, key, value.toString());
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
setUserAttributeArray(key: string, value: string[]): void {
|
|
267
|
+
MParticleModule.setUserAttributeArray(this.userId, key, value);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
getUserAttributes(completion: CompletionCallback<UserAttributes>): void {
|
|
271
|
+
MParticleModule.getUserAttributes(
|
|
272
|
+
this.userId,
|
|
273
|
+
(error: CallbackError | null, result: NativeUserAttributes | null) => {
|
|
274
|
+
if (error?.message) {
|
|
275
|
+
console.log(error.message);
|
|
276
|
+
}
|
|
277
|
+
completion((result as UserAttributes) || {});
|
|
278
|
+
}
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
setUserTag(value: string): void {
|
|
283
|
+
MParticleModule.setUserTag(this.userId, value);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
incrementUserAttribute(key: string, value: number): void {
|
|
287
|
+
MParticleModule.incrementUserAttribute(this.userId, key, value);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
removeUserAttribute(key: string): void {
|
|
291
|
+
MParticleModule.removeUserAttribute(this.userId, key);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
getUserIdentities(completion: CompletionCallback<UserIdentities>): void {
|
|
295
|
+
MParticleModule.getUserIdentities(
|
|
296
|
+
this.userId,
|
|
297
|
+
(error: CallbackError | null, result: UserIdentities | null) => {
|
|
298
|
+
if (error?.message) {
|
|
299
|
+
console.log(error.message);
|
|
300
|
+
}
|
|
301
|
+
completion(result || {});
|
|
302
|
+
}
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
getFirstSeen(completion: CompletionCallback<string>): void {
|
|
307
|
+
MParticleModule.getFirstSeen(this.userId, completion);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
getLastSeen(completion: CompletionCallback<string>): void {
|
|
311
|
+
MParticleModule.getLastSeen(this.userId, completion);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
export class IdentityRequest {
|
|
316
|
+
[key: number]: string;
|
|
317
|
+
email?: string;
|
|
318
|
+
customerId?: string;
|
|
319
|
+
|
|
320
|
+
setEmail(email: string): this {
|
|
321
|
+
this.email = email;
|
|
322
|
+
this[UserIdentityType.Email] = email;
|
|
323
|
+
return this;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
setCustomerID(customerId: string): this {
|
|
327
|
+
this.customerId = customerId;
|
|
328
|
+
this[UserIdentityType.CustomerId] = customerId;
|
|
329
|
+
return this;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
setUserIdentity(userIdentity: string, identityType: number): this {
|
|
333
|
+
this[identityType] = userIdentity;
|
|
334
|
+
return this;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* @deprecated This method is deprecated and will be removed in a future version.
|
|
339
|
+
*/
|
|
340
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
341
|
+
setOnUserAlias(_onUserAlias: any): void {
|
|
342
|
+
console.log(
|
|
343
|
+
"Warning: deprecated method 'setUserAlias(onUserAlias)', will be removed in future releases"
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
export class Identity {
|
|
349
|
+
static getCurrentUser(completion: CompletionCallback<User>): void {
|
|
350
|
+
MParticleModule.getCurrentUserWithCompletion(
|
|
351
|
+
(error: CallbackError | null, userId: string | null) => {
|
|
352
|
+
if (error) {
|
|
353
|
+
console.log(error.message);
|
|
354
|
+
}
|
|
355
|
+
const currentUser = new User(userId || '');
|
|
356
|
+
completion(currentUser);
|
|
357
|
+
}
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
static identify(
|
|
362
|
+
identityRequest: IdentityRequest,
|
|
363
|
+
completion: IdentityCallback
|
|
364
|
+
): void {
|
|
365
|
+
MParticleModule.identify(
|
|
366
|
+
identityRequest,
|
|
367
|
+
(
|
|
368
|
+
error: CallbackError | null,
|
|
369
|
+
userId: string | null,
|
|
370
|
+
previousUserId: string | null
|
|
371
|
+
) => {
|
|
372
|
+
if (error == null || error === undefined) {
|
|
373
|
+
completion(error, userId, previousUserId);
|
|
374
|
+
} else {
|
|
375
|
+
const parsedError = new MParticleError(error);
|
|
376
|
+
completion(parsedError, userId, previousUserId);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
static login(
|
|
383
|
+
identityRequest: IdentityRequest,
|
|
384
|
+
completion: IdentityCallback
|
|
385
|
+
): void {
|
|
386
|
+
MParticleModule.login(
|
|
387
|
+
identityRequest,
|
|
388
|
+
(
|
|
389
|
+
error: CallbackError | null,
|
|
390
|
+
userId: string | null,
|
|
391
|
+
previousUserId: string | null
|
|
392
|
+
) => {
|
|
393
|
+
if (error == null || error === undefined) {
|
|
394
|
+
completion(error, userId, previousUserId);
|
|
395
|
+
} else {
|
|
396
|
+
const parsedError = new MParticleError(error);
|
|
397
|
+
completion(parsedError, userId, previousUserId);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
static logout(
|
|
404
|
+
identityRequest: IdentityRequest,
|
|
405
|
+
completion: IdentityCallback
|
|
406
|
+
): void {
|
|
407
|
+
MParticleModule.logout(
|
|
408
|
+
identityRequest,
|
|
409
|
+
(
|
|
410
|
+
error: CallbackError | null,
|
|
411
|
+
userId: string | null,
|
|
412
|
+
previousUserId: string | null
|
|
413
|
+
) => {
|
|
414
|
+
if (error == null || error === undefined) {
|
|
415
|
+
completion(error, userId, previousUserId);
|
|
416
|
+
} else {
|
|
417
|
+
const parsedError = new MParticleError(error);
|
|
418
|
+
completion(parsedError, userId, previousUserId);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
static modify(
|
|
425
|
+
identityRequest: IdentityRequest,
|
|
426
|
+
completion: IdentityCallback
|
|
427
|
+
): void {
|
|
428
|
+
MParticleModule.modify(
|
|
429
|
+
identityRequest,
|
|
430
|
+
(
|
|
431
|
+
error: CallbackError | null,
|
|
432
|
+
userId: string | null,
|
|
433
|
+
previousUserId: string | null
|
|
434
|
+
) => {
|
|
435
|
+
if (error == null || error === undefined) {
|
|
436
|
+
completion(error, userId, previousUserId);
|
|
437
|
+
} else {
|
|
438
|
+
const parsedError = new MParticleError(error);
|
|
439
|
+
completion(parsedError, userId, previousUserId);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
static aliasUsers(
|
|
446
|
+
aliasRequest: AliasRequest,
|
|
447
|
+
completion: CompletionCallback<boolean>
|
|
448
|
+
): void {
|
|
449
|
+
MParticleModule.aliasUsers(
|
|
450
|
+
aliasRequest as any,
|
|
451
|
+
(success: boolean, message?: string) => {
|
|
452
|
+
if (message) {
|
|
453
|
+
console.log(message);
|
|
454
|
+
}
|
|
455
|
+
completion(success);
|
|
456
|
+
}
|
|
457
|
+
);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
// ******** Commerce ********
|
|
462
|
+
|
|
463
|
+
export class Impression {
|
|
464
|
+
readonly impressionListName: string;
|
|
465
|
+
readonly products: Product[];
|
|
466
|
+
|
|
467
|
+
constructor(impressionListName: string, products: Product[]) {
|
|
468
|
+
this.impressionListName = impressionListName;
|
|
469
|
+
this.products = products;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
export class Promotion {
|
|
474
|
+
readonly id: string;
|
|
475
|
+
readonly name: string;
|
|
476
|
+
readonly creative: string;
|
|
477
|
+
readonly position: string;
|
|
478
|
+
|
|
479
|
+
constructor(id: string, name: string, creative: string, position: string) {
|
|
480
|
+
this.id = id;
|
|
481
|
+
this.name = name;
|
|
482
|
+
this.creative = creative;
|
|
483
|
+
this.position = position;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
export class AliasRequest {
|
|
488
|
+
sourceMpid(mpid: string): this {
|
|
489
|
+
(this as any).sourceMpid = mpid;
|
|
490
|
+
return this;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
destinationMpid(mpid: string): this {
|
|
494
|
+
(this as any).destinationMpid = mpid;
|
|
495
|
+
return this;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
endTime(endTime: number): this {
|
|
499
|
+
(this as any).endTime = endTime;
|
|
500
|
+
return this;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
startTime(startTime: number): this {
|
|
504
|
+
(this as any).startTime = startTime;
|
|
505
|
+
return this;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
export class TransactionAttributes {
|
|
510
|
+
readonly transactionId: string;
|
|
511
|
+
affiliation?: string;
|
|
512
|
+
revenue?: number;
|
|
513
|
+
shipping?: number;
|
|
514
|
+
tax?: number;
|
|
515
|
+
couponCode?: string;
|
|
516
|
+
|
|
517
|
+
constructor(transactionId: string) {
|
|
518
|
+
this.transactionId = transactionId;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
setAffiliation(affiliation: string): this {
|
|
522
|
+
this.affiliation = affiliation;
|
|
523
|
+
return this;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
setRevenue(revenue: string | number): this {
|
|
527
|
+
this.revenue = typeof revenue === 'string' ? parseFloat(revenue) : revenue;
|
|
528
|
+
return this;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
setShipping(shipping: string | number): this {
|
|
532
|
+
this.shipping =
|
|
533
|
+
typeof shipping === 'string' ? parseFloat(shipping) : shipping;
|
|
534
|
+
return this;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
setTax(tax: string | number): this {
|
|
538
|
+
this.tax = typeof tax === 'string' ? parseFloat(tax) : tax;
|
|
539
|
+
return this;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
setCouponCode(couponCode: string): this {
|
|
543
|
+
this.couponCode = couponCode;
|
|
544
|
+
return this;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
export class Product {
|
|
549
|
+
readonly name: string;
|
|
550
|
+
readonly sku: string;
|
|
551
|
+
readonly price: number;
|
|
552
|
+
readonly quantity: number;
|
|
553
|
+
brand?: string;
|
|
554
|
+
couponCode?: string;
|
|
555
|
+
position?: number;
|
|
556
|
+
category?: string;
|
|
557
|
+
variant?: string;
|
|
558
|
+
customAttributes?: CustomAttributes;
|
|
559
|
+
|
|
560
|
+
constructor(name: string, sku: string, price: number, quantity = 1) {
|
|
561
|
+
this.name = name;
|
|
562
|
+
this.sku = sku;
|
|
563
|
+
this.price = price;
|
|
564
|
+
this.quantity = quantity;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
setBrand(brand: string): this {
|
|
568
|
+
this.brand = brand;
|
|
569
|
+
return this;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
setCouponCode(couponCode: string): this {
|
|
573
|
+
this.couponCode = couponCode;
|
|
574
|
+
return this;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
setPosition(position: number): this {
|
|
578
|
+
this.position = position;
|
|
579
|
+
return this;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
setCategory(category: string): this {
|
|
583
|
+
this.category = category;
|
|
584
|
+
return this;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
setVariant(variant: string): this {
|
|
588
|
+
this.variant = variant;
|
|
589
|
+
return this;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
setCustomAttributes(customAttributes: CustomAttributes): this {
|
|
593
|
+
this.customAttributes = customAttributes;
|
|
594
|
+
return this;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
export class GDPRConsent {
|
|
599
|
+
consented?: boolean;
|
|
600
|
+
document?: string;
|
|
601
|
+
timestamp?: number;
|
|
602
|
+
location?: string;
|
|
603
|
+
hardwareId?: string;
|
|
604
|
+
|
|
605
|
+
constructor(
|
|
606
|
+
consented?: boolean,
|
|
607
|
+
doc?: string,
|
|
608
|
+
timestamp?: number,
|
|
609
|
+
location?: string,
|
|
610
|
+
hardwareId?: string
|
|
611
|
+
) {
|
|
612
|
+
this.consented = consented;
|
|
613
|
+
this.document = doc;
|
|
614
|
+
this.timestamp = timestamp;
|
|
615
|
+
this.location = location;
|
|
616
|
+
this.hardwareId = hardwareId;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
setConsented(consented: boolean): this {
|
|
620
|
+
this.consented = consented;
|
|
621
|
+
return this;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
setDocument(doc: string): this {
|
|
625
|
+
this.document = doc;
|
|
626
|
+
return this;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
setTimestamp(timestamp: number): this {
|
|
630
|
+
this.timestamp = timestamp;
|
|
631
|
+
return this;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
setLocation(location: string): this {
|
|
635
|
+
this.location = location;
|
|
636
|
+
return this;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
setHardwareId(hardwareId: string): this {
|
|
640
|
+
this.hardwareId = hardwareId;
|
|
641
|
+
return this;
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
export class CCPAConsent {
|
|
646
|
+
consented?: boolean;
|
|
647
|
+
document?: string;
|
|
648
|
+
timestamp?: number;
|
|
649
|
+
location?: string;
|
|
650
|
+
hardwareId?: string;
|
|
651
|
+
|
|
652
|
+
constructor(
|
|
653
|
+
consented?: boolean,
|
|
654
|
+
doc?: string,
|
|
655
|
+
timestamp?: number,
|
|
656
|
+
location?: string,
|
|
657
|
+
hardwareId?: string
|
|
658
|
+
) {
|
|
659
|
+
this.consented = consented;
|
|
660
|
+
this.document = doc;
|
|
661
|
+
this.timestamp = timestamp;
|
|
662
|
+
this.location = location;
|
|
663
|
+
this.hardwareId = hardwareId;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
setConsented(consented: boolean): this {
|
|
667
|
+
this.consented = consented;
|
|
668
|
+
return this;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
setDocument(doc: string): this {
|
|
672
|
+
this.document = doc;
|
|
673
|
+
return this;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
setTimestamp(timestamp: number): this {
|
|
677
|
+
this.timestamp = timestamp;
|
|
678
|
+
return this;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
setLocation(location: string): this {
|
|
682
|
+
this.location = location;
|
|
683
|
+
return this;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
setHardwareId(hardwareId: string): this {
|
|
687
|
+
this.hardwareId = hardwareId;
|
|
688
|
+
return this;
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
export class CommerceEvent {
|
|
693
|
+
productActionType?: number;
|
|
694
|
+
promotionActionType?: number;
|
|
695
|
+
products?: Product[];
|
|
696
|
+
transactionAttributes?: TransactionAttributes;
|
|
697
|
+
promotions?: Promotion[];
|
|
698
|
+
impressions?: Impression[];
|
|
699
|
+
screenName?: string;
|
|
700
|
+
currency?: string;
|
|
701
|
+
customAttributes?: CustomAttributes;
|
|
702
|
+
checkoutOptions?: string;
|
|
703
|
+
productActionListName?: string;
|
|
704
|
+
productActionListSource?: string;
|
|
705
|
+
checkoutStep?: number;
|
|
706
|
+
nonInteractive?: boolean;
|
|
707
|
+
shouldUploadEvent?: boolean;
|
|
708
|
+
|
|
709
|
+
static createProductActionEvent(
|
|
710
|
+
productActionType: number,
|
|
711
|
+
products: Product[],
|
|
712
|
+
transactionAttributes: TransactionAttributes = new TransactionAttributes('')
|
|
713
|
+
): CommerceEvent {
|
|
714
|
+
return new CommerceEvent()
|
|
715
|
+
.setProductActionType(productActionType)
|
|
716
|
+
.setProducts(products)
|
|
717
|
+
.setTransactionAttributes(transactionAttributes);
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
static createPromotionEvent(
|
|
721
|
+
promotionActionType: number,
|
|
722
|
+
promotions: Promotion[]
|
|
723
|
+
): CommerceEvent {
|
|
724
|
+
return new CommerceEvent()
|
|
725
|
+
.setPromotionActionType(promotionActionType)
|
|
726
|
+
.setPromotions(promotions);
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
static createImpressionEvent(impressions: Impression[]): CommerceEvent {
|
|
730
|
+
return new CommerceEvent().setImpressions(impressions);
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
setTransactionAttributes(transactionAttributes: TransactionAttributes): this {
|
|
734
|
+
this.transactionAttributes = transactionAttributes;
|
|
735
|
+
return this;
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
setProductActionType(productActionType: number): this {
|
|
739
|
+
this.productActionType = productActionType;
|
|
740
|
+
return this;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
setPromotionActionType(promotionActionType: number): this {
|
|
744
|
+
this.promotionActionType = promotionActionType;
|
|
745
|
+
return this;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
setProducts(products: Product[]): this {
|
|
749
|
+
this.products = products;
|
|
750
|
+
return this;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
setPromotions(promotions: Promotion[]): this {
|
|
754
|
+
this.promotions = promotions;
|
|
755
|
+
return this;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
setImpressions(impressions: Impression[]): this {
|
|
759
|
+
this.impressions = impressions;
|
|
760
|
+
return this;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
setScreenName(screenName: string): this {
|
|
764
|
+
this.screenName = screenName;
|
|
765
|
+
return this;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
setCurrency(currency: string): this {
|
|
769
|
+
this.currency = currency;
|
|
770
|
+
return this;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
setCustomAttributes(customAttributes: CustomAttributes): this {
|
|
774
|
+
this.customAttributes = customAttributes;
|
|
775
|
+
return this;
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
setCheckoutOptions(checkoutOptions: string): this {
|
|
779
|
+
this.checkoutOptions = checkoutOptions;
|
|
780
|
+
return this;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
setProductActionListName(productActionListName: string): this {
|
|
784
|
+
this.productActionListName = productActionListName;
|
|
785
|
+
return this;
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
setProductActionListSource(productActionListSource: string): this {
|
|
789
|
+
this.productActionListSource = productActionListSource;
|
|
790
|
+
return this;
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
setCheckoutStep(checkoutStep: number): this {
|
|
794
|
+
this.checkoutStep = checkoutStep;
|
|
795
|
+
return this;
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
setNonInteractive(nonInteractive: boolean): this {
|
|
799
|
+
this.nonInteractive = nonInteractive;
|
|
800
|
+
return this;
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
setShouldUploadEvent(shouldUploadEvent: boolean): this {
|
|
804
|
+
this.shouldUploadEvent = shouldUploadEvent;
|
|
805
|
+
return this;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
export class Event {
|
|
810
|
+
category?: string;
|
|
811
|
+
duration?: number;
|
|
812
|
+
endTime?: number;
|
|
813
|
+
info?: CustomAttributes;
|
|
814
|
+
name?: string;
|
|
815
|
+
startTime?: number;
|
|
816
|
+
type?: number;
|
|
817
|
+
shouldUploadEvent?: boolean;
|
|
818
|
+
customFlags?: { [key: string]: string };
|
|
819
|
+
|
|
820
|
+
setCategory(category: string): this {
|
|
821
|
+
this.category = category;
|
|
822
|
+
return this;
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
setDuration(duration: number): this {
|
|
826
|
+
this.duration = duration;
|
|
827
|
+
return this;
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
setEndTime(endTime: number): this {
|
|
831
|
+
this.endTime = endTime;
|
|
832
|
+
return this;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
setInfo(info: CustomAttributes): this {
|
|
836
|
+
this.info = info;
|
|
837
|
+
return this;
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
setName(name: string): this {
|
|
841
|
+
this.name = name;
|
|
842
|
+
return this;
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
setStartTime(startTime: number): this {
|
|
846
|
+
this.startTime = startTime;
|
|
847
|
+
return this;
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
setType(type: number): this {
|
|
851
|
+
this.type = type;
|
|
852
|
+
return this;
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
setShouldUploadEvent(shouldUploadEvent: boolean): this {
|
|
856
|
+
this.shouldUploadEvent = shouldUploadEvent;
|
|
857
|
+
return this;
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
setCustomFlags(customFlags: { [key: string]: string }): this {
|
|
861
|
+
this.customFlags = customFlags;
|
|
862
|
+
return this;
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
export class MParticleError {
|
|
867
|
+
readonly message: string;
|
|
868
|
+
readonly code: number;
|
|
869
|
+
readonly httpCode: number;
|
|
870
|
+
readonly responseCode?: number;
|
|
871
|
+
readonly mpid?: string;
|
|
872
|
+
readonly errors?: string;
|
|
873
|
+
|
|
874
|
+
constructor(errorResponse: CallbackError | MParticleErrorResponse) {
|
|
875
|
+
this.httpCode = errorResponse.httpCode || 0;
|
|
876
|
+
this.responseCode = errorResponse.responseCode;
|
|
877
|
+
// Handle platform differences in error messages
|
|
878
|
+
this.message =
|
|
879
|
+
errorResponse.message || errorResponse.errors || 'Unknown error';
|
|
880
|
+
this.mpid = errorResponse.mpid;
|
|
881
|
+
this.errors = errorResponse.errors;
|
|
882
|
+
// For backward compatibility with type definitions
|
|
883
|
+
this.code = errorResponse.responseCode || errorResponse.httpCode || 0;
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
// Export Rokt functionality
|
|
888
|
+
export type { IRoktConfig, ColorMode, RoktLayoutViewProps };
|
|
889
|
+
export { Rokt, CacheConfig, RoktLayoutView };
|
|
890
|
+
|
|
891
|
+
// ******** Exports ********
|
|
892
|
+
|
|
893
|
+
const MParticle = {
|
|
894
|
+
EventType, // Constants
|
|
895
|
+
UserIdentityType,
|
|
896
|
+
UserAttributeType,
|
|
897
|
+
ProductActionType,
|
|
898
|
+
PromotionActionType,
|
|
899
|
+
ATTAuthStatus,
|
|
900
|
+
|
|
901
|
+
Product, // Classes
|
|
902
|
+
Impression,
|
|
903
|
+
Promotion,
|
|
904
|
+
CommerceEvent,
|
|
905
|
+
TransactionAttributes,
|
|
906
|
+
IdentityRequest,
|
|
907
|
+
AliasRequest,
|
|
908
|
+
Identity,
|
|
909
|
+
User,
|
|
910
|
+
Event,
|
|
911
|
+
MParticleError,
|
|
912
|
+
GDPRConsent,
|
|
913
|
+
CCPAConsent,
|
|
914
|
+
Rokt,
|
|
915
|
+
CacheConfig,
|
|
916
|
+
RoktEventManager,
|
|
917
|
+
RoktLayoutView,
|
|
918
|
+
|
|
919
|
+
upload, // Methods
|
|
920
|
+
setUploadInterval,
|
|
921
|
+
logEvent,
|
|
922
|
+
logMPEvent,
|
|
923
|
+
logCommerceEvent,
|
|
924
|
+
logScreenEvent,
|
|
925
|
+
setATTStatus,
|
|
926
|
+
setATTStatusWithCustomTimestamp,
|
|
927
|
+
setOptOut,
|
|
928
|
+
getOptOut,
|
|
929
|
+
addGDPRConsentState,
|
|
930
|
+
removeGDPRConsentStateWithPurpose,
|
|
931
|
+
setCCPAConsentState,
|
|
932
|
+
removeCCPAConsentState,
|
|
933
|
+
isKitActive,
|
|
934
|
+
getAttributions,
|
|
935
|
+
logPushRegistration,
|
|
936
|
+
getSession,
|
|
937
|
+
setLocation,
|
|
938
|
+
};
|
|
939
|
+
|
|
940
|
+
export default MParticle;
|