Skip to content

Stop a resize from re-counting a deep-link arrival - #129

Merged
ledwards merged 1 commit into
mainfrom
fix-deep-link-analytics-replay
Aug 12, 2026
Merged

Stop a resize from re-counting a deep-link arrival#129
ledwards merged 1 commit into
mainfrom
fix-deep-link-analytics-replay

Conversation

@ledwards

Copy link
Copy Markdown
Contributor

Follow-up to #128, which started tracking deep-link arrivals.

The bug

xterm clears its buffer on resize, so resizeListener reruns runDeepLink() to redraw the output. With analytics enabled that fires a second commandSent event for the same visit.

Caught it on production right after the deploy — a single load of /portfolio/chargelab/ had already logged two events:

[{"event":"commandSent","command":"tldr","args":"chargelab","gtm.uniqueEventId":5},
 {"event":"commandSent","command":"tldr","args":"chargelab","gtm.uniqueEventId":11}]

It would have inflated exactly the numbers the tracking was added to produce, and worst on mobile, where showing and hiding the address bar fires resize.

The fix

runDeepLink({ replay: true }) from the resize path, which sets trackAnalytics: false. That matches the history replay immediately below it, which calls term.command directly rather than executeCommandLine for the same reason — redrawing is not re-running.

Test plan

  • npm test — 95/95, with a new test asserting the replay path does not count
  • Verified the original double-fire on production before the fix

🤖 Generated with Claude Code

Enabling analytics on deep links in #128 made every window resize fire a second
commandSent event. xterm clears its buffer on resize, so resizeListener reruns
the deep link to redraw the output — that is the same visit, not a new arrival.
Caught it on production: one load of /portfolio/chargelab/ had already logged
two events.

It would have inflated exactly the numbers the tracking was added to produce,
and worst on mobile, where showing and hiding the address bar fires resize.

The replay path now passes trackAnalytics: false, matching the history replay
immediately below it, which calls term.command directly for the same reason.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ledwards
ledwards merged commit c9a09a5 into main Aug 12, 2026
6 checks passed
@ledwards
ledwards deleted the fix-deep-link-analytics-replay branch August 12, 2026 19:03
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