rudderlabs / rudder-sdk-android

Android SDK for RudderStack - the Customer Data Platform for Developers.
https://www.rudderstack.com
Other
18 stars 29 forks source link

fix: prevent setting duplicate externalId types #446

Closed 1abhishekpandey closed 3 months ago

1abhishekpandey commented 3 months ago

About the issue

I observed an issue while setting the externalId's in identify event. Suppose when two identify events are made:

RudderAnalyticsUtils.analytics.identify(
    userId = "user 1",
    options = RudderOption().apply {
        putExternalId("brazeExternalID", "12345")
        putExternalId("amplitudeExternalID", "67890")
        putExternalId("adobeExternalID", "67890")
    }
)

RudderAnalyticsUtils.analytics.identify(
    userId = "user 1",
    options = RudderOption().apply {
        putExternalId("brazeExternalID", "12345-2")
        putExternalId("amplitudeExternalID", "67890-2")
        putExternalId("firebaseExternalID", "67890")
    }
)

Then the expected behaviour (as per v1 SDK) is to merge the externalId of both the identify events giving higher preference to the second identify event externalId. The final payload will look like this:

"externalId": [
    {
        "id": "12345-2",
        "type": "brazeExternalID"
    },
    {
        "id": "67890-2",
        "type": "amplitudeExternalID"
    },
    {
        "id": "67890",
        "type": "adobeExternalID"
    },
    {
        "id": "67890",
        "type": "firebaseExternalID"
    }
],

ISSUE: In v2, this wasn't the case, it was simply adding both identify externalIds values and no merging was taking place. So the externalId data was incorrect.

About the fix

We have solved the merging issues of the externalId's and added new test cases.

Type of change

sonarcloud[bot] commented 3 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud