computed-posthog-events: fall back to the course registration anonymous distinct id for participants who never log in#2807
Conversation
…hor for participants who never log in
|
Warning Review limit reached
Next review available in: 42 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds a shared Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR introduces a
Confidence Score: 4/5Safe to merge — the change is additive, only making previously-dropped events attributable to an anonymous registration anchor, and all three new behaviors are covered by targeted tests. The logic is sound and the new preferredDistinctId helper is a clean consolidation of three identical inline patterns. The only findings are a stale inline test comment and an overly long function signature, both cosmetic. No behavioral regressions were found. No files require special attention; the test file has one stale comment worth updating. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Resolve PostHog distinct_id] --> B{userId set?}
B -- yes --> C{keycloakIdentifier in map?}
B -- no --> E
C -- yes --> D[Use Keycloak sub]
C -- no --> E{registration available?}
E -- yes --> F{posthogDistinctId on registration?}
E -- no --> G[null — event skipped]
F -- yes --> H[Use captured browser anon ID]
F -- no --> I[Use registration record ID as fallback]
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A[Resolve PostHog distinct_id] --> B{userId set?}
B -- yes --> C{keycloakIdentifier in map?}
B -- no --> E
C -- yes --> D[Use Keycloak sub]
C -- no --> E{registration available?}
E -- yes --> F{posthogDistinctId on registration?}
E -- no --> G[null — event skipped]
F -- yes --> H[Use captured browser anon ID]
F -- no --> I[Use registration record ID as fallback]
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@libraries/computed-posthog-events/src/definitions.ts`:
- Around line 36-38: Reformat the preferredDistinctId function declaration and
its destructured parameter in definitions.ts to match the project’s linting and
indentation conventions, removing the unexpected line breaks and correcting
spacing without changing its signature or behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 6aa6f487-a808-4790-b6c9-5db3f76ff389
📒 Files selected for processing (2)
libraries/computed-posthog-events/src/definitions.test.tslibraries/computed-posthog-events/src/definitions.ts
Description
When spot-checking the data in PostHog I noticed that there were some events like
certificate_issuedthat don't get joined up to a user. It turns out that this is legitimate, and a small fraction of people complete courses without ever logging into the website.This PR makes it so these will at least be joined up to the same anonymous user by getting a consistent distinct ID off the linked course registration.
Issue
#2713
Developer checklist