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

chore: use real structs in hoghook payloads #23763

Merged
merged 2 commits into from
Jul 17, 2024
Merged

Conversation

bretthoerner
Copy link
Contributor

@bretthoerner bretthoerner commented Jul 16, 2024

Problem

The manual JSON destructuring was ugly, and @xvello told me about serde(flatten).

Changes

Use flatten to store extra fields, then reconstruct the JSON payload before inserting the job.

The downside of serde(flatten) is we were mutating the incoming payload, risking an unexpected change to the passthrough data. Instead, I've adjusted it to the best of the both worlds: we use structs to deserialize, but we do it only on a copy of the subset of data we care about -- that way the original incoming payload is totally unmodified.

Does this work well for both Cloud and self-hosted?

Yes

How did you test this code?

Existing tests covered all the edge cases.

@bretthoerner bretthoerner requested a review from a team July 16, 2024 22:49
@bretthoerner bretthoerner force-pushed the brett/hoghook-json branch 2 times, most recently from 2b273ac to accc516 Compare July 16, 2024 23:04
@bretthoerner bretthoerner merged commit 4abd864 into master Jul 17, 2024
77 checks passed
@bretthoerner bretthoerner deleted the brett/hoghook-json branch July 17, 2024 17:47
silentninja pushed a commit to silentninja/posthog that referenced this pull request Aug 8, 2024
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.

2 participants