Add Events
Insert synthetic events derived from existing events or a SQL query.
In source_events mode, the new event is inserted at the timestamp of the
first occurrence of a source event in each path.
Exactly one of source_events, sql, or churn must be provided.
The new event rows are appended to the eventstream; original rows are kept.
Usage
stream.add_events("session_start", source_events=["login", "app_open"])
stream.add_events("churned", churn={"inactivity_days": 30})
stream.add_events("churned", churn={"inactivity_days": 30, "active_events": ["purchase"]})
Parameters
| Parameter | Type | Description |
|---|---|---|
name | str | Name of the synthetic event to create. |
source_events | list of str, optional | List of existing event names. For each path, one synthetic event is inserted at the timestamp of the first matching source event. |
sql | str, optional | DuckDB SQL SELECT statement that reads from the eventstream table alias and returns rows in the eventstream schema. Each returned row is added as a new synthetic event. |
churn | dict, optional | Creates a churn event after a period of inactivity. Required key: Optional key: |
Churn keys
inactivity_days(int or float) — gap in days after which a churn event is inserted.active_events(list of str) — only these events count as activity; defaults to all events.