env
Some checks failed
Build & Deploy KLZ Cables / build-and-deploy (push) Failing after 1m46s

This commit is contained in:
2026-01-27 23:43:14 +01:00
parent ad6bfe1457
commit 5a5c10ca36
5 changed files with 69 additions and 73 deletions

View File

@@ -5,6 +5,7 @@ import { GlitchtipErrorReportingService } from './errors/glitchtip-error-reporti
import { NoopErrorReportingService } from './errors/noop-error-reporting-service';
import { NoopLoggerService } from './logging/noop-logger-service';
import { PinoLoggerService } from './logging/pino-logger-service';
import { config, getMaskedConfig } from '../config';
/**
* Singleton instance of AppServices.
@@ -74,48 +75,28 @@ export function getAppServices(): AppServices {
? new PinoLoggerService('server')
: new NoopLoggerService();
// Log environment variables (safely masked)
const envLog = {
// Mask sensitive values - show only last 4 characters or '***' for empty
NEXT_PUBLIC_UMAMI_WEBSITE_ID: process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID
? `***${process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID.slice(-4)}`
: 'not set',
UMAMI_SCRIPT_URL: process.env.UMAMI_SCRIPT_URL ?? 'not set',
NEXT_PUBLIC_SENTRY_DSN: process.env.NEXT_PUBLIC_SENTRY_DSN
? `***${process.env.NEXT_PUBLIC_SENTRY_DSN.slice(-4)}`
: 'not set',
SENTRY_DSN: process.env.SENTRY_DSN
? `***${process.env.SENTRY_DSN.slice(-4)}`
: 'not set',
// Safe to show - no sensitive data
NEXT_PUBLIC_BASE_URL: process.env.NEXT_PUBLIC_BASE_URL ?? 'not set',
NODE_ENV: process.env.NODE_ENV ?? 'not set',
};
// Log initialization
if (typeof window === 'undefined') {
// Server-side
logger.info('Initializing server application services', {
environment: envLog,
environment: getMaskedConfig(),
timestamp: new Date().toISOString(),
});
} else {
// Client-side
logger.info('Initializing client application services', {
environment: envLog,
environment: getMaskedConfig(),
timestamp: new Date().toISOString(),
});
}
// Determine which services to enable based on environment variables
const umamiEnabled = Boolean(process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID);
const sentryClientEnabled = Boolean(process.env.NEXT_PUBLIC_SENTRY_DSN);
const sentryServerEnabled = Boolean(process.env.SENTRY_DSN);
const umamiEnabled = config.analytics.umami.enabled;
const sentryEnabled = config.errors.glitchtip.enabled;
logger.info('Service configuration', {
umamiEnabled,
sentryClientEnabled,
sentryServerEnabled,
sentryEnabled,
isServer: typeof window === 'undefined',
});
@@ -135,20 +116,12 @@ export function getAppServices(): AppServices {
}
// Create error reporting service (GlitchTip/Sentry or no-op)
// Server-side and client-side have separate DSNs
const errors =
typeof window === 'undefined'
? sentryServerEnabled
? new GlitchtipErrorReportingService({ enabled: true })
: new NoopErrorReportingService()
: sentryClientEnabled
? new GlitchtipErrorReportingService({ enabled: true })
: new NoopErrorReportingService();
const errors = sentryEnabled
? new GlitchtipErrorReportingService({ enabled: true })
: new NoopErrorReportingService();
if (typeof window === 'undefined' && sentryServerEnabled) {
logger.info('GlitchTip error reporting service initialized (server)');
} else if (typeof window !== 'undefined' && sentryClientEnabled) {
logger.info('GlitchTip error reporting service initialized (client)');
if (sentryEnabled) {
logger.info(`GlitchTip error reporting service initialized (${typeof window === 'undefined' ? 'server' : 'client'})`);
} else {
logger.info('Noop error reporting service initialized (error reporting disabled)');
}
@@ -161,7 +134,7 @@ export function getAppServices(): AppServices {
logger.info('Pino logger service initialized', {
name: typeof window === 'undefined' ? 'server' : 'client',
level: process.env.LOG_LEVEL ?? 'info',
level: config.logging.level,
});
// Create and cache the singleton