Description
Describe the bug
There are many swift data types that crash in the library's JSON handling that (I believe) shouldn't. And since the type that the JSON object accepts in its initializer is [String: Any]
, the compiler can't catch any of these issues before runtime. This makes working with the library difficult (since you have to know which types are accepted and manually convert everything else to those types) and fragile (since you need to manually test each tracking call to ensure it doesn't crash the JSON logic).
To Reproduce
Steps to reproduce the behavior:
- Do
segment.track(name: "Some Event Name", properties: ["key": value])
where the value is any of the following types (there are probably more, but these are the ones I've run into so far):- UUID
- enum that conforms to Codable (e.g.
enum MyEnum: String, Codable { case a, b, c }
)
- See the following error:
Segment/Utils.swift:54: Fatal error: A critical error occurred: jsonUnableToDeserialize(Segment.JSON.JSONError.nonJSONType(type: ...))
Expected behavior
Ideally, types that conform to Encodable
and that can be properly serialized using a regular JSONEncoder
should not crash in the library's handling of JSON
Platform (please complete the following information):
- Library Version in use: 1.5.3
- Platform being tested: iOS