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

Core: Add error categorization framework #23653

Merged
merged 28 commits into from Aug 21, 2023
Merged

Conversation

yannbf
Copy link
Member

@yannbf yannbf commented Jul 28, 2023

Closes #23511

What I did

This PR proposes a new way to write and throw errors in Storybook.

For more details, please check the README included in this PR.

Checklist

  • Make sure your changes are tested (stories and/or unit, integration, or end-to-end tests)
  • Make sure to add/update documentation regarding your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli/src/sandbox-templates.ts
  • Make sure this PR contains one of the labels below.

["cleanup", "BREAKING CHANGE", "feature request", "bug", "build", "documentation", "maintenance", "dependencies", "other"]

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

Copy link
Contributor

@kylegach kylegach left a comment

Choose a reason for hiding this comment

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

I only reviewed the README, but I'm loving this work! Great job, Yann! 👏

@yannbf yannbf force-pushed the yann/error-categorization-framework branch 4 times, most recently from bdc0d3e to eb877e1 Compare August 9, 2023 09:11
@yannbf yannbf marked this pull request as ready for review August 9, 2023 09:14
Comment on lines 11 to 31
export enum Category {
CLI = 'CLI',
CLI_INIT = 'CLI_INIT',
CLI_AUTOMIGRATE = 'CLI_AUTOMIGRATE',
CLI_UPGRADE = 'CLI_UPGRADE',
CLI_ADD = 'CLI_ADD',
CODEMOD = 'CODEMOD',
CORE_SERVER = 'CORE-SERVER',
CSF_PLUGIN = 'CSF-PLUGIN',
CSF_TOOLS = 'CSF-TOOLS',
NODE_LOGGER = 'NODE-LOGGER',
TELEMETRY = 'TELEMETRY',
BUILDER_MANAGER = 'BUILDER-MANAGER',
BUILDER_VITE = 'BUILDER-VITE',
BUILDER_WEBPACK5 = 'BUILDER-WEBPACK5',
SOURCE_LOADER = 'SOURCE-LOADER',
POSTINSTALL = 'POSTINSTALL',
DOCS_TOOLS = 'DOCS-TOOLS',
CORE_WEBPACK = 'CORE-WEBPACK',
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm thinking that this category should not be a field of StorybookError, but should be should be passed to telemetry at the point where the error is caught.

For example, a function such as readConfig from @storybook/csf-tools will throw all kind of errors, but we likely want to know in telemetry more about the context where this function is called. As it can be called in codemods, the eslint-plugin, build, init, dev etc.

Also, I'm kind of thinking that the boolean telemetry should not be part of the StorybookError class, but is something that is also context dependent. As for example, I don't think we might not want to send telemetry for the eslint plugin, as it can be used independent of storybook (for other integrations)?

Maybe we should just maintain a list of code's that we want telemetry for?

I guess you could say that telemetry is just a different concern all together than throwing errors. For example, when you use composeStories outside of storybook, or when used by other integrators, it is kind of weird that the Error that we throw contains a telemetry boolean.

@yannbf yannbf force-pushed the yann/error-categorization-framework branch from 1559ed2 to 2df20ed Compare August 15, 2023 07:55
@yannbf yannbf force-pushed the yann/error-categorization-framework branch from 2df20ed to f21cf3a Compare August 21, 2023 08:09
@socket-security
Copy link

Removed dependencies detected. Learn more about Socket for GitHub ↗︎

🚮 Removed packages: telejson@7.1.0

code/lib/core-events/src/errors/README.md Outdated Show resolved Hide resolved
code/lib/core-events/src/errors/README.md Outdated Show resolved Hide resolved
code/lib/core-events/src/errors/README.md Show resolved Hide resolved
code/ui/manager/src/runtime.ts Outdated Show resolved Hide resolved
@yannbf yannbf force-pushed the yann/error-categorization-framework branch from c66cf40 to 7192433 Compare August 21, 2023 14:24
@yannbf yannbf merged commit 1192e6f into next Aug 21, 2023
52 of 53 checks passed
@yannbf yannbf deleted the yann/error-categorization-framework branch August 21, 2023 15:46
@github-actions github-actions bot mentioned this pull request Aug 21, 2023
20 tasks
@github-actions github-actions bot mentioned this pull request Aug 23, 2023
22 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create error categorization framework
5 participants