【发布时间】:2020-12-16 07:04:04
【问题描述】:
我最近创建了一个小型 NestJS 项目,我试图将 Sentry 集成到该项目中。我已按照 Nest-Raven 软件包自述文件中的说明以及 Sentry for TypeScript integration 提供的说明进行操作。
不幸的是,我似乎无法让 Sentry 显示 TypeScript 源映射,只能显示常规 JS 源映射,如您在此处看到的:
我已按照说明在 main.ts 中初始化了 Sentry
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();
我还设置了Nest-Raven 以使用全局拦截器
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 {}
还有其他人遇到过这个问题吗?我在想,也许我需要按照these intstructions 将源地图直接上传到 Sentry,但据我所知 NestJS 不使用 Webpack,所以我不确定如何继续。
【问题讨论】:
标签: typescript nestjs source-maps sentry