Skip to content

feat(add_ons): Add lifecycle webhooks - #6308

Merged
groyoh merged 4 commits into
getlago:mainfrom
avanish-garg:feature/add-on-lifecycle-webhooks
Oct 19, 2026
Merged

groyoh merged 4 commits into
getlago:mainfrom
avanish-garg:feature/add-on-lifecycle-webhooks

Conversation

@avanish-garg

@avanish-garg avanish-garg commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Context

Creating, updating or deleting an add-on sent no webhook, unlike plans, billable metrics and features.

Description

Three webhooks are added: add_on.created, add_on.updated and add_on.deleted, sent by the create, update and destroy services. The payload is the add-on object with its taxes, the same object the add-on endpoints return, so an update that only changes the taxes is visible in the payload.

The types are declared in config/webhook_event_types.yml under a new Add Ons category, so a webhook endpoint can subscribe to them and the webhook form lists them. The category name has no dash because the GraphQL enum key is built from it (ADD_ONS). The GraphQL schema was regenerated. Endpoints that listen to all events receive the new webhooks without any change.

The webhook specs compare the whole payload, so a missing or renamed field is caught.

Fixes #6309

@groyoh groyoh 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.

Some points may block the merge: the ⚠️ comments change what API users get and should be fixed first.

  • The branch is based on a main from early September and needs a rebase. spec/models/webhook_endpoint_spec.rb was added on main since then and fails with this change (see the inline comment).
  • The new webhooks are not documented in getlago/lago-openapi (src/webhooks/ has billable_metric_created.yaml but nothing for add-ons). A matching PR there would let SDK users and the docs see the payload.

Comment thread app/jobs/send_webhook_job.rb Resolved
avanish-garg and others added 3 commits October 15, 2026 18:58
AddOn create/update/destroy fired no webhooks and produced no activity
logs at all, unlike sibling catalog resources Plan/BillableMetric/
Coupon, which all fire *.created/*.updated/*.deleted webhooks.

Adds Webhooks::AddOns::{Created,Updated,Deleted}Service mirroring the
existing BillableMetrics/Coupons webhook services, registers them in
SendWebhookJob::WEBHOOK_SERVICES, and wires the SendWebhookJob calls
into AddOns::{Create,Update,Destroy}Service.
## Context

Webhook endpoints can only subscribe to the event types declared in `config/webhook_event_types.yml`. The `add_on.*` webhooks were added to `SendWebhookJob::WEBHOOK_SERVICES` without being declared there, so an endpoint that selects its events could not subscribe to them, and the webhook form did not list them. `spec/models/webhook_endpoint_spec.rb` also requires every handler type to be declared.

## Description

`add_on.created`, `add_on.updated` and `add_on.deleted` are declared under a new `Add Ons` category. The category has no dash because its GraphQL enum key is built from it (`ADD_ONS`). The GraphQL schema was dumped again, since `EventTypeEnum` and `EventCategoryEnum` are built from this file.
## Context

The add-on endpoints of the REST API serialize add-ons with their `taxes`, but the `add_on.*` webhook payloads did not. An update that only changed `tax_codes` sent an `add_on.updated` whose payload looked unchanged.

## Description

The add-on webhooks now serialize with `includes: %i[taxes]`, so the webhook object matches the API object.
## Context

The add-on webhook specs only checked a few keys of the payload, mostly by type, through the `creates webhook` shared example, which ignores the keys it is not given. A field missing from the payload, renamed or with a wrong value was not caught.

## Description

Each spec now builds an add-on with explicit values and one applied tax, and compares the whole payload with `eq`, including every field of the serialized tax.
@groyoh groyoh changed the title feat(add_ons): add lifecycle webhooks feat(add_ons): Add lifecycle webhooks Oct 19, 2026
@groyoh
groyoh merged commit f6c0f2f into getlago:main Oct 19, 2026
14 checks passed
groyoh added a commit to getlago/lago-openapi that referenced this pull request Oct 19, 2026
## Context

lago-api sends `add_on.created`, `add_on.updated` and `add_on.deleted` webhooks once getlago/lago-api#6308 is merged. The payload is the add-on object with its taxes, the same one the add-on endpoints return. These webhooks are not documented yet.

## Description

The three webhooks are documented with `AddOnObject` as payload, following the billable metric and plan webhooks.

This PR should be merged after getlago/lago-api#6308.
@groyoh

groyoh commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Thanks for you contribution @avanish-garg !

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.

[FEAT]: AddOn lifecycle (create/update/destroy) fires no webhooks or activity logs

2 participants