Repository navigation
feat(wizard): name the workspace group, and stamp events on capture - #74
Merged
Merged
Conversation
Two fixes found while checking a real run's events in PostHog.
Events already join a `workspace` group, but nothing ever identified it, so
every workspace read as a bare UUID in the group breakdowns the funnel
dashboard is built on. Identify it once, when the run settles on a
workspace, with the name and whether it is a sandbox — the only workspace
facts the wizard knows first-hand. Group properties are shared with
everything else that reports to that workspace, so nothing else goes in.
The call is attributed to the install's own distinct id, or PostHog mints a
person for the workspace as a side effect.
The second is an ordering bug. The SDK assigns a timestamp inside an async
path, so two events captured in the same tick can be stamped out of order,
and PostHog orders funnel steps by timestamp. A run yesterday reported its
screens as:
screen_index 1 init 18:27:17.181
screen_index 2 method 18:27:17.045
The wizard's own ordering was right and the stamps were inverted, which is
enough to make a screens funnel read a step as skipped. Stamp each event
where it is captured instead.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.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.
Two fixes found by reading a real run's events in PostHog, both in
analytics.ts.1. The workspace group had no name
Events already join a
workspacegroup, but nothing ever calledgroupIdentify, so every workspace showed as a bare UUID in exactly the breakdowns the funnel dashboard is built on:Now, when a run settles on a workspace:
Two deliberate choices:
nameandis_sandbox. Group properties are shared with everything else that reports to that workspace (the Console, webviews, server events), so the wizard writes only what it knows first-hand and doesn't stomp on anyone else's fields.distinctIdis the install's own id. Without it, PostHog mints a synthetic person for the workspace as a side effect of the identify.This also settles the "how many times has each workspace run the wizard" question at the group level rather than needing a property breakdown —
wizard_connectedbroken down by workspace now reads as a name.2. Events could be stamped out of order
The SDK assigns a timestamp inside an async path (
prepareEventMessage), so two events captured in the same tick can be stamped out of order — and PostHog orders funnel steps by timestamp. A real run reported:screen_indexinitmethodThe wizard's own ordering was right (
screen_indexproves it) and the stamps were inverted. That's enough to make an ordered screens funnel read a step as skipped.tracknow passestimestamp: new Date(), taken where the event is captured.Testing
$groupidentifypayload asserted against what the SDK actually sends ($group_type,$group_key,$group_set, and the install's distinct id) — verified first against a local ingest server rather than guessed.$groupidentifylands between the two it was checking.npm run typecheck,npm run lintandnpm test(199 tests) pass.Note
Nothing here changes
distinct_id, which stays the anonymous install. Making it the workspace was considered and rejected: the pre-connect events —wizard_run_started, the welcome/init screens,wizard_init_finished,wizard_connect_method_selected,wizard_connect_failed— happen before any workspace is known, and those are the drop-off the funnel exists to measure. Switching mid-run would split a single run across two persons and break every person-scoped funnel;aliaswould fix that but merges irreversibly, so one machine connecting to a sandbox and then a production workspace would permanently merge those two workspaces.🤖 Generated with Claude Code