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

Build: Filter some manager errors #24217

Merged
merged 1 commit into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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