feat: add customBaseURL CNAME support to NetworkOptions#701
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>
PR SummaryMedium Risk Overview Updates Expands androidTests to cover custom-base URL routing, validation (HTTPS/malformed), and JSON round-trips, and adds ProGuard Reviewed by Cursor Bugbot for commit 42fff2a. 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 96950e7. Configure here.
| @NonNull | ||
| public Builder setCustomBaseURL(@NonNull String customBaseURL) { | ||
| try { | ||
| java.net.URL parsed = new java.net.URL(customBaseURL); |
There was a problem hiding this comment.
Done — imported java.net.URL and java.net.MalformedURLException in 42fff2a.
| host.append(":").append(parsed.getPort()); | ||
| } | ||
| this.customBaseURL = host.toString(); | ||
| } catch (java.net.MalformedURLException e) { |
There was a problem hiding this comment.
nit: import the class here as well.
| -keep class com.mparticle.internal.ConfigManager { | ||
| public com.mparticle.networking.NetworkOptions getNetworkOptions(); | ||
| } |
denischilik
left a comment
There was a problem hiding this comment.
Looks good to me but I think customBaseURL lost during database serialization round-trip should be addressed
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
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
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(unsupported with CDN routing)./config/v4/<key>/config,/nativeevents/v2/<key>/events,/identity/v1/<path>,/nativeevents/v1/identity/<key>/alias,/nativeevents/v1/<key>/audience.android-core/proguard.pro: adds-keeprules forMParticle$InternalandConfigManager.getNetworkOptions()so downstream kits can navigate the public extension surface after R8 minification.Downstream
The Rokt kit reads
NetworkOptions.customBaseURLand forwards it to the Rokt SDK: mparticle-integrations/mparticle-android-integration-rokt#143Test plan
Added 9 androidTest cases in
MParticleBaseClientImplTest:/config/v4//nativeevents/v2//identity/v1//nativeevents/v1/identity//nativeevents/v1/<key>/audienceLocally:
:android-core:testDebugUnitTestpasses (existing unit suite);:android-core:compileDebugAndroidTestKotlincompiles. AndroidTest suite runs on CI emulator.🤖 Generated with Claude Code