Skip to content

Telemetry consent via SessionStart nudge (replaces osascript dialog) - #44

Merged
minarc merged 1 commit into
mainfrom
feat/telemetry-consent-via-session-start
Apr 22, 2026
Merged

minarc merged 1 commit into
mainfrom
feat/telemetry-consent-via-session-start

Conversation

@minarc

@minarc minarc commented Apr 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The plugin's per-project telemetry opt-in flow depended on a macOS-only `osascript` dialog. That's the last cross-OS hole in the consent path: Linux/Windows users hit the `catch` branch silently, got `false` back, and never saw a prompt. This PR removes the dialog and replaces it with a SessionStart stderr nudge that works identically on every platform.

Why not UserPromptSubmit block?

Considered. A hard block on the user's first prompt would force a choice, but:

  • It makes the plugin an interruption before the user has even engaged with Claude
  • SessionStart runs first anyway — any message shown there beats one that fires mid-intent
  • Claude Code's SessionStart hook can't emit `decision: "block"`, so the forcing semantics don't transfer cleanly

SessionStart stderr is the same mechanism the plugin already uses to announce its version (`SkillMeter vX.Y (activated)`). Adding the consent hint there is consistent UX.

Flow

```
Session starts in a working directory
│
▼
SessionStart hook reads .claude/settings.local.json's skillmeter.telemetry
│
├─ true → stderr "SkillMeter vX.Y (activated)", telemetry on
├─ false → stderr "SkillMeter vX.Y (telemetry disabled for this project)"
└─ unset → stderr
"SkillMeter vX.Y (telemetry not configured for this project)
Run /skillmeter:sk-telemetry enable — send anonymized session data
Run /skillmeter:sk-telemetry disable — opt out for this project"
— and skips telemetry this session
```

The existing `/skillmeter:sk-telemetry enable|disable` slash command writes to `.claude/settings.local.json`; next SessionStart takes the corresponding branch.

Changes

  • `scripts/logger.js` — delete `promptTelemetryOptIn` and its export. The function was the only `osascript` caller in the repo.
  • `scripts/session_start.js` — replace `optIn === null → promptTelemetryOptIn` with three explicit branches (enabled / disabled / unset) plus the slash-command hint.

Verified

`spawnSync` harness drives `session_start.js` against a scratch cwd with each of the three consent states seeded into a throwaway `.claude/settings.local.json`:

State Exit Stderr contains
`enabled` 0 `SkillMeter vX (activated)`
`disabled` 0 `telemetry disabled for this project`
`unset` 0 `telemetry not configured for this project` + both slash-command hints

Out of scope

  • Install-time `userConfig.telemetry_default` — not needed once the per-project slash command is the single source of truth. Adding a user-level default would re-introduce the "what if they never pick" question this PR already answers (nudge + skip).
  • `UserPromptSubmit` blocking — the stricter UX path. Available as a follow-up if the stderr nudge proves too easy to ignore.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Changes
    • Removed interactive telemetry opt-in dialog prompts.
    • Updated telemetry configuration to require explicit setup via slash commands (/skillmeter:sk-telemetry enable/disable).
    • When telemetry is not configured, users now receive on-screen instructions for enabling or disabling telemetry tracking.

The plugin gated telemetry on a per-project opt-in stored in
.claude/settings.local.json. On first session in a new working
directory the value was missing and logger.js called
promptTelemetryOptIn, which spawned a macOS osascript Yes/No dialog.
Three problems with that:

  - Linux and Windows had no dialog at all. execSync threw, the
    catch returned false, and telemetry was silently opted out
    forever without the user ever seeing a prompt.
  - The dialog blocked the session startup path until dismissed.
  - It hijacked the user's GUI mid-task.

New flow — no native dialog, consent stays per-project:

  1. SessionStart hook inspects the per-project setting.
       enabled  → stderr "SkillMeter vX (activated)", telemetry on
       disabled → stderr "... (telemetry disabled for this project)"
       unset    → stderr nudge with /skillmeter:sk-telemetry enable|
                  disable instructions; telemetry skipped this session
  2. User runs the slash command once per working directory. The
     existing /skillmeter:sk-telemetry writes to .claude/
     settings.local.json and subsequent SessionStarts take the
     enabled/disabled path.

Cross-OS, non-blocking, visible in-session. The user chooses when
they want to and their choice is per-workdir (same granularity as
before).

Changes:
  logger.js       — remove promptTelemetryOptIn + its export
  session_start.js — new checkOptIn branches with per-state stderr;
                     refactor to use getTelemetryOptIn directly

Verified end-to-end (spawnSync session_start.js with stubbed stdin):
  - enabled state  → stderr "activated", retryFailedLogs runs,
                     checkOptIn returns true (telemetry on)
  - disabled state → stderr "telemetry disabled", returns false
  - unset state    → stderr "telemetry not configured" + the two
                     slash-command hints, returns false

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Apr 22, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a80d4514-ae68-45fd-a286-7a63d5c11f2a

📥 Commits

Reviewing files that changed from the base of the PR and between a0038b5 and fe2fb72.

📒 Files selected for processing (2)
  • skillmeter/scripts/logger.js
  • skillmeter/scripts/session_start.js
💤 Files with no reviewable changes (1)
  • skillmeter/scripts/logger.js

Walkthrough

The changes remove interactive telemetry prompting via native macOS dialogs and replace it with a configuration-driven approach. Users must explicitly set telemetry preferences through configuration files or slash-commands rather than being prompted during session initialization.

Changes

Cohort / File(s) Summary
Interactive Prompting Removal
skillmeter/scripts/logger.js
Removed promptTelemetryOptIn(cwd) function implementation and its export. This function previously displayed a native macOS dialog to request telemetry consent from users.
Telemetry Check Logic Update
skillmeter/scripts/session_start.js
Removed fallback invocation of promptTelemetryOptIn(cwd) when telemetry configuration was absent. Updated checkOptIn to handle tri-state values strictly: true activates telemetry, false disables it, and null logs guidance with slash-command instructions for manual configuration.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 No more dialogs pop, no more questions to ask,
Configuration's now the primary task!
Slash-commands guide the way, clear and bright,
Explicit settings replace the prompt's bite,
Telemetry flows when users choose right! 📋

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: replacing a macOS osascript dialog with a SessionStart-based telemetry consent approach.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 feat/telemetry-consent-via-session-start

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

@minarc
minarc merged commit 1d256f8 into main Apr 22, 2026
1 check passed
@TheStarkor
TheStarkor deleted the feat/telemetry-consent-via-session-start branch September 21, 2026 18:40
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