Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sometimes City is sent to Mixpanel even useIPAddressForGeoLocation is set as false. #631

Closed
ttmdung203 opened this issue Mar 11, 2024 · 5 comments

Comments

@ttmdung203
Copy link

ttmdung203 commented Mar 11, 2024

The way I set useIPAddressForGeoLocation:

mixpanelInstance = Mixpanel.initialize(token: token, trackAutomaticEvents: true)
mixpanelInstance.delegate = self
mixpanelInstance.useIPAddressForGeoLocation = false

Even I check useIPAddressForGeoLocation at mixpanelWillFlush, the city is still sent:

 public func mixpanelWillFlush(_ mixpanel: MixpanelInstance) -> Bool {
       return !mixpanel.useIPAddressForGeoLocation
}

This issue is quite critical since it affects to my privacy document.
Prefer to move delegate & useIPAddressForGeoLocation to initialize function.
Thanks in advance.

@jaredmixpanel
Copy link
Contributor

@ttmdung203 The SDK does not send geolocation info. When useIPAddressForGeoLocation is true the server will use the IP address to add geo info to the event after it is received. Make sure you're not manually setting a city property anywhere in your code. For further assistance please reach out to support@mixpanel.com

@ttmdung203
Copy link
Author

ttmdung203 commented Mar 12, 2024

I set useIPAddressForGeoLocation = false immediately as you see at below code, there's no manual city parameters for sure.

mixpanelInstance = Mixpanel.initialize(token: token, trackAutomaticEvents: true)
mixpanelInstance.delegate = self
mixpanelInstance.useIPAddressForGeoLocation = false

It happens randomly, I was looking into source code and found that there is a chance of flushing events immediately right after Mixpanel.initialize, before I set delegate and useIPAddressForGeoLocation. (Version: 4.2.0)

init(apiToken: String?, flushInterval: Double, name: String, trackAutomaticEvents: Bool, optOutTrackingByDefault: Bool = false,
         useUniqueDistinctId: Bool = false, superProperties: Properties? = nil,
         serverURL: String? = nil) {
....
....
 flushInstance.flushInterval = flushInterval
}
Screenshot 2024-03-12 at 10 44 39 AM Screenshot 2024-03-12 at 10 47 12 AM

@ttmdung203
Copy link
Author

@jaredmixpanel for visibility.

@jaredmixpanel
Copy link
Contributor

@ttmdung203 That's not the correct way to initialize and use the Mixpanel instance. You don't need to store the instance. You should always use the shared instance provided by Mixpanel.mainInstance():

Mixpanel.initialize(token: token, trackAutomaticEvents: true)
Mixpanel.mainInstance().delegate = self
Mixpanel.mainInstance().useIPAddressForGeoLocation = false
...
Mixpanel.mainInstance().track(event: "My Event")

Try that and let me know if it makes a difference.

@ttmdung203
Copy link
Author

Thanks for your quick response, @jaredmixpanel
I've just tried the way you suggested, the city sometimes is sent to Mixpanel when I open app.

Reproduce steps:

  • Open app and open some screens (to track screen viewed event), then close and open app again (to flush events automatically).
  • Repeat it until seeing the city in mixpanel. (It happens ~5-10% the time I do above steps).
Mixpanel.initialize(token: token, trackAutomaticEvents: true)
Mixpanel.mainInstance().useIPAddressForGeoLocation = false
Mixpanel.mainInstance().delegate = self

...
Mixpanel.mainInstance().track(event: "Event name")
```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants