Scheduler Plugin
The scheduler plugin lives in @sentry/junior-scheduler. It registers Slack tools for creating, listing, updating, deleting, and running scheduled tasks, then uses Junior’s internal heartbeat to dispatch due work back to the configured Slack conversation.
Runtime setup
Section titled “Runtime setup”Install the package next to @sentry/junior:
pnpm add @sentry/junior-schedulerAdd the trusted plugin factory to the plugin set exported from plugins.ts. The factory registers the scheduler
manifest, schedule-management tools, and heartbeat behavior together.
import { defineJuniorPlugins } from "@sentry/junior";import { schedulerPlugin } from "@sentry/junior-scheduler";
export const plugins = defineJuniorPlugins([schedulerPlugin()]);juniorNitro() emits the internal heartbeat route into Nitro’s Vercel Build Output config:
import { defineConfig } from "nitro";import { juniorNitro } from "@sentry/junior/nitro";
export default defineConfig({ preset: "vercel", modules: [juniorNitro()],});If you deploy outside Vercel, call the heartbeat route on a one-minute cadence:
| Route | Purpose |
|---|---|
/api/internal/heartbeat | Runs trusted plugin heartbeats. |
Configure environment variables
Section titled “Configure environment variables”Set one heartbeat route secret:
| Variable | Required | Purpose |
|---|---|---|
CRON_SECRET or JUNIOR_SCHEDULER_SECRET | Production | Bearer token for the internal heartbeat route. Use CRON_SECRET with Vercel Cron. |
JUNIOR_TIMEZONE | No | Default IANA timezone for schedule authoring. Defaults to America/Los_Angeles. |
Local development can run without a heartbeat route secret when you call the dev server directly. Production deployments should set CRON_SECRET or JUNIOR_SCHEDULER_SECRET.
Verify
Section titled “Verify”Run the workflow in Slack where users will schedule work:
remind me in 1 minute to stretchThen confirm:
- Junior acknowledges the scheduled task without asking for confirmation for the simple one-off reminder.
what scheduled tasks do i havelists the task in the same Slack conversation.- The reminder posts back to that conversation after the due time.
For recurring or non-reminder scheduled work, Junior should show the proposed task details and wait for confirmation before creating the task.
Failure modes
Section titled “Failure modes”- No due tasks run: confirm
/api/internal/heartbeatis called every minute and the route secret matches the configured bearer token. - Tasks list but never complete: check scheduler and dispatch logs for missing Slack destination fields or stale dispatch recovery errors.
- Unexpected timezone: set
JUNIOR_TIMEZONEto the deployment default, or include the timezone in the user’s schedule request.
Next step
Section titled “Next step”Read Build a Plugin for the trusted tools(ctx) and heartbeat(ctx) APIs that the scheduler uses.