Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions includes/nestjs-sentry-cron-decorator.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,28 @@ export class MyCronService {
}
```


### Monitor Config From `@Cron`

<AvailableSince version="11.5.0" />

If you don't pass a monitor config with a `schedule`, `@SentryCron` sends the schedule and time zone of the `@Cron` decorator on the same method with each check-in, so Sentry creates the monitor on the first run. You can still pass other monitor options, such as `checkinMargin` and `maxRuntime`:

```typescript
import { Cron } from '@nestjs/schedule';
import { SentryCron } from '@sentry/nestjs';

export class MyCronService {
@Cron('0 * * * *', { timeZone: 'America/Los_Angeles' })
@SentryCron('my-monitor-slug', { checkinMargin: 2 })
handleCron() {
// Your cron job logic here
}
}
```

If `@Cron` has no `timeZone`, the job runs in your server's local time zone, so that time zone is sent.

A six-field expression is sent without its seconds field if that field is a single number, such as `0 30 9 * * *`. Presets such as `@daily` and `@weekly` are sent too. Sub-minute schedules, `Date` values, `utcOffset`, numeric months (use names such as `MAY`), a `*/n` day field combined with the other day field, and time zones that aren't IANA names send no monitor config, including any other options you pass. In those cases, pass a full monitor config to `@SentryCron` or create the monitor in Sentry first.

To send check-ins without a monitor config, pass `{ fromCronDecorator: false }`.
Comment on lines +50 to +56

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The documentation for fromCronDecorator: false is for an unreleased SDK feature and may become incorrect if the final implementation uses a different name.
Severity: MEDIUM

Suggested Fix

Confirm the final property name from the corresponding SDK implementation (sentry-javascript PR #25013) once it has been released. It is recommended to merge this documentation change only after the SDK feature is shipped to ensure accuracy.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: includes/nestjs-sentry-cron-decorator.mdx#L50-L56

Potential issue: The documentation introduces the `fromCronDecorator: false` option,
which is tied to an unreleased SDK feature (version 11.5.0). The pull request notes that
this documentation should only be merged after the SDK feature ships. Because the
feature is not yet released, the final property name in the SDK might differ. If the
name changes, the documentation will be incorrect, and users attempting to use
`fromCronDecorator: false` will find that it has no effect, causing confusion.

Did we get this right? 👍 / 👎 to inform future reviews.

Loading