Skip to content

refactor(telemetry): add standalone telemetry for create-sanity#1018

Draft
mttdnt wants to merge 5 commits intofeat/bundled-create-sanity-rebasedfrom
feat/standalone-telemetry-create-sanity
Draft

refactor(telemetry): add standalone telemetry for create-sanity#1018
mttdnt wants to merge 5 commits intofeat/bundled-create-sanity-rebasedfrom
feat/standalone-telemetry-create-sanity

Conversation

@mttdnt
Copy link
Copy Markdown
Contributor

@mttdnt mttdnt commented Apr 24, 2026

Description

Reapply of #892 on top of #1011. Adds real telemetry to create-sanity so we get the same usage/error data as the oclif CLI, without pulling in oclif as a dependency.

  • Replace noop telemetry store with 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
  • Delete noopTelemetry.ts

What to review

  • packages/@sanity/cli/src/util/telemetry/setupStandaloneTelemetry.ts — standalone telemetry setup
  • packages/@sanity/cli/src/actions/telemetry/telemetryDisclosureStandalone.ts — oclif-free disclosure
  • packages/create-sanity/src/index.ts — restructured to parse args first, then setup telemetry
  • packages/create-sanity/src/version.ts — version info for telemetry

Testing

  • New tests for setupStandaloneTelemetry and telemetryDisclosureStandalone
  • TypeScript type checking passes
  • All changed-file tests pass

@mttdnt
Copy link
Copy Markdown
Contributor Author

mttdnt commented Apr 24, 2026

@claude
Copy link
Copy Markdown

claude Bot commented Apr 24, 2026

Claude finished @binoy14's task in 3m 2s —— View job


PR Review

  • Read changed files
  • Check for bugs, logic errors, security issues
  • Check test coverage
  • Check changeset

Missing changeset

No changeset is present in this PR's diff. The previous pr-892.md changeset (removed in db2f242) had:

'@sanity/cli': minor
'create-sanity': minor
---
add standalone telemetry for `create-sanity`

The bump type (minor) and summary were appropriate. The squiggler bot auto-created and then removed a replacement (pr-1018.md) in a later commit. If this PR targets main as part of the stack merge, the changeset needs to be present — confirm whether it's expected to land with the parent (#1011) or needs to be re-added here. Fix this →


Everything else looks good — logic, test coverage, and implementation are clean.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 24, 2026

📦 Bundle Stats — @sanity/cli

Compared against feat/bundled-create-sanity-rebased (25839893)

@sanity/cli

Metric Value vs feat/bundled-create-sanity-rebased (2583989)
Internal (raw) 2.1 KB -
Internal (gzip) 799 B -
Bundled (raw) 1.54 MB -
Bundled (gzip) 395.0 KB -
Import time 771ms -1ms, -0.1%

bin:sanity

Metric Value vs feat/bundled-create-sanity-rebased (2583989)
Internal (raw) 975 B -
Internal (gzip) 460 B -
Bundled (raw) 9.84 MB -
Bundled (gzip) 1.77 MB -
Import time 1.76s -22ms, -1.2%

🗺️ 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-rebased (25839893)

Metric Value vs feat/bundled-create-sanity-rebased (2583989)
Internal (raw) 98.0 KB -
Internal (gzip) 23.3 KB -
Bundled (raw) 21.63 MB -
Bundled (gzip) 3.43 MB -
Import time 740ms +11ms, +1.5%

🗺️ 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-rebased (25839893)

