Skip to content

feat(api): alert rules conditions + scheduled evaluator (#534) - #543

Merged
unjica merged 3 commits into
developfrom
feat/alert-rules-conditions-scheduled-534
Jul 18, 2026
Merged

unjica merged 3 commits into
developfrom
feat/alert-rules-conditions-scheduled-534

Conversation

@unjica

@unjica unjica commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Extends Alert Rules with ERROR_RATE, SESSION_DROP, NEW_ERROR_GROUP, AFFECTED_USERS, QUOTA_PERCENT, NO_EVENTS, and HEARTBEAT condition evaluators (AND semantics; unknown types skipped safely).
  • Adds scheduled evaluator job (alert-rules-evaluator) that coexists with ingest-triggered evaluation; shared cooldown dedupe; delivery only via fireProjectAlert.
  • Documents cadence (ALERT_RULES_SCHEDULE_INTERVAL_MINUTES, default 5) and Railway cron setup; dashboard lists/summarizes new kinds (ERROR_COUNT editor unchanged).

Closes nothing yet — tracks #534 (parent vision #493 stays open).

Test plan

  • pnpm --filter api test -- src/lib/alert-rules.test.ts src/jobs/alert-rules-evaluator.test.ts
  • pnpm --filter dashboard test -- lib/alert-rules.test.ts
  • pnpm lint
  • Create a HEARTBEAT / NO_EVENTS rule via API; run pnpm --filter api alert-rules-evaluator and confirm fire + cooldown
  • Confirm ingest still fires ERROR_COUNT rules and does not evaluate schedule-only rules
  • Confirm unknown condition types in stored JSON do not crash evaluation and do not block sibling AND conditions

Made with Cursor

Add ERROR_RATE, SESSION_DROP, NEW_ERROR_GROUP, AFFECTED_USERS, QUOTA_PERCENT,
NO_EVENTS, and HEARTBEAT evaluators plus an idempotent cron job so non-ingest
conditions can fire through fireProjectAlert with shared cooldown dedupe.

Co-authored-by: Cursor <[email protected]>
@unjica unjica added this to the v1.15.x — Alert Rules milestone Jul 18, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit aa8520f. Configure here.

Comment thread apps/api/src/lib/alert-rules.ts Resolved
Replace wall-clock bucket cooldown with atomic last_fired_at claims so
elapsed cooldown is enforced across concurrent sweeps, and skip scheduled
evaluation for soft-deleted projects/orgs to match ingest auth.

Co-authored-by: Cursor <[email protected]>
@unjica
unjica merged commit ef7303f into develop Jul 18, 2026
5 of 6 checks passed
@unjica
unjica deleted the feat/alert-rules-conditions-scheduled-534 branch July 18, 2026 08:56
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.

1 participant