Open jurajmajerik opened 11 months ago
I vote for this feature.
+1 to this one. I used Zapier to effectively create a cron that runs nightly, it hits the PostHog API to get a list of users in a specific cohort, then loops through each user and checks if they are in a list in our CRM. I they are not in the list, it adds them to the list. If they are already in the list it updates a timestamp (this allows us to both mirror the cohort into our CRM but also maintain a list of folks who dropped off the cohort based on the timestamp).
The current setup is pretty inefficient, brittle, and expensive in terms of Zapier "compute". Would love to just call a web-hook whenever a change a cohort happens!
This is a great feature request, but at present hard to pull off.
This is how we update cohorts: https://github.com/PostHog/posthog/blob/0257b2bcb90278349b67022923c9e9c62bb4d229/posthog/models/cohort/sql.py#L37-L48
It's one SQL query that happens fully within ClickHouse. There's no way to hook into "when new people got added to the cohort".
The way to get this information is to make a HogQL query to the raw_cohort_people
table and select values with a higher version
than what you saw the last time:
This also is the only way we could trigger updates if someone got added to a cohort. However such a system is brittle by design if scaled out to a lot of users, and taking on the risk of maintaining this is not something we've had the resources to do.
Is your feature request related to a problem?
From a user:
Describe the solution you'd like
Add the ability to call a webhook on a cohort update.
Additional context
Community question: https://posthog.com/questions/is-it-possible-to-get-a-notification-when-members-of-a-cohort-change
Thank you for your feature request – we love each and every one!