Skip to main content
wit uses an event-driven architecture to power notifications, webhooks, CI/CD triggers, and other automated workflows. The src/events/ module provides a lightweight, in-process event bus.

Architecture

Key Files

Overview

The events system provides:
  • Real-time event emission for repository activities
  • Handler registration for processing events
  • Integration with notifications, CI, and webhooks
  • Extensibility for custom event handling
  • Event logging for debugging

Event Types

Repository Events

Push Events

Pull Request Events

Issue Events

CI Events

Mention Events

Merge Queue Events

Event Bus

The central event bus manages event emission and handler registration.

Emitting Events

Subscribing to Events

Built-in Handlers

Notification Handler

Automatically creates notifications for relevant events:
This creates notifications for:
  • PR comments and reviews
  • Mentions in comments
  • Review requests
  • Issue assignments
  • Access grants

CI Handler

Triggers CI workflows based on events:
Triggered by:
  • Push events
  • PR opened/synchronized
  • Manual workflow dispatch

Merge Queue Handler

Processes merge queue state changes:

Event Structure

All events follow a common structure:

Example Events

Push Event:
PR Review Event:

Custom Event Handlers

Creating a Handler

Handler with Filtering

Error Handling

Helper Functions

Extracting Mentions

Creating Events

Integration Points

Webhooks

Events are automatically sent to configured webhooks:

Activity Feed

Events populate the activity feed:

Real-time Updates

Events can be sent to connected clients:

Testing Event Handlers

Best Practices

  1. Keep handlers fast - Long-running operations should be queued
  2. Handle errors gracefully - Don’t let one handler break others
  3. Use specific events - Subscribe to specific types when possible
  4. Idempotency - Design handlers to be safely re-run
  5. Logging - Log event processing for debugging