@@ -24,7 +24,7 @@ yarn add @sentry/nestjs
2424
2525## Usage
2626
27- ``` js
27+ ``` typescript
2828// CJS Syntax
2929const Sentry = require (' @sentry/nestjs' );
3030// ESM Syntax
@@ -38,12 +38,12 @@ Sentry.init({
3838
3939Note that it is necessary to initialize Sentry ** before you import any package that may be instrumented by us** .
4040
41- ## Span Decorator
41+ ## SentryTraced
4242
43- Use the @SentryTraced () decorator to gain additional performance insights for any function within your NestJS
43+ Use the ` @SentryTraced() ` decorator to gain additional performance insights for any function within your NestJS
4444applications.
4545
46- ``` js
46+ ``` typescript
4747import { Injectable } from ' @nestjs/common' ;
4848import { SentryTraced } from ' @sentry/nestjs' ;
4949
@@ -56,6 +56,35 @@ export class ExampleService {
5656}
5757```
5858
59+ ## SentryCron
60+
61+ Use the ` @SentryCron() ` decorator to augment the native NestJS ` @Cron ` decorator to send check-ins to Sentry before and
62+ after each cron job run.
63+
64+ ``` typescript
65+ import { Cron } from ' @nestjs/schedule' ;
66+ import { SentryCron , MonitorConfig } from ' @sentry/nestjs' ;
67+ import type { MonitorConfig } from ' @sentry/types' ;
68+
69+ const monitorConfig: MonitorConfig = {
70+ schedule: {
71+ type: ' crontab' ,
72+ value: ' * * * * *' ,
73+ },
74+ checkinMargin: 2 , // In minutes. Optional.
75+ maxRuntime: 10 , // In minutes. Optional.
76+ timezone: ' America/Los_Angeles' , // Optional.
77+ };
78+
79+ export class MyCronService {
80+ @Cron (' * * * * *' )
81+ @SentryCron (' my-monitor-slug' , monitorConfig )
82+ handleCron() {
83+ // Your cron job logic here
84+ }
85+ }
86+ ```
87+
5988## Links
6089
6190- [ Official SDK Docs] ( https://docs.sentry.io/platforms/javascript/guides/nestjs/ )
0 commit comments