feat(code): Set posthog-js project + organization groups#2074
Merged
Conversation
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
Contributor
Prompt To Fix All With AIFix 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 |
Generated-By: PostHog Code Task-Id: fe3aec7b-02ed-418f-8476-0298557dba9a
joshsny
approved these changes
May 6, 2026
Co-authored-by: Michael Matloka <dev@twixes.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
We have a
inbox-gated-due-to-scaleflag 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
projectandorganizationgroups viaposthog.group(...)after identify. Groups update on login, project switch, and org switch.posthog.reset()on logout clears them.Created with PostHog Code