Repository navigation
feat: telemetry-sent notice + SessionEnd drain fix + v0.20.0 (re-land of #88) - #89
Conversation
After a drain uploads (or fails to upload) telemetry, surface a single line the
next time SessionStart runs — without a FileChanged watcher. The drain runs in a
detached process that can't print to the session, so it records the outcome in a
small upload-result sentinel; SessionStart reads it, shows one line, and marks it
notified so it never repeats.
- credstore: upload-result sentinel (writeUploadResult / readUploadResult /
markUploadNotified) storing { events, transcripts, error, ts, notified }.
- transfer.js: upload fns now return { ok, error } (error only for real
transmission failures — HTTP/network — not precondition skips like a missing
token). drainQueuesOnce (the single choke point) tallies successes + errors and
records a success result when anything uploaded, else a failure result with the
error.
- banner.js: telemetrySentNotice (✓ ... N events, M transcripts) and
telemetryFailedNotice (✗ ... <error>). Plain text — systemMessage renders ANSI
literally.
- session_start: emit the notice line (once) alongside any existing banner.
Verified end-to-end: success drain → "✓ telemetry sent · 3 events, 1 transcript"
shown once then suppressed; failed drain (unreachable endpoint) → "✗ telemetry
send failed · fetch failed" shown once then suppressed. Gate golden diff
unchanged; harness tests 20/20.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…y failed)
runHook invokes `afterLog`/`afterSkip` as `(input, deviceId)`, but
sealFinalSessionArtifactsAndDrain(input, timeoutMs) and
sealEventLogAndDrain(timeoutMs) were wired directly as those callbacks — so the
deviceId string landed in `timeoutMs` (and `input` did, for afterSkip). That made
`AbortSignal.timeout(<deviceId>)` throw `The "delay" argument must be of type
number`, so every SessionEnd event-log/transcript upload failed silently (the
error only went to stderr).
The new upload-result notice surfaced it as:
✗ SkillMeter · telemetry send failed · The "delay" argument must be of type
number. Received type string ('890454D8-…')
Fix: both functions now take `(input)` (the afterLog/afterSkip convention) and
use the fixed SESSION_END_DRAIN_TIMEOUT_MS internally. Verified: the SessionEnd
path invoked as (input, deviceId) now drains with the correct timeout and
reports the real outcome (e.g. "fetch failed") instead of the delay error.
Gate golden diff unchanged; harness tests 20/20.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
Disabled knowledge base sources:
WalkthroughAdds a telemetry upload-result sentinel with read/write/notify helpers, converts transfer functions to return structured ChangesTelemetry Upload Result Reporting
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant SessionEnd
participant drainQueuesOnce
participant transferEventLog
participant uploadPendingTranscript
participant credstore
participant SessionStart
participant banner
SessionEnd->>drainQueuesOnce: run drain (fixed timeout)
drainQueuesOnce->>transferEventLog: retry failed logs
drainQueuesOnce->>uploadPendingTranscript: upload pending transcripts
transferEventLog-->>drainQueuesOnce: { ok, error }
uploadPendingTranscript-->>drainQueuesOnce: { ok, error }
drainQueuesOnce->>credstore: writeUploadResult(events, transcripts, error)
SessionStart->>credstore: readUploadResult()
credstore-->>SessionStart: { events, transcripts, error, notified:false }
alt events or transcripts > 0
SessionStart->>banner: telemetrySentNotice(events, transcripts)
else error present
SessionStart->>banner: telemetryFailedNotice(error)
end
SessionStart->>credstore: markUploadNotified()
Possibly related PRs
Suggested reviewers: Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Re-lands PR #88's content onto main. #88 was merged into the
feat/require-jwt-for-telemetrybranch, but #87 had already squash-merged to main first, so #88's changes never reached main. This brings them straight to main.Includes
runHookinvokesafterLog/afterSkipas(input, deviceId), butsealFinalSessionArtifactsAndDrain(input, timeoutMs)/sealEventLogAndDrain(timeoutMs)were wired directly as those callbacks — so the deviceId landed intimeoutMs,AbortSignal.timeout(<deviceId>)threwThe "delay" argument must be of type number, and every SessionEnd event-log/transcript upload has been failing silently. Both now take(input)and useSESSION_END_DRAIN_TIMEOUT_MSinternally.upload-result.jsonsentinel; the next SessionStart shows✓ SkillMeter · telemetry sent · N events, M transcripts(or✗ … send failed · <error>) once, then marks it notified. No FileChanged watcher./pluginreporting 0.19.0 as latest).Verification
(input, deviceId)now drains with the correct timeout and reports the real outcome (fetch failed) instead of the delay error.node --test skillmeter/test/harness.test.js→ 20/20;claude plugin validate skillmeter→ ✔.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes