Amplitude-Android
Amplitude-Android copied to clipboard
AmplitudeClient.setOptOut Doesn't Work
Expected Behavior
Calling amplitudeClient.setOptOut(true)
should make amplitudeClient.isOptedOut
return true
.
Current Behavior
Calling amplitudeClient.isOptedOut
always returns false
despite calling amplitudeClient.setOptOut(true)
.
Images
Amplitude client is initialized as such
@Provides
@Singleton
fun provideAmplitudeClient(): AmplitudeClient {
return Amplitude.getInstance()
.setLogLevel(Log.VERBOSE)
.setFlushEventsOnClose(false)
.setOptOut(true)
}
Environment
- SDK Version: v2.38.3
- Android API Level: API 33
- Device: Pixel 4 Emulator
Hi @gusuly0rum, Thanks for choosing Amplitude. The setOptOut still works fine. The issue is that the isOptedOut return value is incorrect. We will fix this issue soon.
@gusuly0rum
After investigation, this bug is caused by the setOptOut
is executed in Runnable
at here. All runnable will be executed in order, this makes sure the logEvent
happens after setOptOut
will get the correct optOut value. But since the isOptOut
get the optOut value immediately, it may happen before setOptOut
.
Again, the setOptOut still works fine. The issue is that the isOptedOut return value might be incorrect.
Since this SDK is in Maintenance mode. We highly recommend you upgrade your SDK to our latest android SDK. It's more reliable and has better performance.
@yuhao900914 Thanks for letting me know. Yes we want to upgrade to the new SDK soon but there are some features not supported.
Thank you @gusuly0rum. What features do you need that are missing in the new SDK?
Hello seems like it is missing two things:
- Setting
isOffline (true/false)
on the amplitude object - Dynamically changing the value of
setOptOut (true/false)
after initializing the amplitude object