From 18e045f4456b60ae1e546c58baed3f776082c3cd Mon Sep 17 00:00:00 2001 From: Christophe Date: Mon, 13 Jan 2025 14:51:07 +0000 Subject: [PATCH 1/4] fix: Improve logs for sentry error --- .../arb-token-bridge-ui/src/pages/_app.tsx | 17 +++++++++++++++ .../src/util/SentryUtils.ts | 21 +++++++++++++------ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/packages/arb-token-bridge-ui/src/pages/_app.tsx b/packages/arb-token-bridge-ui/src/pages/_app.tsx index 95048a4def..514a987623 100644 --- a/packages/arb-token-bridge-ui/src/pages/_app.tsx +++ b/packages/arb-token-bridge-ui/src/pages/_app.tsx @@ -50,10 +50,27 @@ Sentry.init({ /^WebSocket connection failed for host: wss:\/\/relay.walletconnect.org$/i ], beforeSend: (event, hint) => { + if (!hint.originalException) { + return event + } + if (isUserRejectedError(hint.originalException)) { return null } + const { code, message } = hint.originalException as { + code?: number + message?: string + } + + if (code && message) { + Sentry.getCurrentScope().setFingerprint([ + '{{ default }}', + code.toString(), + message + ]) + } + return event } }) diff --git a/packages/arb-token-bridge-ui/src/util/SentryUtils.ts b/packages/arb-token-bridge-ui/src/util/SentryUtils.ts index 1d5684c040..c3a260a25d 100644 --- a/packages/arb-token-bridge-ui/src/util/SentryUtils.ts +++ b/packages/arb-token-bridge-ui/src/util/SentryUtils.ts @@ -9,11 +9,20 @@ export function captureSentryErrorWithExtraData({ originFunction: string additionalData?: Record }) { - // 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) + } + + Sentry.captureException(error) + }) } From 77b4b30a07700555c3fc4b738c18973912cafb32 Mon Sep 17 00:00:00 2001 From: Christophe Date: Mon, 13 Jan 2025 16:12:19 +0000 Subject: [PATCH 2/4] Fix fingerprint --- packages/arb-token-bridge-ui/src/pages/_app.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/arb-token-bridge-ui/src/pages/_app.tsx b/packages/arb-token-bridge-ui/src/pages/_app.tsx index 514a987623..625449e912 100644 --- a/packages/arb-token-bridge-ui/src/pages/_app.tsx +++ b/packages/arb-token-bridge-ui/src/pages/_app.tsx @@ -64,11 +64,7 @@ Sentry.init({ } if (code && message) { - Sentry.getCurrentScope().setFingerprint([ - '{{ default }}', - code.toString(), - message - ]) + event.fingerprint = ['{{ default }}', code.toString(), message] } return event From 6fbb6d70cb3e882d21eb3a2395e76210fa78af46 Mon Sep 17 00:00:00 2001 From: Christophe Date: Wed, 22 Jan 2025 11:50:12 +0000 Subject: [PATCH 3/4] Use ethers enum --- packages/arb-token-bridge-ui/src/pages/_app.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/arb-token-bridge-ui/src/pages/_app.tsx b/packages/arb-token-bridge-ui/src/pages/_app.tsx index 625449e912..3713925fa3 100644 --- a/packages/arb-token-bridge-ui/src/pages/_app.tsx +++ b/packages/arb-token-bridge-ui/src/pages/_app.tsx @@ -8,6 +8,7 @@ import advancedFormat from 'dayjs/plugin/advancedFormat' import timeZone from 'dayjs/plugin/timezone' import utc from 'dayjs/plugin/utc' import type { Chain } from 'wagmi' +import { errors } from 'ethers' import 'tippy.js/dist/tippy.css' import 'tippy.js/themes/light.css' @@ -59,12 +60,12 @@ Sentry.init({ } const { code, message } = hint.originalException as { - code?: number + code?: errors message?: string } if (code && message) { - event.fingerprint = ['{{ default }}', code.toString(), message] + event.fingerprint = ['{{ default }}', code, message] } return event From 30de8abc191f867722e44f0e46f8ea01d90031ec Mon Sep 17 00:00:00 2001 From: Christophe Date: Thu, 6 Feb 2025 17:10:31 +0000 Subject: [PATCH 4/4] Scope query parameters --- packages/arb-token-bridge-ui/src/util/SentryUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/arb-token-bridge-ui/src/util/SentryUtils.ts b/packages/arb-token-bridge-ui/src/util/SentryUtils.ts index c3a260a25d..0b03437b39 100644 --- a/packages/arb-token-bridge-ui/src/util/SentryUtils.ts +++ b/packages/arb-token-bridge-ui/src/util/SentryUtils.ts @@ -20,7 +20,7 @@ export function captureSentryErrorWithExtraData({ // Add query string to tags const query = new URLSearchParams(window.location.search) for (const [key, value] of query.entries()) { - scope.setTag(key, value) + scope.setTag(`query.${key}`, value) } Sentry.captureException(error)