Skip to content

Commit e225079

Browse files
nicohrubeccodex
andauthored
docs(nestjs): Point README to SDK documentation (#24618)
This is an initial proposal for a minimal package README format that keeps detailed guidance in the docs, starting off with simplifying the NestJS SDK README. Once this is in, I'll get started on updating the remaining package README's. --------- Co-authored-by: GPT-6 <codex@openai.com>
1 parent 233cd72 commit e225079

1 file changed

Lines changed: 8 additions & 144 deletions

File tree

‎packages/nestjs/README.md‎

Lines changed: 8 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -10,151 +10,15 @@
1010
[![npm dm](https://img.shields.io/npm/dm/@sentry/nestjs.svg)](https://www.npmjs.com/package/@sentry/nestjs)
1111
[![npm dt](https://img.shields.io/npm/dt/@sentry/nestjs.svg)](https://www.npmjs.com/package/@sentry/nestjs)
1212

13-
## Installation
13+
The official Sentry SDK for monitoring NestJS applications.
1414

15-
```bash
16-
npm install @sentry/nestjs
15+
## Documentation
1716

18-
# Or yarn
19-
yarn add @sentry/nestjs
20-
```
17+
- [Getting started](https://docs.sentry.io/platforms/javascript/guides/nestjs/)
18+
- [Configuration](https://docs.sentry.io/platforms/javascript/guides/nestjs/configuration/)
19+
- [NestJS-specific features](https://docs.sentry.io/platforms/javascript/guides/nestjs/features/)
2120

22-
## Usage
21+
## Support
2322

24-
Add an `instrument.ts` file:
25-
26-
```typescript
27-
import * as Sentry from '@sentry/nestjs';
28-
29-
Sentry.init({
30-
dsn: '__DSN__',
31-
// ...
32-
});
33-
```
34-
35-
You need to require or import the `instrument.ts` file before requiring any other modules in your application. This is
36-
necessary to ensure that Sentry can automatically instrument all modules in your application:
37-
38-
```typescript
39-
// Import this first!
40-
import './instrument';
41-
42-
// Now import other modules
43-
import * as Sentry from '@sentry/nestjs';
44-
import { NestFactory } from '@nestjs/core';
45-
import { AppModule } from './app.module';
46-
47-
async function bootstrap() {
48-
const app = await NestFactory.create(AppModule);
49-
await app.listen(3000);
50-
}
51-
52-
bootstrap();
53-
```
54-
55-
Afterwards, add the `SentryModule` as a root module to your main module:
56-
57-
```typescript
58-
import { Module } from '@nestjs/common';
59-
import { SentryModule } from '@sentry/nestjs/setup';
60-
61-
@Module({
62-
imports: [
63-
SentryModule.forRoot(),
64-
// ...other modules
65-
],
66-
})
67-
export class AppModule {}
68-
```
69-
70-
In case you are using a global catch-all exception filter (which is either a filter registered with
71-
`app.useGlobalFilters()` or a filter registered in your app module providers annotated with an empty `@Catch()`
72-
decorator), add a `@SentryExceptionCaptured()` decorator to the `catch()` method of this global error filter. This
73-
decorator will report all unexpected errors that are received by your global error filter to Sentry:
74-
75-
```typescript
76-
import { Catch, ExceptionFilter } from '@nestjs/common';
77-
import { SentryExceptionCaptured } from '@sentry/nestjs';
78-
79-
@Catch()
80-
export class YourCatchAllExceptionFilter implements ExceptionFilter {
81-
@SentryExceptionCaptured()
82-
catch(exception, host): void {
83-
// your implementation here
84-
}
85-
}
86-
```
87-
88-
In case you do not have a global catch-all exception filter, add the `SentryGlobalFilter` to the providers of your main
89-
module. This filter will report all unhandled errors that are not caught by any other error filter to Sentry.
90-
**Important:** The `SentryGlobalFilter` needs to be registered before any other exception filters.
91-
92-
```typescript
93-
import { Module } from '@nestjs/common';
94-
import { APP_FILTER } from '@nestjs/core';
95-
import { SentryGlobalFilter } from '@sentry/nestjs/setup';
96-
97-
@Module({
98-
providers: [
99-
{
100-
provide: APP_FILTER,
101-
useClass: SentryGlobalFilter,
102-
},
103-
// ..other providers
104-
],
105-
})
106-
export class AppModule {}
107-
```
108-
109-
**Note:** In NestJS + GraphQL applications replace the `SentryGlobalFilter` with the `SentryGlobalGraphQLFilter`.
110-
111-
## SentryTraced
112-
113-
Use the `@SentryTraced()` decorator to gain additional performance insights for any function within your NestJS
114-
applications.
115-
116-
```typescript
117-
import { Injectable } from '@nestjs/common';
118-
import { SentryTraced } from '@sentry/nestjs';
119-
120-
@Injectable()
121-
export class ExampleService {
122-
@SentryTraced('example function')
123-
async performTask() {
124-
// Your business logic here
125-
}
126-
}
127-
```
128-
129-
## SentryCron
130-
131-
Use the `@SentryCron()` decorator to augment the native NestJS `@Cron` decorator to send check-ins to Sentry before and
132-
after each cron job run.
133-
134-
```typescript
135-
import { Cron } from '@nestjs/schedule';
136-
import { SentryCron } from '@sentry/nestjs';
137-
import type { MonitorConfig } from '@sentry/core';
138-
139-
const monitorConfig: MonitorConfig = {
140-
schedule: {
141-
type: 'crontab',
142-
value: '* * * * *',
143-
},
144-
checkinMargin: 2, // In minutes. Optional.
145-
maxRuntime: 10, // In minutes. Optional.
146-
timezone: 'America/Los_Angeles', // Optional.
147-
};
148-
149-
export class MyCronService {
150-
@Cron('* * * * *')
151-
@SentryCron('my-monitor-slug', monitorConfig)
152-
handleCron() {
153-
// Your cron job logic here
154-
}
155-
}
156-
```
157-
158-
## Links
159-
160-
- [Official SDK Docs](https://docs.sentry.io/platforms/javascript/guides/nestjs/)
23+
- [Report a bug](https://github.com/getsentry/sentry-javascript/issues/new/choose)
24+
- [Contributing](https://github.com/getsentry/sentry-javascript/blob/develop/CONTRIBUTING.md)

0 commit comments

Comments
 (0)