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

fix(PE-5263): ignore errors from unknown extension #404

Merged
merged 3 commits into from
Jan 12, 2024
Merged
Changes from 2 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
25 changes: 24 additions & 1 deletion src/utils/sentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,37 @@ const sentry =
tracesSampleRate: 1.0,
environment: ENVIRONMENT,
beforeSend(event) {
if (shouldFilterEvent(event)) {
return null;
}
return sanitizeEvent(event);
},
beforeSendTransaction(event) {
if (shouldFilterEvent(event)) {
return null;
}
return sanitizeEvent(event);
},
})
: {};

export default sentry;

const sanitizeEvent = (event: Sentry.Event): Sentry.Event => {
const filterMessages = new Set([
'chrome-extension://aflkmfhebedbjioipglgcbcmnbpgliof/injected.js',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this the best way to ignore extensions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly. I was getting this as the method for ignoring messages, there may be a better way to ignore an actually extension specifically.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I just realized, with new releases of the extension, this would break. More durable to check for the error message I suppose.

]);

const shouldFilterEvent = (event: Sentry.Event): boolean => {
const isFiltered = [...filterMessages].some((message) =>
event.exception?.values?.some((value) =>
value.value?.includes(message.toLowerCase()),
),
);

return isFiltered;
};

const sanitizeEvent = (event: Sentry.Event): Sentry.Event | null => {
// Remove user's IP address
if (event.request) {
if (event.request.headers) {
Expand Down
Loading