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

ParameterTypeDescription
namestrName of the synthetic event to create.
source_eventslist of str, optionalList of existing event names. For each path, one synthetic event is inserted at the timestamp of the first matching source event.
sqlstr, optionalDuckDB 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.
churndict, optionalCreates 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.