Skip to content

Commit e02c223

Browse files
committed
feat: Introduce PlacementOptions and jointSdkSelectPlacements
- Propagate PlacementOptions and timestamps to Rokt SDK - Capture timestamp in compose scenario
1 parent 3f9087c commit e02c223

3 files changed

Lines changed: 20 additions & 1 deletion

File tree

src/main/kotlin/com/mparticle/kits/RoktConfigExtensions.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.mparticle.kits
22

3+
import com.mparticle.rokt.PlacementOptions
34
import com.mparticle.rokt.RoktConfig
45
import com.rokt.roktsdk.CacheConfig
56
import com.mparticle.rokt.CacheConfig as MpCacheConfig
@@ -30,3 +31,9 @@ fun RoktConfig.toRoktSdkConfig(): RoktSdkConfig {
3031

3132
return builder.build()
3233
}
34+
35+
// TODO: Update the mapping
36+
/*fun PlacementOptions.toRoktSdkPlacementOptions(): com.rokt.roktsdk.PlacementOptions = com.rokt.roktsdk.PlacementOptions(
37+
jointSdkSelectPlacements = this.jointSdkSelectPlacements,
38+
dynamicPerformanceMarkers = this.dynamicPerformanceMarkers,
39+
)*/

src/main/kotlin/com/mparticle/kits/RoktKit.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import com.mparticle.internal.Logger
2020
import com.mparticle.kits.KitIntegration.CommerceListener
2121
import com.mparticle.kits.KitIntegration.IdentityListener
2222
import com.mparticle.kits.KitIntegration.RoktListener
23+
import com.mparticle.rokt.PlacementOptions
2324
import com.mparticle.rokt.RoktConfig
2425
import com.mparticle.rokt.RoktEmbeddedView
2526
import com.rokt.roktsdk.Rokt
@@ -174,6 +175,7 @@ class RoktKit :
174175
fontTypefaces: MutableMap<String, WeakReference<Typeface>>?,
175176
filterUser: FilteredMParticleUser?,
176177
mpRoktConfig: RoktConfig?,
178+
placementOptions: PlacementOptions?,
177179
) {
178180
val placeholders: Map<String, WeakReference<Widget>>? = placeHolders?.mapNotNull { entry ->
179181
val widget = Widget(entry.value.get()?.context as Context)
@@ -198,6 +200,7 @@ class RoktKit :
198200
this.mpRoktEventCallback = mpRoktEventCallback
199201
val finalAttributes = prepareFinalAttributes(filterUser, attributes)
200202
val roktConfig = mpRoktConfig?.toRoktSdkConfig()
203+
// TODO: propagate the `placementOptions` to Rokt SDK after the API changes are available
201204
Rokt.execute(
202205
viewName,
203206
finalAttributes,

src/main/kotlin/com/mparticle/kits/RoktLayout.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ import androidx.compose.runtime.mutableStateOf
66
import androidx.compose.runtime.remember
77
import androidx.compose.ui.Modifier
88
import com.mparticle.MpRoktEventCallback
9+
import com.mparticle.rokt.PlacementOptions
910
import com.mparticle.rokt.RoktConfig
1011
import com.rokt.roktsdk.Rokt
12+
import com.rokt.roktsdk.RoktLayout
1113

1214
@Composable
1315
@Suppress("FunctionName")
@@ -20,9 +22,15 @@ fun RoktLayout(
2022
mpRoktEventCallback: MpRoktEventCallback? = null,
2123
config: RoktConfig? = null,
2224
) {
25+
var placementOptions: PlacementOptions? = null
2326
val instance = RoktKit.instance
2427
val resultMapState = remember { mutableStateOf<RoktResult?>(null) }
2528
if (sdkTriggered) {
29+
// Capture the timestamp when the SDK is triggered
30+
placementOptions = PlacementOptions(
31+
jointSdkSelectPlacements = System.currentTimeMillis(),
32+
dynamicPerformanceMarkers = mutableMapOf(),
33+
)
2634
LaunchedEffect(Unit) {
2735
instance?.runComposableWithCallback(
2836
HashMap(attributes),
@@ -35,7 +43,8 @@ fun RoktLayout(
3543
}
3644

3745
resultMapState.value?.let { resultMap ->
38-
com.rokt.roktsdk.RoktLayout(
46+
// TODO: Propagate the `placementOptions` to Rokt SDK after the API changes are available
47+
RoktLayout(
3948
sdkTriggered, identifier, modifier, resultMap.attributes, location,
4049
onLoad = { resultMap.callback.onLoad() },
4150
onShouldShowLoadingIndicator = { resultMap.callback.onShouldShowLoadingIndicator() },

0 commit comments

Comments
 (0)