posthog icon indicating copy to clipboard operation
posthog copied to clipboard

feat(tracing): carry the date range through the operation scene URL

Open jonmcwest opened this issue 4 months ago • 11 comments

Problem

Clicking a row on the Operations tab computed over, say, the last 7 days opens the operation detail scene on the default last hour — the stats describe a different window than the row the user clicked. The scene's date range also doesn't survive reloads or shared links, though the duration selection and sample index already do.

Changes

urls.tracingOperation takes an optional dateRange, the Operations tab passes its active range, and the scene logic persists non-default ranges to the URL and restores them on load (restored before the selection params, since setDateRange resets the pager). Also swaps a JSON.stringify comparison for objectsEqual.

How did you test this code?

tracingOperationSceneLogic.test.ts passes locally. products.tsx regenerated via pnpm build:products.

Automatic notifications

  • [ ] Publish to changelog?
  • [ ] Alert Sales and Marketing teams?

Docs update

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Built with PostHog Code (Claude); /writing-kea-logics conventions followed for the router bindings. Part of a set of small PRs split from the too-broad #71484 (now closed).


Created with PostHog Code

jonmcwest avatar Jul 16 '26 11:07 jonmcwest

🤖 CI report

⚠️ Bundle size — 🔺 +468 B (+0.0%)

Uncompressed size of every built .js bundle, compared against the base branch.

Total: 64.21 MiB · 🔺 +468 B (+0.0%)

No file changed by more than 1000 B.

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.23 MiB · 22 files no change ███░░░░░░░ 28.6% of 4.29 MiB
authenticated shell (every logged-in page)
src/scenes/AuthenticatedShell.tsx
8.18 MiB · 2,996 files 🔺 +40 B (+0.0%) █████████░ 88.4% 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/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.production.min.js
24.6 KiB ../node_modules/.pnpm/[email protected]/node_modules/buffer/index.js
6.3 KiB ../node_modules/.pnpm/[email protected]/node_modules/react/cjs/react.production.min.js
4.5 KiB ../node_modules/.pnpm/@[email protected]/node_modules/@jspm/core/nodelibs/browser/process.js
3.9 KiB ../node_modules/.pnpm/[email protected]/node_modules/scheduler/cjs/scheduler.production.min.js
1.4 KiB ../node_modules/.pnpm/[email protected]/node_modules/base64-js/index.js
1.3 KiB src/RootErrorBoundary.tsx
912 B ../node_modules/.pnpm/[email protected]/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
281.3 KiB ../node_modules/.pnpm/[email protected]/node_modules/posthog-js/dist/rrweb.js
267.7 KiB ../node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@posthog/icons/dist/posthog-icons.es.js
235.8 KiB src/taxonomy/core-filter-definitions-by-group.json
223.4 KiB ../node_modules/.pnpm/[email protected]/node_modules/posthog-js/dist/module.js
167.1 KiB src/queries/validators.js
154.3 KiB ../node_modules/.pnpm/[email protected]/node_modules/re2js/build/index.esm.js
126.8 KiB ../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.production.min.js
105.9 KiB src/lib/api.ts
93.3 KiB ../node_modules/.pnpm/[email protected]/node_modules/prosemirror-view/dist/index.js
93.2 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 — 🔺 +4.3 KiB (+0.0%)

Total size of the built frontend/dist folder (all assets), compared against the base branch.

Total: 1351.70 MiB · 🔺 +4.3 KiB (+0.0%)

✅ Playwright — all passed

All tests passed.

View test results →

github-actions[bot] avatar Jul 16 '26 11:07 github-actions[bot]

🦔 Hogbox preview · ✅ ready

▶ Open the preview

🔑 Login [email protected] / 12345678 (demo data)
🧩 Running this PR's backend and frontend, on the PostHog :master base
🔗 Link stable across rebuilds — a re-push swaps the box underneath, the URL stays
🔒 Access tailnet only (PostHog VPN)
🛠️ Admin inspect & debug state in hogland
💤 Idle sleeps after ~30 min idle (snapshot to S3, zero node cost) and wakes on your next visit in ~30s, behind a brief "waking up" screen

