feat(logs): honor configured session id keys in session detection - #70736
Conversation
Session-ID detection in logs (replay links, related errors, session context pivots) now checks the team's logs_session_id_attribute_keys setting first — in list order, exact match, attributes before resource_attributes — and falls back to the built-in convention list, so teams that never touch the setting see no change. Generated-By: PostHog Code Task-Id: 964398f1-fa06-46f5-8605-2236fa2a3c32
🤖 CI report
|
| File | Size | Δ vs base |
|---|---|---|
posthog-app/src/scenes/AuthenticatedShell.js |
222.4 KiB | 🔺 +1.3 KiB (+0.6%) |
Posted automatically by build-bundle-size-report · uncompressed bytes from dist-report
✅ Eager graph — within budget
How much code each root ships on the eager path — downloaded and parsed before the surface is interactive. Measured from the esbuild output chunks (post-tree-shake, static imports only); lazy import() / React.lazy chunks are not counted.
| Root | Eager (shipped) | Δ vs base | Budget |
|---|---|---|---|
entry (logged-out pages, app bootstrap)src/index.tsx |
1.22 MiB · 22 files | 🔺 +316 B (+0.0%) | ███░░░░░░░ 28.4% of 4.29 MiB |
authenticated shell (every logged-in page)src/scenes/AuthenticatedShell.tsx |
8.14 MiB · 2,978 files | 🔺 +2.6 KiB (+0.0%) | █████████░ 88.0% of 9.25 MiB |
🟢 node_modules/monaco-editor/ stays out of src/index.tsx
🟢 src/lib/components/ActivityLog/describers stays out of src/index.tsx
🟢 [object Object] stays out of src/index.tsx
🟢 [object Object] stays out of src/index.tsx
🟢 node_modules/monaco-editor/ stays out of src/scenes/AuthenticatedShell.tsx
🟢 src/lib/components/ActivityLog/describers stays out of src/scenes/AuthenticatedShell.tsx
🟢 [object Object] stays out of src/scenes/AuthenticatedShell.tsx
🟢 [object Object] stays out of src/scenes/AuthenticatedShell.tsx
Largest files eagerly shipped from src/index.tsx
| Size | File |
|---|---|
| 126.8 KiB | ../node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/cjs/react-dom.production.min.js |
| 24.6 KiB | ../node_modules/.pnpm/buffer@6.0.3/node_modules/buffer/index.js |
| 6.3 KiB | ../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react.production.min.js |
| 4.5 KiB | ../node_modules/.pnpm/@jspm+core@2.1.0/node_modules/@jspm/core/nodelibs/browser/process.js |
| 3.9 KiB | ../node_modules/.pnpm/scheduler@0.23.2/node_modules/scheduler/cjs/scheduler.production.min.js |
| 1.4 KiB | ../node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.js |
| 1.3 KiB | src/RootErrorBoundary.tsx |
| 912 B | ../node_modules/.pnpm/ieee754@1.2.1/node_modules/ieee754/index.js |
| 789 B | src/scenes/ChunkLoadErrorBoundary.tsx |
| 762 B | src/index.tsx |
Largest files eagerly shipped from src/scenes/AuthenticatedShell.tsx
| Size | File |
|---|---|
| 280.3 KiB | ../node_modules/.pnpm/posthog-js@1.400.1/node_modules/posthog-js/dist/rrweb.js |
| 267.7 KiB | ../node_modules/.pnpm/@posthog+icons@0.38.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@posthog/icons/dist/posthog-icons.es.js |
| 235.5 KiB | src/taxonomy/core-filter-definitions-by-group.json |
| 222.7 KiB | ../node_modules/.pnpm/posthog-js@1.400.1/node_modules/posthog-js/dist/module.js |
| 164.0 KiB | src/queries/validators.js |
| 154.3 KiB | ../node_modules/.pnpm/re2js@0.4.1/node_modules/re2js/build/index.esm.js |
| 126.8 KiB | ../node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/cjs/react-dom.production.min.js |
| 105.9 KiB | src/lib/api.ts |
| 93.3 KiB | ../node_modules/.pnpm/prosemirror-view@1.40.1/node_modules/prosemirror-view/dist/index.js |
| 92.7 KiB | ../packages/quill/packages/quill/dist/index.js |
Posted automatically by check-eager-graph · sizes are eager output bytes (shipped, post-tree-shake) from the esbuild metafile · part of #32479
✅ Dist folder size — 🟢 -304.2 KiB (-0.0%)
Total size of the built frontend/dist folder (all assets), compared against the base branch.
Total: 1307.77 MiB · 🟢 -304.2 KiB (-0.0%)
Polish pass on the detection wiring: configuredSessionIdKeys selector on logsConfigLogic replaces repeated inline reads, unified param naming, plain-object connect, and a test pinning that the session pivot filter uses the matched configured key. Generated-By: PostHog Code Task-Id: 964398f1-fa06-46f5-8605-2236fa2a3c32
🦔 Hogbox preview · ✅ ready▶ Open the preview
commit |
|
Reviews (1): Last reviewed commit: "refactor(logs): centralize configured se..." | Re-trigger Greptile |
Match AttributeCell's `&& value` guard in the LogAttributes value cell so the ViewRecordingButton is only rendered for a non-empty configured session id key, even if the empty-value early return is ever refactored away. Generated-By: PostHog Code Task-Id: f4ae2e8b-13ad-4671-b6df-6f375b4fc516
Generated-By: PostHog Code Task-Id: f4ae2e8b-13ad-4671-b6df-6f375b4fc516
Generated-By: PostHog Code Task-Id: ce4fe931-775c-45cc-9a77-3e6a06882673
Generated-By: PostHog Code Task-Id: 00b6a2ea-643f-4e76-ad7b-44efedc6e023
Generated-By: PostHog Code Task-Id: 45ceaeac-8adf-4815-8ba6-e76a75db1cb6
|
👋 Visual changes detected for this PR. Review and approve in PostHog Visual Review If these changes are unexpected, they may be caused by a flaky test or a broken snapshot on master. Don't approve — rerun the job or wait for a fix. |
Status updateThe branch is now merged up to date with The only red checks are the visual-review trio (
This logs PR doesn't touch AI observability. The diffs come from I'm deliberately not finalizing/approving them here: doing so would commit an unrelated AIO baseline into Remaining to merge: a human review approval ( 🦉 via talyn.dev |
Generated-By: PostHog Code Task-Id: 00b6a2ea-643f-4e76-ad7b-44efedc6e023
Status: green except one unrelated visual-review gateReview threads: the one review thread (the Merge state: branch is up to date with CI: every functional check is green — Jest (FOSS + EE), frontend typecheck, backend, Rust, Node, and all 16 Storybook chromium shards pass. The only red is the PostHog Visual Review gate ("6 changed"), and those 6 changed snapshots are not from this PR: All six are AI-observability I deliberately did not resolve it by finalizing the baseline here: that would commit an unrelated AIO To unblock: a reviewer can approve those 6 AIO diffs in the visual review run during review (or the baseline gets regenerated on master), plus the usual review approval. 🦉 via talyn.dev |
CI status: all green except Visual Review — root cause is a
|
Generated-By: PostHog Code Task-Id: 7fecffbc-6444-4e4d-b958-937551407cb6
Generated-By: PostHog Code Task-Id: 96e692ef-17e6-4cb8-b58b-0c0d704659f8
CI fully green — only a human review approval remainsLatest commit (
The PR still shows 🦉 via talyn.dev |
|
This PR is in a clean, mergeable state:
The only thing left is a required human review approval — nothing further to fix on my end. 🦉 via talyn.dev |
There was a problem hiding this comment.
Contained frontend feature (argument pass-through + fallback logic) by an owning-team author with strong recent familiarity; the one substantive review comment (empty session id button) was fixed and resolved, with new parameterized tests covering the added behavior.
- Author wrote 96% of the modified lines and has 230 merged PRs in these paths (familiarity STRONG).
- 👍 on the PR from greptile-apps[bot], hex-security-app[bot].
Gate mechanics and policy version
| Gate | Result | |
|---|---|---|
| prerequisites | ✓ | all clear |
| deny-list | ✓ | no deny categories matched |
| size | ✓ | 92L, 8F substantive, 157L/10F incl. docs/generated/snapshots — within ceiling |
| tier | ✓ | T1-agent / T1c-medium (157L, 10F, single-area, feat) |
| stamphog 2.0.0b3 | .stamphog/policy.yml @ 46b0dba · reviewed head 446e3c0 |
Problem
The
logs_session_id_attribute_keysteam setting shipped recently (#70414), but nothing consumes it yet: logs session-ID detection still only knows the hardcoded convention list inproducts/logs/frontend/utils.tsx. A team whose pipeline emits the session ID under a custom attribute key gets no replay links, no related-errors matching, and no "view session logs" pivot, even after configuring their keys.Second PR in the logs-in-error-tracking series - the error tracking "view logs" surface will build on the same configured keys.
Changes
Detection now checks the configured keys first, then falls back to the built-in list, so teams that never touch the setting see no change:
isSessionIdKey,getSessionIdWithKey,getSessionIdFromLogAttributesaccept an optionalconfiguredKeyslist. Semantics, now locked in by tests: configured keys are checked in list order, exact match only (no dot-suffix matching, unlike the built-ins), attributes before resource_attributes per key, first value found wins.logsConfigLogic:LogRowFAB)logDetailsModalLogicnow connectslogsConfigLogic, so thesessionIdselector recomputes when config loads)AttributeCell,LogAttributes)logContextUtils+LogContextSelector) - the session filter it builds uses the matched configured key, so the pivot works for custom keys tooWhile config is loading the functions fall back to the built-in list, which contains the default
posthogSessionId- no flash of missing buttons for default configs.How did you test this code?
products/logs/frontend/utils.test.tswith a configured-keys block (92 tests pass across the two affected suites). Each case pins a contract no existing test covered: configured key beats a built-in key present on the same log (the priority rule), list order wins between two configured keys (aSet/object-iteration refactor would silently break ordering), exact-match-only for configured keys (merging them into the suffix-matching helper would silently widen matching), and fallback to built-ins when configured keys are absent (an "exclusive mode" refactor would break every default team).Automatic notifications
Docs update
The setting itself is behind the
LOGS_SETTINGSflag and its docs will land with the user-facing error-tracking surface later in the series.🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Written with PostHog Code (Claude). Skills invoked:
/writing-tests.Decisions:
logDetailsModalLogic) gets proper reactivity by connectinglogsConfigLogicinto its selector dependencies instead.custom.keyshouldn't silently matchanything.custom.key; if they want the suffixed form they can add it as another key.Created with PostHog Code