Repository navigation
Report clean analytics paths and redirect /sitemap.xml - #35
Merged
Merged
Conversation
Astro's file build format was sending /index.html, /es.html, and /404.html. Rewrite data-pathname before the analytics element records its single pageview, and use the requested URL on the 404 document. Co-authored-by: Joan Comadran <joancomadran@users.noreply.github.com>
robots.txt already points at the index. A permanent Vercel redirect covers the conventional sitemap path without touching sitemap-index.xml or sitemap-0.xml. Co-authored-by: Joan Comadran <joancomadran@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Vercel Web Analytics on the Astro pages was recording file-build pathnames (
/index.html,/es.html,/blog.html,/404.html) because@vercel/analytics/astrocopiesAstro.url.pathnameintodata-pathname. Withbuild.format: 'file'that pathname includes.html, even thoughcleanUrlsserves/,/es, and/blog. The 404 document is always/404.html, so broken URLs never showed up./sitemap.xmlalso 404s whilerobots.txtpoints at/sitemap-index.xml.What changed
data-pathnamebefore the deferred analytics module defines<vercel-analytics>and sends its one pageview. Static pages drop/index.htmland.html. The 404 page reportslocation.pathname(including a miss that itself ends in.html).@vercel/analytics/astrocomponent still performs the onlyinject()/pageview().disableAutoTrack,framework: 'astro', andwindow.webAnalyticsBeforeSendare unchanged, so custom events and the editor's React analytics are left alone.vercel.jsonpermanently redirects/sitemap.xmlto/sitemap-index.xml(Vercelpermanent: true, HTTP 308)./sitemap-index.xmland/sitemap-0.xmlare not redirected.Verification
npm testnpm run lintnpm run build(astro checkand the static build)npx playwright test(22 passed on Chromium and mobile Chromium)Built HTML still has one
<vercel-analytics>element. Playwright queued a single pageview of/,/es, and/blog/edit-raw-photos-in-browser(route/blog/[slug]), and/no-such-pageon the 404./editorhas no Astro analytics element.distcontainssitemap-index.xmlandsitemap-0.xml, and nositemap.xml.