Amplitude-Android icon indicating copy to clipboard operation
Amplitude-Android copied to clipboard

AmplitudeClient.setOptOut Doesn't Work

Open gusuly0rum opened this issue 1 year ago • 5 comments

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)
}
image image image

Environment

  • SDK Version: v2.38.3
  • Android API Level: API 33
  • Device: Pixel 4 Emulator

gusuly0rum avatar Jul 13 '23 17:07 gusuly0rum

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.

yuhao900914 avatar Jul 13 '23 19:07 yuhao900914

@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 avatar Jul 14 '23 00:07 yuhao900914

@yuhao900914 Thanks for letting me know. Yes we want to upgrade to the new SDK soon but there are some features not supported.

gusuly0rum avatar Jul 14 '23 15:07 gusuly0rum

Thank you @gusuly0rum. What features do you need that are missing in the new SDK?

justin-fiedler avatar Jul 14 '23 16:07 justin-fiedler

Hello seems like it is missing two things:

  1. Setting isOffline (true/false) on the amplitude object
  2. Dynamically changing the value of setOptOut (true/false) after initializing the amplitude object

gusuly0rum avatar Jul 17 '23 20:07 gusuly0rum