Skip to content

Commit

Permalink
perf: dynamically import sentry lib in catch clause (#19607)
Browse files Browse the repository at this point in the history
  • Loading branch information
hbjORbj authored Feb 27, 2025
1 parent 0ad5770 commit 2cf7673
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion apps/web/app/api/apiRouteMiddleware.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
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";
Expand All @@ -19,6 +18,7 @@ export const apiRouteMiddleware =
// we don't want to report Bad Request errors to Sentry / console
if (!(serverError.statusCode >= 400 && serverError.statusCode < 500)) {
console.error(error);
const captureException = (await import("@sentry/nextjs")).captureException;
captureException(error);
}
return NextResponse.json(
Expand Down

0 comments on commit 2cf7673

Please sign in to comment.