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_idYesstringEmpty 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.