Events & Analytics
Device and web funnel events, the one outbox-to-ClickHouse pipeline, the Sessions tab, and the funnel webhooks.
Two producers, one pipeline. A native funnel is presented on a device that
reports what happened; a web funnel runs on the server, which records what
it did. Both end up as rows in the same ClickHouse table, split by the
target dimension — and only some of them ever reach a webhook.
Device events
The device reports these wire names over POST /v1/events, each mapped to
the funnel vocabulary in exactly one place
(apps/api/src/lib/funnel-event-shape.ts:109-122):
| Device wire name | Becomes |
|---|---|
funnel_view | funnel.session.started |
funnel_screen_view | funnel.session.advanced |
funnel_complete | funnel.session.completed |
funnel_dismiss | funnel.session.dismissed |
funnel_photo_selected | Analytics only: a photo question got a photo (never the image or an id) |
funnel_photo_uploaded | Analytics only: a web photo finished uploading (size and timing) |
funnel_option_preselected | Analytics only: an app value preselected an option (spec B §7.1), so a default can be told from a choice |
funnel_check_started | Analytics only: a photo check started |
funnel_check_completed | Analytics only: a photo check finished — never the checker's label or reason text |
funnel_popup_shown | Analytics only: a popup opened — see Element events |
funnel_popup_dismissed | Analytics only: an open popup was closed |
funnel_countdown_expired | Analytics only: a countdown key ran out (once per key per session) |
funnel_loader_completed | Analytics only: a loader finished |
The nine analytics names are never funnel.session.* webhook, integration
or Slack deliveries — they reach ClickHouse only.
What a device sends for them
The device's FunnelSession (the Rust core, so Swift, Kotlin, React Native
and Flutter emit identically) sends four of the five, under the same
presentation id and through the same durable, at-least-once queue as
funnel_view; a preview or draft session sends none:
| Device event | When | screenId |
|---|---|---|
funnel_option_preselected | Once per fresh session, when an app value (or a declared fallback) preselected at least one option. Which keys is the claim result's preselected list. A restored session sends nothing. | The first screen |
funnel_photo_selected | A photo question took a NEW on-device photo (local: reference). Clearing a missing file or re-sending the same photo is not a selection. | The screen the photo was picked on |
funnel_check_started | Each RunCheck the session hands the host (an onEnter or onAnswer check), after the arrival it belongs to. | The screen the check runs on |
funnel_check_completed | The session ACCEPTED the host checker's result (a stale or refused result sends nothing), before the arrival an onPass/onFail route causes. | The screen the check ran on |
funnel_photo_uploaded is web-only: a native photo is never uploaded, it
stays on the device as a local: reference.
A device event carries only the envelope above — POST /v1/events refuses
any other field — plus, on the two check events alone, funnelCheck:
| Field | funnel_check_started | funnel_check_completed |
|---|---|---|
checkKey | The check's answer key | The check's answer key |
attempt | The RunCheck's attempt (1-based) | The attempt that ran — a skipped check reports its RunCheck's attempt too |
result | — (refused) | pass, fail, timeout or skipped (required) |
reasonCode | — (refused) | Absent on a pass; otherwise checker_fail (the host's checker said fail), timeout (the façade's deadline), unavailable (no handler, no answer, the photo gone — whenUnavailable) |
durationMs | — (refused) | Milliseconds from the RunCheck to the accepted result, measured by the core; absent when the check started before an app restart |
The core decides the reason code once, for every façade: a fail the
façade built itself for whenUnavailable: fail (no label, no reason, no
step statuses) is unavailable; any other fail is checker_fail. A
device never reports busy or checker_error — those are the web's
server-side checker codes. funnelCheck is .strict() too: a label,
reason or any other key inside it is refused, the reason code and result
are closed lists, and the field is refused on every other event name and
required on the two check names. So a device sends no sizes or timings for
photos, and never a photo, a reference, an answer, or the checker's label
or reason text.
Web and native check rows land in the same ClickHouse columns
(raw_funnel_events.checkKey, checkResult, checkReasonCode,
checkDurationMs, checkAttempt, migration 0045): the web's check routes
and the device shaper write the same payload keys (check_key, attempt,
result, reason_code, duration_ms), so the two targets compare by
target. A start fills checkKey and checkAttempt only; every
non-check row keeps the defaults ('' / 0).
Element events
The Engage elements report four events, the same names and the same facts on web and native. They carry ids, codes and numbers only — never a label, a title or any copy:
| Event | When | Facts besides elementId |
|---|---|---|
funnel_popup_shown | A popup opened: its enter delay ran out, an exit intent fired, or an action showed it. An enter / exit popup that already opened once this session, or that cannot open now, sends nothing | trigger: action, enter or exit |
funnel_popup_dismissed | An open popup closed while its screen stays — once per closing. A close the popup's dismiss turned off (its close button or the scrim) sends nothing, and neither does leaving the screen with the popup open: navigating closes it without a dismissal | via: close, scrim, escape (Esc, or the VoiceOver escape gesture), back (Android back) or action (a hide_element in an action chain) |
funnel_countdown_expired | A countdown key ran out — once per key per session, however many countdowns share the key and however often the clock is checked; also when it ran out while the visitor was on another screen | key: the timer key; mode: evergreen or deadline |
funnel_loader_completed | A loader on the current screen finished, once, as its onComplete runs | durationMs: the loader's configured wait in ms |
elementId is the element's id in the document; screenId (in
funnelContext) is the screen it happened on. The core decides every one
of these — the device's FunnelSession and the web's session step run the
same funnel-core-rs machine — so a host cannot add one the machine did
not observe.
- Native: the device sends them through
POST /v1/eventslike the other device events, with anelementobject:{ "elementId": "waitOffer", "trigger": "enter" }.elementis.strict(): it is required on these four names and refused on every other, each name takes exactly its own fields from the table,trigger,viaandmodeare the closed lists above,elementIdandkeyare at most 128 characters, anddurationMsis a whole number from 0 to 86,400,000. - Web: the runner calls
POST /public/funnel-sessions/:sessionId/element(tick,countdown_anchor,popup_trigger,popup_dismiss,loader_completed). The server runs the call through the session's machine at its own clock, and writes each event the step observed as an analytics-only outbox row in the same transaction, so a step that loses a race emits nothing. The runner ticks on screen entry, on resume and when its display clock crosses a deadline — never every second.
Both write the same payload keys on the rovenue.funnel wire —
element_id, trigger, via, mode, timer_key, duration_ms — and the
session vocabulary names them funnel.session.popup_shown,
funnel.session.popup_dismissed, funnel.session.countdown_expired and
funnel.session.loader_completed (none is a webhook key). They land in five
columns of raw_funnel_events (ClickHouse migration
0055_funnel_element_events.sql, through mv_funnel_events_to_raw_v11):
| Column | Filled on | Value |
|---|---|---|
elementId | all four | The element's id (cut at 128 characters) |
elementKind | all four | popup, countdown or loader — derived from the event name, never read from the payload |
elementReason | popup shown · popup dismissed · countdown expired | The trigger, the via, or the countdown's mode |
elementKey | countdown expired | The timer key (cut at 128 characters) |
elementDurationMs | loader completed | The loader's wait, ms |
Each column is read only on its own event names, so an element_id forged
onto any other event lands as ''; every other row keeps the defaults
('' / 0). Chart, Lottie and cookie consent emit nothing new — the
consent element's decision reaches the session the same way the consent
sheet's does.
The list is closed: any other funnel_<x> never enters the session
vocabulary and is kept under funnel.device.<x> instead
(apps/api/src/lib/funnel-event-shape.ts:94,
apps/api/src/lib/funnel-event-shape.ts:109-122). A screen view is an
arrival — there is no from, because the device names only the screen it
landed on (apps/api/src/lib/funnel-event-shape.ts:441-455).
Every device event carries funnelContext, and funnelContext.sessionId
is required and non-empty
(apps/api/src/routes/v1/events.ts:139-152): one presentation mints one
session id, and every event from opening to close or finish carries it. A
funnel_* body without its context is refused at the boundary, never
stored (apps/api/src/routes/v1/events.ts:171-180). The route files the
row under its own aggregate, FUNNEL_DEVICE_EVENT
(apps/api/src/routes/v1/events.ts:236-243) — never folded into
the retired paywall aggregate, so onboarding screens cannot inflate
a paywall conversion rate.
{
"eventType": "funnel_view",
"eventId": "<client-generated idempotency key>",
"subscriberId": "<the device's Rovenue id>",
"occurredAt": "2026-09-24T12:00:00.000Z",
"funnelContext": {
"funnelId": "<the funnels row id from the placement envelope>",
"sessionId": "<one id per presentation>",
"placementId": "<the placement identifier>",
"placementRevision": 7,
"revision": 3,
"screenId": "welcome",
"variantId": "<variant id when drawn from an experiment>",
"experimentKey": "onboarding-copy-test"
}
}funnelId is the served funnel's row id — the placement envelope carries
it because a native funnel has no slug
(apps/api/src/lib/placement-resolution.ts:139-143). Restoring a session
from state_json emits nothing and keeps the same sessionId; dismiss()
emits the one terminal event the device owns, funnel_dismiss.
Web session events
The web runner emits the same vocabulary minus the one event it cannot
produce: everything in FUNNEL_EVENT_TYPE except DISMISSED
(apps/api/src/lib/funnel-event-shape.ts:31-52,
apps/api/src/lib/funnel-event-shape.ts:56-57) — started, advanced,
moved_back, paid, completed, abandoned, and custom_action, plus
the claim_token mechanics. abandoned is a server-side inactivity
timeout written by the funnel-abandoner worker
(apps/api/src/workers/funnel-abandoner.ts:40-46), never a device close;
dismissed is the reverse — a device close, never a timeout
(apps/api/src/services/funnel/analytics.ts:44-53). A backward move is
moved_back, not advanced, so going back to an already-reached screen
never counts as a second arrival
(apps/api/src/services/funnel/analytics.ts:131-156).
Every web payload is stamped target: "web" at emission, unconditionally
(apps/api/src/services/funnel/outbox.ts:33-56) — never read off the
funnel's current, mutable target, so converting a funnel cannot rewrite
which side its old sessions belong to
(apps/api/src/services/funnel/analytics.ts:60-86).
The experiment stamp
A web session that a web funnel A/B test
assigned to an arm carries that arm on every event it emits, from
started to abandoned. The stamp is added once, by the emitter
(emitFunnelEvent in apps/api/src/services/funnel/outbox.ts), from the
session row, so no call site can leave it out:
| Payload key | ClickHouse column | Meaning |
|---|---|---|
experiment_id | experimentId | the experiment |
experiment_key | experimentKey | its key |
variant_id | variantId | the arm; legacy for a session from a previous-release runner |
visitor_id | visitorId | the runner's random visitor id |
allocation_revision | allocationRevision | the split revision the visitor was drawn under |
assignment_source | assignmentSource | hash, sticky, forced, holdout or legacy |
is_bot | isBot | the session was classified as a bot or automation |
The columns are on raw_funnel_events (ClickHouse migration
0046_web_funnel_experiments.sql). A session with no experiment — a
funnel not under test, a variant opened on its own slug, a device funnel —
keeps the defaults ('' and 0). started is the exposure: the results
count unique visitorIds, each in the arm of their earliest exposure
within the current revision, and leave out forced, legacy and isBot
sessions.
paid also carries trial, a boolean: whether the purchase started a free
trial. It is not money — a trial start is a checkout completion, not a
conversion.
Revenue reaches the arm through the funnel session it was bought in: the
purchase's presented context carries funnelSessionId (with
experimentKey and variantId), and each revenue row records it in
raw_revenue_events.funnelSessionId, which joins
raw_funnel_events.sessionId. Subscriptions and their renewals, one-time
purchases and refunds all carry it; revenue from before this release has
it empty.
The session language
started carries two more top-level keys, the language the session was
given (see Which language a visitor sees):
| Payload key | ClickHouse column | Meaning |
|---|---|---|
locale | visitorLocale | the funnel language served (de, never the visitor's raw de-AT), so it has at most as many values as the funnel has translations |
locale_source | localeSource | param, browser, country or default |
They are added by the session start
(startedLocalePayload, apps/api/src/services/funnel/outbox.ts:99-108;
apps/api/src/routes/public/funnels.ts:1186-1187) and land in
raw_funnel_events through mv_funnel_events_to_raw_v10 (ClickHouse
migration 0054_funnel_session_locale.sql,
packages/db/clickhouse/migrations/0054_funnel_session_locale.sql:139-140).
Only started carries them, and a later ?lng= switch is not re-emitted:
analytics keep the language the session started in. Native sessions and
sessions from an older runner have both columns empty ('').
The one pipeline
Both aggregates share the rovenue.funnel topic: FUNNEL and
FUNNEL_DEVICE_EVENT map to it in the same table
(apps/api/src/lib/outbox-topics.ts:25-33), and the dispatcher picks the
shaper by aggregate, never by topic
(apps/api/src/workers/outbox-dispatcher.ts:142-160). A web row goes
verbatim with eventId equal to its outbox id; a device row is reshaped
from its raw client body into the same wire, with a content-hash id so a
retried POST dedups
(apps/api/src/workers/outbox-dispatcher.ts:142-160,
apps/api/src/lib/funnel-event-shape.ts:269-284).
From there the path is fixed: outbox → Redpanda → the Kafka Engine table
(packages/db/clickhouse/migrations/0026_funnel_events_kafka_engine.sql:40-46)
→ the materialized view into raw_funnel_events
(packages/db/clickhouse/migrations/0029_funnel_events_target.sql:63-107).
A message that predates target falls back to 'web' in the view, not by
column default
(packages/db/clickhouse/migrations/0029_funnel_events_target.sql:86-95).
Reads go through FINAL over the deduped raw table, so an at-least-once
redelivery cannot inflate a count
(apps/api/src/services/funnel/analytics.ts:14-21). One event aggregate
with a target dimension, one raw table, one MV — that unification is
spec §5
(docs/superpowers/specs/2026-09-21-funnels-flows-unification-design.md:222-228).
The Sessions tab
The builder's Sessions tab reads this pipeline (shipped in wave 7, Task 8 —
docs/superpowers/plans/2026-09-24-funnels-unification-wave-7-rename.md:477,
docs/superpowers/plans/2026-09-24-funnels-unification-wave-7-rename.md:484).
Each screen row shows two numbers: sessions next to arrivals
(apps/dashboard/src/components/funnel-builder/sessions-tab.tsx:410).
They differ on purpose. An arrival is a row: started names the screen a
session opened on, advanced names the one a forward move landed on
(apps/api/src/services/funnel/analytics.ts:131-156). sessions is a uniq
over session ids over the whole window, read off the raw table rather than
summed from the daily view — adding per-day uniqs would count a session
that spanned midnight twice
(apps/api/src/services/funnel/analytics.ts:181-194).
Two details follow from that. The entry is the document's first page — the
screen the resolver starts every session at — not screens[0], which is
the busiest screen, since the API orders busiest-first
(apps/dashboard/src/components/funnel-builder/sessions-tab.tsx:293-304).
And dismissed appears only when non-zero, so a web-only funnel's history
never grows a permanent "0 dismissed"
(apps/dashboard/src/components/funnel-builder/sessions-tab.tsx:306-310).
With no analytics store configured there is no history at all — the live
numbers above it come from Postgres, which knows where sessions are, not
where they went
(apps/dashboard/src/components/funnel-builder/sessions-tab.tsx:280-290,
apps/api/src/services/funnel/analytics.ts:6-21).
Break down by splits the same screens into one column per value of a
visitor fact the session started with: Country, OS, Browser, Traffic or
Language (FUNNEL_SCREEN_BREAKDOWN_DIMENSIONS,
packages/shared/src/funnel/history-window.ts:23). Language groups by the
visitorLocale of the session's started row
(apps/api/src/services/funnel/analytics.ts:364), so its columns are the
funnel's languages, each with its English name under the tag
(apps/dashboard/src/components/funnel-builder/sessions-tab.tsx:467-471).
Native sessions and sessions from an older runner carry no language and
fall under (none).
Webhooks
Seven funnel keys reach webhooks, and only the catch-all providers offer
them — Custom Webhook, Slack, Discord
(packages/shared/src/integrations.ts:20-28,
apps/docs/content/docs/integrations/outbound-webhooks.mdx:154):
started, advanced, paid, completed, abandoned, dismissed, and
custom_action. Deliberately absent: moved_back (analytics hygiene, not
a business moment), the claim_token mechanics, and any funnel.device.*
name (packages/shared/src/integrations.ts:7-14,
apps/api/src/services/integrations-fanout/consumer.ts:321-326). paid
carries no amount — money stays on revenue.*
(packages/shared/src/integrations.ts:16-18); abandoned is web-only and
dismissed native-only, the same split as above. The full per-key table
lives on Outbound Webhooks.
data is a curated camelCase object with sessionId taken from the wire's
aggregate id and omitted when empty
(apps/api/src/services/integrations-fanout/consumer.ts:286-296,
apps/docs/content/docs/integrations/outbound-webhooks.mdx:69):
{
"id": "<the wire eventId — the outbox id for web, the content hash for native>",
"type": "funnel.session.started",
"created": "2026-09-24T12:00:00.000Z",
"apiVersion": "2026-08-24",
"projectId": "<the project id>",
"data": {
"sessionId": "<the presentation id>",
"funnelId": "<the funnels row id>",
"target": "web",
"pageId": "welcome"
}
}A web session under an A/B test also carries
"experiment": { "key": "<experiment key>", "variantId": "<arm id>" },
paid carries trial, and a web started carries locale (the funnel
language served) and localeSource (param, browser, country or
default) — absent for native sessions and older runners
(apps/api/src/services/integrations-fanout/consumer.ts:399-402). The visitor id, revision, assignment source and bot
flag stay internal: they are analytics mechanics, and the visitor id is a
pseudonymous identifier. See
Outbound Webhooks.
Native funnel webhooks are client-asserted. A device event is submitted
with the project's public SDK key — the same key that ships inside the
app binary — so anyone holding it can submit an event that never happened
on a real device
(apps/docs/content/docs/integrations/outbound-webhooks.mdx:113). Web
funnel events and every revenue.* event are produced server-side and
carry no such exposure. Never treat a native funnel webhook as proof of
anything a client could fake; for a trustworthy signal use revenue.* or
a web funnel event instead.