Skip to content

Commit

Permalink
Merge branch 'getsentry:develop' into feedback/fix-feedback-integrati…
Browse files Browse the repository at this point in the history
…on-init-setup
  • Loading branch information
jaspreet57 authored Jul 18, 2024
2 parents 41c36f8 + ce1e7c7 commit ce5bcc7
Showing 1 changed file with 33 additions and 4 deletions.
37 changes: 33 additions & 4 deletions packages/nestjs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ yarn add @sentry/nestjs

## Usage

```js
```typescript
// CJS Syntax
const Sentry = require('@sentry/nestjs');
// ESM Syntax
Expand All @@ -38,12 +38,12 @@ Sentry.init({

Note that it is necessary to initialize Sentry **before you import any package that may be instrumented by us**.

## Span Decorator
## SentryTraced

Use the @SentryTraced() decorator to gain additional performance insights for any function within your NestJS
Use the `@SentryTraced()` decorator to gain additional performance insights for any function within your NestJS
applications.

```js
```typescript
import { Injectable } from '@nestjs/common';
import { SentryTraced } from '@sentry/nestjs';

Expand All @@ -56,6 +56,35 @@ export class ExampleService {
}
```

## SentryCron

Use the `@SentryCron()` decorator to augment the native NestJS `@Cron` decorator to send check-ins to Sentry before and
after each cron job run.

```typescript
import { Cron } from '@nestjs/schedule';
import { SentryCron, MonitorConfig } from '@sentry/nestjs';
import type { MonitorConfig } from '@sentry/types';

const monitorConfig: MonitorConfig = {
schedule: {
type: 'crontab',
value: '* * * * *',
},
checkinMargin: 2, // In minutes. Optional.
maxRuntime: 10, // In minutes. Optional.
timezone: 'America/Los_Angeles', // Optional.
};

export class MyCronService {
@Cron('* * * * *')
@SentryCron('my-monitor-slug', monitorConfig)
handleCron() {
// Your cron job logic here
}
}
```

## Links

- [Official SDK Docs](https://docs.sentry.io/platforms/javascript/guides/nestjs/)

0 comments on commit ce5bcc7

Please sign in to comment.