Skip to content

Event Subscription

Introduction

Any integration may subscribe to events happening in Leyra (e.g. a user logged in, a video was played, a purchase was validated) by listing them in the eventSubscriptions of its manifest (IntegrationService.GetManifest). Leyra then calls the integration's EventNotificationService.OnEvent whenever one of these events occurs. See Event subscription for more details.

Development with IDK

To start IDK in Event Subscription mode, simply run idk up event-subscription

$ idk up event-subscription

grpc-mock Done!
router Done!
event-subscription-api Done!
ui Done!
Creating network "default-evsubidk" with the default driver
Creating event-subscription_default_event-subscription-api_1 ...
Creating event-subscription_default_grpc-mock_1              ...
Creating event-subscription_default_ui_1                     ...
Creating event-subscription_default_router_1                 ...
Creating event-subscription_default_ui_1                     ... done
Creating event-subscription_default_router_1                 ... done
Creating event-subscription_default_grpc-mock_1              ... done
Creating event-subscription_default_event-subscription-api_1 ... done
### IDK environment URLs ###

    - IDK - Admin UI: http://localhost:49154/

Once your integration URL is saved in the Settings tab, use the Send event tab to send events to your integration:

  • Pick the event to send in the Event type list, where events are grouped by kind (Catalog, Content, Purchase, User, etc.)
  • The event details are prefilled with a template for the selected event. Edit them freely: switching to another event type keeps your changes, and the Template list may be used to replace them with one of the predefined templates available for the event

Like Leyra, the IDK attaches the integration configuration to the request. Note that the IDK sends the event regardless of the eventSubscriptions listed in the integration manifest, while Leyra only sends the events the integration subscribed to.

APIs

Following APIs must be fulfilled by the integration:

  • EventNotificationService - as defined in notification/notification.proto