Project events: timestamped
data points you record (for example order.created) that can trigger
workflows, plus the definitions that describe them.
Event names are lowercase, optionally with dot-separated segments; each segment starts with a letter and may contain letters, numbers and underscores.
Summary
Functions
Creates an event definition, or updates (and unarchives) the one with the
same name. Attributes: name (required), description,
property_schema.
Permanently deletes an event definition and all its recorded events.
Deletion runs in the background (202 Accepted). To keep history,
archive it with update_definition/3 instead.
Emits an event.
Gets an event definition.
Lists events, newest first.
Lists event definitions. Params: include_archived.
Updates an event definition: name, description, property_schema,
or archived (to hide it while keeping its events).
Types
@type result() :: {:ok, map() | nil} | {:error, KapsoEx.Error.t()}
Functions
@spec create_definition(KapsoEx.Client.t(), map() | keyword()) :: result()
Creates an event definition, or updates (and unarchives) the one with the
same name. Attributes: name (required), description,
property_schema.
@spec delete_definition(KapsoEx.Client.t(), String.t()) :: result()
Permanently deletes an event definition and all its recorded events.
Deletion runs in the background (202 Accepted). To keep history,
archive it with update_definition/3 instead.
@spec emit(KapsoEx.Client.t(), String.t(), keyword()) :: result()
Emits an event.
Options
:properties- map of event properties.:conversation_id- link the event to a WhatsApp conversation.:occurred_at-DateTimeor ISO 8601 string; defaults to now.
Examples
Events.emit(client, "order.created", properties: %{order_id: "1234", total: 59.9})
@spec get_definition(KapsoEx.Client.t(), String.t()) :: result()
Gets an event definition.
@spec list(KapsoEx.Client.t(), map() | keyword()) :: result()
Lists events, newest first.
Params: name, conversation_id, occurred_after, occurred_before,
limit, before, after.
@spec list_definitions(KapsoEx.Client.t(), map() | keyword()) :: result()
Lists event definitions. Params: include_archived.
@spec update_definition(KapsoEx.Client.t(), String.t(), map() | keyword()) :: result()
Updates an event definition: name, description, property_schema,
or archived (to hide it while keeping its events).