CATALYST-1532: Fix analytics visit count inflation#2916
Merged
chanceaclark merged 1 commit intocanaryfrom Mar 10, 2026
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 1c91011 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
510c0b4 to
a7cdc53
Compare
Contributor
Bundle Size ReportComparing against baseline from No bundle size changes detected. |
jorgemoya
approved these changes
Mar 10, 2026
Contributor
jorgemoya
left a comment
There was a problem hiding this comment.
I was seeing this with the unstable_cache refactor, nice fix
rtalvarez
approved these changes
Mar 10, 2026
Resolve inflated visitor counts caused by three issues: - Visit cookie used a fixed TTL instead of a sliding window, creating new visits for users browsing longer than 30 minutes. Now refreshes the cookie TTL on every request. - Prefetch and RSC requests triggered new visit and product view events. Now guards against Next-Router-Prefetch and RSC headers so only real navigations fire analytics mutations. - Locale redirects from withIntl bypassed analytics entirely. Reorder middleware so withAnalyticsCookies runs before withIntl, ensuring cookies survive redirect responses. Fixes CATALYST-1532 Co-Authored-By: Claude <noreply@anthropic.com>
a7cdc53 to
1c91011
Compare
chanceaclark
commented
Mar 10, 2026
Contributor
Author
There was a problem hiding this comment.
Just added a changeset and rebased the PR.
chanceaclark
added a commit
that referenced
this pull request
Apr 27, 2026
Resolve inflated visitor counts caused by three issues: - Visit cookie used a fixed TTL instead of a sliding window, creating new visits for users browsing longer than 30 minutes. Now refreshes the cookie TTL on every request. - Prefetch and RSC requests triggered new visit and product view events. Now guards against Next-Router-Prefetch and RSC headers so only real navigations fire analytics mutations. - Locale redirects from withIntl bypassed analytics entirely. Reorder middleware so withAnalyticsCookies runs before withIntl, ensuring cookies survive redirect responses. Fixes CATALYST-1532 Co-authored-by: Claude <noreply@anthropic.com>
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.
Jira: CATALYST-1532
What/Why?
Enterprise merchant (Marucci Sports) reported significantly inflated visitor counts after migrating from Stencil to Catalyst. Three root causes:
visitIdcookie TTL was set once and never refreshed, so sessions >30 minutes silently created new visits.RSCandNext-Router-Prefetchrequests through middleware. With an expired cookie, each triggered a separateVisitStartedmutation.withIntlran beforewithAnalyticsCookiesand returned early on redirects, so the visit cookie was never refreshed on those requests.Notable edge case: when a prefetch/RSC request arrives with an expired cookie, we intentionally skip setting a new
visitIdcookie so the subsequent real navigation properly detects a new visit and fires the event. The same prefetch guard is applied torecordProductVisitinwith-routes.ts.Fixes CATALYST-1532
Rollout/Rollback
Standard code rollout. No feature flags, database migrations, or experiments. Rollback is a simple revert.
Testing
catalyst.visitIdcookie expiry resets on each navigation.RSC: 1orNext-Router-Prefetch: 1headers). Confirm these do not triggerVisitStartedmutations in GraphQL client logs.Set-Cookieforcatalyst.visitIdis present on the redirect response.cd core && npx playwright test