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
base: next
Are you sure you want to change the base?
Conversation
☁️ Nx Cloud ReportCI 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 targetSent with 💌 from NxCloud. |
There was a problem hiding this 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/**'], |
There was a problem hiding this comment.
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
ignore: ['**/node_modules/**', '**/storybook-static/**', '**/dist/**'], | |
ignore: ['**/node_modules/**', '**/storybook-static/**', '**/dist/**', '**/build/**'], |
}; | ||
|
||
const CACHE_KEY = 'portableStories'; | ||
export const getPortableStoriesFileCount = async () => { |
There was a problem hiding this comment.
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
@shilman, please consider updating the documentation regarding telemetry. |
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:
Manual testing
composeStory
orcomposeStories
in any number of source files in a sandbox. Comments are fine.STORYBOOK_TELEMETRY_DEBUG=1
portableStoriesFileCount
matches the number of matching files (not includingnode_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>