commit b608a7d · box box-5901e5b1961b · ready in 755s (push → usable) · build log · rebuilds on every push, torn down on close

github-actions[bot] avatar Jul 16 '26 12:07 github-actions[bot]

Reviews (1): Last reviewed commit: "feat(tracing): carry the date range thro..." | Re-trigger Greptile

greptile-apps avatar Jul 16 '26 12:07 greptile-apps

[!NOTE] 🤖 stamphog reviewed f2207ec05fce3c31bfd3622a07904d66c459eed3 — verdict: REFUSED

Low-risk frontend URL/state change with a STRONG-familiarity author, but Greptile left three unresolved P1/P2 findings describing concrete correctness bugs (stale state, invalid parsed values, REPLACE-path restoration gap) that the current diff has not addressed.

  • Author wrote 100% of the modified lines and has 137 merged PRs in these paths (familiarity STRONG).
  • greptile-apps[bot] reviewed the current head.
  • 3 unresolved P1/P2 inline review comments from Greptile on tracingOperationSceneLogic.ts flag real correctness bugs: (1) navigating to a URL without dateRange leaves the stale range in state instead of resetting to default, (2) JSON.parse accepts non-shape-conforming values (null, numbers, arrays) that bypass the DateRange contract and can produce broken operation queries, (3) the dateRange restoration is unreachable on REPLACE navigations because of the early return above it.
  • None of these threads are marked resolved or outdated, and the diff still shows the same code the comments describe.
Gate mechanics and policy version
Gate Result
prerequisites ✓ all clear
deny-list ✓ no deny categories matched
size ✓ 54L, 4F substantive — within ceiling
tier ✓ T1-agent / T1b-small (54L, 4F, two-areas, feat)
stamphog 2.0.0b3 .stamphog/policy.yml @ 800cd6f · reviewed head f2207ec

stamphog[bot] avatar Jul 16 '26 12:07 stamphog[bot]

Static Badge   Static Badge   Static Badge   Static Badge

View Full Report ↗︎ ⋅ Docs

trunk-io[bot] avatar Jul 16 '26 12:07 trunk-io[bot]

[!NOTE] 🤖 stamphog review failed before producing a verdict

Check the workflow run and re-apply the label to retry.

stamphog[bot] avatar Jul 16 '26 22:07 stamphog[bot]

[!NOTE] 🤖 stamphog review failed before producing a verdict

Check the workflow run and re-apply the label to retry.

stamphog[bot] avatar Jul 16 '26 22:07 stamphog[bot]

👋 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.

posthog[bot] avatar Jul 16 '26 22:07 posthog[bot]

Status: only the visual-review gate is blocking, and it's pre-existing baseline drift

All conflicts are resolved (branch rebased cleanly onto master, diff is exactly the 5 intended tracing/URL files), reviews are resolved and the PR is approved, and it's MERGEABLE. Every non-visual CI check is green.

The one remaining blocker is the required visual-review gate (Complete Visual Review run / Visual regression tests pass), failing on 2 changed snapshots:

  • scenes-app-settings-authentication-domains--boost-needs-upgrade--dark
  • scenes-app-settings-authentication-domains--boost-needs-upgrade--light

These are not caused by this PR. This branch's own commits are tracing-only and touch nothing under frontend/src/scenes/ — the changed story is the Settings → Authentication domains "boost needs upgrade" scene. The diff is a real ~2–3% structural change (ssim ≈ 0.79), so it's genuine baseline drift carried in from master, not flaky anti-aliasing noise, and it would surface on any PR that re-captures this story until the baseline is refreshed.

I did not finalize the VR run: the VR tooling requires explicit, per-run human confirmation before finalizing, and finalizing would commit an unrelated story's baseline into this tracing PR. Deciding how to clear this drift is a call for a human:

  • Finalize this run (approve the 2 snapshots + commit the refreshed baseline) to green the gate here, or
  • Refresh the baseline on master so it stops drifting across PRs, then re-run CI here.

