mixpanel / mixpanel-swift

Official iOS (Swift) Tracking Library for Mixpanel Analytics
https://mixpanel.com
Apache License 2.0
434 stars 234 forks source link

Opt-out Persistence Broken in 3.0.0.beta #457

Closed nibe closed 3 years ago

nibe commented 3 years ago

hasOptedOutTracking() always returns false on launch and track sends events even if the user opted out before.

Example code:

func applicationDidFinishLaunching(_ aNotification: Notification) {
    Mixpanel.initialize(token: YOUR_TOKEN_HERE)

    print("hasOptedOutTracking on applicationDidFinishLaunching: \(Mixpanel.mainInstance().hasOptedOutTracking())")

    if Mixpanel.mainInstance().hasOptedOutTracking() {
        Mixpanel.mainInstance().optInTracking()
    } else {
        Mixpanel.mainInstance().optOutTracking()
    }

    print("hasOptedOutTracking after toggling: \(Mixpanel.mainInstance().hasOptedOutTracking())")
}

Branch 3.0.0.beta Compiled for macOS macOS 11.4 Xcode 12.4

zihejia commented 3 years ago

hi @nibe , thanks for bringing up it, we will have a look.

zihejia commented 3 years ago

hi @nibe , similar to https://github.com/mixpanel/mixpanel-swift/issues/458. Now the issue has been fixed in v2.10.2. Closing it now.

zihejia commented 3 years ago

Updated in 3.0.0.beta branch