I've created a small NestJS project recently which I attempting to integrate Sentry into. I have followed the instructions on the Nest-Raven package readme, along with the instructions provided by Sentry for TypeScript integration.
Unfortunately I cannot seem to get Sentry to display the TypeScript sourcemaps, only the regular JS ones, as you can see here:
I have Sentry initialised in main.ts
as per the instructions
import { NestFactory } from '@nestjs/core';
import { RewriteFrames } from '@sentry/integrations';
import * as Sentry from '@sentry/node';
import { AppModule } from './app.module';
// This allows TypeScript to detect our global value
declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace NodeJS {
interface Global {
__rootdir__: string;
}
}
}
global.__rootdir__ = __dirname || process.cwd();
async function bootstrap() {
Sentry.init({
dsn: 'https://mySentryDSN.ingest.sentry.io/0',
integrations: [
new RewriteFrames({
root: global.__rootdir__,
}),
],
});
const app = await NestFactory.create(AppModule);
await app.listen(3000);
}
bootstrap();
I have also set up Nest-Raven
to use a Global Interceptor
import { APP_INTERCEPTOR } from '@nestjs/core';
import { RavenInterceptor, RavenModule } from 'nest-raven';
import { AppController } from './app.controller';
import { AppService } from './app.service';
@Module({
imports: [
RavenModule,
...
],
controllers: [AppController],
providers: [
AppService,
{
provide: APP_INTERCEPTOR,
useValue: new RavenInterceptor(),
},
],
})
export class AppModule {}
Has anyone else encountered this issue? I am thinking that perhaps I need to upload the sourcemaps directly to Sentry as per these intstructions, however as far as I know NestJS does not make use of Webpack so I am unsure how to proceed.