diff --git a/env/server.ts b/env/server.ts index f7fa00451..4c6d79ad1 100644 --- a/env/server.ts +++ b/env/server.ts @@ -9,7 +9,7 @@ export const env = createEnv({ */ isServer: typeof window === "undefined" || "Deno" in window, server: { - APPLICATION_INSIGHTS_CONNECTION_STRING: z.string(), + APPLICATION_INSIGHTS_CONNECTION_STRING: z.string().optional(), ADOBE_SCRIPT_SRC: z.string().optional(), ADOBE_SDK_SCRIPT_SRC: z.string().optional(), API_BASEURL: z.string(), diff --git a/instrumentation.ts b/instrumentation.ts index 2bd4dae45..ac09da613 100644 --- a/instrumentation.ts +++ b/instrumentation.ts @@ -1,7 +1,10 @@ import { env } from "./env/server" export async function register() { - if (process.env.NEXT_RUNTIME === "nodejs") { + if ( + process.env.NEXT_RUNTIME === "nodejs" && + env.APPLICATION_INSIGHTS_CONNECTION_STRING + ) { const { AzureMonitorTraceExporter } = await import( "@azure/monitor-opentelemetry-exporter" )