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 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
23 changes: 22 additions & 1 deletion src/utils/sentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,35 @@ 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(['Cannot redefine property: ethereum']);

const shouldFilterEvent = (event: Sentry.Event): boolean => {
const isFiltered = [...filterMessages].some((message) =>
event.exception?.values?.some((value) =>
value.value?.toLowerCase().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