MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / notifySlackCriticalError

Function notifySlackCriticalError

server/src/utils/posthog.ts:262–293  ·  view source on GitHub ↗
(message: string, error?: Error, module?: string)

Source from the content-addressed store, hash-verified

260let notifyingCriticalError = false;
261
262function notifySlackCriticalError(message: string, error?: Error, module?: string): void {
263 if (!OPS_ALERT_CHANNEL_ID) return;
264 if (notifyingCriticalError) return;
265 notifyingCriticalError = true;
266
267 const safeMessage = sanitizeForSlack(message);
268 const safeStack = error?.stack ? sanitizeForSlack(error.stack.slice(0, 500)) : '';
269
270 import('../slack/client.js')
271 .then(({ sendChannelMessage, isSlackConfigured }) => {
272 if (!isSlackConfigured()) return;
273 return sendChannelMessage(OPS_ALERT_CHANNEL_ID!, {
274 text: `FATAL ERROR on ${process.env.FLY_APP_NAME || 'aao-server'}: ${safeMessage}`,
275 blocks: [
276 {
277 type: 'section',
278 text: {
279 type: 'mrkdwn',
280 text: [
281 `:rotating_light: *FATAL ERROR* on \`${process.env.FLY_APP_NAME || 'aao-server'}\``,
282 module ? `*Module:* \`${module}\`` : '',
283 `*Message:* ${safeMessage}`,
284 safeStack ? `\`\`\`${safeStack}\`\`\`` : '',
285 ].filter(Boolean).join('\n'),
286 },
287 },
288 ],
289 });
290 })
291 .catch(() => {})
292 .finally(() => { notifyingCriticalError = false; });
293}

Callers 1

initPostHogErrorTrackingFunction · 0.85

Calls 3

sanitizeForSlackFunction · 0.85
isSlackConfiguredFunction · 0.85
sendChannelMessageFunction · 0.85

Tested by

no test coverage detected