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

fix: Webhooks groups properties #23822

Merged
merged 3 commits into from
Jul 22, 2024
Merged

fix: Webhooks groups properties #23822

merged 3 commits into from
Jul 22, 2024

Conversation

tiina303
Copy link
Contributor

@tiina303 tiina303 commented Jul 18, 2024

Problem

When we stopped writing groups on events (which was the right thing to do as it's not used in analytics queries and used up resources unnecessarily), then it broke webhooks using group properties.

This is innefficient as the comment says, but we don't want to spend too much time improving a legacy system that's going away soon.

Also made sure we don't accidentally break this functionality by adding a functional test for it.

Changes

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

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

How did you test this code?

@tiina303 tiina303 requested a review from a team July 18, 2024 21:45
@mariusandra
Copy link
Collaborator

mariusandra commented Jul 19, 2024

When we stopped writing groups on events (which was the right thing to do as it's not used in analytics queries and used up resources unnecessarily), then it broke webhooks using group properties.

Which were never enabled because nobody told us we can, despite groups being a first class citizen. You were still getting persons on events. However which would actually be great to do in analytics, as queries with groups can get slow for our biggest and most important customers.

Fixed that for you. "The right thing" is extremely subjective.

@tiina303 tiina303 marked this pull request as ready for review July 19, 2024 10:29
@tiina303
Copy link
Contributor Author

@mariusandra this came from Product Analytics side, see #22764

Group properties on events never went anywhere, having only been partially implemented (certainly not at all in HogQL), and I don't think we want to prioritize that idea now.
(I'm a tiny bit worried that group properties behaving differently from person ones might be confusing for users, but this just doesn't seem important.)

@mariusandra
Copy link
Collaborator

mariusandra commented Jul 19, 2024

I don't see how these two things are at odds. The conclusion is different. You concluded "let's kill it". I would've concluded "let's finish it (next month?) cause it'll be a nightmare to re-enable and backfill, so no action now". Notably missing is an analysis on either option.

@tiina303
Copy link
Contributor Author

Unfortunately it would have required data fixing / backfill anyway, which I called this out in #22962

There was at some point a problem with data written to group properties, so they aren't fully in a good state anyway.

@mariusandra
Copy link
Collaborator

Don't forget, we're serving the customer here. The customer is using "frontend apps" like Product Analytics or Feature Flags to do what they need to do. Whatever would be great for users of Product Analytics (and the other products) should take priority over what inconveniences a team that effectively serves other teams, like Pipeline.

PoE clearly was done to help end users with performance. GoE was discussed, but put on the back burner as the next step. Having it would obviously help with any query that uses group properties (enough users to matter, I've seen reports). We have also always said Groups should be a "first class citizen", whatever that means, so removing features from Groups seems like a steps backwards.

In any case, please own up and fix the regression from webhooks (and CDP?), and/or communicate with the users why groups are not a first class citizen anymore if you choose that.

@tiina303
Copy link
Contributor Author

fix the regression from webhooks

I'm confused, this is exactly what this PR does

@mariusandra
Copy link
Collaborator

mariusandra commented Jul 19, 2024

Yes, thank you. If you need help with reviewing, let me know. It was still draft when I opened it earlier.

@bretthoerner
Copy link
Contributor

I don't know much about these code paths, and since this is undoing a breaking change and people are talking about backfills it makes me nervous to breeze through this.

I didn't review #22962 but is this just a revert of that change, or something more complicated?


const queryString = `SELECT group_properties FROM posthog_group WHERE team_id = $1 AND group_type_index = $2 AND group_key = $3`

const selectResult: QueryResult = await postgres.query(
Copy link
Contributor

Choose a reason for hiding this comment

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

Just noting for others that the previous group code used a Redis cache before Postgres: https://github.com/PostHog/posthog/pull/22962/files#diff-0769dccc3458a7eb730036617ac32002072330fcdc5ec5a1d11364769d5dd5b6L488

Since this is just for Webhooks now and we're using a PG read replica this seems fine for now. If anything, it would be nice to do one query for all of them rather than a query each...

@bretthoerner bretthoerner merged commit 54875e1 into master Jul 22, 2024
88 checks passed
@bretthoerner bretthoerner deleted the webhooks-groups branch July 22, 2024 20:21
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.

3 participants