Skip to content

Telemetry: Record known CLI integrations#32448

Merged
ndelangen merged 1 commit into
nextfrom
shilman/cli-integratino-telemetry
Sep 15, 2025
Merged

Telemetry: Record known CLI integrations#32448
ndelangen merged 1 commit into
nextfrom
shilman/cli-integratino-telemetry

Conversation

@shilman
Copy link
Copy Markdown
Member

@shilman shilman commented Sep 14, 2025

Closes N/A

What I did

Record whether an install came from a known integration, such as sv create or sv add by inspecting the process ancestry.

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

Did not manual test. Will verify the results once we release.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>

Greptile Summary

Updated On: 2025-09-14 18:35:03 UTC

This PR implements telemetry tracking for CLI integrations that invoke Storybook initialization, specifically detecting usage of sv create and sv add commands. The implementation adds a new getCliIntegrationFromAncestry() function that analyzes the process ancestry chain to identify these known integration patterns, similar to the existing getStorybookVersionFromAncestry() function.

The change introduces minimal code additions to the initialization flow in code/lib/create-storybook/src/initiate.ts. The new function uses regex pattern matching to detect sv create and sv add commands in the process chain, handling version specifiers (like @latest) and prioritizing nested calls. The detected integration information is then passed to the existing telemetry system as an optional cliIntegration parameter.

This enhancement allows the Storybook team to understand adoption patterns and usage statistics for third-party integrations that leverage their initialization tooling. The implementation follows established patterns in the codebase, reuses existing infrastructure for process ancestry inspection, and maintains backward compatibility. Error handling ensures that telemetry failures never impact the core initialization process.

The change includes comprehensive unit tests covering various scenarios: detecting nested CLI calls, handling version specifiers, and gracefully handling cases where no integration is found. The tests follow the same pattern as existing tests for the similar getStorybookVersionFromAncestry function.

Confidence score: 5/5

  • This PR is extremely safe to merge with virtually no risk of breaking existing functionality
  • Score reflects simple, well-tested telemetry addition with proper error handling and no impact on core functionality
  • No files require special attention as the changes are straightforward and well-isolated

@shilman shilman added maintenance User-facing maintenance tasks cli patch:yes Bugfix & documentation PR that need to be picked to main branch telemetry ci:normal labels Sep 14, 2025
@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Sep 14, 2025

View your CI Pipeline Execution ↗ for commit dac9e9c

Command Status Duration Result
nx run-many -t build --parallel=3 ✅ Succeeded 46s View ↗

☁️ Nx Cloud last updated this comment at 2025-09-14 18:45:54 UTC

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 1 comment

Edit Code Review Bot Settings | Greptile

Comment on lines +238 to +241
it('returns the CLI integration if found', () => {
const ancestry = [{ command: 'node' }, { command: 'npx sv@latest add' }];
expect(getCliIntegrationFromAncestry(ancestry as any)).toBe('sv add');
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Duplicate test description - both test cases have identical descriptions but test different scenarios

Suggested change
it('returns the CLI integration if found', () => {
const ancestry = [{ command: 'node' }, { command: 'npx sv@latest add' }];
expect(getCliIntegrationFromAncestry(ancestry as any)).toBe('sv add');
});
it('returns the CLI integration if found with version stripped', () => {
const ancestry = [{ command: 'node' }, { command: 'npx sv@latest add' }];
expect(getCliIntegrationFromAncestry(ancestry as any)).toBe('sv add');
});

@ndelangen ndelangen merged commit 1e65c88 into next Sep 15, 2025
59 of 61 checks passed
@ndelangen ndelangen deleted the shilman/cli-integratino-telemetry branch September 15, 2025 06:36
ndelangen added a commit that referenced this pull request Sep 15, 2025
…lemetry

Telemetry: Record known CLI integrations
(cherry picked from commit 1e65c88)
@github-actions github-actions Bot added the patch:done Patch/release PRs already cherry-picked to main/release branch label Sep 15, 2025
@github-actions github-actions Bot mentioned this pull request Sep 16, 2025
23 tasks
@ndelangen ndelangen removed the patch:yes Bugfix & documentation PR that need to be picked to main branch label Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:normal cli maintenance User-facing maintenance tasks patch:done Patch/release PRs already cherry-picked to main/release branch telemetry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants