refactor: notification messages (#1774)
* feat: add @openstatus/notification-base package
Create shared types and utilities for notification providers:
- NotificationContext, FormattedMessageData types
- formatDuration() for human-readable duration formatting
- formatTimestamp() using date-fns for consistent time display
- getIncidentDuration() for calculating resolved incident durations
- buildCommonMessageData() for centralized message formatting
- formatStatusCode() with HTTP status descriptions
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat: update alerting to fetch and pass incident data to notification providers
- Add logic to fetch incident by ID for recovery/degraded notifications in alerting.ts
- Update SendNotification type signature to use incident?: Incident instead of incidentId?: string
- Update all 11 notification providers to accept incident?: Incident parameter
- Providers using incidentId for dedup keys (opsgenie, pagerduty) now use incident?.id
- Incident is only fetched when notifType is recovery/degraded and incidentId is present
- Add error handling for failed incident fetches (logs warning, doesn't block notification)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat: add Slack block builder utilities for enhanced notifications
Create block builder functions for Slack notifications with rich formatting:
- escapeSlackText() for safe mrkdwn escaping
- buildAlertBlocks() with header, monitor link, 4-field grid, error code block, dashboard button
- buildRecoveryBlocks() with optional downtime duration display
- buildDegradedBlocks() with optional previous incident duration
Add @openstatus/notification-base dependency to Slack package.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat: update Slack provider to use enhanced blocks and incident data
- Import buildCommonMessageData from @openstatus/notification-base
- Import block builders (buildAlertBlocks, buildRecoveryBlocks, buildDegradedBlocks)
- Update sendAlert to use buildCommonMessageData and buildAlertBlocks
- Update sendRecovery to pass incident for duration calculation
- Update sendDegraded to pass incident for duration calculation
- Rich Slack notifications now include formatted fields, error blocks, and dashboard buttons
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat: add Discord embed builder utilities for enhanced notifications
Add Discord embed builders that create rich embed messages with proper
formatting including colored embeds, inline fields, markdown links, and
incident duration tracking.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat: update Discord provider to use enhanced embeds and incident data
- Import buildCommonMessageData from @openstatus/notification-base
- Import embed builders from ./embeds
- Update postToWebhook to accept embeds array instead of plain content
- Update sendAlert to build context, call buildCommonMessageData and buildAlertEmbed
- Update sendRecovery to pass incident for duration calculation
- Update sendDegraded to pass incident for duration calculation
- Update sendTestDiscordMessage to use embed format
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* docs: mark duration formatting tests task as complete
The unit tests for duration formatting already exist in
packages/notification-base/src/utils/duration.test.ts with
complete coverage of all required test cases.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* test: add unit tests for incident duration calculation
Add comprehensive unit tests for getIncidentDuration() utility function,
covering null cases, resolved incidents, different time formats, and
edge cases.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* docs: verify package dependencies and workspace configuration
Verified that the @openstatus/notification-base package is properly
integrated into the monorepo workspace. All workspace dependencies
are correctly linked and imports work as expected.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* chore: verify backward compatibility for all notification providers
- Applied biome formatting fixes to all 11 notification provider files
- Applied biome formatting fixes to notification-base utility files
- Verified all providers have incident?: Incident optional parameter
- Confirmed all providers compile and lint successfully
- Updated PRD to mark backward compatibility task as complete
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* docs: verify all notification providers have the newly created utils/types
- Verified Slack and Discord providers fully integrate with @openstatus/notification-base
- Confirmed all 11 providers have consistent function signatures with incident?: Incident
- Documented which providers use notification-base and rationale for those that don't
- Fixed biome formatting issue in types.ts (import sorting)
- Updated progress.txt with comprehensive verification summary
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* docs: verify implementation follows official Slack and Discord documentation
- Verified Slack Block Kit best practices (mrkdwn/plain_text types, emoji, escaping)
- Verified Discord embed guidelines (ISO 8601 timestamps, decimal colors, inline fields)
- Fixed trailing comma formatting issues in blocks.ts and embeds.ts (biome)
- Updated PRD task to passes: true
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* perf: verify database query performance for incident fetching
Verified that the incident fetching in alerting.ts:
- Uses primary key lookup on incidentTable.id (O(log n), <1ms)
- Only runs for recovery/degraded notifications, not alerts
- Gracefully handles missing incidents (continues with undefined)
- Catches and logs errors without blocking notifications
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: format and pnpm lock
* chore: examples
* wip:
* refactor: package location
* fix: incident id
* fix: dockerfile
* fix: remove ralph files
* fix: packages
* fix: opsgenie test
* fix: dofigen
* fix: test alerts
* fix: test
* fix: review
* fix: remove action
* fix: send dashboard test
* fix: review
* chore: dedupe key
* fix: color grading
* fix: review
* chore: docs logo asset
* fix: color test
* fix: degraded
* chore: minor stuff
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
authored by
This is a binary file and will not be displayed.