Repository navigation
Test the telemetry client - #43
Merged
Merged
Conversation
Chunk 1. Adds src/telemetry.test.ts, 30 tests. No source changes. Two properties matter more than the payload shape and both get their own tests: the client never throws into the wizard (a rejected request is swallowed and later events still send), and it delivers nothing before authorize(), since the endpoint rejects unauthenticated posts and an early event is dropped rather than queued. Also pins the duration stamping (start gets duration_ms, complete gets total_duration_ms, and explicit metadata beats both defaults), the Bearer-vs-Basic scheme carried from login, finish()'s start-vs-complete choice, and flush() giving up at its deadline so exit can't hang on an endpoint that never answers. One asymmetry worth recording: note() is gated on --debug alone, not on telemetry being enabled. It never leaves the terminal, so that's fine, but there's now a test saying so on purpose.
This was referenced Sep 24, 2026
Merged
Merged
Merged
Merged
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.
Chunk 1 of the test plan. One new file,
src/telemetry.test.ts, 30 tests. No source changes.What it pins
Two properties matter more here than the payload shape, and each gets its own tests:
It never throws into the wizard. A rejected request is swallowed inside
step(), and later events still send after an earlier one failed. A telemetry outage can't break an install.It delivers nothing before
authorize(). The endpoint rejects unauthenticated posts, so an event fired early is dropped, not queued — visible under--debug, invisible otherwise. Worth a test because "we'll flush it later" is the intuitive-but-wrong reading.Beyond that:
startgetsduration_ms,completegetstotal_duration_ms, neither is stamped on an intermediate step, and explicit metadata beats both defaults (an agent-reported duration has to win over the wizard's fallback).Bearerfor an OAuth token,Basicfor an API key, carried from login rather than hardcoded. Plus theUser-Agentversion and the abort signal.finish()— reports onstartwhen no start has gone out yet, oncompleteonce one has. That's how a run that dies before the handoff still closes its funnel entry.flush()— waits for in-flight requests, but gives up at its deadline when one never settles, so exit can't hang on a dead endpoint.--debug.One asymmetry, recorded on purpose
note()is gated on--debugalone, not on telemetry being enabled — so--no-telemetry --debugstill prints breadcrumbs. They never leave the user's terminal and are never sent, so this looks intentional rather than a leak. There's now a test saying so, so a future reader doesn't have to guess.Verification
30 tests passing,
typecheckclean. I also mutation-checked two of the subtler assertions — flipping the metadata spread order and makingfinish()always sendcomplete— and confirmed exactly those tests fail, then reverted.Note
Low Risk
Test-only change with no runtime or production code modifications.
Overview
Adds
src/telemetry.test.ts(~30 Vitest cases) for the wizardTelemetryclient. No production code changes — this locks in delivery behavior via stubbedfetch, capturedconsole.errordebug output, and fake timers.The suite emphasizes failure isolation (rejected requests never throw; later events still send) and pre-
authorize()behavior (events are dropped, not queued; visible only under--debug). It also covers JSON POST shape, Bearer vs Basic auth,User-Agent, abort signals, duration stamping onstart/complete,finish()routing, debug-onlynote()(including when telemetry is opted out), andflush()waiting vs deadline timeout.Reviewed by Cursor Bugbot for commit 9c6cd46. Bugbot is set up for automated code reviews on this repo. Configure here.