Skip to content

Attach a process-wide session id to every telemetry capture - #412

Merged
TheGreatAxios merged 3 commits into
mainfrom
cl-5727-posthog-identity-session-linking
Aug 8, 2026
Merged

Attach a process-wide session id to every telemetry capture#412
TheGreatAxios merged 3 commits into
mainfrom
cl-5727-posthog-identity-session-linking

Conversation

@TheGreatAxios

Copy link
Copy Markdown
Collaborator

Summary

  • Every capture() call now attaches a process-scoped session_id (generated once via randomUUID() at module load) alongside the existing installation-UUID distinct_id, so PostHog can group a process's product and future AI/feedback events into one session.
  • Adds getSessionId() so future emitters (AI turn events from CL-5723, feedback from CL-5722) can attach the same session id without re-threading it.
  • No change to distinct_id resolution, the property allowlist discipline, or the held-cli_start-until-consent first-run flow.

Test plan

  • bun run test (via shared lock script)
  • bun run typecheck (pre-existing vendor/node_modules type mismatches unrelated to this change, no telemetry errors)
  • bun run build
  • New tests: same session_id across multiple captures in one process, stable across separate createTelemetry() instances in the same process

Linear: CL-5727

Product and future AI observability events need to group into one
PostHog session per process. Generate the session id once at module
load and attach it to every capture() payload's common properties,
alongside the existing installation-UUID distinct_id, so nothing
downstream has to thread a session identifier through call sites.
@linear-code

linear-code Bot commented Aug 8, 2026

Copy link
Copy Markdown

CL-5727

The prior test called createTelemetry() twice but asserted against
getSessionId(), which never reads from a Telemetry instance — it
would have passed even if createTelemetry() were never called. The
replacement drives the actual toggle.ts enable/disable/enable cycle
and asserts session_id stays constant across the captured payloads.
Callers reading the privacy section need to know session_id is a
fresh in-memory UUID per process run, never persisted, so it cannot
be used to correlate events across separate CLI launches.
@TheGreatAxios
TheGreatAxios merged commit 1fb2a4f into main Aug 8, 2026
2 checks passed
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.

1 participant