Skip to content

Commit

Permalink
fix(sentry): fix captureMessage and captureMessage for intercepted (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
unadlib authored Apr 24, 2024
1 parent 50ffac9 commit 12f4d4c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/sentry/src/useSentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,17 @@ export const useSentry = ({ urls, ...options }: BrowserClientOptions) => {
const beforeSend: BrowserClientOptions['beforeSend'] = (event, hint) => {
const frames = event?.exception?.values?.[0].stacktrace?.frames || [];
const filename = frames.slice(-1)[0]?.filename;
if (!filename) return event;
if (!filename) {
for (const instance of sentryInstances) {
// For using `Sentry.captureMessage` and `Sentry.captureException`,
// When the event is intercepted, we should not send it to the server
// you can use `mfeSentry.setTags({ intercepted })`
if (instance.tags.intercepted) {
return null;
}
}
return event;
}
for (const instance of sentryInstances) {
if (instance.urls.find((url) => new RegExp(url).test(filename))) {
// When the event is intercepted, we should not send it to the server
Expand Down

0 comments on commit 12f4d4c

Please sign in to comment.