feat: add customBaseURL CNAME support to NetworkOptions#702
Conversation
Adds NetworkOptions.Builder.setCustomBaseURL(String) which routes all mParticle endpoint traffic (config, events, identity, alias, audience) through a single HTTPS CNAME host. When set, customBaseURL takes priority over individual domain mappings and rewrites paths to match CDN routing: /config/v4/, /nativeevents/v2/, /identity/v1/, /nativeevents/v1/identity/, /nativeevents/v1/<key>/audience. Also adds R8 keep rules for MParticle$Internal and ConfigManager.getNetworkOptions() so kits can read customBaseURL after minification. The Rokt kit reads NetworkOptions.customBaseURL and forwards it to the Rokt SDK: mparticle-integrations/mparticle-android-integration-rokt#143 Mirrors iOS work from mparticle-apple-sdk#760. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
When the integrating app sets a custom CNAME on MParticleOptions via NetworkOptions.customBaseURL, forward it to the Rokt SDK so Rokt traffic routes through the same first-party domain. No-op when customBaseURL is unset, empty, or MParticle is uninitialized. Mirrors the iOS Rokt kit behavior added in mparticle-apple-sdk#760. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
PR SummaryMedium Risk Overview Updates Updates the Rokt kit to forward the configured Reviewed by Cursor Bugbot for commit 8935e6b. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes 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 e75def6. Configure here.
NetworkOptions.toJson() and withNetworkOptions(String) did not include customBaseURL, so any value was silently dropped when UploadSettings serialized NetworkOptions to the upload database. Events and alias uploads read back NetworkOptions without customBaseURL and routed to the default mParticle endpoints instead of the partner CNAME. Also: - Extract the customBaseURL/DomainMapping host-resolution branch out of getUrl() into a private resolveHost() helper plus a small ResolvedHost value type, lowering getUrl()'s cyclomatic complexity. - Switch java.net.URL / java.net.MalformedURLException to imports. - Add two androidTest cases covering the round-trip. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|




Summary
Port of #701 onto
workstation/6.0-Release, with the Rokt kit passthrough included since kits now live in this repo.Adds
NetworkOptions.Builder.setCustomBaseURL(String)which routes all mParticle endpoint traffic (config, events, identity, alias, audience) through a single HTTPS CNAME host. Mirrors iOS work from mparticle-apple-sdk#760.What changed
Core (android-core):
NetworkOptions: newcustomBaseURLfield + getter;Builder.setCustomBaseURL(@NonNull String)validates HTTPS scheme, requires a host, and stores host(:port) only — path/query/fragment ignored.MParticleBaseClientImpl.getUrl: whencustomBaseURLis set:DomainMappingandoverridesSubdirectory./config/v4/<key>/config,/nativeevents/v2/<key>/events,/identity/v1/<path>,/nativeevents/v1/identity/<key>/alias,/nativeevents/v1/<key>/audience.proguard.pro: adds-keeprules forMParticle$InternalandConfigManager.getNetworkOptions()so the Rokt kit can navigate the public extension surface after R8 minification.Rokt kit (kits/rokt/rokt):
RoktKit.onKitCreate, readsMParticle.getInstance().Internal().configManager.networkOptions.customBaseURLand forwards it toRokt.setCustomBaseURL(URL("https://<host>"))beforeRokt.init.applyCustomBaseURLIfSet()method for testability.customBaseURLis null, empty, or MParticle is uninitialized.Pre-merge dependency
The Rokt kit's
com.rokt:roktsdk:4.14.0does not yet exposeRokt.setCustomBaseURL(URL). A follow-up commit will bump the Rokt SDK to the 5.x release containing that API (currently onworkstation/5.0.0andmaininROKT/sdk-android-source, see PR #993). The kit change itself is correct against the upcoming API.Test plan
MParticleBaseClientImplTest(HTTPS validation, path/query stripping, port preservation, malformed-URL rejection, and per-endpoint URL routing).kits/rokt/rokt'sRoktKitTestsfor the kit passthrough (forwards URL, preserves port, no-op when null/empty/uninitialized).:android-core:testDebugUnitTestpasses locally;:android-core:compileDebugAndroidTestKotlincompiles.:kits:android-rokt:rokt:testDebugUnitTestpasses locally against a SNAPSHOT roktsdk (60 tests, 0 failures).🤖 Generated with Claude Code