Skip to content

feat: telemetry-sent notice + SessionEnd drain fix + v0.20.0 (re-land of #88) - #89

Merged
minarc merged 3 commits into
mainfrom
chore/telemetry-notice-and-sessionend-fix
Jul 8, 2026
Merged

minarc merged 3 commits into
mainfrom
chore/telemetry-notice-and-sessionend-fix

Conversation

@minarc

@minarc minarc commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Re-lands PR #88's content onto main. #88 was merged into the feat/require-jwt-for-telemetry branch, but #87 had already squash-merged to main first, so #88's changes never reached main. This brings them straight to main.

Net diff vs main = notice + SessionEnd fix + version bump (require-JWT is already on main via #87).

Includes

  1. fix: SessionEnd drain passed deviceId as the timeout ⚠️ currently live-broken on main. runHook invokes afterLog/afterSkip as (input, deviceId), but sealFinalSessionArtifactsAndDrain(input, timeoutMs) / sealEventLogAndDrain(timeoutMs) were wired directly as those callbacks — so the deviceId landed in timeoutMs, AbortSignal.timeout(<deviceId>) threw The "delay" argument must be of type number, and every SessionEnd event-log/transcript upload has been failing silently. Both now take (input) and use SESSION_END_DRAIN_TIMEOUT_MS internally.
  2. feat: one-line telemetry-sent notice at SessionStart — the detached drain records its outcome in an upload-result.json sentinel; the next SessionStart shows ✓ SkillMeter · telemetry sent · N events, M transcripts (or ✗ … send failed · <error>) once, then marks it notified. No FileChanged watcher.
  3. chore: bump plugin version to 0.20.0 — so the marketplace actually offers the update (this was the blocker for /plugin reporting 0.19.0 as latest).

Verification

  • SessionEnd path invoked as (input, deviceId) now drains with the correct timeout and reports the real outcome (fetch failed) instead of the delay error.
  • Notice: success shown once then suppressed; failure shown once then suppressed.
  • Telemetry-gate golden diff unchanged; node --test skillmeter/test/harness.test.js → 20/20; claude plugin validate skillmeter → ✔.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added a one-time session-start notice that reports whether telemetry uploads completed successfully or failed.
    • Session start messages now include clearer upload status alongside existing sign-in or telemetry availability notices.
  • Bug Fixes

    • Improved upload handling so results are tracked more reliably and displayed only once.
    • Session end processing now uses more consistent timing and returns clearer status for upload outcomes.

minarc and others added 3 commits July 9, 2026 01:02
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>
@coderabbitai

coderabbitai Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 84f139b1-bfec-491a-9fea-38ad1321c6a7

📥 Commits

Reviewing files that changed from the base of the PR and between 7d8525d and ffc4b96.

📒 Files selected for processing (5)
  • skillmeter/.claude-plugin/plugin.json
  • skillmeter/scripts/credstore.js
  • skillmeter/scripts/lib/banner.js
  • skillmeter/scripts/lib/transfer.js
  • skillmeter/scripts/session_start.js

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.


Walkthrough

Adds a telemetry upload-result sentinel with read/write/notify helpers, converts transfer functions to return structured {ok, error} results, aggregates drain outcomes into upload results, adds SessionStart banner notices for upload success/failure, wires SessionStart to display them once, and bumps the plugin manifest version.

Changes

Telemetry Upload Result Reporting

Layer / File(s) Summary
Upload-result sentinel storage
skillmeter/scripts/credstore.js
Adds UPLOAD_RESULT_FILE, writeUploadResult, readUploadResult, and markUploadNotified helpers and exports them, using atomic writes with a notified flag.
Structured ok/error results in transfer functions
skillmeter/scripts/lib/transfer.js
transferEventLog and uploadPendingTranscript now return { ok, error? } instead of void across precondition, success, and failure paths.
Drain aggregation and session-end wiring
skillmeter/scripts/lib/transfer.js
Adds tally() to aggregate settled results; drainFailedLogs, drainPendingTranscripts, drainQueuesOnce return aggregated counts/errors and write upload results; sealFinalSessionArtifactsAndDrain/sealEventLogAndDrain drop the timeoutMs parameter in favor of a fixed constant.
SessionStart telemetry notice display
skillmeter/scripts/lib/banner.js, skillmeter/scripts/session_start.js
Adds telemetrySentNotice/telemetryFailedNotice banner functions; SessionStart reads the unread upload result, prepends the corresponding notice, marks it notified, and combines it with existing sign-in/telemetry banners.
Plugin manifest version bump
skillmeter/.claude-plugin/plugin.json
Version bumped from 0.19.0 to 0.20.0.

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()
Loading

Possibly related PRs

Suggested reviewers: jhunlee-dev

Poem

A rabbit checks the drain each night,
"Did events fly off in flight?"
One notice shown, then hushed away,
No repeats to spoil your day.
Hop, hop — version's up a notch too! 🐇✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/telemetry-notice-and-sessionend-fix

Comment @coderabbitai help to get the list of available commands.

@minarc
minarc merged commit f027892 into main Jul 8, 2026
1 check was pending
@minarc
minarc deleted the chore/telemetry-notice-and-sessionend-fix branch July 8, 2026 16: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