Skip to content

Conversation

efr-chriswilliams
Copy link

Add Global Webhook Support

Description

This PR adds support for global webhooks in Flagr, allowing users to receive notifications for system events. The implementation includes:

  • A new Webhook entity for storing webhook configurations
  • A WebhookEvent entity for tracking webhook delivery status
  • A webhook service for triggering and managing webhook deliveries
  • REST API endpoints for managing webhooks
  • Integration with existing CRUD operations to trigger webhooks on relevant events

Motivation and Context

Currently, Flagr lacks a way to notify external systems about changes to flags, segments, variants, and other entities. This makes it difficult to integrate Flagr with other systems that need to react to these changes. The webhook system provides a flexible way to notify external systems about these events.

How Has This Been Tested?

  • Added unit tests for the webhook service
  • Tested webhook delivery with various event types
  • Verified webhook signature generation and validation
  • Tested error handling and retry logic
  • Tested webhook configuration management through the API

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@efr-chriswilliams
Copy link
Author

Screenshot 2025-06-06 at 16 48 31

Copy link

github-actions bot commented Aug 5, 2025

Stale pull request message

Description string `gorm:"type:text"`
Events string `gorm:"type:text"` // Comma-separated list of events to trigger on
Secret string `gorm:"type:text"` // Optional secret for webhook signature
Enabled bool `gorm:"default:true"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

please add an index here, since the query uses enabled = true

}
if params.Body.EntityType != nil {
et := *params.Body.EntityType
if err := entity.CreateFlagEntityType(tx, et); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

looks like this logic got removed?

@@ -1,22 +1,28 @@
package handler

import (
Copy link
Collaborator

Choose a reason for hiding this comment

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

many of the trigger logic seems repetitive, do you think it can be done with refactor much of this logic into GORM model hooks (‎BeforeCreate, ‎AfterCreate, ‎BeforeUpdate, ‎AfterUpdate, ‎BeforeDelete, ‎AfterDelete)? This would centralize the webhook logic within the model definitions, making the CRUD handlers cleaner and reducing the risk of missing a webhook trigger in future code changes.

Copy link

github-actions bot commented Oct 6, 2025

Stale pull request message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants