You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
Thanks @jbbakst, I'll have a look at what I can do about this. If you see Utils.swift line 54, this only happens in debug mode. Using the strongly typed version of track, what you're asking for should already work. For the more free-form dictionary stuff like you mention, there is a gap that could be improved for sure.
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:
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):enum MyEnum: String, Codable { case a, b, c }
)Expected behavior
Ideally, types that conform to
Encodable
and that can be properly serialized using a regularJSONEncoder
should not crash in the library's handling of JSONPlatform (please complete the following information):
The text was updated successfully, but these errors were encountered: