Skip to content

feat(code): Set posthog-js project + organization groups#2074

Merged
Twixes merged 3 commits intomainfrom
posthog-code/posthog-js-groups
May 6, 2026
Merged

feat(code): Set posthog-js project + organization groups#2074
Twixes merged 3 commits intomainfrom
posthog-code/posthog-js-groups

Conversation

@Twixes
Copy link
Copy Markdown
Member

@Twixes Twixes commented May 6, 2026

Summary

We have a inbox-gated-due-to-scale flag to effectively put a more controlled waitlist. But it hasn't actually taken effect, because PH Code didn't set the group analytics properties.

Fixing by mirroring how the main PostHog frontend (userLogic.ts) attaches the user to project and organization groups via posthog.group(...) after identify. Groups update on login, project switch, and org switch. posthog.reset() on logout clears them.


Created with PostHog Code

Mirrors how the main PostHog frontend (frontend/src/scenes/userLogic.ts)
attaches the user to project and organization groups so feature flags
targeting those group types evaluate correctly. Without this, flags like
inbox-gated-due-to-scale rolled out to specific organizations never
match in PostHog Code.

Generated-By: PostHog Code
Task-Id: fe3aec7b-02ed-418f-8476-0298557dba9a
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 6, 2026

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
apps/code/src/renderer/features/auth/hooks/useAuthSession.ts:75-89
**Duplicated group-setting logic (OnceAndOnlyOnce)**

The 16-line block that calls `setUserGroup` for `"project"` and `"organization"` is copy-pasted verbatim into `authStore.ts` (lines 168–183). If the set of group properties ever needs to change (e.g. adding a `region` property to the project group), both places must be updated in sync. A small helper like `setUserGroups(user: { team?: ...; organization?: ... })` exported from `analytics.ts` (or a shared utility) would remove the duplication and make future changes a one-liner at both call sites.

Reviews (1): Last reviewed commit: "feat(code): set posthog-js project + org..." | Re-trigger Greptile

Comment thread apps/code/src/renderer/features/auth/hooks/useAuthSession.ts Outdated
@Twixes Twixes changed the title feat(code): set posthog-js project + organization groups on identify feat(code): Set posthog-js project + organization groups May 6, 2026
@Twixes Twixes requested a review from a team May 6, 2026 19:07
Generated-By: PostHog Code
Task-Id: fe3aec7b-02ed-418f-8476-0298557dba9a
Co-authored-by: Michael Matloka <dev@twixes.com>
@Twixes Twixes merged commit 4fe2a62 into main May 6, 2026
15 checks passed
@Twixes Twixes deleted the posthog-code/posthog-js-groups branch May 6, 2026 23:57
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