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
| Column | Type | Notes |
|---|
| id | text PK | |
| organization_id | text | |
| session_id | text | SDK-generated session ID |
| referrer | text | nullable |
| initial_url | text | nullable |
| user_agent | text | nullable |
| ip_address | text | nullable |
| country | text | nullable |
| device_type | text | nullable |
| browser | text | nullable |
| os | text | nullable |
| has_replay | boolean | default false |
| exit_context | text | nullable, JSON |
| started_at | integer | epoch ms |
| ended_at | integer | nullable, epoch ms |
| created_at | integer | epoch ms |
| updated_at | integer | epoch ms |
events
| Column | Type | Notes |
|---|
| id | text PK | |
| session_id | text FK | references sessions.id |
| type | text | click, scroll, pageview, input, custom, etc. |
| url | text | Page URL where event occurred |
| timestamp | integer | epoch ms |
| data | text | JSON event payload |
| created_at | integer | epoch ms |
replay_chunks
| Column | Type | Notes |
|---|
| id | text PK | |
| session_id | text FK | references sessions.id |
| chunk_index | integer | Sequential chunk number |
| r2_key | text | R2 object key for the chunk data |
| event_count | integer | Number of events in chunk |
| size_bytes | integer | Chunk size |
| created_at | integer | epoch 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.
| Method | Path | Description |
|---|
| POST | /track | Submit tracking events |
| POST | /batch | Submit a batch of events |
| POST | /session/start | Start a new session |
| POST | /session/end | End a session |
| GET | /sessions/{orgId} | List sessions for org |
| GET | /sessions/{orgId}/{sessionId} | Get session details |
| GET | /sessions/{orgId}/{sessionId}/replay | Get session replay data |
Environment Variables
| Variable | Example |
|---|
| ENVIRONMENT | dev |
| AUTH_SERVICE_URL | https://dev.internal.auth-api.crowai.dev |
Secrets
| Secret | Purpose |
|---|
| SERVICE_API_KEY | API key for auth service verification |
Bindings
| Binding | Type | Name |
|---|
| DB | D1 | crow-web-ingest-service-db |
| R2_BUCKET | R2 | crow-web-ingest-service-store (replay chunks) |
| AI | Workers AI | Future use |
| WEB_SESSION | Durable Object | CrowWebSession |
| INTERACTION_QUEUE | Queue (producer) | crow-interaction-queue |
Queue Production
| Queue | Purpose |
|---|
crow-interaction-queue | Sends 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