Skip to main content
Product change workflows emit events after they commit, so you can run side effects, such as notifying a seller or reindexing search, without polling. The change events are in ProductChangeWorkflowEvents, and the revision request event is in ProductWorkflowEvents, both exported from @mercurjs/core/workflows.

Change events

Each change event carries the id of one change. A workflow that handles several changes emits one event per change. Audit changes from recordProductAuditChangeWorkflow emit no change event. An auto-confirmed change emits product-change.created and then product-change.confirmed.

Revision request event

The revision request event comes from requestProductChangeWorkflow. Its id is the product id, because the request is recorded on the product rather than resolving a change.

Subscribe to an event

This subscriber loads a confirmed change with its actions:
src/subscribers/product-change-confirmed.ts
created_by tells you who to notify: a seller id for edits from the Vendor panel. To react to declines with the reason, read declined_reason the same way from a product-change.declined subscriber.