Environment variables in multiple files have been updated to correctly reference public variables. Moreover, the conditional check for MONITORING_INSTRUMENTATION_ENABLED has been corrected to explicitly check for the string 'true'. This change ensures that our application correctly accesses public environmental variables and behaves as expected under the conditions defined by these variables.
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import { getMonitoringProvider } from './get-monitoring-provider';
|
|
import { InstrumentationProvider } from './monitoring-providers.enum';
|
|
|
|
const PROVIDER = getMonitoringProvider();
|
|
|
|
/**
|
|
* @name registerMonitoringInstrumentation
|
|
* @description Register monitoring instrumentation based on the MONITORING_PROVIDER environment variable.
|
|
*
|
|
* Please set the MONITORING_PROVIDER environment variable to register the monitoring instrumentation provider.
|
|
*/
|
|
export async function registerMonitoringInstrumentation() {
|
|
if (!PROVIDER) {
|
|
console.info(`No instrumentation provider specified. Skipping...`);
|
|
|
|
return;
|
|
}
|
|
|
|
switch (PROVIDER) {
|
|
case InstrumentationProvider.Baselime: {
|
|
const { registerInstrumentation } = await import(
|
|
'@kit/baselime/instrumentation'
|
|
);
|
|
|
|
return registerInstrumentation();
|
|
}
|
|
|
|
case InstrumentationProvider.Sentry: {
|
|
const { registerInstrumentation } = await import(
|
|
'@kit/sentry/instrumentation'
|
|
);
|
|
|
|
return registerInstrumentation();
|
|
}
|
|
|
|
default:
|
|
throw new Error(
|
|
`Unknown instrumentation provider: ${process.env.NEXT_PUBLIC_MONITORING_PROVIDER}`,
|
|
);
|
|
}
|
|
}
|