Skip to content

feat: pass mParticle CNAME through to Rokt SDK#143

Merged
thomson-t merged 2 commits into
mainfrom
feat/cname-passthrough
May 14, 2026
Merged

feat: pass mParticle CNAME through to Rokt SDK#143
thomson-t merged 2 commits into
mainfrom
feat/cname-passthrough

Conversation

@jamesnrokt
Copy link
Copy Markdown
Collaborator

Summary

  • In RoktKit.onKitCreate, reads MParticle.getInstance().Internal().configManager.networkOptions.customBaseURL and forwards it to Rokt.setCustomBaseURL(URL("https://<host>")) before Rokt.init.
  • Logic extracted into a private applyCustomBaseURLIfSet() method for testability.
  • No-op when customBaseURL is null, empty, or MParticle is uninitialized.
  • Mirrors iOS behavior from mparticle-apple-sdk PR #760.

Pre-merge dependencies

This PR requires two upstream releases before it can be merged/published:

  1. com.rokt:roktsdk release containing Rokt.setCustomBaseURL(URL) (currently on workstation/5.0.0 in sdk-android-source).
  2. com.mparticle:android-core release containing NetworkOptions.customBaseURL plus R8 keep rules for MParticle$Internal and ConfigManager.getNetworkOptions().

A follow-up commit will bump com.rokt:roktsdk from 4.14.2 to the released 5.x version once available.

Test plan

Added 6 unit tests in RoktKitTests.kt:

  • forwards `https://` URL when `customBaseURL` is set
  • preserves port when `customBaseURL` contains a port
  • no-op when `customBaseURL` is null
  • no-op when `customBaseURL` is empty string
  • no-op when `NetworkOptions` is null
  • no-op when `MParticle.getInstance()` is null

All 60 unit tests pass locally.

🤖 Generated with Claude Code

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>
thomson-t
thomson-t previously approved these changes May 13, 2026
4.14.3 exposes Rokt.setCustomBaseURL(URL) used by the new CNAME
passthrough in onKitCreate.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jamesnrokt
Copy link
Copy Markdown
Collaborator Author

CI failures are expected as the mParticle Core needs to be released in order to reference customBaseURL - Usual chicken and egg problem when adding net new methods used by kits

@thomson-t thomson-t merged commit ff28ccd into main May 14, 2026
12 of 16 checks passed
@thomson-t thomson-t deleted the feat/cname-passthrough branch May 14, 2026 14:00
thomson-t added a commit to mParticle/mparticle-android-sdk that referenced this pull request May 14, 2026
* feat: add customBaseURL CNAME support to NetworkOptions

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>

* fix: persist customBaseURL across NetworkOptions JSON round-trip

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>

* test(android-core): cover custom base URL upload storage

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Thomson Thomas <thomson.thomas@rokt.com>
jamesnrokt added a commit to mParticle/mparticle-android-sdk that referenced this pull request May 20, 2026
* feat: add customBaseURL CNAME support to NetworkOptions

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>

* feat: pass mParticle CNAME through to Rokt SDK

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>

* fix: persist customBaseURL across NetworkOptions JSON round-trip

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>

* Bump Rokt dependency version

* fix: only warn on domain-mapping conflict when mapping is non-default

NetworkOptionsManager.validateAndResolve auto-populates a default
DomainMapping for every endpoint, so the previous check fired the
"customBaseURL is set; domain mapping for X is ignored" warning on
every getUrl() call for every endpoint — even when the integrator
never configured a custom mapping. Compare against the default URL
so the warning only fires for genuinely user-configured mappings
that conflict with customBaseURL.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

2 participants