-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add RoktConfig support #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,9 @@ import com.mparticle.internal.Logger | |
| import com.mparticle.kits.KitIntegration.CommerceListener | ||
| import com.mparticle.kits.KitIntegration.IdentityListener | ||
| import com.mparticle.kits.KitIntegration.RoktListener | ||
| import com.mparticle.rokt.RoktConfig | ||
| import com.mparticle.rokt.RoktEmbeddedView | ||
| import com.rokt.roktsdk.CacheConfig | ||
| import com.rokt.roktsdk.Rokt | ||
| import com.rokt.roktsdk.RoktWidgetDimensionCallBack | ||
| import com.rokt.roktsdk.Widget | ||
|
|
@@ -139,7 +141,8 @@ class RoktKit : KitIntegration(), CommerceListener, IdentityListener, RoktListen | |
| mpRoktEventCallback: MParticle.MpRoktEventCallback?, | ||
| placeHolders: MutableMap<String, WeakReference<RoktEmbeddedView>>?, | ||
| fontTypefaces: MutableMap<String, WeakReference<Typeface>>?, | ||
| filterUser: FilteredMParticleUser? | ||
| filterUser: FilteredMParticleUser?, | ||
| mpRoktConfig: RoktConfig? | ||
| ) { | ||
| val placeholders: Map<String, WeakReference<Widget>>? = placeHolders?.mapNotNull { entry -> | ||
| val widget = Widget(entry.value.get()?.context as Context) | ||
|
|
@@ -184,17 +187,44 @@ class RoktKit : KitIntegration(), CommerceListener, IdentityListener, RoktListen | |
| attributes?.get(SANDBOX_MODE_ROKT)?.let { value -> | ||
| finalAttributes.put(SANDBOX_MODE_ROKT, value) | ||
| } | ||
|
|
||
| val roktConfig = mpRoktConfig?.let { mapToRoktConfig(it) } | ||
| Rokt.execute( | ||
| viewName, | ||
| finalAttributes, | ||
| this, | ||
| // Pass placeholders and fontTypefaces only if they are not empty or null | ||
| placeholders.takeIf { it?.isNotEmpty() == true }, | ||
| fontTypefaces.takeIf { it?.isNotEmpty() == true } | ||
| fontTypefaces.takeIf { it?.isNotEmpty() == true }, | ||
| roktConfig | ||
| ) | ||
| } | ||
|
|
||
| public fun mapToRoktConfig(config: RoktConfig): com.rokt.roktsdk.RoktConfig { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Mansi-mParticle I know it's merged already but wondering if this really should be public?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It shouldn't be public. I just made it public for testing and will change it back. |
||
| val colorMode = when (config.colorMode) { | ||
| RoktConfig.ColorMode.LIGHT -> com.rokt.roktsdk.RoktConfig.ColorMode.LIGHT | ||
| RoktConfig.ColorMode.DARK -> com.rokt.roktsdk.RoktConfig.ColorMode.DARK | ||
| RoktConfig.ColorMode.SYSTEM -> com.rokt.roktsdk.RoktConfig.ColorMode.SYSTEM | ||
| else -> com.rokt.roktsdk.RoktConfig.ColorMode.SYSTEM | ||
| } | ||
|
|
||
| val cacheConfig = config.cacheConfig?.cacheDurationInSeconds?.let { | ||
| CacheConfig( | ||
| cacheDurationInSeconds = it, | ||
| cacheAttributes = config.cacheConfig?.cacheAttributes | ||
| ) | ||
| } | ||
|
|
||
| val edgeToEdgeDisplay = config.edgeToEdgeDisplay | ||
|
|
||
| val builder = com.rokt.roktsdk.RoktConfig.Builder() | ||
| .colorMode(colorMode) | ||
| .edgeToEdgeDisplay(edgeToEdgeDisplay) | ||
|
|
||
| cacheConfig?.let { | ||
| builder.cacheConfig(it) | ||
| } | ||
| return builder.build() | ||
| } | ||
|
|
||
| private fun addIdentityAttributes(attributes: MutableMap<String, String>?, filterUser: FilteredMParticleUser?): MutableMap<String, String> { | ||
| val identityAttributes = mutableMapOf<String, String>() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lint rules to add these automatically would be nice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
KtLint currently isn't working in the repo from what I can tell. Bumping to version 12.3.0 of the plugin used fixes the issue but there are around 50 issues flagged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made this ticket to update KTKLint. We can prioritize it in the future for someone. It may make sense for right after or before the release once the
purchaseFinalizedAPI gets in bc I think that's the last one we need for release.