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: Improve logs for sentry error #2185

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
17 changes: 17 additions & 0 deletions packages/arb-token-bridge-ui/src/pages/_app.tsx
fionnachan marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,27 @@ Sentry.init({
/^WebSocket connection failed for host: wss:\/\/relay.walletconnect.org$/i
],
beforeSend: (event, hint) => {
if (!hint.originalException) {
fionnachan marked this conversation as resolved.
Show resolved Hide resolved
return event
}

if (isUserRejectedError(hint.originalException)) {
return null
}

const { code, message } = hint.originalException as {
code?: number
fionnachan marked this conversation as resolved.
Show resolved Hide resolved
message?: string
}
fionnachan marked this conversation as resolved.
Show resolved Hide resolved

if (code && message) {
Sentry.getCurrentScope().setFingerprint([
'{{ default }}',
code.toString(),
message
])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Current issue have multiple unrelated events, this should help split the future events properly

}

return event
}
})
Expand Down
21 changes: 15 additions & 6 deletions packages/arb-token-bridge-ui/src/util/SentryUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,20 @@ export function captureSentryErrorWithExtraData({
originFunction: string
additionalData?: Record<string, string>
}) {
// tags only allow primitive values
Sentry.getCurrentScope().setTag('origin function', originFunction)
Sentry.withScope(scope => {
// tags only allow primitive values
scope.setTag('origin function', originFunction)

if (additionalData) {
Sentry.getCurrentScope().setTags(additionalData)
}
Sentry.captureException(error)
if (additionalData) {
scope.setTags(additionalData)
}

// Add query string to tags
const query = new URLSearchParams(window.location.search)
for (const [key, value] of query.entries()) {
scope.setTag(key, value)
}
Comment on lines +21 to +24
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding query string to tags will help filtering events and issues


Sentry.captureException(error)
})
}
Loading