Skip to content

fix: keep hash routes in performance and heatmap paths - #4644

Open
DahanItamar wants to merge 1 commit into
umami-software:devfrom
DahanItamar:fix/keep-hash-in-heatmap-and-performance-paths
Open

DahanItamar wants to merge 1 commit into
umami-software:devfrom
DahanItamar:fix/keep-hash-in-heatmap-and-performance-paths

Conversation

@DahanItamar

@DahanItamar DahanItamar commented Oct 19, 2026 •

Copy link
Copy Markdown

Reported in #4642.

Problem

On sites that use a hash router (https://app.example.com/#/orders/42), pageviews are split by route, but Performance and Heatmaps put everything on /. The three collection paths derive url_path differently:

Collection Code /#/orders/42 is saved as
Pageview / event src/app/api/send/route.ts (event branch) /#/orders/42
Performance src/app/api/send/route.ts (performance branch) /
Heatmap click / scroll getUrlPath in src/app/api/record/route.ts /

So every route's Web Vitals are averaged together, and all heatmap clicks land on the start page. The tracker's data-before-send can work around Performance, but the recorder has no hook, so Heatmaps can't be fixed client-side.

Change

  • Add getHashRoute to src/lib/url.ts. It returns the hash when it's a router path (#/... or #!/...), without the query inside the hash, and '' otherwise.
  • Append it to the path in the performance branch of /api/send and in getUrlPath in /api/record (both the absolute-URL and relative-URL cases).

Plain in-page anchors such as /docs#install are still saved as /docs, so Performance and Heatmaps don't change for sites that don't use a hash router. Heatmaps don't get split by every anchor, and getHeatmap's iframe preview URL (new URL(urlPath, origin)) now points at the actual hash route instead of the start page.

Tests

  • src/lib/url.test.ts: getHashRoute for #/ and #!/ routes, a query inside the hash, a plain anchor, and empty input.
  • src/app/api/send/route.test.ts: performance events for /#/orders/42, /#!/orders/42, /#/settings?tab=2 and /docs#install.
  • src/app/api/record/route.test.ts: a heatmap batch with absolute and relative URLs, hash routes and anchors.

The hash-route cases fail on dev and pass with this change. The anchor cases pass on both, so normal sites see no change. The full pnpm test suite passes (135 files, 1065 tests) after pnpm build:packages. biome check reports nothing for the changed lines. Its only finding in these files is an existing formatting difference at send/route.test.ts line 107, which I left untouched.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

Pageviews store `pathname + hash`, but performance events and heatmap
clicks/scrolls store only `pathname`. On sites that use a hash router,
every route's Web Vitals and heatmap data collapse into `/`.

Keep the hash when it is a router path (`#/...` or `#!/...`), without
its query. Plain in-page anchors such as `#install` are still dropped,
so heatmaps and performance for other sites are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 19, 2026

Copy link
Copy Markdown

@DahanItamar is attempting to deploy a commit to the Umami Software Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps

greptile-apps Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Keeps hash-router paths in Performance and Heatmaps while leaving plain in-page anchors out.

  • Performance and Heatmap paths keep hash-router routes.

No actionable issues found. Tests were inspected but not run.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Incoming URL] --> B[Parse pathname and hash]
  B --> C{Hash starts with #/ or #!/?}
  C -->|Yes| D[Drop query inside hash]
  C -->|No| E[Ignore hash]
  D --> F[Save pathname plus hash route]
  E --> G[Save pathname only]
Loading

Reviews (1) · Last reviewed commit: "fix: keep hash routes in performance and..." · Reviewed by Greptile

This branch has not been deployed

No deployments
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