Skip to content

Codable support #52

Closed as not planned
Closed as not planned

Description

@JoeFerrucci

Is your feature request related to a problem?

You don't support Codable when using capture for events.

Describe the solution you'd like

Getting error: key does not conform to NSCoding and cannot be serialized for delivery.

Describe alternatives you've considered

Allow Codable

Additional context

Thanks! Looking forward to reply.

Thank you for your feature request – we love each and every one!

Activity

  1. transferred this issue fromPostHog/posthogon May 23, 2023
  2. marandaneto commented on Oct 9, 2023

    @marandaneto
    Member
  3. JoeFerrucci commented on Oct 9, 2023

    @JoeFerrucci
    Author

    Yes, that is the one. When I try to pass a dictionary into capture(event:properties:) it fails with that error.

    Here is a trivial example to help highlight it

    struct MyType: Codable {}
    
    posthog?.capture("My Event", properties: ["somekey": MyType()])

    This yields the error. Technically PostHog SDK only needs to support Encodable; it doesn't need to be Decodable

    Note: the error appears at runtime when you try to send the data over the wire; it's not a compile time error.

  4. marandaneto commented on Oct 9, 2023

    @marandaneto
    Member

    We're currently rewriting the iOS SDK and we'll consider this use case, thanks for the context.
    Edit: Consider using the customstringconvertible as well.

  5. github-actions commented on Apr 14, 2026

    @github-actions
    Contributor

    This issue hasn't seen activity in two years! If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in two weeks.

  6. marandaneto commented on Apr 14, 2026

    @marandaneto
    Member

    superseeded by #557

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions