{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/derive-to/json-schema/derive-to-analytics-schema.json",
  "title": "Analytics",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/derive-to-analytics-api-openapi.yml#/components/schemas/Analytics",
  "type": "object",
  "properties": {
    "total": {
      "type": "number",
      "description": "Total recorded views across all versions (de-duped opens)"
    },
    "last24h": {
      "type": "number",
      "description": "Views in the trailing 24 hours. A rolling window rather than a calendar day, so it carries no timezone assumption about the reader"
    },
    "unique": {
      "type": "number",
      "description": "Distinct viewers; a signed-in person or anon cookie counts once"
    },
    "anonViewers": {
      "type": "number",
      "description": "How many of the unique viewers are anonymous"
    },
    "reads": {
      "type": "number",
      "description": "Unique viewers who stayed, not just fetched (link previews do not count)"
    },
    "perVersion": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "version": {
            "type": "number"
          },
          "count": {
            "type": "number",
            "description": "Views recorded for that version"
          }
        },
        "required": [
          "version",
          "count"
        ]
      }
    },
    "daily": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "day": {
            "type": "string",
            "description": "Calendar day bucket (YYYY-MM-DD)"
          },
          "count": {
            "type": "number",
            "description": "Views recorded on that day"
          }
        },
        "required": [
          "day",
          "count"
        ]
      }
    },
    "recent": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "viewer": {
            "type": "string",
            "description": "Display name (resolved @handle for users), or the anon viewer id"
          },
          "kind": {
            "type": "string",
            "enum": [
              "user",
              "anon"
            ],
            "description": "Whether the viewer is a signed-in user or anonymous"
          },
          "at": {
            "type": "string",
            "description": "When they last viewed (ISO timestamp)"
          },
          "avatar": {
            "type": [
              "string",
              "null"
            ],
            "description": "The user's avatar URL, or null/absent for anonymous viewers"
          }
        },
        "required": [
          "viewer",
          "kind",
          "at"
        ]
      }
    }
  },
  "required": [
    "total",
    "last24h",
    "unique",
    "anonViewers",
    "reads",
    "perVersion",
    "daily",
    "recent"
  ]
}