Refactor monitoring instrumentation setup

Removed the MONITORING_PROVIDER constant from the monitoring package, replaced it with direct process.env access. This ensures that environment variables are accessed directly at the time of use without intermediate variables. In the apps/web/instrumentation.ts file, refactored condition checks for runtime environment and instrumentation enablement, using direct access environmental variables. This change simplifies the code and improves readability.
This commit is contained in:
giancarlo
2024-04-15 14:41:48 +08:00
parent e75fcfc750
commit f1e3a44c89
4 changed files with 13 additions and 19 deletions

View File

@@ -53,4 +53,8 @@ NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=
NEXT_PUBLIC_ENABLE_ACCOUNT_DELETION=true
NEXT_PUBLIC_ENABLE_PERSONAL_ACCOUNT_BILLING=true
NEXT_PUBLIC_ENABLE_ORGANIZATION_DELETION=true
NEXT_PUBLIC_ENABLE_ORGANIZATION_BILLING=true
NEXT_PUBLIC_ENABLE_ORGANIZATION_BILLING=true
# MONITORING
MONITORING_PROVIDER=
MONITORING_INSTRUMENTATION_ENABLED=false

View File

@@ -3,14 +3,12 @@
* for your Next.js application.
*/
const RUNTIME = process.env.NEXT_RUNTIME;
const ENABLE_INSTRUMENTATION =
process.env.MONITORING_INSTRUMENTATION_ENABLED === 'true';
export async function register() {
// only run in nodejs runtime
if (RUNTIME === 'nodejs' && ENABLE_INSTRUMENTATION) {
if (
process.env.NEXT_RUNTIME === 'nodejs' &&
process.env.MONITORING_INSTRUMENTATION_ENABLED
) {
const { registerMonitoringInstrumentation } = await import(
'@kit/monitoring/instrumentation'
);