-
Notifications
You must be signed in to change notification settings - Fork 109
Description
Describe the bug
In the 1.4.x version of the library, the ObjCAnalytics track calls have been changed to call back to the Swift functions forcing the properties parameter to [Any, Codable]. This causes all properties to be dropped from Segment track calls and the event to have no properties and no indication anything is wrong.
From line 42 of ObjCAnalytics.swift:
@objc(track:properties:)
public func track(name: String, properties: [String: Any]?) {
analytics.track(name: name, properties: properties as? [String: Codable])
}
The Events.swift track method that is being called here even takes [String: Any] so it's only this code in the ObjCAnalytics helpers that is enforcing Codable and causing it not to work with NSDictionaries for properties.
To Reproduce
Steps to reproduce the behavior:
- From ObjC, set up a SEGAnalytics object
- Create an NSDictionary or NSMutableDictionary for properties
- Call track with that properties object
- No properties will be sent to Segment (if you step through the track calls, the one in Events.swift will have a nil properties object) and no errors are displayed or returned.
Expected behavior
I understand the point of creating strongly typed properties, but ObjC doesn't support this directly, so it would be helpful if the ObjCAnalytics object didn't try to enforce Codable on the properties. Even your example for Objective-C in the documentation just says to pass a simple dictionary: https://segment.com/docs/connections/sources/catalog/libraries/mobile/apple/implementation/#track
This worked fine in 1.3.5 of the library and was only changed recently. We have temporarily reverted our use of analytics-swift back to 1.3.5 because of this issue.
Platform (please complete the following information):
- Library Version in use: 1.4.x
- Platform being tested: iOS
- Integrations in use: None