nestjs-sentry
nestjs-sentry copied to clipboard
options not found. Did you use SentryModule.forRoot?
Hi,
I'm using version 2.x because I have Nest 7.x
Everything seems to be working (logs are sending to sentry and local debug works) but I am curious about this console log I am getting ("options not found. Did you use SentryModule.forRoot?"). I noticed that in 3.x this log was commented out (shown below). Should I be concerned that the service isn't being initialized correctly?
Thanks for the awesome library!
3.x:
export class SentryService extends ConsoleLogger {
app = '@ntegral/nestjs-sentry: ';
private static serviceInstance: SentryService;
constructor(
@Inject(SENTRY_MODULE_OPTIONS)
readonly opts?: SentryModuleOptions,
) {
super();
if (!(opts && opts.dsn)) {
// console.log('options not found. Did you use SentryModule.forRoot?');
return;
}
2.x:
export class SentryService extends Logger {
app: string = '@ntegral/nestjs-sentry: ';
private static serviceInstance: SentryService;
constructor(
@Inject(SENTRY_MODULE_OPTIONS)
private readonly options?: SentryModuleOptions,
@Optional() prior?: SentryService
) {
super();
if (!(options && options.dsn)) {
console.log('options not found. Did you use SentryModule.forRoot?');
return;
}
For reference, here is how I am importing:
SentryModule.forRootAsync({
imports: [ConfigModule],
useFactory: async (config: ConfigService) => {
return {
dsn: config.get('SENTRY_DSN'),
debug: true,
environment: 'development',
logLevel: LogLevel.Error
}
},
inject: [ConfigService],
}),
^ made sure sentry dsn is set correctly
and my bootstrap (not sure this is relevant):
async function bootstrap() {
const app = await NestFactory.create(AppModule, {
logger: false
});
app.useLogger(SentryService.SentryServiceInstance());
await app.listen(3000);
}
bootstrap();
Some additional info – I logged out the options
right before the if (!(options && options.dsn))
and when I start my app it logs three times. The first two times the options look correct and the third is undefined. Seems like it might be an issue on my end?
{
dsn: '[my_dsn],
debug: true,
environment: 'development',
logLevel: 1
}
{
dsn: '[my_dsn],
debug: true,
environment: 'development',
logLevel: 1
}
undefined
i get same issue. did you find any solution ?
+1
I am curious if you found a solution to this problem as well
Confirming that I'm seeing this as well on 2.0.9
, with @nestjs/core
at 7.2.0