mixpanel / mixpanel-iphone

Official iOS (Objective-C) Tracking Library for Mixpanel Analytics
http://mixpanel.com
Apache License 2.0
1.05k stars 567 forks source link

$carrier property can be reported as `nil` when there is multiple SIMs support #949

Closed 4hakke closed 2 years ago

4hakke commented 2 years ago

Integration Method: CocoaPods Xcode Version: 12.5.1 Library Version: Platform: iOS Language: Swift Testen on: iPhone SE (2nd gen) iOS 13.5.1 and iPhone 12 Pro iOS 15.0 Description: We noticed that number of events where $carrier value is underfined was increased. After some investigation of collectAutomaticProperties method it was found that carrier name and all other properties retrieved from telephonyInfo are nil for devices. Further investigation showed that correct information are still provide by telephonInfo object but wrong object (always the first one aka [[telephonyInfo serviceSubscriberCellularProviders] allValues].firstObject;) were taken.

Down below you can see a console output for [[telephonyInfo serviceSubscriberCellularProviders] allValues] that proves needed information is there:

Screenshot 2021-10-07 at 10 58 48

I suppose that reason for that is devices that supports multiple sims (nano-Sim and esim) and only one of them is setup. In that case sim that are not setup still can be retrieved but are nil. So my suggestion to cover this case is to enhance logic for picking proper carrier (CTCarrier) object e.g. picking first where carrier name is not nil if any.

Expected Behavior: If device has at least one carrier properly setup it should take object that has name information.

Happy to answer any additional questions or provide more insights. Thanks.

zihejia commented 2 years ago

hi @4hakke , sorry for the late response and thanks so much for bringing this up. Do you mind opening a PR for this?

4hakke commented 2 years ago

Hey @zihejia, sure thing, will make change and open PR soon.

zihejia commented 2 years ago

hi @4hakke , It's been included in v3.9.1. Thank you so much!