Skip to content

feat(telemetry): add standalone telemetry for create-sanity#892

Draft
mttdnt wants to merge 10 commits intofeat/bundled-create-sanityfrom
feat/bundled-create-sanity-telemetry-clean
Draft

feat(telemetry): add standalone telemetry for create-sanity#892
mttdnt wants to merge 10 commits intofeat/bundled-create-sanityfrom
feat/bundled-create-sanity-telemetry-clean

Conversation

@mttdnt
Copy link
Copy Markdown
Contributor

@mttdnt mttdnt commented Apr 7, 2026

Description

  • Replace noop telemetry store in create-sanity with real telemetry
  • Add setupStandaloneTelemetry — mirrors the oclif prerun hook without the oclif dependency, flushes inline with a 3s timeout instead of a detached worker
  • Add telemetryDisclosureStandalone and unify telemetryDisclosure to re-export it
  • Parse args before telemetry setup so --help exits without showing the disclosure banner (parity with oclif where --help runs before the prerun hook)
  • output.error throws InitError so errors flush through the same catch path as other errors
  • Delete noopTelemetry.ts

Copy link
Copy Markdown
Contributor Author

mttdnt commented Apr 7, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@claude
Copy link
Copy Markdown

claude bot commented Apr 7, 2026

Claude finished @mttdnt's task in 3m 40s —— View job


Review

  • Read CLAUDE.md and gather context
  • Review changed files
  • Check for changeset
  • Post findings

Missing changeset

create-sanity gains real telemetry where there was previously a noop store — a user-facing runtime behavior change. A changeset is required for create-sanity (minor) and probably a patch for @sanity/cli (telemetry disclosure refactored to remove oclif dependency). None of the existing changesets cover this PR.


output.error drops the original error's cause

packages/create-sanity/src/index.ts:67

error: (msg: Error | string): never => {
  throw new InitError(msg instanceof Error ? msg.message : msg, 1)
},

When msg is an Error, only .message is preserved — the original stack trace and cause chain are silently dropped. Telemetry then records InitError (with the message text) rather than the original error type, which makes error analytics harder to interpret.

Fix: Fix this →

error: (msg: Error | string): never => {
  throw new InitError(
    msg instanceof Error ? msg.message : msg,
    1,
    msg instanceof Error ? {cause: msg} : undefined,
  )
},

Telemetry disclosure message may confuse first-time users

packages/@sanity/cli/src/actions/telemetry/telemetryDisclosureStandalone.ts:30

The banner tells users to run npx sanity telemetry enable/disable — but create-sanity runs before sanity is installed. A user running npm create sanity@latest for the first time won't have the sanity CLI available yet, so the opt-out instruction is not actionable at that moment. Consider noting they can also run the command after installation, e.g. "Once installed, run npx sanity telemetry disable to opt out."

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

📦 Bundle Stats — @sanity/cli

Compared against feat/bundled-create-sanity (bc02ced5)

@sanity/cli

Metric Value vs feat/bundled-create-sanity (bc02ced)
Internal (raw) 2.1 KB -
Internal (gzip) 799 B -
Bundled (raw) 1.54 MB -
Bundled (gzip) 394.7 KB -
Import time 870ms +7ms, +0.8%

bin:sanity

Metric Value vs feat/bundled-create-sanity (bc02ced)
Internal (raw) 975 B -
Internal (gzip) 460 B -
Bundled (raw) 9.84 MB -
Bundled (gzip) 1.77 MB -
Import time 1.96s -48ms, -2.4%

🗺️ View treemap · Artifacts

Details
  • Import time regressions over 10% are flagged with ⚠️
  • Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.

📦 Bundle Stats — @sanity/cli-core

Compared against feat/bundled-create-sanity (bc02ced5)

Metric Value vs feat/bundled-create-sanity (bc02ced)
Internal (raw) 98.0 KB -
Internal (gzip) 23.3 KB -
Bundled (raw) 21.65 MB -
Bundled (gzip) 3.43 MB -
Import time 814ms -6ms, -0.7%

🗺️ View treemap · Artifacts

Details
  • Import time regressions over 10% are flagged with ⚠️
  • Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.

📦 Bundle Stats — create-sanity

Compared against feat/bundled-create-sanity (bc02ced5)

Metric Value vs feat/bundled-create-sanity (bc02ced)
Internal (raw) 2.56 MB +199.4 KB, +8.2%
Internal (gzip) 605.4 KB +50.1 KB, +9.0%
Bundled (raw) 2.56 MB +199.8 KB, +8.2%
Bundled (gzip) 605.4 KB +50.2 KB, +9.0%
Import time ❌ TypeError: Cannot add property upath, object is not extensible -
Details
  • Import time regressions over 10% are flagged with ⚠️
  • Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.

@mttdnt mttdnt changed the title feat(telemetry): add standalone telemetry disclosure without oclif dep feat(telemetry): add standalone telemetry for create-sanity Apr 7, 2026
@binoy14 binoy14 force-pushed the feat/bundled-create-sanity-telemetry-clean branch from 4817cd2 to 96a3752 Compare April 10, 2026 18:19
@binoy14 binoy14 force-pushed the feat/bundled-create-sanity branch from 0492ffa to 00daf50 Compare April 10, 2026 18:19
rexxars and others added 9 commits April 16, 2026 18:44
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The oclif-based telemetryDisclosure now delegates to
telemetryDisclosureStandalone, removing the @oclif/core dependency
from the disclosure module. Both the main CLI and create-sanity
use the same code path.
@mttdnt mttdnt force-pushed the feat/bundled-create-sanity-telemetry-clean branch from 96a3752 to efebeeb Compare April 16, 2026 23:14
@mttdnt mttdnt force-pushed the feat/bundled-create-sanity branch from 00daf50 to bc02ced Compare April 16, 2026 23:14
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.

2 participants