Skip to content

feat(integrations): add AlertingIntegration interface and SentryAlertingIntegration class#1040

Merged
aaight merged 1 commit intodevfrom
feature/sentry-alerting-integration
Mar 24, 2026
Merged

feat(integrations): add AlertingIntegration interface and SentryAlertingIntegration class#1040
aaight merged 1 commit intodevfrom
feature/sentry-alerting-integration

Conversation

@aaight
Copy link
Copy Markdown
Collaborator

@aaight aaight commented Mar 24, 2026

Summary

  • Adds AlertingIntegration interface in src/integrations/alerting.ts extending IntegrationModule with category: 'alerting' and getConfig() method
  • Adds SentryAlertingIntegration class in src/sentry/alerting-integration.ts implementing the new interface
  • Registers SentryAlertingIntegration in the unified integrationRegistry via src/pm/bootstrap.ts
  • Exports AlertingIntegration from src/integrations/index.ts
  • Preserves full backward compatibility — existing hasAlertingIntegration() and getSentryIntegrationConfig() functions remain unchanged

Details

AlertingIntegration interface (src/integrations/alerting.ts)

Extends IntegrationModule with:

  • readonly category: 'alerting' — narrowed type for type-safe filtering
  • getConfig(projectId): Promise<SentryIntegrationConfig | null> — retrieves alerting provider config

SentryAlertingIntegration class (src/sentry/alerting-integration.ts)

  • type = 'sentry', category = 'alerting'
  • hasIntegration() — delegates to existing hasAlertingIntegration() logic
  • getConfig() — delegates to existing getSentryIntegrationConfig() logic
  • withCredentials() — resolves SENTRY_API_TOKEN via getIntegrationCredential(projectId, 'alerting', 'api_token') and scopes it in process.env for the callback duration (following the same env-scoping pattern used by ackMessageGenerator.ts and squintDb.ts)

Registration

SentryAlertingIntegration is registered in src/pm/bootstrap.ts alongside the existing PM and SCM integrations, using the same guard pattern (getOrNull check before registering).

Test plan

  • Unit tests in tests/unit/sentry/alerting-integration.test.ts cover: metadata, hasIntegration, getConfig, withCredentials (token scoping, restore, error propagation)
  • All 356 unit test files pass (6853 tests)
  • TypeScript type check passes with zero errors
  • Biome lint passes with zero errors

Closes https://trello.com/c/mfdkkSWv/546-as-a-developer-i-want-alertingintegration-and-sentryalertingintegration-so-that-sentry-follows-the-unified-integration-pattern

🤖 Generated with Claude Code

🕵️ claude-code · claude-sonnet-4-6 · run details

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 24, 2026

Codecov Report

❌ Patch coverage is 86.66667% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/pm/bootstrap.ts 0.00% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Collaborator

@nhopeatall nhopeatall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

LGTM — Clean implementation that correctly follows the established IntegrationModule pattern. The SentryAlertingIntegration class mirrors the structure of GitHubSCMIntegration, the withCredentials env-scoping pattern matches existing usage in ackMessageGenerator.ts and squintDb.ts, and the bootstrap registration uses the same guard pattern. Tests are thorough with good edge-case coverage. All CI checks pass.

Minor Design Observation

  • src/integrations/alerting.ts:29 — The getConfig() return type is coupled to SentryIntegrationConfig, which makes this interface Sentry-specific rather than a true generic alerting abstraction. Compare with SCMIntegration which avoids GitHub-specific types entirely. Not blocking — this can be generalized when/if a second alerting provider is added — but worth noting for future extensibility.

🕵️ claude-code · claude-opus-4-6 · run details

@aaight aaight merged commit e85a750 into dev Mar 24, 2026
9 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