Skip to content

Commit

Permalink
Merge pull request #24217 from storybookjs/yann/filter-certain-manage…
Browse files Browse the repository at this point in the history
…r-errors

Build: Filter some manager errors
  • Loading branch information
yannbf authored Sep 19, 2023
2 parents f49c9a2 + 73183e9 commit 63f3384
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
8 changes: 5 additions & 3 deletions code/ui/manager/src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { renderStorybookUI } from './index';

import { values } from './globals/runtime';
import { Keys } from './globals/types';
import { prepareForTelemetry } from './utils/prepareForTelemetry';
import { prepareForTelemetry, shouldSkipError } from './utils/prepareForTelemetry';

const { FEATURES, CONFIG_TYPE } = global;

Expand Down Expand Up @@ -63,8 +63,10 @@ Object.keys(Keys).forEach((key: keyof typeof Keys) => {
});

global.sendTelemetryError = (error) => {
const channel = global.__STORYBOOK_ADDONS_CHANNEL__;
channel.emit(TELEMETRY_ERROR, prepareForTelemetry(error));
if (!shouldSkipError(error)) {
const channel = global.__STORYBOOK_ADDONS_CHANNEL__;
channel.emit(TELEMETRY_ERROR, prepareForTelemetry(error));
}
};

// handle all uncaught errors at the root of the application and log to telemetry
Expand Down
13 changes: 13 additions & 0 deletions code/ui/manager/src/utils/prepareForTelemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ function getBrowserInfo() {
return browserInfo;
}

// If you're adding errors to filter, please explain why they should be filtered.
const errorMessages = [
// It's a harmless issue with react-resize-detector that supposedly will be gone when we move to React 18.
// https://github.com/maslianok/react-resize-detector/issues/45#issuecomment-1500958024
'ResizeObserver loop completed with undelivered notifications.',
'ResizeObserver loop limit exceeded',
// Safari does not seem to provide any helpful info on window.onerror
// https://bugs.webkit.org/show_bug.cgi?id=132945
'Script error.',
];

export const shouldSkipError = (error: Error) => errorMessages.includes(error?.message);

export function prepareForTelemetry(
originalError: Error & {
fromStorybook?: boolean;
Expand Down

0 comments on commit 63f3384

Please sign in to comment.