analytics-ios icon indicating copy to clipboard operation
analytics-ios copied to clipboard

Segment Crash issue!

Open FoxCooper opened this issue 3 years ago • 2 comments

Receiving the following crash from some users. The cause of this crash remains unclear, since it’s occurring within the Segment Library. App is running on latest iOS, application written in latest Swift, Cocoa-pods Analytics library install on 4.1.3.

Segment
-[SEGFileStorage dataFromJSON:] at SEGFileStorage.m:232
Segment
-[SEGFileStorage setJSON:forKey:] at SEGFileStorage.m:221
Segment
-[SEGSegmentIntegration persistQueue] SEGSegmentIntegration.m:475
Segment
-[SEGSegmentIntegration sendData:]_block_invoke_2 at SEGSegmentIntegration.m:405
Segment
_seg_dispatch_specific_block_invoke at SEGUtils.m:494
dispatch_block_t autoreleasing_block

FoxCooper avatar Apr 11 '22 21:04 FoxCooper

We have the same issue, is there any progress on this?

mickyzinho avatar Aug 24 '22 10:08 mickyzinho

In my case, it's due to some unexpected NaN values in my tracking data. So I ended up creating the below extension for dictionary

extension Dictionary where Key == String, Value == Any {
    func removeInvalidValues() -> [String : Any]? {
        return filter { (_, value) in
            if let numberValue = value as? NSNumber {
                return !numberValue.floatValue.isNaN
            }
            return !(value is NSNull)
        }
    }
}

Usage:

var properties: [String: Any] = myTrackingData
Analytics.shared().track(event, properties: properties.removeInvalidValues())

thynguyen248 avatar Aug 28 '22 03:08 thynguyen248