Skip to content

refactor: deduplicate Slack posting logic with createSlackPoster factory#86

Merged
douglance merged 1 commit intomainfrom
dl/slack-dedup
Jan 15, 2026
Merged

refactor: deduplicate Slack posting logic with createSlackPoster factory#86
douglance merged 1 commit intomainfrom
dl/slack-dedup

Conversation

@douglance
Copy link
Contributor

Summary

  • Add createSlackPoster factory to packages/utils that consolidates common Slack posting patterns
  • Reduces ~75 lines of duplicated boilerplate across 3 monitors to 6 lines each
  • Includes 6 unit tests for the new factory

Changes

New files:

  • packages/utils/createSlackPoster.ts - Factory that handles env var validation, DEV/CI mode skipping
  • packages/utils/__test__/createSlackPoster.test.ts - Unit tests
  • packages/utils/vitest.config.ts - Test config

Simplified:

  • packages/assertion-monitor/reportAssertionMonitorAlertToSlack.ts (27 → 6 lines)
  • packages/batch-poster-monitor/reportBatchPosterAlertToSlack.ts (24 → 6 lines)
  • packages/retryable-monitor/handlers/slack/postSlackMessage.ts (18 → 6 lines)

Test plan

  • npx vitest run packages/utils/__test__/createSlackPoster.test.ts - 6 tests pass
  • TypeScript compilation passes for all packages

Add createSlackPoster factory to utils that handles common Slack posting
patterns: env var validation, DEV/CI mode skipping, and message routing.

Reduces ~75 lines of duplicated boilerplate across 3 monitors to 6 lines each.
@douglance douglance merged commit a884d10 into main Jan 15, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants