Skip to content

fix(web): prevent UTM click handler from breaking cross-app navigation#7798

Merged
AmanVarshney01 merged 1 commit intomainfrom
fix/utm-cross-app-navigation
Apr 15, 2026
Merged

fix(web): prevent UTM click handler from breaking cross-app navigation#7798
AmanVarshney01 merged 1 commit intomainfrom
fix/utm-cross-app-navigation

Conversation

@AmanVarshney01
Copy link
Copy Markdown
Member

@AmanVarshney01 AmanVarshney01 commented Apr 15, 2026

Summary

  • Site app: Clicking "Docs" or "Blog" from pages with UTM params (e.g. /?utm_term=devrel) did nothing — router.push("/docs") tried client-side routing to a proxied path that doesn't exist as a page in the site app
  • Blog app: Clicking any non-blog link (Pricing, Docs, etc.) from /blog?utm_term=devrel → 404 because router.push("/pricing") got basePath: "/blog" prepended → /blog/pricing
  • Fix: each app's UTM click handler now only uses router.push() for paths it owns. Cross-app links fall through to anchor.setAttribute() so the browser does a full navigation and server rewrites apply correctly

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Refined internal link routing logic to improve navigation accuracy across the site
    • Enhanced handling for links within blog and documentation sections to ensure proper navigation flow
    • Optimized routing behavior for distinct route types

…igation

router.push() only works for pages owned by the current Next.js app.
The UTM persistence click handler was using it for every same-origin
link, which broke navigation to pages served by other apps:

- Site app: /docs and /blog are proxied via rewrites to separate
  origins. router.push() tried client-side routing to a page that
  doesn't exist in the site app — click did nothing.

- Blog app: has basePath "/blog", so router.push("/pricing") became
  /blog/pricing — 404.

Now each app only uses router.push() for paths it owns. Cross-app
links fall through to anchor.setAttribute(), letting the browser
do a full navigation where server rewrites apply correctly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
blog Ready Ready Preview, Comment Apr 15, 2026 8:53am
docs Ready Ready Preview, Comment Apr 15, 2026 8:53am
eclipse Ready Ready Preview, Comment Apr 15, 2026 8:53am
site Ready Ready Preview, Comment Apr 15, 2026 8:53am

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 15, 2026

Walkthrough

Two UtmPersistence components updated with refined navigation logic: blog version adds a guard to only apply client-side routing for blog-path targets, while site version extends internal route handling to recognize proxied paths and allows their natural navigation instead of forcing client-side routing.

Changes

Cohort / File(s) Summary
Blog UtmPersistence
apps/blog/src/components/utm-persistence.tsx
Refactored click-handling logic to introduce isBlogPath guard, restricting preventDefault() and router.push() to internal links whose target URL pathname is within the blog prefix subtree. Removes precomputed nextInternalHref variable in favor of inline construction from internalPathname.
Site UtmPersistence
apps/site/src/components/utm-persistence.tsx
Extended internal route handling to identify proxied paths (/docs, /blog and their subtrees) and bypass client-side routing for these targets, allowing natural browser navigation. Preserves existing router.push() behavior for other internal links.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the core issue being fixed: preventing the UTM click handler from breaking cross-app navigation between the site and blog applications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@argos-ci
Copy link
Copy Markdown

argos-ci Bot commented Apr 15, 2026

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - Apr 15, 2026, 9:12 AM

@AmanVarshney01 AmanVarshney01 changed the title fix(blog,site): prevent UTM click handler from breaking cross-app navigation fix(web): prevent UTM click handler from breaking cross-app navigation Apr 15, 2026
@AmanVarshney01 AmanVarshney01 merged commit 9bcb676 into main Apr 15, 2026
16 checks passed
@AmanVarshney01 AmanVarshney01 deleted the fix/utm-cross-app-navigation branch April 15, 2026 09:00
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.

3 participants