Metric Value vs feat/bundled-create-sanity-rebased (2583989)
Internal (raw) 2.25 MB +146.2 KB, +6.8%
Internal (gzip) 531.4 KB +38.1 KB, +7.7%
Bundled (raw) 2.25 MB +146.6 KB, +6.8%
Bundled (gzip) 531.4 KB +38.1 KB, +7.7%
Import time --output-path must be specified in unattended mode -
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 for create-sanity (#892) feat(telemetry): add standalone telemetry for create-sanity Apr 24, 2026
@binoy14 binoy14 force-pushed the feat/bundled-create-sanity-rebased branch from 02d7b28 to dcc9323 Compare May 1, 2026 18:08
@binoy14 binoy14 force-pushed the feat/standalone-telemetry-create-sanity branch from e023fe6 to 7b272c6 Compare May 1, 2026 18:08
squiggler-app Bot added a commit that referenced this pull request May 1, 2026
@binoy14 binoy14 force-pushed the feat/bundled-create-sanity-rebased branch from dcc9323 to d705c00 Compare May 4, 2026 15:36
@binoy14 binoy14 force-pushed the feat/standalone-telemetry-create-sanity branch from 48cb05b to df29e68 Compare May 4, 2026 15:37
squiggler-app Bot added a commit that referenced this pull request May 4, 2026
@claude
Copy link
Copy Markdown

claude Bot commented May 4, 2026

Claude Code is working…

I'll analyze this and get back to you.

View job run

@binoy14 binoy14 changed the title feat(telemetry): add standalone telemetry for create-sanity refactor(telemetry): add standalone telemetry for create-sanity May 4, 2026
squiggler-app Bot added a commit that referenced this pull request May 4, 2026
mttdnt and others added 5 commits May 4, 2026 13:01
Reapply PR #892 on top of the rebased bundled-create branch.
Replaces the noop telemetry store with real standalone telemetry
for create-sanity, including telemetry disclosure and error reporting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@binoy14 binoy14 force-pushed the feat/standalone-telemetry-create-sanity branch from 4d826fc to 1c91fe5 Compare May 4, 2026 17:01
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

Coverage Delta

File Statements
packages/@sanity/cli-core/src/_exports/index.ts 100.0% (new)
packages/@sanity/cli-core/src/errors/CLIError.ts 72.7% (new)
packages/@sanity/cli-core/src/errors/CLIWarning.ts 100.0% (new)
packages/@sanity/cli-core/src/errors/NonInteractiveError.ts 100.0% (±0%)
packages/@sanity/cli-core/src/errors/ProjectRootNotFoundError.ts 100.0% (±0%)
packages/@sanity/cli-core/src/telemetry/getCliTelemetry.ts 100.0% (±0%)
packages/@sanity/cli-core/src/ux/errors.ts 65.1% (new)
packages/@sanity/cli-core/src/ux/output.ts 100.0% (new)
packages/@sanity/cli/src/SanityHelp.ts 88.1% (+ 7.7%)
packages/@sanity/cli/src/actions/init/env/createOrAppendEnvVars.ts 0.0% (±0%)
packages/@sanity/cli/src/actions/init/flags.ts 100.0% (new)
packages/@sanity/cli/src/actions/init/flagsToInitOptions.ts 100.0% (new)
packages/@sanity/cli/src/actions/init/initError.ts 100.0% (±0%)
packages/@sanity/cli/src/actions/init/initStudio.ts 85.1% (- 1.9%)
packages/@sanity/cli/src/actions/mcp/setupMCP.ts 100.0% (±0%)
packages/@sanity/cli/src/actions/telemetry/telemetryDisclosureStandalone.ts 100.0% (new)
packages/@sanity/cli/src/commands/init.ts 100.0% (±0%)
packages/@sanity/cli/src/prompts/promptForDefaultConfig.ts 100.0% (±0%)
packages/@sanity/cli/src/util/flagAdapter.ts 91.7% (new)
packages/@sanity/cli/src/util/telemetry/setupStandaloneTelemetry.ts 96.3% (new)
packages/create-sanity/rollup.config.ts 0.0% (new)
packages/create-sanity/src/createCommand.ts 0.0% (new)
packages/create-sanity/src/help.ts 0.0% (new)
packages/create-sanity/src/index.ts 0.0% (new)
packages/create-sanity/src/parseArgs.ts 0.0% (new)
packages/create-sanity/src/version.ts 0.0% (new)

Comparing 26 changed files against main @ ccda8fd8f6db84cdc47490d94342f9a4f6352afd

Overall Coverage

Metric Coverage
Statements 82.7% (- 1.5%)
Branches 72.5% (- 1.6%)
Functions 83.3% (- 0.7%)
Lines 83.3% (- 1.4%)

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