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

Telemetry: CSF feature usage #28622

Merged
merged 8 commits into from
Jul 19, 2024
Merged

Telemetry: CSF feature usage #28622

merged 8 commits into from
Jul 19, 2024

Conversation

shilman
Copy link
Member

@shilman shilman commented Jul 16, 2024

Closes N/A

What I did

Add the ability to track CSF language features in telemetry without touching the index. This PR tracks stories that use custom render function and CSF1/2 storyFn-style stories. Will telescope PRs to add new CSF constructs including beforeEach, mount, moduleMocking, etc.

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

Run a sandbox with STORYBOOK_TELEMETRY_DEBUG=1 and observe the payload with the number of render/storyFn counts.

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

name before after diff z %
createSize 0 B 0 B 0 B - -
generateSize 76.5 MB 76.5 MB 0 B 0.96 0%
initSize 198 MB 198 MB 2.34 kB 1.74 0%
diffSize 121 MB 121 MB 2.34 kB 1.93 0%
buildSize 7.6 MB 7.6 MB 0 B 2 0%
buildSbAddonsSize 1.63 MB 1.63 MB 0 B 1.65 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 2.3 MB 2.3 MB 0 B 2 0%
buildSbPreviewSize 349 kB 349 kB 0 B 1.53 0%
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 4.47 MB 4.47 MB 0 B 2 0%
buildPreviewSize 3.12 MB 3.12 MB 0 B 1.36 0%
testBuildSize 0 B 0 B 0 B - -
testBuildSbAddonsSize 0 B 0 B 0 B - -
testBuildSbCommonSize 0 B 0 B 0 B - -
testBuildSbManagerSize 0 B 0 B 0 B - -
testBuildSbPreviewSize 0 B 0 B 0 B - -
testBuildStaticSize 0 B 0 B 0 B - -
testBuildPrebuildSize 0 B 0 B 0 B - -
testBuildPreviewSize 0 B 0 B 0 B - -
name before after diff z %
createTime 17.3s 7s -10s -223ms -0.87 -144.1%
generateTime 21.7s 21.3s -369ms -0.68 -1.7%
initTime 22.1s 21.7s -327ms -1.09 -1.5%
buildTime 15.2s 13s -2s -251ms -1.65 🔰-17.3%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 11.3s 7.8s -3s -502ms -0.84 -44.4%
devManagerResponsive 6.9s 5.3s -1s -603ms -0.79 -29.8%
devManagerHeaderVisible 1.6s 778ms -859ms -0.32 -110.4%
devManagerIndexVisible 1.6s 804ms -858ms -0.34 -106.7%
devStoryVisibleUncached 1.8s 1.2s -665ms -0.65 -55.1%
devStoryVisible 1.6s 820ms -868ms -0.38 -105.9%
devAutodocsVisible 794ms 747ms -47ms 0.04 -6.3%
devMDXVisible 910ms 796ms -114ms 0.8 -14.3%
buildManagerHeaderVisible 730ms 713ms -17ms -0.76 -2.4%
buildManagerIndexVisible 735ms 716ms -19ms -0.75 -2.7%
buildStoryVisible 779ms 763ms -16ms -0.76 -2.1%
buildAutodocsVisible 694ms 660ms -34ms -0.77 -5.2%
buildMDXVisible 646ms 680ms 34ms -0.23 5%

@shilman shilman changed the title Update package.json Telemetry: Record feature usage Jul 16, 2024
Copy link

nx-cloud bot commented Jul 16, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 631bafd. 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.

@shilman shilman changed the title Telemetry: Record feature usage Telemetry: CSF feature usage Jul 17, 2024
@shilman shilman added maintenance User-facing maintenance tasks telemetry ci:normal labels Jul 17, 2024
@shilman shilman added the csf label Jul 17, 2024
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.

LGTM generally, might need an extra test

@shilman shilman added the patch:yes Bugfix & documentation PR that need to be picked to main branch label Jul 19, 2024
@shilman shilman marked this pull request as ready for review July 19, 2024 12:59
Copy link
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.

PR Summary

  • Updated code/core/package.json to use @storybook/[email protected]
  • Enhanced StoryIndexGenerator.ts to track CSF features in telemetry
  • Added summarizeStats.ts and corresponding tests for aggregating CSF stats
  • Modified doTelemetry.ts to capture detailed CSF feature usage
  • Introduced mock stories in Features.stories.jsx for telemetry testing

13 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings

Object.entries(stat).forEach(([key, value]) => {
const statsKey = key as keyof IndexInputStats;
if (!acc[statsKey]) acc[statsKey] = 0;
acc[statsKey] += value ? 1 : 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Logic: The increment logic acc[statsKey] += value ? 1 : 0 only increments by 1 if value is truthy. Ensure this is the intended behavior.

@shilman shilman merged commit 4db60d6 into next Jul 19, 2024
53 checks passed
@shilman shilman deleted the shilman/csf-feature-telemetry branch July 19, 2024 13:47
@shilman shilman added the patch:done Patch/release PRs already cherry-picked to main/release branch label Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:normal csf maintenance User-facing maintenance tasks patch:done Patch/release PRs already cherry-picked to main/release branch patch:yes Bugfix & documentation PR that need to be picked to main branch telemetry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants