Same '$identify' event being sent on every app background, even after opt-out/not updating user properties
aadityaer91 opened this issue · 0 comments
Expected Behavior
- If app isn't setting user_properties and opt-put as well, app should not sent '$identify' events.
- Once set/updated, and sync was successful with API success. It should be cleared from local and shouldn't be sent again and again on every app's background.
- Previously set custom user_properties should be visible on amplitude dashboard.
Current Behavior
- As per observation, app is setting custom user properties and it's being sent in APIs as well.
- Once set, app is opting out as per user request and stop sending events as well as not setting/updating any user properties.
- Even after restricting, we can monitor single amplitude api call, when iOS app goes to background.
- On capturing request data, we found that, 'timestamp' of event data is always same even after it's being sent after few minutes. But, 'event_id' is always different and in increasing order. Other data like, session_id, user_properties etc. are always same.
- Custom user_properties aren't visible on amplitude dashboard for all iOS device.
- Note: On Android, everything works fine, with same implementation.
Possible Solution
- Once user_properties set/updated, and sync was successful with API success. It should be cleared from local and shouldn't be sent again and again on every app's background.
Steps to Reproduce
- Launch the app, do the initial amplitude setup, as given below.
- In first session, as per setup, Set opt-out to false, enable session tracking and set custom user properties.
- Monitor API calls while app is running or when app goes in background.
- Re-launch the app. So setup update again. This time, disable session tracking, setOptOut to true and don’t set any user properties.
- Keep app in background, monitor network, you will see api call to https://api2.amplitude.com/ with request data having event_type: $identify .
- Repeat this last step again and again and monitor. API is sending same data having same session_id and timestamp, with new event_id in increasing order.
- amplitude setup:
await _analytics.init(amplitudeKey, userId: userId);
await _analytics.setOptOut(!(globals.prefs.isFirstSession.value || globals.prefs.isHereImprovementOn.value));
await _analytics.enableCoppaControl();
await _analytics.setOffline(globals.prefs.isOfflineModeOn.value);
if (globals.prefs.isFirstSession.value || globals.prefs.isHereImprovementOn.value) {
await _setAmplitudeUserProperties(_analytics);
}
await _analytics.trackingSessionEvents(globals.prefs.isFirstSession.value || globals.prefs.isHereImprovementOn.value);
- My use case:
- Allowing tracking on first session only, if no analytics consent given.
- And track always if consent is provided.
- Stop tracking again, if user revoked consent.
-
Event data in request:
{
"session_id": 1706513065590,
"user_properties": {
"$set": {
"Map version": "114.114.73.73",
"Door-to-door": true,
"App Theme": "Sync with device",
"Channel": "Beta",
"Map Theme": "Sync with device",
"Traffic": false,
"Map View": "DEFAULT",
"SDK deviceID": "0a6aa9"
}
},
"language": "English",
"event_type": "$identify",
"sequence_number": 1,
"user_id": "6e0****c05",
"country": "United States",
"api_properties": {
"tracking_options": {
"lat_lng": false,
"city": false,
"ip_address": false
}
},
"device_id": "7E74355E-B8C3-4486-94AE-DF03D19046B1",
"event_properties": {},
"uuid": "DA190D21-5F61-4B0C-890C-DA3005EF6BD7",
"device_manufacturer": "Apple",
"version_name": "4.11.200",
"library": {
"name": "amplitude-flutter",
"version": "3.16.1"
},
"os_name": "ios",
"platform": "iOS",
"event_id": 32,
"carrier": "Unknown",
"timestamp": 1706513072174,
"groups": {},
"os_version": "17.2",
"device_model": "Simulator",
"group_properties": {}
} -
Above logs are from simulator.
Environment
- SDK Version: 3.16.0
- Flutter Version: 3.10.5
- Device: iPhone 15 Pro Max simulator
- Device OS and Version: iOS 17.2