Amplitude Logger [Error]: Invalid id length for user_id or device_id

  • 22 November 2022
  • 5 replies

I'm getting this error when using from @amplitude/analytics-react-native

In Android is work and it appears on the my amplitude dashboard, but on iOS it doesn't work.

I try in my Development Environment, this picture only show from android only


Here’s my code when user login:

  initializeAmplitude = async () => {
    const event = new Identify()
    event.set('properties', this.props.userAccountInformation.members)
    event.set('platform', Platform.OS)
    track('Auth Middleware')
    track('App Version', { version: Application.nativeApplicationVersion })
    return true

Best answer by eddie.gaona 18 July 2023, 20:40

View original

5 replies

Userlevel 5
Badge +5

Hi @imanuelvic,

Thank you for sharing the post! 

I understand you are instrumenting the React Active SDK following this doc, correct? To prevent instrumentation issues, device IDs and user IDs must be strings with a length of 5 characters or more. If an event contains a device ID or user ID that's too short, the ID value is removed from the event. But you can choose to override the default minimum length of 5 character by passing the min_id_length option with the request. Please kindly refer to this post for more discussion on this topic: 

I hope this helps!

@Yuanyuan Zhang thanks a lot!

init(AMPLITUDE_API_KEY,, { minIdLength: 1 })
this code solve my problem
Userlevel 1
Badge +1


I’m getting the same error in our stage environment itself and we use the SDK in Google Tag Manager. Is there any way to tell what might be causing this? Will bring to IT again but wondering what else could be causing this. It’s only happening on 1 of our stage urls which was working fine last week. The tag is firing but nothing shows in the Amplitude Chrome Extension. Thanks

Library error on stage url
Error on our stage url itself which is blocking the Amplitude event from firing. IT is going to tell me it’s on Amplitude’s end but where is the API key missing from?


Userlevel 4
Badge +7

@mkoiva thanks for the update! I’ve asked the team to look into the issue and they’ll reach out directly!

Userlevel 5
Badge +9

Hello @mkoiva hope you are well!

The error that appears in the screenshot suggests that the Amplitude API Key was not passed when the SDK was initialized. The API Key can be found under project settings within the Amplitude UI as described, here.

The documentation on how to set the API Key on the Marketing Analytics SDK can be found, here.

Hope this helps!