Skip to content

refactor: migrate Rokt contracts and facade ownership to rokt-kit#700

Merged
denischilik merged 23 commits into
workstation/6.0-Releasefrom
feat/migrate-rokt-types-1
May 19, 2026
Merged

refactor: migrate Rokt contracts and facade ownership to rokt-kit#700
denischilik merged 23 commits into
workstation/6.0-Releasefrom
feat/migrate-rokt-types-1

Conversation

@denischilik
Copy link
Copy Markdown

Background

This change completes the Rokt ownership migration to the rokt-kit module so Rokt-specific contracts no longer leak through android-core and android-kit-base.
It also removes fragile reflection in the Rokt enablement check to improve runtime reliability.

What Has Changed

  • Moved Rokt facade and related Rokt view/callback contracts into kits/rokt/rokt
  • Replaced mParticle wrapper contracts with native com.rokt.roktsdk types across the Rokt kit flow
  • Removed RoktKitApi bridging from core kit manager contracts
  • Updated Rokt request and bridge flow to resolve and execute through kit-owned components only
  • Reworked isEnabled resolution to use a callback provider instead of reflection and updated unit tests accordingly

Screenshots/Video

N/A

Checklist

  • I have performed a self-review of my own code.
  • I have made corresponding changes to the documentation.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have tested this locally.

Additional Notes

This PR is intentionally scoped to internal ownership/type migration for Rokt integration and related reliability fixes.

Stop instantiating and storing Rokt inside android-core MParticle, and create it from rokt-kit extensions instead to start decoupling Rokt object ownership from the core SDK.
Relocate the Rokt facade class and its unit tests from android-core to the rokt kit so Rokt-specific API ownership continues shifting out of core while preserving current behavior and test coverage.
Use a single helper in the Rokt facade to resolve the kit API for all operations, making the upcoming decoupling from the legacy roktKitApi chain incremental and safer.
Remove the mParticle RoktEvent wrapper and return native Rokt SDK events directly to simplify the event pipeline and reduce duplicate mapping logic.
Remove the mParticle unload reason wrapper and pass Rokt SDK unload reasons through directly to simplify callback handling and eliminate redundant mapping.
Replace MpRoktEventCallback with the native RoktCallback across the rokt kit and tests to remove callback wrappers and simplify callback delegation.
Replace the local PlacementOptions wrapper with the native Rokt SDK PlacementOptions across the rokt kit and remove the now-redundant conversion layer.
Replace mParticle RoktConfig and CacheConfig wrappers with native Rokt SDK config types and remove the now-unnecessary config conversion layer and tests.
Relocate Rokt, RoktEmbeddedView, RoktLayoutDimensionCallBack, and RoktTest into com.mparticle.kits to keep kit-owned types co-located and simplify package boundaries.
Avoid runtime method lookup for isEnabled by injecting an explicit enablement callback and wiring it to core callbacks with a safe opt-out fallback, preserving behavior under obfuscation.
@denischilik denischilik requested a review from a team as a code owner May 13, 2026 17:00
@cursor
Copy link
Copy Markdown

cursor Bot commented May 13, 2026

PR Summary

Medium Risk
Moderate risk due to breaking API/package changes around the Rokt integration and rewritten bridge/enablement wiring; runtime behavior depends on correct kit resolution and new isEnabled() plumbing.

Overview
Completes the Rokt ownership migration by removing Rokt-specific API surface from android-core and android-kit-base (drops MParticle.Rokt(), RoktKitApi, and the com.mparticle.rokt wrapper types/callbacks) and shifting the public facade into the kits/rokt module.

The Rokt flow now uses native com.rokt.roktsdk types end-to-end and resolves/executes requests via a kit-owned bridge (RoktKitBridge + RoktKitRequestHelper) rather than core kit-manager bridging.

Enablement checks are reworked to rely on a new KitManager.isEnabled() delegation (implemented in KitFrameworkWrapper/KitManagerImpl) instead of previous mechanisms, and tests/build tooling are updated accordingly (including added test deps in rokt kit and a small task-name capitalization fix in MavenCentralPublish).

Reviewed by Cursor Bugbot for commit 4aec17d. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment thread kits/rokt/rokt/src/main/kotlin/com/mparticle/kits/MParticleRoktExtensions.kt Outdated
Add isEnabled to KitManager and use it from the Rokt facade so enablement is resolved through a stable kit-layer API without reflection or config manager coupling.
Clean up stale imports in KitManagerImplTest so android-kit-base ktlint test source checks pass in CI.
Comment thread kits/rokt/rokt/src/main/kotlin/com/mparticle/kits/MParticleRokt.kt Outdated
Replace replaceFirstChar in buildSrc for older Kotlin compatibility and address rokt ktlint violations by suppressing Java-style accessor naming and wrapping long warning messages.
Comment thread kits/rokt/rokt/src/main/kotlin/com/mparticle/kits/MParticleRokt.kt
Comment thread kits/rokt/rokt/src/main/kotlin/com/mparticle/kits/MParticleRokt.kt
Comment thread kits/rokt/rokt/src/main/kotlin/com/mparticle/kits/MParticleRoktExtensions.kt Outdated
Comment thread kits/rokt/rokt/src/main/kotlin/com/mparticle/kits/Rokt.kt
Comment thread kits/rokt/rokt/src/main/kotlin/com/mparticle/kits/Rokt.kt Outdated
Keep only the no-arg public Rokt accessor with explicit start precondition, restore original public method documentation text, and make prepareAttributesAsync internal per review feedback.
Comment thread kits/rokt/rokt/src/main/kotlin/com/mparticle/kits/Rokt.kt
Update MParticleRokt package to com.mparticle.kits so declaration matches the file location and resolves package/path review feedback.
@denischilik denischilik requested a review from thomson-t May 14, 2026 13:43
Comment thread kits/rokt/rokt/src/main/kotlin/com/mparticle/kits/MParticleRokt.kt
Keep a synchronized singleton Rokt instance in MParticleRokt to avoid repeated allocations while preserving the explicit start precondition.
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 4aec17d. Configure here.

Comment thread kits/rokt/rokt/src/main/kotlin/com/mparticle/kits/MParticleRokt.kt

@Suppress("FunctionName")
@JvmStatic
fun Rokt(): Rokt {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comes across slightly confusing as it's accessed like MParticleRokt.Rokt() - How about MParticleRokt.getInstance() or similar?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We access it with MParticle.getInstance().Rokt() like before. That is extension to MParticle class

* Java-friendly accessors for the legacy Rokt API object.
*/
object MParticleRokt {
@Volatile
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this? rokt is only read inside synchronized(this) at line 20

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this code, @volatile is used to ensure correct lazy singleton initialization in a multithreaded environment.

Comment thread kits/rokt/rokt/src/main/kotlin/com/mparticle/kits/MParticleRokt.kt
Comment thread kits/rokt/rokt/src/main/kotlin/com/mparticle/kits/MParticleRokt.kt
Copy link
Copy Markdown
Contributor

@BrandonStalnaker BrandonStalnaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@denischilik denischilik merged commit 99dead8 into workstation/6.0-Release May 19, 2026
22 of 23 checks passed
@denischilik denischilik deleted the feat/migrate-rokt-types-1 branch May 19, 2026 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants