Conversation
Add a `monitorCronTriggers` option. When set, each Cron Trigger run of the `scheduled` handler sends in-progress and ok/error check-ins whose monitor config carries the trigger's cron expression, so Sentry creates the monitor on the first run. The slug is derived from the cron expression, or picked by a user function. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
size-limit report 📦
|
Cloudflare numbers weekdays from 1 = Sunday, while Sentry uses 0 = Sunday, so the weekday field is now converted to names (or a 0-based number for `nL`) before it is sent. Expressions that can't be converted are sent without a schedule. Derived slugs now write `,`, `-` and `/` as distinct tokens and append a hash when the expression has other characters or the slug is too long. A throwing `monitorCronTriggers` function and runs without a cron expression send no check-ins instead of affecting the handler, and the function can return other monitor settings along with the slug. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tion
Replaces the `monitorCronTriggers` option with an opt-in
`cronTriggersIntegration({ slug })`, so the schedule conversion and slug
code is tree-shaken for Workers that don't use it. The scheduled handler
only looks the integration up by name. Also drops `nL` and `n#k` weekday
conversion (sent without a schedule) and simplifies the slug hash.
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
*/n gives the same days in both numberings and keeps Sentry's AND rule for the day fields. Sentry rejects W and ? in the day of month, so send no schedule. Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit eb22bd1. Configure here.
| // Check-ins are captured directly rather than through `withMonitor`, which would fork the | ||
| // isolation scope and lose the invocation state attached to it. | ||
| const checkInId = captureCheckIn( | ||
| { monitorSlug, status: 'in_progress' }, |
There was a problem hiding this comment.
Bug: When a cron expression is unconvertible, all monitor settings like checkinMargin are silently discarded, not just the schedule, because the argument to captureCheckIn becomes undefined.
Severity: MEDIUM
Suggested Fix
Update the ternary operator to ensure monitorSettings are passed to captureCheckIn even when crontab is undefined. The expression should return the monitorSettings object if it has keys, otherwise undefined.
crontab
? { ...monitorSettings, schedule: { type: 'crontab', value: crontab } }
: Object.keys(monitorSettings).length > 0 ? monitorSettings : undefinedPrompt 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: packages/cloudflare/src/integrations/cronTriggers.ts#L134-L137
Potential issue: When a cron expression cannot be converted to a standard crontab
format, any user-provided monitor settings (e.g., `checkinMargin`, `maxRuntime`) are
silently discarded. This is caused by a ternary operator that resolves to `undefined`
when the `crontab` variable is `undefined`, causing the entire monitor configuration
object to be dropped from the `captureCheckIn` call. As a result, check-ins are sent
without any of the intended settings, which can lead to incorrect alert behavior, such
as missed alerts for check-in margins.
Did we get this right? 👍 / 👎 to inform future reviews.
…dler Start the check-in before the handler's try block and guard the final check-in, so a failing check-in never skips the job, fails a successful run, or is captured as the handler's exception. Co-Authored-By: Claude <noreply@anthropic.com>
On Cloudflare 1 = Sunday, so `1-5` runs Sunday to Thursday. Day names are unambiguous. Co-Authored-By: Claude <noreply@anthropic.com>

Cron Triggers already run through the instrumented
scheduledhandler, andcontroller.cronholds the schedule, so the SDK can send check-ins that create the monitor on the first run. Monitors are billed, so this is an opt-in integration:@sentry/cloudflare (withSentry) - minified.1-5→SUN-THU). Fields Sentry would read differently or reject are sent without a schedule.slug, the slug comes from the expression (cron-30-9-x-x-montofri).slugcan also return monitor settings, orundefinedto skip a trigger.captureCheckIn, notwithMonitor, which forks the isolation scope and loses the invocation'swaitUntil.Docs: getsentry/sentry-docs#19783