46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
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,
|
|
integrations: [
|
|
// Add our Profiling integration
|
|
nodeProfilingIntegration(),
|
|
Sentry.consoleLoggingIntegration({ levels: ['log', 'error', 'warn'] }),
|
|
Sentry.openAIIntegration({
|
|
recordInputs: true,
|
|
recordOutputs: true,
|
|
}),
|
|
],
|
|
tracesSampleRate: process.env.NODE_ENV === 'development' ? 1.0 : 0.25,
|
|
enableLogs: true,
|
|
|
|
// Profiling
|
|
profileSessionSampleRate: process.env.NODE_ENV === 'development' ? 1.0 : 0.45,
|
|
profileLifecycle: 'trace',
|
|
});
|
|
} catch (err) {
|
|
console.log(err);
|
|
}
|
|
return true;
|
|
};
|