feat: attach group properties in all channels#60870
Conversation
|
PR overviewAll previously flagged issues have been addressed. No open security concerns remain on this pull request. Security reviewNo open security issues remain on this pull request. Fixed/addressed: 1 · PR risk: 0/10 |
There was a problem hiding this comment.
Security concerns flagged in review (group attribution spoofing via widget email, fallback firing for identified persons with no membership) are genuinely fixed in the current diff with the channel allowlist and early-return logic. Tests cover the attack scenarios explicitly. No showstoppers.
Problem
capture_ticket_created only resolves org $groups when ticket.distinct_id is a real PostHog distinct_id (web widget). Slack/Email/MS Teams set distinct_id to the customer email (or ""), so OrganizationMembership.objects.filter(user__distinct_id=ticket.distinct_id) never matches and no $groups get attached. GitHub has neither a real distinct_id nor an email, so it stays unenriched (out of scope).
Changes
Add an email fallback: when the distinct_id path yields no membership, look up the person by properties.email via ClickHouse (_get_persons_by_email), take that person's real distinct_ids, and resolve the org membership through them.