feat: enhance notification system and migrate to pubsub/v2 to fix CI#642
Open
nothing0012 wants to merge 3 commits intomainfrom
Open
feat: enhance notification system and migrate to pubsub/v2 to fix CI#642nothing0012 wants to merge 3 commits intomainfrom
nothing0012 wants to merge 3 commits intomainfrom
Conversation
marceloboeira
approved these changes
Dec 26, 2025
80d6654 to
a603682
Compare
a05edd2 to
007a828
Compare
fdabd0b to
ac52865
Compare
…rations - Add generic HTTP webhook notifier with retry, jitter, and config validation - Fire notifications on all flag CRUD operations (create/update/delete/restore) - Track component changes (flag/segment/variant/constraint/distribution/tag) - Async dispatch with semaphore limiting (max 100 concurrent) - Privacy-by-default: diffs disabled unless FLAGR_NOTIFICATION_DETAILED_DIFF_ENABLED=true - Payload: operation, flag_id, flag_key, component_type, component_id, component_key, pre_value, post_value, diff, user, timestamp (snake_case JSON with omitempty) - Statsd metrics (notification.sent) tagged by provider, operation, and status - Docs: flagr_notifications.md with payload spec and env var reference
9ecf6d7 to
c94c1ef
Compare
…ants Add ComponentType type with constants (ComponentFlag, ComponentSegment, ComponentVariant, ComponentConstraint, ComponentDistribution, ComponentTag) to replace magic string literals across handler call sites.
…te events Sub-resource handlers (CreateTag, CreateSegment, CreateConstraint, CreateVariant) were using OperationUpdate instead of OperationCreate. Similarly, DeleteTag, DeleteSegment, DeleteConstraint, DeleteVariant were using OperationUpdate instead of OperationDelete. Fix them so the operation field accurately reflects what happened to the component. Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a notification webhook system to Flagr that fires on every flag CRUD operation. A single generic webhook provider sends a structured JSON payload to a configurable URL — simple, extensible, and dependency-light.
Changes
New:
pkg/notification/notifier.goNotifierinterface,SendNotification(),MockNotifier,Notificationstructdispatch.gowebhook.goio.LimitReadersafetyretry.govalidate.goModified
pkg/entity/flag_snapshot.goSaveFlagSnapshotfiresSendNotificationafter commitpkg/handler/crud.gopkg/config/env.gopkg/util/util.goParseHeaders()for webhook custom headersDependencies
pmezard/go-difflib— forCalculateDiff()(unified diff of flag snapshots)Webhook Payload
{ "operation": "update", "flag_id": 123, "flag_key": "my-feature-flag", "component_type": "segment", "component_id": 7, "component_key": "power-users", "pre_value": "...", "post_value": "...", "diff": "--- Previous\n+++ Current\n@@ ...", "user": "admin@example.com", "timestamp": "2026-04-26T18:51:03Z" }Configuration
FLAGR_NOTIFICATION_WEBHOOK_ENABLEDfalseFLAGR_NOTIFICATION_WEBHOOK_URLFLAGR_NOTIFICATION_WEBHOOK_HEADERSKey: Val, Key: Val)FLAGR_NOTIFICATION_TIMEOUT10sFLAGR_NOTIFICATION_DETAILED_DIFF_ENABLEDfalseFLAGR_NOTIFICATION_MAX_RETRIES3FLAGR_NOTIFICATION_RETRY_BASE1sFLAGR_NOTIFICATION_RETRY_MAX10sDesign Decisions
Notifierinterface.omitemptyon optional fieldsflag_id/flag_keynotentity_*— avoids confusion with Flagr's evaluation entity conceptcomponent_type/component_id/component_key— tracks which sub-component was modifieddescription— the flag's static description isn't useful context for a change event; operation + component + diff already tell the full storyTests
27/27 passing across
pkg/notification,pkg/handler,pkg/entity— covering dispatch, retry (with body leak tracking), webhook payload format, concurrency safety, and handler integration.Types of changes