Skip to content

Commit c8a67ff

Browse files
committed
fix typing issue
1 parent 71bfb09 commit c8a67ff

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

instrumentation-client.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
1-
import posthog from "posthog-js"
1+
import posthog from "posthog-js";
22

3-
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
4-
api_host: "/ingest",
5-
ui_host: "https://us.posthog.com",
6-
defaults: "2025-05-24",
7-
capture_exceptions: true, // This enables capturing exceptions using Error Tracking
8-
session_recording: {
9-
// Prevent large base64 images from being serialized into recordings
10-
blockClass: "ph-no-capture",
11-
blockSelector: ".ph-no-capture",
12-
},
13-
debug: process.env.NODE_ENV === "development",
14-
});
3+
const posthogKey = process.env["NEXT_PUBLIC_POSTHOG_KEY"];
4+
5+
if (posthogKey) {
6+
posthog.init(posthogKey, {
7+
api_host: "/ingest",
8+
ui_host: "https://us.posthog.com",
9+
defaults: "2025-05-24",
10+
capture_exceptions: true, // This enables capturing exceptions using Error Tracking
11+
session_recording: {
12+
// Prevent large base64 images from being serialized into recordings
13+
blockClass: "ph-no-capture",
14+
blockSelector: ".ph-no-capture",
15+
},
16+
debug: process.env.NODE_ENV === "development",
17+
});
18+
} else if (process.env.NODE_ENV === "development") {
19+
console.warn("PostHog: NEXT_PUBLIC_POSTHOG_KEY is not defined");
20+
}

0 commit comments

Comments
 (0)