openapi: "3.0.3"
info:
  title: "Product telemetry API"
  version: "1.0.0"
  description: "Events are the highest-volume table in the system, so the generator has to reuse session ids instead of inventing new ones. The props column is json and holds a flat object of event properties. A session belongs to an account, so accounts are the first table in the insert order. The platform enum has exactly three members and every event must inherit one of them through its session."
paths: {}
x-domain-id: "telemetry"
x-dialect: "postgres"
components:
  schemas:
    accounts:
      type: "object"
      x-primary-key: "id"
      required: ["id", "email"]
      properties:
        id:
          type: "string"
          format: "uuid"
        email:
          type: "string"
          format: "email"
          x-unique: true
    sessions:
      type: "object"
      x-primary-key: "id"
      required: ["id", "account_id", "started_at", "platform"]
      properties:
        id:
          type: "string"
          format: "uuid"
        account_id:
          $ref: "#/components/schemas/accounts"
        started_at:
          type: "string"
          format: "date-time"
        platform:
          type: "string"
          enum: ["web", "ios", "android"]
    events:
      type: "object"
      x-primary-key: "id"
      required: ["id", "session_id", "name", "props", "occurred_at"]
      properties:
        id:
          type: "string"
          format: "uuid"
        session_id:
          $ref: "#/components/schemas/sessions"
        name:
          type: "string"
        props:
          type: "object"
        occurred_at:
          type: "string"
          format: "date-time"
