From 25d130073ccb6b0df1653cc0464c4a97f2fb707c Mon Sep 17 00:00:00 2001 From: delivan Date: Tue, 20 Dec 2022 23:09:26 +0900 Subject: [PATCH] Update error handling --- queries/icns.ts | 4 ++-- sentry.server.config.js | 9 ++------- utils/url.ts | 6 ++++-- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/queries/icns.ts b/queries/icns.ts index afedfc2..dac7521 100644 --- a/queries/icns.ts +++ b/queries/icns.ts @@ -29,7 +29,7 @@ export const queryRegisteredTwitterId = async ( Buffer.from(JSON.stringify(msg)).toString("base64"), ), {}, - true, + { isErrorIgnore: true }, ); }; @@ -61,6 +61,6 @@ export const queryOwnerOfTwitterName = async ( Buffer.from(JSON.stringify(msg)).toString("base64"), ), {}, - true, + { isErrorIgnore: true }, ); }; diff --git a/sentry.server.config.js b/sentry.server.config.js index c92d241..82df7ca 100644 --- a/sentry.server.config.js +++ b/sentry.server.config.js @@ -5,15 +5,10 @@ import * as Sentry from "@sentry/nextjs"; const SENTRY_DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN; -const IS_ENABLE_USER_TRACKING = - process.env.NEXT_PUBLIC_IS_ENABLE_USER_TRACKING || - process.env.NEXT_IS_ENABLE_USER_TRACKING; Sentry.init({ - enabled: IS_ENABLE_USER_TRACKING === "true", - dsn: - SENTRY_DSN || - "https://78c91641e90f4f7cad28f50aaec9fb95@o4504343701946368.ingest.sentry.io/4504343708827648", + enabled: !!SENTRY_DSN, + dsn: SENTRY_DSN, // Adjust this value in production, or use tracesSampler for greater control tracesSampleRate: 1.0, // ... diff --git a/utils/url.ts b/utils/url.ts index 074cfd3..b09e4f1 100644 --- a/utils/url.ts +++ b/utils/url.ts @@ -5,11 +5,13 @@ import { WALLET_INSTALL_URL } from "../constants/wallet"; export function request( url: string, config: RequestInit = {}, - isIgnore?: boolean, + customConfig?: { + isErrorIgnore?: boolean; + }, ): Promise { return fetch(url, config) .then((response) => { - if (!response.ok && !isIgnore) { + if (!response.ok && !customConfig?.isErrorIgnore) { throw new Error( `This is an HTTP error: The status is ${response.status} ${response.statusText}`, );