Skip to content

Commit

Permalink
add storybook error metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbf committed Aug 21, 2023
1 parent 3b1c1c4 commit f21cf3a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions code/lib/core-server/src/withTelemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,31 @@ export async function sendTelemetryError(
error instanceof Error,
'The error passed to sendTelemetryError was not an Error, please only send Errors'
);

let storybookErrorProperties = {};
// if it's an UNCATEGORIZED error, it won't have a coded name, so we just pass UNCATEGORIZED
if ((error as any).category) {
const { category } = error as any;
storybookErrorProperties = {
category,
};
}
if ((error as any).fromStorybook) {
const { code, name } = error as any;
storybookErrorProperties = {
...storybookErrorProperties,
code,
name,
};
}
await telemetry(
'error',
{
eventType,
precedingUpgrade,
error: errorLevel === 'full' ? error : undefined,
errorHash: oneWayHash(error.message),
...storybookErrorProperties,
},
{
immediate: true,
Expand Down

0 comments on commit f21cf3a

Please sign in to comment.