-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathinstrumentation.ts
More file actions
57 lines (50 loc) · 1.38 KB
/
instrumentation.ts
File metadata and controls
57 lines (50 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
* Next.js instrumentation: Sentry (node + edge) and app services (Redis, QStash).
*/
import * as Sentry from "@sentry/nextjs";
export async function register() {
if (process.env.NEXT_RUNTIME === "nodejs") {
try {
await import("./sentry.server.config");
} catch {
// Sentry optional when DSN missing
}
try {
const { initializeRedis } = await import("@/lib/cache/redis");
initializeRedis();
const { getRedis, isRedisConfigured } = await import("@/lib/cache/redis");
if (isRedisConfigured()) {
const redis = getRedis();
if (redis) {
redis
.exists("app:start_time")
.then((exists) => {
if (!exists) {
redis
.set("app:start_time", new Date().toISOString())
.catch(() => {});
}
})
.catch(() => {});
}
}
} catch {
// Redis optional
}
try {
const { initializeQStash } = await import("@/lib/queue/qstash");
initializeQStash();
} catch {
// QStash optional
}
}
if (process.env.NEXT_RUNTIME === "edge") {
try {
await import("./sentry.edge.config");
} catch {
// Sentry optional when DSN missing
}
}
}
/** App Router: report unhandled request errors to Sentry */
export const onRequestError = Sentry.captureRequestError;