Replace dead react-ga with @vercel/analytics#45
Open
dawsbot wants to merge 1 commit into
Open
Conversation
react-ga v3 targets Google Universal Analytics, which was sunset in July 2023, so the site has collected no analytics data since then. - Remove react-ga, utils/analytics.js, and all initGA/logPageView/ logEvent wiring in components/layout.js and pages/index.js - Add @vercel/analytics and render <Analytics /> from a new pages/_app.js per the Next.js pages-router docs (zero-config on Vercel hosting) Co-Authored-By: Claude Fable 5 <noreply@anthropic.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
utils/analytics.js+components/layout.jswire upreact-gav3, which targets Google Universal Analytics — sunset July 2023. The site has been sending pageviews/events into the void for ~3 years.What
react-ga,utils/analytics.js, theinitGA/logPageViewuseEffectincomponents/layout.js, and thelogEventcalls inpages/index.js(custom events aren't part of the zero-config Web Analytics free tier, so they were dropped rather than ported).@vercel/analyticsand a newpages/_app.jsthat renders<Analytics />(imported from@vercel/analytics/next), per the Next.js pages-router quickstart. Zero config since the site is Vercel-hosted — just enable Web Analytics in the project dashboard if it isn't already.preact/compat note
next.config.jsaliases React topreact/compatin client production builds.<Analytics />from@vercel/analytics/nextusesSuspenseplusnext/navigationhooks, both of whichpreact/compat/ Next pages-router support.next build(which runs the preact-aliased client compile) passes cleanly, so no gating was needed. Caveat: verified at build time only, not in a live browser session — worth a one-click check in Vercel preview that/_vercel/insights/script.jsloads.Verification
next buildpasses (client bundle compiled with the preact alias)eslint .— no new warnings (3 pre-existing warnings untouched)🤖 Generated with Claude Code