Skip to content

Support Swift's Set as a JSON type #198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jnpdx opened this issue Mar 6, 2023 · 6 comments · Fixed by #201
Closed

Support Swift's Set as a JSON type #198

jnpdx opened this issue Mar 6, 2023 · 6 comments · Fixed by #201
Assignees
Labels

Comments

@jnpdx
Copy link

jnpdx commented Mar 6, 2023

Is your feature request related to a problem? Please describe.
track(name: String, properties: [String: Any]? = nil) will crash if one of the Any is a Swift Set. It will not crash if that same property is an Array.

Describe the solution you'd like
Because to JSON, Array and Set are identical, it would be nice if Segment's JSON type could encode Set without crashing

Describe alternatives you've considered
At this point, we just ensure we're always sending an Array

Additional context
N/A

@rtharston
Copy link

It might be nice to support all types of Collection or maybe Sequence and treat them all like Array.

@bsneed
Copy link
Contributor

bsneed commented Mar 7, 2023

Thanks @jnpdx & @rtharston! I'll have a look at this and get back to you guys shortly.

@bsneed
Copy link
Contributor

bsneed commented Mar 10, 2023

I handled Set explicitly. I didn't see a good way to handle types like Collection or Sequence easily. If you guys have a suggestion, lemme know. Otherwise we'll roll with this.

@rtharston
Copy link

I handled Set explicitly. I didn't see a good way to handle types like Collection or Sequence easily. If you guys have a suggestion, lemme know. Otherwise we'll roll with this.

That's great! Thanks! The Collection and Sequence idea was just if it was simple. Set is the common one. 😄

@jnpdx
Copy link
Author

jnpdx commented Mar 10, 2023

Thanks so much!

@bsneed
Copy link
Contributor

bsneed commented Mar 10, 2023

No problem! Thank you guys for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants