diff --git a/code/ui/manager/src/runtime.ts b/code/ui/manager/src/runtime.ts index 21c6922ddf7e..efa348ac47e0 100644 --- a/code/ui/manager/src/runtime.ts +++ b/code/ui/manager/src/runtime.ts @@ -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; @@ -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 diff --git a/code/ui/manager/src/utils/prepareForTelemetry.ts b/code/ui/manager/src/utils/prepareForTelemetry.ts index 2ae99ba431a1..3b28b8c42506 100644 --- a/code/ui/manager/src/utils/prepareForTelemetry.ts +++ b/code/ui/manager/src/utils/prepareForTelemetry.ts @@ -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;