a fun bot for the hc slack
at v0.0.3 1.2 kB view raw
1import * as Sentry from "@sentry/bun"; 2import TakesConfig from "../../../libs/config"; 3import { blog } from "../../../libs/Logger"; 4import { 5 checkActiveSessions, 6 expirePausedSessions, 7} from "../services/notifications"; 8 9export default function setupNotifications() { 10 try { 11 const notificationInterval = TakesConfig.NOTIFICATIONS.CHECK_INTERVAL; 12 13 setInterval(async () => { 14 try { 15 await checkActiveSessions(); 16 await expirePausedSessions(); 17 } catch (error) { 18 if (error instanceof Error) 19 blog( 20 `Error in notifications check: ${error.message}`, 21 "error", 22 ); 23 Sentry.captureException(error, { 24 extra: { 25 context: "notifications check", 26 checkInterval: notificationInterval, 27 }, 28 tags: { 29 type: "notification_check", 30 }, 31 }); 32 } 33 }, notificationInterval); 34 } catch (error) { 35 if (error instanceof Error) 36 blog(`Error setting up notifications: ${error.message}`, "error"); 37 Sentry.captureException(error, { 38 extra: { 39 context: "notifications setup", 40 }, 41 tags: { 42 type: "notification_setup", 43 }, 44 }); 45 throw error; // Re-throw to prevent the app from starting with broken notifications 46 } 47}