react-native-mparticle 2.7.13 → 2.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +1208 -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/.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/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 -678
- 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/xcschemes/xcschememanagement.plist +0 -14
- package/js/index.js +0 -697
- package/release.sh +0 -6
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
package com.mparticle.react
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.TurboReactPackage
|
|
4
|
+
import com.facebook.react.bridge.ModuleSpec
|
|
5
|
+
import com.facebook.react.bridge.NativeModule
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
7
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
8
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
9
|
+
import com.facebook.react.uimanager.ViewManager
|
|
10
|
+
import com.mparticle.react.rokt.MPRoktModule
|
|
11
|
+
import com.mparticle.react.rokt.MPRoktModuleImpl
|
|
12
|
+
import com.mparticle.react.rokt.RoktLayoutViewManager
|
|
13
|
+
|
|
14
|
+
class MParticlePackage : TurboReactPackage() {
|
|
15
|
+
override fun getModule(
|
|
16
|
+
name: String,
|
|
17
|
+
reactContext: ReactApplicationContext,
|
|
18
|
+
): NativeModule? =
|
|
19
|
+
when (name) {
|
|
20
|
+
MParticleModule.MODULE_NAME -> {
|
|
21
|
+
MParticleModule(reactContext)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
MPRoktModuleImpl.MODULE_NAME -> {
|
|
25
|
+
MPRoktModule(reactContext)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
else -> null
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> = listOf(RoktLayoutViewManager())
|
|
32
|
+
|
|
33
|
+
override fun getReactModuleInfoProvider() =
|
|
34
|
+
ReactModuleInfoProvider {
|
|
35
|
+
val moduleInfos: MutableMap<String, ReactModuleInfo> =
|
|
36
|
+
HashMap()
|
|
37
|
+
moduleInfos.put(
|
|
38
|
+
MParticleModule.MODULE_NAME,
|
|
39
|
+
ReactModuleInfo(
|
|
40
|
+
MParticleModule.MODULE_NAME,
|
|
41
|
+
MParticleModule.MODULE_NAME,
|
|
42
|
+
true, // canOverrideExistingModule
|
|
43
|
+
false, // needsEagerInit
|
|
44
|
+
true, // hasConstants
|
|
45
|
+
false, // isCxxModule
|
|
46
|
+
BuildConfig.IS_NEW_ARCHITECTURE_ENABLED, // isTurboModule
|
|
47
|
+
),
|
|
48
|
+
)
|
|
49
|
+
moduleInfos.put(
|
|
50
|
+
MPRoktModuleImpl.MODULE_NAME,
|
|
51
|
+
ReactModuleInfo(
|
|
52
|
+
MPRoktModuleImpl.MODULE_NAME,
|
|
53
|
+
MPRoktModuleImpl.MODULE_NAME,
|
|
54
|
+
true, // canOverrideExistingModule
|
|
55
|
+
false, // needsEagerInit
|
|
56
|
+
true, // hasConstants
|
|
57
|
+
false, // isCxxModule
|
|
58
|
+
BuildConfig.IS_NEW_ARCHITECTURE_ENABLED, // isTurboModule
|
|
59
|
+
),
|
|
60
|
+
)
|
|
61
|
+
moduleInfos.toMap()
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
override fun getViewManagers(reactContext: ReactApplicationContext): List<ModuleSpec> =
|
|
65
|
+
listOf(
|
|
66
|
+
ModuleSpec.viewManagerSpec { RoktLayoutViewManager() },
|
|
67
|
+
)
|
|
68
|
+
}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
package com.mparticle.react.rokt
|
|
2
|
+
|
|
3
|
+
import android.app.Activity
|
|
4
|
+
import androidx.lifecycle.Lifecycle
|
|
5
|
+
import androidx.lifecycle.LifecycleOwner
|
|
6
|
+
import androidx.lifecycle.lifecycleScope
|
|
7
|
+
import androidx.lifecycle.repeatOnLifecycle
|
|
8
|
+
import com.facebook.react.bridge.Arguments
|
|
9
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
10
|
+
import com.facebook.react.bridge.ReactContext
|
|
11
|
+
import com.facebook.react.bridge.ReadableMap
|
|
12
|
+
import com.facebook.react.bridge.WritableMap
|
|
13
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
14
|
+
import com.mparticle.MParticle
|
|
15
|
+
import com.mparticle.MpRoktEventCallback
|
|
16
|
+
import com.mparticle.RoktEvent
|
|
17
|
+
import com.mparticle.UnloadReasons
|
|
18
|
+
import com.mparticle.WrapperSdk
|
|
19
|
+
import com.mparticle.rokt.CacheConfig
|
|
20
|
+
import com.mparticle.rokt.RoktConfig
|
|
21
|
+
import kotlinx.coroutines.Job
|
|
22
|
+
import kotlinx.coroutines.flow.Flow
|
|
23
|
+
import kotlinx.coroutines.launch
|
|
24
|
+
|
|
25
|
+
class MPRoktModuleImpl(
|
|
26
|
+
private val reactContext: ReactApplicationContext,
|
|
27
|
+
) {
|
|
28
|
+
init {
|
|
29
|
+
MParticle.getInstance()?.setWrapperSdk(WrapperSdk.WrapperSdkReactNative, "")
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private var roktEventHandler: MpRoktEventCallback? = null
|
|
33
|
+
|
|
34
|
+
private val eventSubscriptions = mutableMapOf<String, Job?>()
|
|
35
|
+
private val listeners: MutableMap<Long, MpRoktEventCallback> =
|
|
36
|
+
object : LinkedHashMap<Long, MpRoktEventCallback>() {
|
|
37
|
+
override fun removeEldestEntry(eldest: Map.Entry<Long, MpRoktEventCallback>): Boolean = this.size > MAX_LISTENERS
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
fun getName(): String = MODULE_NAME
|
|
41
|
+
|
|
42
|
+
fun purchaseFinalized(
|
|
43
|
+
placementId: String,
|
|
44
|
+
catalogItemId: String,
|
|
45
|
+
success: Boolean,
|
|
46
|
+
) {
|
|
47
|
+
MParticle.getInstance()?.Rokt()?.purchaseFinalized(placementId, catalogItemId, success)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
fun setRoktEventHandler(roktEventHandler: MpRoktEventCallback) {
|
|
51
|
+
this.roktEventHandler = roktEventHandler
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
fun createRoktCallback(): MpRoktEventCallback {
|
|
55
|
+
val callback: MpRoktEventCallback =
|
|
56
|
+
object : MpRoktEventCallback {
|
|
57
|
+
override fun onLoad() {
|
|
58
|
+
sendCallback("onLoad", null)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
override fun onUnload(reason: UnloadReasons) {
|
|
62
|
+
sendCallback("onUnLoad", reason.toString())
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
override fun onShouldShowLoadingIndicator() {
|
|
66
|
+
sendCallback("onShouldShowLoadingIndicator", null)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
override fun onShouldHideLoadingIndicator() {
|
|
70
|
+
sendCallback("onShouldHideLoadingIndicator", null)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
listeners[System.currentTimeMillis()] = callback
|
|
74
|
+
return callback
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
fun sendCallback(
|
|
78
|
+
eventValue: String,
|
|
79
|
+
reason: String?,
|
|
80
|
+
) {
|
|
81
|
+
val params = Arguments.createMap()
|
|
82
|
+
params.putString("callbackValue", eventValue)
|
|
83
|
+
if (reason != null) {
|
|
84
|
+
params.putString("reason", reason)
|
|
85
|
+
}
|
|
86
|
+
sendEvent(reactContext, "RoktCallback", params)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
fun sendEvent(
|
|
90
|
+
reactContext: ReactContext?,
|
|
91
|
+
eventName: String,
|
|
92
|
+
params: WritableMap?,
|
|
93
|
+
) {
|
|
94
|
+
reactContext?.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)?.emit(eventName, params)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
fun readableMapToMapOfStrings(attributes: ReadableMap?): Map<String, String> =
|
|
98
|
+
attributes?.toHashMap()?.filter { it.value is String }?.mapValues { it.value as String }
|
|
99
|
+
?: emptyMap()
|
|
100
|
+
|
|
101
|
+
fun String.toColorMode(): RoktConfig.ColorMode =
|
|
102
|
+
when (this) {
|
|
103
|
+
"dark" -> RoktConfig.ColorMode.DARK
|
|
104
|
+
"light" -> RoktConfig.ColorMode.LIGHT
|
|
105
|
+
else -> RoktConfig.ColorMode.SYSTEM
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
fun buildRoktConfig(roktConfig: ReadableMap?): RoktConfig {
|
|
109
|
+
val builder = RoktConfig.Builder()
|
|
110
|
+
val configMap: Map<String, String> = readableMapToMapOfStrings(roktConfig)
|
|
111
|
+
configMap["colorMode"]?.let {
|
|
112
|
+
builder.colorMode(it.toColorMode())
|
|
113
|
+
}
|
|
114
|
+
roktConfig?.getMap("cacheConfig")?.let {
|
|
115
|
+
builder.cacheConfig(buildCacheConfig(it))
|
|
116
|
+
}
|
|
117
|
+
return builder.build()
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
fun buildCacheConfig(cacheConfigMap: ReadableMap?): CacheConfig {
|
|
121
|
+
val cacheDurationInSeconds =
|
|
122
|
+
if (cacheConfigMap?.hasKey("cacheDurationInSeconds") == true) {
|
|
123
|
+
cacheConfigMap.getDouble("cacheDurationInSeconds").toLong()
|
|
124
|
+
} else {
|
|
125
|
+
0L
|
|
126
|
+
}
|
|
127
|
+
val cacheAttributes =
|
|
128
|
+
if (cacheConfigMap?.hasKey("cacheAttributes") == true) {
|
|
129
|
+
cacheConfigMap.getMap("cacheAttributes")?.toHashMap()?.mapValues { it.value as String }
|
|
130
|
+
} else {
|
|
131
|
+
null
|
|
132
|
+
}
|
|
133
|
+
return CacheConfig(
|
|
134
|
+
cacheDurationInSeconds = cacheDurationInSeconds,
|
|
135
|
+
cacheAttributes = cacheAttributes,
|
|
136
|
+
)
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
fun startRoktEventListener(
|
|
140
|
+
flow: Flow<RoktEvent>,
|
|
141
|
+
currentActivity: Activity?,
|
|
142
|
+
viewName: String? = null,
|
|
143
|
+
) {
|
|
144
|
+
val activeJob = eventSubscriptions[viewName.orEmpty()]?.takeIf { it.isActive }
|
|
145
|
+
if (activeJob != null) {
|
|
146
|
+
return
|
|
147
|
+
}
|
|
148
|
+
val job =
|
|
149
|
+
(currentActivity as? LifecycleOwner)?.lifecycleScope?.launch {
|
|
150
|
+
(currentActivity as LifecycleOwner).repeatOnLifecycle(Lifecycle.State.CREATED) {
|
|
151
|
+
flow.collect { event ->
|
|
152
|
+
val params = Arguments.createMap()
|
|
153
|
+
var eventName: String
|
|
154
|
+
val placementId: String? =
|
|
155
|
+
when (event) {
|
|
156
|
+
is RoktEvent.FirstPositiveEngagement -> {
|
|
157
|
+
eventName = "FirstPositiveEngagement"
|
|
158
|
+
event.placementId
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
RoktEvent.HideLoadingIndicator -> {
|
|
162
|
+
eventName = "HideLoadingIndicator"
|
|
163
|
+
null
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
is RoktEvent.OfferEngagement -> {
|
|
167
|
+
eventName = "OfferEngagement"
|
|
168
|
+
event.placementId
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
is RoktEvent.PlacementClosed -> {
|
|
172
|
+
eventName = "PlacementClosed"
|
|
173
|
+
event.placementId
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
is RoktEvent.PlacementCompleted -> {
|
|
177
|
+
eventName = "PlacementCompleted"
|
|
178
|
+
event.placementId
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
is RoktEvent.PlacementFailure -> {
|
|
182
|
+
eventName = "PlacementFailure"
|
|
183
|
+
event.placementId
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
is RoktEvent.PlacementInteractive -> {
|
|
187
|
+
eventName = "PlacementInteractive"
|
|
188
|
+
event.placementId
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
is RoktEvent.PlacementReady -> {
|
|
192
|
+
eventName = "PlacementReady"
|
|
193
|
+
event.placementId
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
is RoktEvent.PositiveEngagement -> {
|
|
197
|
+
eventName = "PositiveEngagement"
|
|
198
|
+
event.placementId
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
RoktEvent.ShowLoadingIndicator -> {
|
|
202
|
+
eventName = "ShowLoadingIndicator"
|
|
203
|
+
null
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
is RoktEvent.InitComplete -> {
|
|
207
|
+
eventName = "InitComplete"
|
|
208
|
+
params.putString("status", event.success.toString())
|
|
209
|
+
null
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
is RoktEvent.OpenUrl -> {
|
|
213
|
+
eventName = "OpenUrl"
|
|
214
|
+
params.putString("url", event.url)
|
|
215
|
+
event.placementId
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
is RoktEvent.CartItemInstantPurchase -> {
|
|
219
|
+
eventName = "CartItemInstantPurchase"
|
|
220
|
+
params.putString("cartItemId", event.cartItemId)
|
|
221
|
+
params.putString("catalogItemId", event.catalogItemId)
|
|
222
|
+
params.putString("currency", event.currency)
|
|
223
|
+
params.putString("description", event.description)
|
|
224
|
+
params.putString("linkedProductId", event.linkedProductId)
|
|
225
|
+
params.putDouble("totalPrice", event.totalPrice)
|
|
226
|
+
params.putInt("quantity", event.quantity)
|
|
227
|
+
params.putDouble("unitPrice", event.unitPrice)
|
|
228
|
+
event.placementId
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
else -> {
|
|
232
|
+
eventName = "Unknown"
|
|
233
|
+
null
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
placementId?.let { params.putString("placementId", it) }
|
|
238
|
+
params.putString("event", eventName)
|
|
239
|
+
viewName?.let { params.putString("viewName", it) }
|
|
240
|
+
sendEvent(reactContext, "RoktEvents", params)
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
eventSubscriptions[viewName.orEmpty()] = job
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
companion object {
|
|
248
|
+
const val MAX_LISTENERS = 5
|
|
249
|
+
const val MODULE_NAME = "RNMPRokt"
|
|
250
|
+
}
|
|
251
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
package com.mparticle.react.rokt
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Arguments
|
|
4
|
+
import com.facebook.react.bridge.ReactContext
|
|
5
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
6
|
+
import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
7
|
+
import com.mparticle.rokt.RoktEmbeddedView
|
|
8
|
+
import com.mparticle.rokt.RoktLayoutDimensionCallBack
|
|
9
|
+
|
|
10
|
+
class RoktLayoutViewManagerImpl {
|
|
11
|
+
companion object {
|
|
12
|
+
const val REACT_CLASS = "RoktNativeLayout"
|
|
13
|
+
const val EVENT_HEIGHT_CHANGED = "onLayoutHeightChanged"
|
|
14
|
+
const val EVENT_MARGIN_CHANGED = "onLayoutMarginChanged"
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
fun getName(): String = REACT_CLASS
|
|
18
|
+
|
|
19
|
+
fun createViewInstance(reactContext: ThemedReactContext): RoktEmbeddedView {
|
|
20
|
+
val widget = RoktEmbeddedView(reactContext)
|
|
21
|
+
setUpWidgetListeners(widget)
|
|
22
|
+
return widget
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
fun setPlaceholderName(
|
|
26
|
+
view: RoktEmbeddedView?,
|
|
27
|
+
value: String?,
|
|
28
|
+
) {
|
|
29
|
+
view?.tag = value
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private fun setUpWidgetListeners(widget: RoktEmbeddedView) {
|
|
33
|
+
widget.dimensionCallBack =
|
|
34
|
+
object : RoktLayoutDimensionCallBack {
|
|
35
|
+
override fun onHeightChanged(height: Int) {
|
|
36
|
+
changeHeight(widget.context as ReactContext, height, widget.id)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
override fun onMarginChanged(
|
|
40
|
+
start: Int,
|
|
41
|
+
top: Int,
|
|
42
|
+
end: Int,
|
|
43
|
+
bottom: Int,
|
|
44
|
+
) {
|
|
45
|
+
changeMargin(widget.context as ReactContext, widget.id, start, top, end, bottom)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
fun changeHeight(
|
|
51
|
+
context: ReactContext,
|
|
52
|
+
height: Int,
|
|
53
|
+
id: Int,
|
|
54
|
+
) {
|
|
55
|
+
val event = Arguments.createMap()
|
|
56
|
+
event.putString("height", height.toString())
|
|
57
|
+
context
|
|
58
|
+
.getJSModule(RCTEventEmitter::class.java)
|
|
59
|
+
.receiveEvent(id, EVENT_HEIGHT_CHANGED, event)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
fun changeMargin(
|
|
63
|
+
context: ReactContext,
|
|
64
|
+
id: Int,
|
|
65
|
+
start: Int,
|
|
66
|
+
top: Int,
|
|
67
|
+
end: Int,
|
|
68
|
+
bottom: Int,
|
|
69
|
+
) {
|
|
70
|
+
val event = Arguments.createMap()
|
|
71
|
+
event.putString("marginLeft", start.toString())
|
|
72
|
+
event.putString("marginTop", top.toString())
|
|
73
|
+
event.putString("marginRight", end.toString())
|
|
74
|
+
event.putString("marginBottom", bottom.toString())
|
|
75
|
+
context
|
|
76
|
+
.getJSModule(RCTEventEmitter::class.java)
|
|
77
|
+
.receiveEvent(id, EVENT_MARGIN_CHANGED, event)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
package com.mparticle.react.rokt
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
import com.facebook.react.bridge.ReactMethod
|
|
5
|
+
import com.facebook.react.bridge.ReadableMap
|
|
6
|
+
import com.facebook.react.bridge.ReadableType
|
|
7
|
+
import com.facebook.react.bridge.UiThreadUtil
|
|
8
|
+
import com.facebook.react.uimanager.UIManagerHelper
|
|
9
|
+
import com.mparticle.MParticle
|
|
10
|
+
import com.mparticle.WrapperSdk
|
|
11
|
+
import com.mparticle.react.NativeMPRoktSpec
|
|
12
|
+
import com.mparticle.rokt.RoktEmbeddedView
|
|
13
|
+
import com.mparticle.internal.Logger
|
|
14
|
+
import java.lang.ref.WeakReference
|
|
15
|
+
import java.util.concurrent.CountDownLatch
|
|
16
|
+
|
|
17
|
+
class MPRoktModule(
|
|
18
|
+
private val reactContext: ReactApplicationContext,
|
|
19
|
+
) : NativeMPRoktSpec(reactContext) {
|
|
20
|
+
|
|
21
|
+
private val impl = MPRoktModuleImpl(reactContext)
|
|
22
|
+
|
|
23
|
+
override fun getName(): String = impl.getName()
|
|
24
|
+
|
|
25
|
+
@ReactMethod
|
|
26
|
+
override fun selectPlacements(
|
|
27
|
+
identifier: String,
|
|
28
|
+
attributes: ReadableMap?,
|
|
29
|
+
placeholders: ReadableMap?,
|
|
30
|
+
roktConfig: ReadableMap?,
|
|
31
|
+
fontFilesMap: ReadableMap?,
|
|
32
|
+
) {
|
|
33
|
+
if (identifier.isBlank()) {
|
|
34
|
+
Logger.warning("selectPlacements failed. identifier cannot be empty")
|
|
35
|
+
return
|
|
36
|
+
}
|
|
37
|
+
MParticle.getInstance()?.Rokt()?.events(identifier)?.let {
|
|
38
|
+
impl.startRoktEventListener(it, reactContext.currentActivity, identifier)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Process placeholders for Fabric
|
|
42
|
+
val placeholdersMap = processPlaceholders(placeholders)
|
|
43
|
+
val config = roktConfig?.let { impl.buildRoktConfig(it) }
|
|
44
|
+
|
|
45
|
+
MParticle.getInstance()?.Rokt()?.selectPlacements(
|
|
46
|
+
identifier = identifier,
|
|
47
|
+
attributes = impl.readableMapToMapOfStrings(attributes),
|
|
48
|
+
callbacks = impl.createRoktCallback(),
|
|
49
|
+
embeddedViews = placeholdersMap,
|
|
50
|
+
fontTypefaces = null, // TODO
|
|
51
|
+
config = config,
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@ReactMethod
|
|
56
|
+
override fun purchaseFinalized(
|
|
57
|
+
placementId: String,
|
|
58
|
+
catalogItemId: String,
|
|
59
|
+
success: Boolean,
|
|
60
|
+
) {
|
|
61
|
+
impl.purchaseFinalized(placementId, catalogItemId, success)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Process placeholders from ReadableMap to a map of Widgets for use with Rokt.
|
|
67
|
+
* This method handles the Fabric-specific view resolution.
|
|
68
|
+
*/
|
|
69
|
+
private fun processPlaceholders(placeholders: ReadableMap?): Map<String, WeakReference<RoktEmbeddedView>> {
|
|
70
|
+
val placeholdersMap = HashMap<String, WeakReference<RoktEmbeddedView>>()
|
|
71
|
+
|
|
72
|
+
if (placeholders != null) {
|
|
73
|
+
// Use CountDownLatch to wait for UI thread processing
|
|
74
|
+
val latch = CountDownLatch(1)
|
|
75
|
+
|
|
76
|
+
// Run view resolution on UI thread
|
|
77
|
+
UiThreadUtil.runOnUiThread {
|
|
78
|
+
try {
|
|
79
|
+
val iterator = placeholders.keySetIterator()
|
|
80
|
+
while (iterator.hasNextKey()) {
|
|
81
|
+
val key = iterator.nextKey()
|
|
82
|
+
try {
|
|
83
|
+
// Get the tag value as an integer
|
|
84
|
+
val reactTag =
|
|
85
|
+
when {
|
|
86
|
+
placeholders.getType(key) == ReadableType.Number ->
|
|
87
|
+
placeholders.getDouble(key).toInt()
|
|
88
|
+
|
|
89
|
+
else -> {
|
|
90
|
+
Logger.warning("Invalid view tag for key: $key")
|
|
91
|
+
continue
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Get the UIManager for this specific tag
|
|
96
|
+
val uiManager =
|
|
97
|
+
UIManagerHelper.getUIManagerForReactTag(reactContext, reactTag)
|
|
98
|
+
if (uiManager == null) {
|
|
99
|
+
Logger.warning("UIManager not found for tag: $reactTag")
|
|
100
|
+
continue
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Resolve the view using the manager (now on UI thread)
|
|
104
|
+
val view = uiManager.resolveView(reactTag)
|
|
105
|
+
if (view is RoktEmbeddedView) {
|
|
106
|
+
placeholdersMap[key] = WeakReference(view)
|
|
107
|
+
Logger.debug("Successfully found Widget for key: $key with tag: $reactTag")
|
|
108
|
+
} else {
|
|
109
|
+
Logger.warning("View with tag $reactTag is not a Widget: ${view?.javaClass?.simpleName}")
|
|
110
|
+
}
|
|
111
|
+
} catch (e: Exception) {
|
|
112
|
+
Logger.warning("Error processing placeholder for key $key: ${e.message}")
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
} finally {
|
|
116
|
+
latch.countDown()
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
try {
|
|
121
|
+
// Wait for UI thread to finish processing
|
|
122
|
+
latch.await()
|
|
123
|
+
} catch (e: InterruptedException) {
|
|
124
|
+
Logger.warning("Interrupted while waiting for UI thread: ${e.message}")
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return placeholdersMap
|
|
129
|
+
}
|
|
130
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
package com.mparticle.react.rokt
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.uimanager.SimpleViewManager
|
|
4
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
5
|
+
import com.facebook.react.uimanager.annotations.ReactProp
|
|
6
|
+
import com.facebook.react.viewmanagers.RoktNativeLayoutManagerInterface
|
|
7
|
+
import com.mparticle.rokt.RoktEmbeddedView
|
|
8
|
+
|
|
9
|
+
class RoktLayoutViewManager : SimpleViewManager<RoktEmbeddedView>(),
|
|
10
|
+
RoktNativeLayoutManagerInterface<RoktEmbeddedView> {
|
|
11
|
+
private val impl = RoktLayoutViewManagerImpl()
|
|
12
|
+
|
|
13
|
+
override fun getName(): String = impl.getName()
|
|
14
|
+
|
|
15
|
+
override fun createViewInstance(reactContext: ThemedReactContext): RoktEmbeddedView =
|
|
16
|
+
impl.createViewInstance(reactContext)
|
|
17
|
+
|
|
18
|
+
@ReactProp(name = "placeholderName")
|
|
19
|
+
override fun setPlaceholderName(view: RoktEmbeddedView?, value: String?) {
|
|
20
|
+
impl.setPlaceholderName(view, value)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
package com.mparticle.react
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
5
|
+
import com.facebook.react.bridge.ReadableMap
|
|
6
|
+
|
|
7
|
+
abstract class NativeMPRoktSpec(
|
|
8
|
+
reactContext: ReactApplicationContext,
|
|
9
|
+
) : ReactContextBaseJavaModule(reactContext) {
|
|
10
|
+
companion object {
|
|
11
|
+
private const val MODULE_NAME = "RNMPRokt"
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
override fun getName(): String = MODULE_NAME
|
|
15
|
+
|
|
16
|
+
abstract fun selectPlacements(
|
|
17
|
+
identifier: String,
|
|
18
|
+
attributes: ReadableMap?,
|
|
19
|
+
placeholders: ReadableMap?,
|
|
20
|
+
roktConfig: ReadableMap?,
|
|
21
|
+
fontFilesMap: ReadableMap?,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
abstract fun purchaseFinalized(
|
|
25
|
+
placementId: String,
|
|
26
|
+
catalogItemId: String,
|
|
27
|
+
success: Boolean,
|
|
28
|
+
)
|
|
29
|
+
}
|