Everything else is done; happy to finalize on this run if that's the preferred path — just confirm.

🦉 via talyn.dev

jonmcwest avatar Jul 17 '26 00:07 jonmcwest

Status: green except for one human-gated visual-review flake

Everything on this PR is resolved and passing except the PostHog Visual Review gate, which is blocking merge on two snapshots that are unrelated to this change.

What's done

  • All three review threads (greptile P1/P1/P2) are resolved with the fixes landed (parseDateRangeParam/isDateRange shape guard, stale-range reset when the URL has no dateRange, and dropping the blanket REPLACE early-return).
  • master is merged in cleanly (signed merge, no file leak — the PR still owns only the five tracing/URL files).
  • The review is APPROVED, and all functional CI (Django, frontend build, semgrep, the 16 Playwright visual-regression shards, etc.) is green after a re-run — the earlier failures were transient GitHub API HTTP 503s during that run window.

The remaining red checks — Complete Visual Review run, PostHog Visual Review / storybook, Visual regression tests pass — all stem from the hosted Visual Review flagging 2 snapshots: scenes-app-settings-authentication-domains--boost-needs-upgrade (light + dark).

These are not caused by this PR (a tracing-only change to urls.tracingOperation and the operation scene logic cannot affect the settings/authentication-domains scene). I pulled the baseline/current images:

  • Baseline (both themes): a broken flaky capture showing the command-palette "Hello John" home overlay instead of the settings page.
  • Current (this PR): the correct "Settings – Authentication domains & SSO" page.

So the flagged "change" is the baseline being a bad capture, not a regression here. The committed Playwright snapshot suite is fully green.

What's needed: a human to approve/finalize (or re-baseline) these 2 snapshots in the Visual Review run. I'm not finalizing on my own initiative — finalizing rewrites the committed baseline and pushes a commit, which per policy needs explicit human confirmation.

🦉 via talyn.dev

jonmcwest avatar Jul 17 '26 00:07 jonmcwest

Status: green except the visual-review gate (pre-existing master drift)

Everything actionable on this PR is resolved:

  • All review threads are resolved and the PR is approved.
  • The earlier red checks (Semgrep ×2, build PR frontend, deploy preview) were a transient GitHub-API error in the paths-filter step — they pass on re-run.
  • Merged master in (branch was 3 behind); it's now up to date with no conflicts and no unrelated files in the diff.
  • The full CI suite — Django, product tests, Playwright, Semgrep, frontend build, deploy preview — is green on the latest commit.

The only remaining red is the visual-review gate (Visual regression tests pass / Complete Visual Review run), which flags 2 changed snapshots:

  • scenes-app-settings-authentication-domains--boost-needs-upgrade--dark (3.31%)
  • scenes-app-settings-authentication-domains--boost-needs-upgrade--light (2.36%)

These are unrelated to this PR — it only touches the tracing product's scene logic and URL builders, no settings/authentication/billing UI. The snapshot history shows this story drifting on master itself (runs with no PR number flip between changed and unchanged across recent commits), and a fresh re-render on the merged commit reproduced the identical diff, so it's deterministic baseline drift on master rather than anything this branch introduced — re-running won't clear it.

I've intentionally not finalized/approved the baseline from here: that would commit an updated (and unverified) authentication-domains baseline into this tracing PR, and refreshing that baseline — or confirming the upgrade UI hasn't actually regressed — is a call for whoever owns that surface. A maintainer can approve/finalize the visual run at merge time, or handle the baseline refresh separately.

🦉 via talyn.dev

jonmcwest avatar Jul 17 '26 00:07 jonmcwest

Deploy status

Environment Status Deployed At Workflow
dev :white_check_mark: Deployed 2026-07-21 11:15 UTC Run
prod-us :white_check_mark: Deployed 2026-07-21 11:33 UTC Run
prod-eu :white_check_mark: Deployed 2026-07-21 11:34 UTC Run