feat(rokt): add setSession/getSession with optional sessionToken - #816
Conversation
📦 SDK Size Impact ReportMeasures how much the SDK adds to an app's size (with-SDK minus without-SDK).
➡️ SDK size impact change is minimal. Raw measurementsTarget branch (main): {"baseline_app_size_kb":84,"baseline_executable_size_bytes":75464,"with_sdk_app_size_kb":1936,"with_sdk_executable_size_bytes":76312,"sdk_impact_kb":1852,"sdk_executable_impact_bytes":848,"xcframework_size_kb":6672}This PR: {"baseline_app_size_kb":84,"baseline_executable_size_bytes":75464,"with_sdk_app_size_kb":1940,"with_sdk_executable_size_bytes":76312,"sdk_impact_kb":1856,"sdk_executable_impact_bytes":848,"xcframework_size_kb":6692} |
PR SummaryMedium Risk Overview The Rokt kit forwards complete sessions to Rokt iOS SDK 5.4 ( Core SDK behavior: The Example app adds a hybrid WebView demo ( Tests cover kit validation, Reviewed by Cursor Bugbot for commit 2088e32. Bugbot is set up for automated code reviews on this repo. Configure here. |
Expose MPRoktSession handoff (id + optional JWT) for native ↔ WebView continuity, matching Web launcherOptions. Kit seeds Rokt.setSession when a token is present and falls back to setSessionId for id-only.
fc31e6f to
bd05c1a
Compare
Keep native WebView handoff ordered so the session is seeded before the next placement forward.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ 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 9a35bbf. Configure here.
…rokt-session-token-handoff # Conflicts: # UnitTests/ObjCTests/MPRoktTests.m
📝 WalkthroughWalkthroughThe SDK adds ChangesRokt session handoff
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant ViewController
participant MPRokt
participant RoktHybridWebViewController
participant WKWebView
participant mParticleWebSDK
ViewController->>MPRokt: getSession
MPRokt-->>ViewController: return MPRoktSession
ViewController->>RoktHybridWebViewController: initialize with session
RoktHybridWebViewController->>WKWebView: inject __ROKT_HANDOFF
WKWebView->>mParticleWebSDK: initialize with launcherOptions
mParticleWebSDK->>WKWebView: post roktSession message
WKWebView->>RoktHybridWebViewController: deliver session payload
RoktHybridWebViewController->>MPRokt: setSession and selectPlacements
Suggested reviewers: Merge Risk: 🟡 Moderate · up to Session tokens can be exposed through the example UI and logs, and reading a session immediately after setting it can return stale state. Resolve these behaviors before merging. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Note
Quiet mode is enabled, so only the most important comments were posted inline. Other review comments are grouped below.
🟡 Other comments (1)
Kits/rokt/rokt/Sources/mParticle-Rokt/MPKitRokt.m-608-608 (1)
608-608: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick winClear the full session before applying an ID-only session.
MPSetRoktSessionIdforwards to the deprecated ID-only API, which does not clear the transaction token. AfterRokt.setSession:,getSessioncan return the previous token-bearing session. CallRokt.clearSessionbeforeMPSetRoktSessionId(sessionId), and add a full-session → ID-only →getSessiontransition test.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: QUIET
Plan: Advanced
Run ID: d9e6e3d4-1470-4cc5-9514-ced5d7cf58d2
📒 Files selected for processing (17)
Example/PodfileExample/mParticleExample.xcodeproj/project.pbxprojExample/mParticleExample/AppDelegate.mExample/mParticleExample/RoktHybridWebViewController.hExample/mParticleExample/RoktHybridWebViewController.mExample/mParticleExample/ViewController.mExample/mParticleExample/rokt-hybrid.htmlKits/rokt/rokt/Sources/mParticle-Rokt/MPKitRokt.mKits/rokt/rokt/Tests/mParticle-RoktObjCTests/mParticle_RoktTests.mKits/rokt/rokt/mParticle-Rokt.podspecUnitTests/ObjCTests/MPRoktTests.mmParticle-Apple-SDK.xcodeproj/project.pbxprojmParticle-Apple-SDK/Include/MPRokt.hmParticle-Apple-SDK/Include/MPRoktSession.hmParticle-Apple-SDK/Include/mParticle.hmParticle-Apple-SDK/MPRokt.mmParticle-Apple-SDK/MPRoktSession.m
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
mParticle-Apple-SDK/MPRokt.m (1)
222-222: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winPreserve read-after-write behavior for
getSession.Line 222 forwards
setSession:asynchronously, butgetSessionreads the kit immediately. A caller that invokessetSession:and thengetSessioncan receive the previous session ornil. Serialize session reads with writes, and add coverage for this immediate sequence.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: QUIET
Plan: Enterprise
Run ID: 79d310cf-317b-48e1-bb9d-a4291ab67924
📒 Files selected for processing (5)
Example/mParticleExample/rokt-hybrid.htmlKits/rokt/rokt/Sources/mParticle-Rokt/MPKitRokt.mKits/rokt/rokt/Tests/mParticle-RoktObjCTests/mParticle_RoktTests.mmParticle-Apple-SDK/Include/MPRokt.hmParticle-Apple-SDK/MPRokt.m
Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.
There was a problem hiding this comment.
Note
Quiet mode is enabled, so only the most important comments were posted inline. Other review comments are grouped below.
🟡 Other comments (1)
Example/mParticleExample/RoktHybridWebViewController.m-127-130 (1)
127-130: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winReject invalid expiration strings.
numberValue:converts a nonnumericexpiresAtstring to@0. Line 127 accepts that value, so the controller constructsMPRoktSessionand selects placements for malformed session data. Parse string values strictly and reject values that are not valid epoch-millisecond integers before creating the session.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: QUIET
Plan: Enterprise
Run ID: 979394ed-aa68-4d4e-aa2a-7e94d0633e4e
📒 Files selected for processing (7)
Example/mParticleExample/RoktHybridWebViewController.mKits/rokt/rokt/Sources/mParticle-Rokt/MPKitRokt.mKits/rokt/rokt/Tests/mParticle-RoktObjCTests/mParticle_RoktTests.mUnitTests/ObjCTests/MPRoktTests.mmParticle-Apple-SDK/Include/MPRokt.hmParticle-Apple-SDK/Include/MPRoktSession.hmParticle-Apple-SDK/MPRokt.m
Included review availability: Your plan provides up to 12 included reviews per hour; 10 remain after this review.

Background
What Has Changed
Screenshots/Video
Checklist
Additional Notes
Reference Issue (For employees only. Ignore if you are an outside contributor)
Summary by CodeRabbit