Developer

Public event schema

The Apex analytics event wire format accepted by the Worker and written to Tinybird.

Apex events flow from the SDK, Shopify Pixel, external checkout pixels, or server integrations to the Worker, then to Tinybird. The shared @drip/event-schema package owns the public field list, validation patterns, and Tinybird column mapping.

Incoming event shape

The Worker accepts batches as an array of events, or as an object with an events array plus ingest auth:

json
{
  "events": [
    {
      "type": "goal",
      "eventId": "evt_demo_1001",
      "shopId": "11111111-1111-4111-8111-111111111111",
      "visitorId": "visitor_demo_123",
      "sessionId": "session_demo_123",
      "experimentId": "22222222-2222-4222-8222-222222222222",
      "variationId": "33333333-3333-4333-8333-333333333333",
      "url": "https://example.com/products/demo",
      "data": {
        "goalId": "__add_to_cart__",
        "revenue": 49,
        "currency": "EUR"
      },
      "ts": 1783502400000
    }
  ],
  "_shopId": "11111111-1111-4111-8111-111111111111",
  "_signature": "px_signed_ingest_token_here"
}

Accepted aliases:

Canonical meaningAccepted incoming keys
Shop IDshop_id, shopId
Visitor IDvisitor_id, visitorId
Session IDsession_id, sessionId
User IDuser_id, userId
Event typeevent_type, type
Event IDevent_id, eventId
Experiment IDexperiment_id, experimentId
Variation IDvariation_id, variationId
Propertiesproperties as a JSON object string or object, or data as an object
Timestamptimestamp, ts

event_type must match /^[a-zA-Z0-9_.:-]{1,120}$/. Properties must be a JSON object after normalization. Apex rejects common sensitive property names such as email, phone, password, ssn, credit_card, and card_number.

Outgoing field reference

After normalization, Apex writes these fields:

FieldRequiredType or ruleNotes
event_idNostringGenerated when missing. Used for bounded dedupe when present.
shop_idYesstringValidated from ingest auth.
visitor_idYesstringRequired after aliases; missing values are quarantined.
session_idYesstringDefaults to unknown if missing.
user_idYesstringEmpty string when unknown.
event_typeYespattern stringSame pattern as incoming event_type.
experiment_idYesstringEmpty string for unattributed events.
variation_idYesstringEmpty string for unattributed events.
urlYesstringCleaned event URL.
propertiesYesJSON object stringSanitized event properties plus event_id.
botYes0 or 1Worker bot evidence flag.
live_run_idYesstringExtracted from liveRunId or live_run_id; empty when absent.
order_keyYesstringDerived from order, booking, checkout, or attribution properties.
revenueNofinite numberPromoted from properties when present and valid.
currencyNo3 uppercase lettersPromoted from currency, currencyCode, or currency_code.
durationNofinite numberPromoted from properties.
scroll_depthNofinite numberPromoted from scroll_depth or scrollDepth.
goal_idNostringPromoted from goalId or goal_id.
referrerNostringPromoted from properties.
utm_sourceNostringPromoted from utm_source or utmSource.
utm_mediumNostringPromoted from utm_medium or utmMedium.
utm_campaignNostringPromoted from utm_campaign or utmCampaign.
deviceYesstringDerived from the request user agent.
countryYesstringDerived from Cloudflare request metadata or unknown.
timestampYesparseable datetime stringDerived from timestamp, ts, or receipt time.
qa_modeYes0 or 11 when incoming qa_mode is true.
qa_session_idYesstringSet from the preview link's drip_qa_session parameter and preserved for the browser session so QA event readback can isolate one run. Empty string when absent.

user_id, experiment_id, variation_id, live_run_id, order_key, and qa_session_id intentionally use empty strings when absent for Tinybird compatibility.

Server API source requirements

Events sent with a tracking source key through x-apex-source-key or Authorization: Bearer apx_src_... must include a stable event_id. Apex uses that ID for replay protection and can quarantine missing IDs for server API sources.

Shops that drop user identifiers

For shops covered by the identifier-free analytics policy, the Worker and direct commerce publisher always apply the same identifier-free row builder. The canonical shop-id list is reviewed and released with the code; there is no runtime setting or policy read. Other shops retain their existing event behavior.

user_id is blank and its aliases are omitted. Visitor and session ids retain independent generated anonymous ids (UUID, 32-character random hex, or the browser SDK random/time shape). Invalid identities use a UUID anonymous fallback or unknown. Server-side commerce order events keep their order-scoped visitor and session ids (for example shopify_order:<order>), so each order stays a separate observation. URLs and referrers retain their origin and public route words, with other path segments replaced by _; credentials, query and fragment are removed. Properties use a fixed typed allow-list, including shallow catalog-only line items; unknown fields and nested metadata are omitted.

Caller event ids must be UUIDs or the SDK base36 time/random fallback. A caller event id that equals or embeds a declared customer identifier quarantines with identifier_in_event_id even when its shape is valid; it is never redacted, because a changed id could collide two events or break retry deduplication. Caller order ids use the normal derived order key, including ct_<hash> for checkout tokens. Present experiment/variation ids and aliases must be UUIDs. Invalid identities quarantine with identifier_in_event_id, identifier_in_order_key, or identifier_in_experiment_id; declared identifiers in the environment quarantine as identifier_in_environment. The trusted commerce publisher keeps its own event/order keys unless one embeds a declared identifier, which quarantines the row with the same column reason; it still validates experiment/variation ids.

Declared identifiers are the case-sensitive strings (or decimal numbers) of at least four characters in user_id, userId, customer_id, and customerId, including the unprefixed portion of supported customer prefixes, also in visitor and session ids. Rule 5 clears any other finished string column (not the event or order id, which quarantine) containing one of these identifiers, including valid UUIDs and anonymous fallbacks. Property values are checked one by one: numeric money values are kept, other numbers are dropped only when they equal an identifier. Valid timestamp, ingest_at and fx_rate_date values are exempt. Quarantine contains only the rebuilt row and a fixed reason, never raw input. A quarantined row is never appended.

The Worker normalizes first, runs the existing erased-visitor filter, validates identities, deduplicates and claims, then projects before queue, Tinybird or reporting. Projection fails closed. Logged-in assignment exposures are not published for these shops, including hashed customer-derived exposure ids. Assignment decisions and daily ingest ceilings retain their existing behavior.