Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Portable stories: Add telemetry #26764

Open
wants to merge 1 commit into
base: next
Choose a base branch
from

Conversation

shilman
Copy link
Member

@shilman shilman commented Apr 7, 2024

Closes N/A

What I did

Count the number of files that use portable stories and add to Storybook metadata

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

  1. Add the string composeStory or composeStories in any number of source files in a sandbox. Comments are fine.
  2. Run the sandbox with the STORYBOOK_TELEMETRY_DEBUG=1
  3. Observe the portableStoriesFileCount matches the number of matching files (not including node_modules, dist, storybook-static.

NOTE: The results will be cached for 24h. You can clear the cache by removing node_modules/.cache

🦋 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>

@shilman shilman added maintenance User-facing maintenance tasks ci:normal portable stories labels Apr 7, 2024
Copy link

nx-cloud bot commented Apr 7, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 2ab061a. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

Copy link
Member

@tmeasday tmeasday left a comment

Choose a reason for hiding this comment

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

Searching the files ourselves seems like a pretty slow way to do it - did you see if there was a file search solution? This package seems like it'd be significantly faster, although it doesn't have many downloads: https://www.npmjs.com/package/fast-find-in-files

Probably having looked around, it's best to do similar to what we have, but perhaps use .read() or createReadStream() to avoid having to read the whole file into memory.


export const getPortableStoriesFiles = async (base: string) => {
const files = await glob('**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx}', {
ignore: ['**/node_modules/**', '**/storybook-static/**', '**/dist/**'],
Copy link
Member

Choose a reason for hiding this comment

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

it would be nice to get values from user's gitignore, but I don't know how complex it is as projects might have multiple gitignore files

Suggested change
ignore: ['**/node_modules/**', '**/storybook-static/**', '**/dist/**'],
ignore: ['**/node_modules/**', '**/storybook-static/**', '**/dist/**', '**/build/**'],

};

const CACHE_KEY = 'portableStories';
export const getPortableStoriesFileCount = async () => {
Copy link
Member

Choose a reason for hiding this comment

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

Just to keep in mind that people might have helper functions that wrap composeStory/ies and therefore the count won't be accurate

@valentinpalkovic
Copy link
Contributor

@shilman, please consider updating the documentation regarding telemetry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:normal maintenance User-facing maintenance tasks portable stories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants