Skip to content
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

feat: Support serializing dataclasses #206

Merged
merged 4 commits into from
Mar 17, 2025

Conversation

rossgray
Copy link
Contributor

Adds support for serializing Python dataclasses in event data.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

Added support for serializing Python dataclasses in event data, allowing for better integration with modern Python codebases.

  • Added _clean_dataclass function in posthog/utils.py to handle dataclass serialization
  • Added comprehensive test coverage in test_utils.py for nested dataclasses with various field types
  • Modified clean function to detect and process dataclass instances appropriately
  • Version bumped to 3.21.0 to reflect new feature addition

4 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

Copy link
Member

@rafaeelaudibert rafaeelaudibert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but I don't know enough about the release process on this lib so I'll leave that to you :)

@rafaeelaudibert
Copy link
Member

Actually, question: won't that from dataclasses import ... fail on older Python versions?

Copy link
Member

@pauldambra pauldambra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

looking at CI we only explicitly support python 3.9 and above so good to directly reference dataclasses

@rossgray rossgray merged commit 2779ad1 into master Mar 17, 2025
6 checks passed
@rossgray rossgray deleted the feat/support-serializing-dataclasses branch March 17, 2025 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants