Skip to content

Core: Add error categorization framework#23653

Merged
yannbf merged 28 commits into
nextfrom
yann/error-categorization-framework
Aug 21, 2023
Merged

Core: Add error categorization framework#23653
yannbf merged 28 commits into
nextfrom
yann/error-categorization-framework

Conversation

@yannbf
Copy link
Copy Markdown
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>

@yannbf yannbf added feature request core ci:normal Run our default set of CI jobs (choose this for most PRs). patch:no labels Jul 28, 2023
Comment thread code/lib/core-server/src/presets/common-preset.ts Outdated
Comment thread code/lib/core-events/src/errors/preview-errors.ts Outdated
Comment thread code/lib/core-events/src/errors/README.md Outdated
Comment thread code/lib/core-events/src/errors/README.md Outdated
Comment thread code/lib/core-events/src/errors/README.md
Comment thread code/lib/core-events/src/errors/README.md
Copy link
Copy Markdown
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 thread scripts/eslint-plugin-local-rules/no-duplicated-error-codes.js Outdated
Comment thread code/lib/core-server/src/presets/common-preset.ts Outdated
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
Copy Markdown
Member

@kasperpeulen kasperpeulen Aug 14, 2023

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.

Comment thread code/lib/core-events/src/errors/storybook-error.ts Outdated
@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
Comment thread code/ui/manager/src/runtime.ts Outdated
Comment thread code/lib/core-server/src/withTelemetry.ts
@socket-security
Copy link
Copy Markdown

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

🚮 Removed packages: telejson@7.1.0

Comment thread code/lib/core-events/src/errors/README.md Outdated
Comment thread code/lib/core-events/src/errors/README.md Outdated
Comment thread code/lib/core-events/src/errors/README.md
Comment thread code/ui/manager/src/runtime.ts Outdated
Comment thread code/ui/manager/src/runtime.ts
@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
@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

Labels

ci:normal Run our default set of CI jobs (choose this for most PRs). core feature request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create error categorization framework

5 participants