diff --git a/apps/web/app/api/defaultResponderForAppDir.ts b/apps/web/app/api/defaultResponderForAppDir.ts index 7b72874ec2..99a99d78a2 100644 --- a/apps/web/app/api/defaultResponderForAppDir.ts +++ b/apps/web/app/api/defaultResponderForAppDir.ts @@ -1,4 +1,5 @@ import { wrapApiHandlerWithSentry } from "@sentry/nextjs"; +import { captureException } from "@sentry/nextjs"; import type { Params } from "app/_types"; import { ApiError } from "next/dist/server/api-utils"; import type { NextRequest } from "next/server"; @@ -48,7 +49,6 @@ export const defaultResponderForAppDir = = 400 && serverError.statusCode < 500)) { console.error(serverError); - const captureException = (await import("@sentry/nextjs")).captureException; captureException(error); } diff --git a/packages/features/flags/features.repository.ts b/packages/features/flags/features.repository.ts index d7ff5419a2..8fc6b96126 100644 --- a/packages/features/flags/features.repository.ts +++ b/packages/features/flags/features.repository.ts @@ -1,3 +1,5 @@ +import { captureException } from "@sentry/nextjs"; + import db from "@calcom/prisma"; import type { AppFlags } from "./config"; @@ -9,7 +11,6 @@ export class FeaturesRepository implements IFeaturesRepository { try { return await getFeatureFlag(db, slug); } catch (err) { - const captureException = (await import("@sentry/nextjs")).captureException; captureException(err); throw err; } @@ -34,7 +35,6 @@ export class FeaturesRepository implements IFeaturesRepository { if (userBelongsToTeamWithFeature) return true; return false; } catch (err) { - const captureException = (await import("@sentry/nextjs")).captureException; captureException(err); throw err; } @@ -61,7 +61,6 @@ export class FeaturesRepository implements IFeaturesRepository { if (user) return true; return false; } catch (err) { - const captureException = (await import("@sentry/nextjs")).captureException; captureException(err); throw err; } @@ -73,7 +72,6 @@ export class FeaturesRepository implements IFeaturesRepository { }); return !!teamFeature; } catch (err) { - const captureException = (await import("@sentry/nextjs")).captureException; captureException(err); throw err; } diff --git a/packages/features/users/users.repository.ts b/packages/features/users/users.repository.ts index cf5eedfd96..279c4e55d6 100644 --- a/packages/features/users/users.repository.ts +++ b/packages/features/users/users.repository.ts @@ -1,3 +1,5 @@ +import { captureException } from "@sentry/nextjs"; + import db from "@calcom/prisma"; import type { IUsersRepository } from "./users.repository.interface"; @@ -11,7 +13,6 @@ export class UsersRepository implements IUsersRepository { }); return user; } catch (err) { - const captureException = (await import("@sentry/nextjs")).captureException; captureException(err); throw err; } diff --git a/packages/features/watchlist/watchlist.repository.ts b/packages/features/watchlist/watchlist.repository.ts index d224de57d4..0891a39ef7 100644 --- a/packages/features/watchlist/watchlist.repository.ts +++ b/packages/features/watchlist/watchlist.repository.ts @@ -1,3 +1,5 @@ +import { captureException } from "@sentry/nextjs"; + import db from "@calcom/prisma"; import { WatchlistType, WatchlistSeverity } from "@calcom/prisma/enums"; @@ -18,7 +20,6 @@ export class WatchlistRepository implements IWatchlistRepository { }); return emailInWatchlist; } catch (err) { - const captureException = (await import("@sentry/nextjs")).captureException; captureException(err); throw err; } @@ -34,7 +35,6 @@ export class WatchlistRepository implements IWatchlistRepository { }); return domainInWatchWatchlist; } catch (err) { - const captureException = (await import("@sentry/nextjs")).captureException; captureException(err); throw err; } @@ -90,7 +90,6 @@ export class WatchlistRepository implements IWatchlistRepository { }); return blockedRecords; } catch (err) { - const captureException = (await import("@sentry/nextjs")).captureException; captureException(err); throw err; } diff --git a/packages/lib/server/defaultResponder.ts b/packages/lib/server/defaultResponder.ts index e6fb0accee..7fee04e165 100644 --- a/packages/lib/server/defaultResponder.ts +++ b/packages/lib/server/defaultResponder.ts @@ -1,4 +1,5 @@ import { wrapApiHandlerWithSentry } from "@sentry/nextjs"; +import { captureException } from "@sentry/nextjs"; import type { NextApiRequest, NextApiResponse } from "next"; import { getServerErrorFromUnknown } from "./getServerErrorFromUnknown"; @@ -28,7 +29,6 @@ export function defaultResponder( // we don't want to report Bad Request errors to Sentry / console if (!(error.statusCode >= 400 && error.statusCode < 500)) { console.error(error); - const captureException = (await import("@sentry/nextjs")).captureException; captureException(error); } return res diff --git a/packages/trpc/server/middlewares/captureErrorsMiddleware.ts b/packages/trpc/server/middlewares/captureErrorsMiddleware.ts index 8e9f19381c..40a5b6559b 100644 --- a/packages/trpc/server/middlewares/captureErrorsMiddleware.ts +++ b/packages/trpc/server/middlewares/captureErrorsMiddleware.ts @@ -1,3 +1,5 @@ +import { captureException } from "@sentry/nextjs"; + import { redactError } from "@calcom/lib/redactError"; import { middleware } from "../trpc"; @@ -9,7 +11,6 @@ const captureErrorsMiddleware = middleware(async ({ next }) => { if (!cause) { return result; } - const { captureException } = await import("@sentry/nextjs"); captureException(cause); throw redactError(cause); }