Skip to content

Scheduling infrastructure for absolutely everyone.

perf: dynamic import for sentry CaptureException (#19730)

Benny Joo65898f29eba5
diff --git a/packages/features/flags/features.repository.ts b/packages/features/flags/features.repository.ts
index 8fc6b961260..d7ff5419a26 100644
--- a/packages/features/flags/features.repository.ts
+++ b/packages/features/flags/features.repository.ts
@@ -1,5 +1,3 @@
-import { captureException } from "@sentry/nextjs";
-
import db from "@calcom/prisma";
import type { AppFlags } from "./config";
@@ -11,6 +9,7 @@ export class FeaturesRepository implements IFeaturesRepository {
try {
return await getFeatureFlag(db, slug);
} catch (err) {
+ const captureException = (await import("@sentry/nextjs")).captureException;
captureException(err);
throw err;
}
@@ -35,6 +34,7 @@ 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,6 +61,7 @@ export class FeaturesRepository implements IFeaturesRepository {
if (user) return true;
return false;
} catch (err) {
+ const captureException = (await import("@sentry/nextjs")).captureException;
captureException(err);
throw err;
}
@@ -72,6 +73,7 @@ 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 279c4e55d6c..cf5eedfd968 100644
--- a/packages/features/users/users.repository.ts
+++ b/packages/features/users/users.repository.ts
@@ -1,5 +1,3 @@
-import { captureException } from "@sentry/nextjs";
-
import db from "@calcom/prisma";
import type { IUsersRepository } from "./users.repository.interface";
@@ -13,6 +11,7 @@ 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 1c6f1355de5..bb6e0cbb4fd 100644
--- a/packages/features/watchlist/watchlist.repository.ts
+++ b/packages/features/watchlist/watchlist.repository.ts
@@ -1,5 +1,3 @@
-import { captureException } from "@sentry/nextjs";
-
import db from "@calcom/prisma";
import { WatchlistType, WatchlistSeverity } from "@calcom/prisma/enums";
@@ -20,6 +18,7 @@ export class WatchlistRepository implements IWatchlistRepository {
});
return emailInWatchlist;
} catch (err) {
+ const captureException = (await import("@sentry/nextjs")).captureException;
captureException(err);
throw err;
}
@@ -35,6 +34,7 @@ export class WatchlistRepository implements IWatchlistRepository {
});
return domainInWatchWatchlist;
} catch (err) {
+ const captureException = (await import("@sentry/nextjs")).captureException;
captureException(err);
throw err;
}