Developers

Client SDK: Direct Url Routing

Android

This document explains the changes needed to stay compatible with the October 1st, 2024 update regarding Direct URL Routing.

You must make changes to your implementation if you currently whitelist subdomains for mparticle.com as part of your Network Security Configuration.

Please consult your Android development and security teams to determine if this update affects you, and review our Network Security Configuration docs. You must be on Android SDK version 5.57.0 or later to use this feature. If you use an earlier version, you do not need to take any action at this time. Customers using version 5.57.0 or later should review the instructions for each scenario below:

My company DOES use a CNAME to route data to mParticle

No further action is required. If you use a CNAME, you should not need to whitelist any mParticle domains.

My company DOES NOT use a CNAME to route data to mParticle, and we DO NOT whitelist subdomains using Network Security Configuration

No further action is required. If you do not whitelist subdomains via Network Security Configuration, there is no risk for data being interrupted.

My company DOES NOT use a CNAME, and we DO whitelist subdomains using Network Security Configuration

  1. To align with Android’s Network Security Configuration docs, add the following to your network-security-config.xml file.
<network-security-config>
    <domain-config cleartextTrafficPermitted="false">
        <domain includeSubdomains="true">mparticle.com</domain>
    </domain-config>
</network-security-config>

Key Points:

  • Setting cleartextTrafficPermitted="false" ensures that all traffic to mparticle.com is secured over HTTPS, preventing any unencrypted HTTP traffic.
  • Setting includeSubdomains="true" future-proofs your configuration, accommodating potential changes or additions to the mParticle SDK that might involve subdomains.
  1. Once the above has been added to your network-security-config whitelist, you can test your changes by copying the below codeblock to mimic the behavior changes starting October 1st, 2024. Make the below adjustment to your mParticle options object and test that data continues to flow properly.
// note that "[pod]" should be replaced with the geographic pod that you send data to

import com.mparticle.MParticleOptions;
import com.mparticle.network.NetworkOptions;
import com.mparticle.network.DomainMapping;

val options = MParticleOptions.builder(this)
    .credentials("REPLACE ME WITH KEY", "REPLACE ME WITH SECRET")
    .networkOptions(NetworkOptions.builder()
    .addDomainMapping(
        DomainMapping.eventsMapping("nativesdks.[pod].mparticle.com/v2", true)
        .build())
    .addDomainMapping(
        DomainMapping.identityMapping("identity.[pod].mparticle.com/v1", true)
        .build())
    .addDomainMapping(
        DomainMapping.aliasMapping("nativesdks.[pod].mparticle.com/v1/identity", true)
        .build())
    .build())
// note that "[pod]" should be replaced with the geographic pod that you send data to

import com.mparticle.MParticleOptions;
import com.mparticle.network.NetworkOptions;
import com.mparticle.network.DomainMapping;

MParticleOptions options = MParticleOptions.builder(this)
    .credentials("REPLACE ME WITH KEY", "REPLACE ME WITH SECRET")
    .networkOptions(NetworkOptions.builder()
            .addDomainMapping(DomainMapping.eventsMapping("nativesdks.[pod].mparticle.com/v2", true).build())
            .addDomainMapping(DomainMapping.identityMapping("identity.[pod].mparticle.com/v1", true).build())
            .addDomainMapping(DomainMapping.aliasMapping("nativesdks.[pod].mparticle.com/v1/identity", true).build())
            .build())
    .build();

Was this page helpful?