Skip to main content

web-ingest-service

Backend for the CROW JavaScript tracking SDK. Receives interaction events from web, mobile (React Native), and desktop (Electron) applications. Uses Durable Objects (CrowWebSession) for session buffering and replay chunk management. Dispatches processed interactions to the interaction service via queues.

Worker name: crow-web-ingest-service Domain (prod): internal.ingest-worker.crowai.dev Domain (dev): dev.internal.ingest-worker.crowai.dev

Schema

sessions

ColumnTypeNotes
idtext PK
organization_idtext
session_idtextSDK-generated session ID
referrertextnullable
initial_urltextnullable
user_agenttextnullable
ip_addresstextnullable
countrytextnullable
device_typetextnullable
browsertextnullable
ostextnullable
has_replaybooleandefault false
exit_contexttextnullable, JSON
started_atintegerepoch ms
ended_atintegernullable, epoch ms
created_atintegerepoch ms
updated_atintegerepoch ms

events

ColumnTypeNotes
idtext PK
session_idtext FKreferences sessions.id
typetextclick, scroll, pageview, input, custom, etc.
urltextPage URL where event occurred
timestampintegerepoch ms
datatextJSON event payload
created_atintegerepoch ms

replay_chunks

ColumnTypeNotes
idtext PK
session_idtext FKreferences sessions.id
chunk_indexintegerSequential chunk number
r2_keytextR2 object key for the chunk data
event_countintegerNumber of events in chunk
size_bytesintegerChunk size
created_atintegerepoch ms

Durable Object

CrowWebSession

Manages the lifecycle of a web tracking session:

  • Buffers incoming events within a session window
  • Defines sessions as 1 hour of user inactivity
  • Chunks replay data and stores in R2
  • Dispatches completed session data to the interaction queue

Routes

The service uses a raw fetch handler (not Hono). All routes require Bearer API key authentication verified against the auth service.

MethodPathDescription
POST/trackSubmit tracking events
POST/batchSubmit a batch of events
POST/session/startStart a new session
POST/session/endEnd a session
GET/sessions/{orgId}List sessions for org
GET/sessions/{orgId}/{sessionId}Get session details
GET/sessions/{orgId}/{sessionId}/replayGet session replay data

Environment Variables

VariableExample
ENVIRONMENTdev
AUTH_SERVICE_URLhttps://dev.internal.auth-api.crowai.dev

Secrets

SecretPurpose
SERVICE_API_KEYAPI key for auth service verification

Bindings

BindingTypeName
DBD1crow-web-ingest-service-db
R2_BUCKETR2crow-web-ingest-service-store (replay chunks)
AIWorkers AIFuture use
WEB_SESSIONDurable ObjectCrowWebSession
INTERACTION_QUEUEQueue (producer)crow-interaction-queue

Queue Production

QueuePurpose
crow-interaction-queueSends processed web interactions to the interaction service

Dependencies

  • Inbound: JavaScript tracking SDK (web, mobile, desktop clients)
  • Outbound: auth service (API key verification), interaction service (via queue)

Key Behaviors

  • Bearer API key auth: All requests require a valid crow_ API key passed as Authorization: Bearer crow_...
  • Session definition: A session is defined by 1 hour of user inactivity. New activity after 1 hour starts a new session.
  • Replay recording: Session events are recorded for replay, stored as chunks in R2
  • Event types: Captures clicks, scrolls, pageviews, input changes, custom events, and DOM mutations