Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Device ID Appending Issue - Device ID sometimes appended with an 'R #148

Closed
initishbhatt opened this issue Oct 9, 2023 · 8 comments
Closed

Comments

@initishbhatt
Copy link

The Amplitude Kotlin SDK occasionally generates a random device ID with R , which affects approximately 30% of the devices. The expected behaviour is for the device ID to be registered as 'xxxx-xxxx-xxxx-xxxx,' but it is sometimes recorded as 'xxxx-xxxx-xxxx-xxxxR.'

Expected Behavior

The device ID should consistently follow the format 'xxxx-xxxx-xxxx-xxxx' without any additional characters like 'R' appended at the end.

Current Behavior

In some cases, the device ID recorded by the Amplitude Kotlin SDK contains an extra 'R' character, causing discrepancies in the data.

Possible Solution

Steps to Reproduce

Steps to reproduce the behavior:

  1. Use the Amplitude Kotlin SDK in an Android application.
  2. Collect data from various devices.
  3. Observe that approximately 30% of the devices have device IDs with the 'R' character appended.

Environment

  • SDK Version: 1.7.1
  • Device: All devices
  • Android SDK Version - 33
  • Gradle Version -8.0.2
  • KGP - 1.9.0
@justin-fiedler
Copy link
Contributor

justin-fiedler commented Oct 10, 2023

Hi @initishbhatt thanks for using Amplitude.

I reviewed the code and R is appended to the device ID anytime it is randomly generated based on a UUID vs AppSetId or ADID.

I am not sure the exact reason behind this logic and the original developer is currently out of town. I would like to check with him before making a change.

In the meantime, can you please provide more details on the issues caused by the extra "R"? Is it causing an error?

Thanks again

@initishbhatt
Copy link
Author

Hi @justin-fiedler thanks for looking into it. There is no error on the app but we have data discrepancies as other tools and sdks that we use have the correct device ID while amplitude has randomly generated one.
We pass the same device id to all the tools and SDK's but the Amplitude SDK is generating random ones for some users.

@liuyang1520
Copy link
Collaborator

Hi @initishbhatt , thanks for reporting this!

I have synced with @qingzhuozhen offline on the behavior, the R suffix is for distinguishing whether the device id is generated by the SDK, in the case that previous device id or adid/appsetId is absent. Could you share more on "We pass the same device id to all the tools and SDK"?

Thanks!

@ronnieotieno
Copy link

ronnieotieno commented Oct 17, 2023

Hi @liuyang1520 Nitish colleague here.
We are providing the amplitude when launching the app and setting the device id then.

fun provideAmplitude( ): Amplitude {
            val amplitude = Amplitude(
                    Configuration(
                         // configuration
                    ),
            )
            amplitude.setDeviceId("id here")
            return amplitude
        }

@liuyang1520
Copy link
Collaborator

Hi @ronnieotieno , thanks for sharing this!

Could you provide more information in the Configuration? There are several related configs might affect this, like:

  • useAdvertisingIdForDeviceId
  • useAppSetIdForDeviceId
  • newDeviceIdPerInstall
  • identityStorageProvider

For "affects approximately 30% of the devices", could you share more about the affected event types, like is it the session_start event or custom event sent via track? The reason is I think the SDK is trying to read device_id during initialization from persistent storage, the setDeviceId above in your code is after the initialization.

If the above info is not helpful for us to identify the issue, maybe can try to implement a ObservePlugin's onDeviceIdChanged for printing some more useful debugging information, here is the doc for plugins.

@ronnieotieno
Copy link

Hi @liuyang1520 thank you.
Regarding the configuration we are only passing:

  • Application context
  • ApiKey
  • Server zone
  • OptOut as false

When the session starts we get the generated device id which is different from what we set in the function but after one or two tracking events our id is set.

From our understanding we need to set the device id after initialisation, thats when we get the amplitude instance. And the code shared above should run before we use Amplitude.

Is there a chance that the session could start before the initialisation and setting the device id?

@qingzhuozhen
Copy link
Contributor

Hi @ronnieotieno, it seems a race condition between the device id initialization in SDK versus set from outside directly. We will investigate further on the solutions to help solve it.

@izaaz
Copy link
Collaborator

izaaz commented Aug 20, 2024

The SDK configuration now takes in a device id as input and when that parameter is passed, it would default to using that.

Closing this issue since this is now resolved.

@izaaz izaaz closed this as completed Aug 20, 2024
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

No branches or pull requests

6 participants