amplitude / Amplitude-Android

Native Android SDK for Amplitude
MIT License
162 stars 90 forks source link

Amplitude stops tracking events when server zone is set #341

Closed NuclearSnake closed 2 years ago

NuclearSnake commented 2 years ago

Hello! Thank you for making a great lib for analytics better!

Expected Behavior

Normal events tracking

Current Behavior

Getting the "com.amplitude.api.AmplitudeClient: Invalid API key, make sure your API key is correct in initialize()" in logs; no events coming to the dashboard

Steps to Reproduce

  1. I have a simple test project where Amplitude works fine on v2
  2. Then I add .setServerZone(AmplitudeServerZone.EU) and it doesn't track anymore I tried two ways:
    Amplitude.getInstance()
            .initialize(activity, "my api key goes here")
            .setServerZone(AmplitudeServerZone.EU)
            .enableForegroundTracking(activity.application)

and

Amplitude.getInstance()
            .initialize(activity, "my api key goes here")
            .enableForegroundTracking(activity.application)
Amplitude.getInstance().setServerZone(AmplitudeServerZone.EU)

and also both ways but with .setServerUrl("https://api.eu.amplitude.com")

Environment

NuclearSnake commented 2 years ago

I noticed the latest version is 2.38.1 (not marked as the latest on the right on main lib page, but listed in text readme), and tried it too with the same result

bohan-amplitude commented 2 years ago

Hi @NuclearSnake , Thanks for using Amplitude. The project in EU zone amplitude website and project in US zone amplitude website have different API key. Could you check and make sure to use the API key from EU website project setting when sending events to EU API endpoint?

NuclearSnake commented 2 years ago

Hi, @bohan-amplitude! So is the correct website for EU zone "https://analytics.eu.amplitude.com/"? If so, should I recreate my organization and a project? I was using "https://analytics.amplitude.com/" website and see an API key but do not see any ways to create a EU-api key, project or organization

bohan-amplitude commented 2 years ago

@NuclearSnake Correct. Need to create org and project on https://analytics.eu.amplitude.com/. The EU API key can be found under project setting on the EU website.