Openstatus www.openstatus.dev
at main 30 lines 781 B view raw
1// Props: https://github.com/getsentry/sentry-javascript/issues/9335#issuecomment-1779057528 2import { captureCheckIn, flush } from "@sentry/nextjs"; 3 4export function runSentryCron(monitorSlug: string) { 5 // 🟡 Notify Sentry your job is running: 6 const checkInId = captureCheckIn({ 7 monitorSlug, 8 status: "in_progress", 9 }); 10 return { 11 cronCompleted: async () => { 12 // 🟢 Notify Sentry your job has completed successfully: 13 captureCheckIn({ 14 checkInId, 15 monitorSlug, 16 status: "ok", 17 }); 18 return flush(); 19 }, 20 cronFailed: async () => { 21 // 🔴 Notify Sentry your job has failed: 22 captureCheckIn({ 23 checkInId, 24 monitorSlug, 25 status: "error", 26 }); 27 return flush(); 28 }, 29 }; 30}