RYP-F1 in Wave P. Everything scoped by the org through website.team_id with bound parameters only; tested at the SQL level on a throwaway cluster with the upstream migrations plus the fork's 90 and 91. - Identify: the edge collector (contract v1.1, additive) and the page tag accept `identify(userId, traits)` and a `user` on any event. Insights links the session (upstream session_link and session.distinct_id) and keeps one profile per (app, user) with first and last seen and merged traits (migration 91_railyard_people). Before this, an identify from the collector made Insights refuse the whole batch. - Saved cohorts: performed (with min times), not performed, trait equals and first seen within; counts are live. On fixtures a cohort equals a hand-written SQL count (two definitions). - Retention by property (country, language, screen, trait.<key>; day or week periods), breakdowns (path, referrer, country, language, screen, event, hostname, data.<key>, trait.<key>). - Export: events (31 days) or profiles, JSON or CSV, 100,000 rows; formula cells defused. - Delete by user id: one statement removes events, event data, session data, revenue, replay and heatmap rows, links, sessions and the profile in the org's apps only; recorded in railyard_erasure; a pending request is retried by POST /api/v1/erasure/sweep (hourly), so it is done within 24 h. - Console /api/v1/insights/* for an org's ry_ token: the org comes from the token, app names resolve to the org's own app, the platform token never leaves; served only with RAILYARD_REPLAY_LIVE=1 (denylist rule railyard-slot-replay), else 503 "arriving". - New packages: @railyard/insights-react-native (offline queue, identify kept across restarts, reset, consent) and @railyard/insights-server (server track and identify; profiles, cohorts, retention, breakdown, export, deleteUser through the console). No dependencies. Env: RAILYARD_REPLAY_LIVE (console). Migration: insights 91_railyard_people (idempotent; scratch Postgres only). Tests: insights fork 9/9 (depth SQL incl. isolation, cohort vs hand SQL, erasure), edge 18/18, console 125/125 (tsc clean), RN 3/3, server 5/5 (incl. copy lint), CLI 18/18. The upstream vitest suite runs in the image build on box 2 or CI (not on the Mac). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
147 lines
3.7 KiB
JSON
147 lines
3.7 KiB
JSON
{
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"$id": "https://railyard.dev/schemas/insights/ingest-batch.v1.json",
|
|
"title": "Insights ingest batch v1",
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"required": [
|
|
"org_id",
|
|
"sent_at",
|
|
"batches"
|
|
],
|
|
"properties": {
|
|
"org_id": {
|
|
"type": "string",
|
|
"minLength": 1
|
|
},
|
|
"sent_at": {
|
|
"type": "string",
|
|
"format": "date-time"
|
|
},
|
|
"batches": {
|
|
"type": "array",
|
|
"minItems": 1,
|
|
"items": {
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"required": [
|
|
"site_key",
|
|
"app_id",
|
|
"events"
|
|
],
|
|
"properties": {
|
|
"site_key": {
|
|
"type": "string"
|
|
},
|
|
"app_id": {
|
|
"type": "string"
|
|
},
|
|
"events": {
|
|
"type": "array",
|
|
"maxItems": 10000,
|
|
"items": {
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"required": [
|
|
"type",
|
|
"url",
|
|
"visitor",
|
|
"ts"
|
|
],
|
|
"properties": {
|
|
"type": {
|
|
"enum": [
|
|
"event",
|
|
"identify"
|
|
]
|
|
},
|
|
"name": {
|
|
"type": [
|
|
"string",
|
|
"null"
|
|
],
|
|
"maxLength": 50
|
|
},
|
|
"url": {
|
|
"type": "string",
|
|
"maxLength": 1000
|
|
},
|
|
"hostname": {
|
|
"type": [
|
|
"string",
|
|
"null"
|
|
],
|
|
"maxLength": 100
|
|
},
|
|
"referrer": {
|
|
"type": [
|
|
"string",
|
|
"null"
|
|
],
|
|
"maxLength": 1000
|
|
},
|
|
"title": {
|
|
"type": [
|
|
"string",
|
|
"null"
|
|
],
|
|
"maxLength": 500
|
|
},
|
|
"language": {
|
|
"type": [
|
|
"string",
|
|
"null"
|
|
],
|
|
"maxLength": 35
|
|
},
|
|
"screen": {
|
|
"type": [
|
|
"string",
|
|
"null"
|
|
],
|
|
"maxLength": 11
|
|
},
|
|
"data": {
|
|
"type": [
|
|
"object",
|
|
"null"
|
|
],
|
|
"maxProperties": 20
|
|
},
|
|
"visitor": {
|
|
"type": "string",
|
|
"pattern": "^[0-9a-f]{32}$"
|
|
},
|
|
"country": {
|
|
"type": [
|
|
"string",
|
|
"null"
|
|
],
|
|
"maxLength": 2
|
|
},
|
|
"ts": {
|
|
"type": "string",
|
|
"format": "date-time"
|
|
},
|
|
"user": {
|
|
"type": [
|
|
"string",
|
|
"null"
|
|
],
|
|
"pattern": "^[A-Za-z0-9@._:+=-]{1,50}$",
|
|
"description": "v1.1 (PY3.2): the app's own user id; required when type is identify"
|
|
},
|
|
"id": {
|
|
"type": "string",
|
|
"pattern": "^[A-Za-z0-9_-]{8,64}$",
|
|
"description": "PY2.5: the client event id the collector de-duplicates on"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|