Skip to content

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.

Install the package next to @sentry/junior:

Terminal window
pnpm add @sentry/junior-scheduler

Add 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.

plugins.ts
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:

nitro.config.ts
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:

RoutePurpose
/api/internal/heartbeatRuns trusted plugin heartbeats.

Set one heartbeat route secret:

VariableRequiredPurpose
CRON_SECRET or JUNIOR_SCHEDULER_SECRETProductionBearer token for the internal heartbeat route. Use CRON_SECRET with Vercel Cron.
JUNIOR_TIMEZONENoDefault 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.

Run the workflow in Slack where users will schedule work:

remind me in 1 minute to stretch

Then confirm:

  1. Junior acknowledges the scheduled task without asking for confirmation for the simple one-off reminder.
  2. what scheduled tasks do i have lists the task in the same Slack conversation.
  3. 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.

  • No due tasks run: confirm /api/internal/heartbeat is 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_TIMEZONE to the deployment default, or include the timezone in the user’s schedule request.

Read Build a Plugin for the trusted tools(ctx) and heartbeat(ctx) APIs that the scheduler uses.