Amplitude sending user's location to Google every app launch #240
Description
Initially reported on May 8, 2020
Every app launch, Amplitude gets the users current location and sends it to Google's reverse geocoding api, and there's no way to prevent this.
AmplitudeClient.initialize(...)
calls runOnLogThread()
the code run on the log thread includes:
deviceInfo = new DeviceInfo(context);
deviceInfo.prefetch();
prefetch()
calls getCachedInfo();
which calls new CachedInfo();
The CachedInfo
constructor calls getCountry();
which calls getCountryFromLocation();
getCountryFromLocation()
will abort if DeviceInfo
's locationListening
property is false, but there is no way to get it to be false at this point (see below).
If it doesn't abort, getCountryFromLocation()
then gets the most recent location and sends it to Google.
Why disableLocationListening doesn't work:
AmplitudeClient.disableLocationListening()
sets DeviceInfo's locationListening
property to false, but it's impossible to get this to happen in time to prevent Amplitude from getting current location and sending to Google.
- If I put the call to
disableLocationListening
before the call toinitialize
then it crashes because AmplitudeClient'sdeviceInfo
property is null. - If I put the call to
disableLocationListening
after the call toinitialize
then that's too late, it already made the call to Google.
This is the same bug that is causing issue #189 but it was not introduced in PR #117. Even before runOnLogThread
was added, disableLocationListening
wouldn't work unless AmplitudeClient's deviceInfo
was non-null, and prefetch()
is called as soon as deviceInfo
is initialized so there's no way to turn off location listening in time.
BTW I am already calling AmplitudeClient.setTrackingOptions
and disabling city, country, LatLng, etc before the call to initialize
and this has no effect.