File size: 1,296 Bytes
a271c58 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | import * as Sentry from '@sentry/nestjs';
import { nodeProfilingIntegration } from '@sentry/profiling-node';
import { capitalize } from 'lodash';
export const initializeSentry = (appName: string, allowLogs = false) => {
if (!process.env.NEXT_PUBLIC_SENTRY_DSN) {
return null;
}
try {
Sentry.init({
initialScope: {
tags: {
service: appName,
component: 'nestjs',
},
contexts: {
app: {
name: `Postiz ${capitalize(appName)}`,
},
},
},
environment: process.env.NODE_ENV || 'development',
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
spotlight: process.env.SENTRY_SPOTLIGHT === '1',
integrations: [
// Add our Profiling integration
nodeProfilingIntegration(),
Sentry.consoleLoggingIntegration({ levels: ['log', 'info', 'warn', 'error', 'debug', 'assert', 'trace'] }),
Sentry.openAIIntegration({
recordInputs: true,
recordOutputs: true,
}),
],
tracesSampleRate: 1.0,
enableLogs: true,
// Profiling
profileSessionSampleRate: process.env.NODE_ENV === 'development' ? 1.0 : 0.45,
profileLifecycle: 'trace',
});
} catch (err) {
console.log(err);
}
return true;
};
|