{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/ZAAI-com/Astro-AEO/main/schema/analytics-event-v1.schema.json",
  "title": "Astro-AEO request observation, version 1",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "version",
    "type",
    "timestamp",
    "registryVersion",
    "method",
    "status",
    "path",
    "pathKind",
    "crawler",
    "representation",
    "cache",
    "surface",
    "sampleRate",
    "scope",
    "coverage"
  ],
  "properties": {
    "version": {
      "const": 1
    },
    "type": {
      "const": "request"
    },
    "timestamp": {
      "type": "string",
      "format": "date-time",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:00\\.000Z$"
    },
    "registryVersion": {
      "type": "string",
      "minLength": 1,
      "maxLength": 16,
      "pattern": "^\\d+$"
    },
    "method": {
      "enum": [
        "GET",
        "HEAD"
      ]
    },
    "status": {
      "type": "integer",
      "minimum": 0,
      "maximum": 599
    },
    "path": {
      "type": "string",
      "minLength": 1,
      "maxLength": 2048,
      "pattern": "^(?:/[^?#\\u0000-\\u001f\\u007f]*|\\(unlisted\\))$"
    },
    "pathKind": {
      "enum": [
        "inventory",
        "artifact",
        "pattern",
        "unlisted"
      ]
    },
    "crawler": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "identity",
        "classification"
      ],
      "properties": {
        "identity": {
          "enum": [
            "unknown",
            "OAI-SearchBot",
            "GPTBot",
            "ChatGPT-User",
            "ClaudeBot",
            "Claude-SearchBot",
            "Claude-User",
            "PerplexityBot",
            "Perplexity-User",
            "Googlebot",
            "bingbot",
            "Meta-ExternalAgent",
            "Amazonbot",
            "CCBot",
            "Applebot",
            "Amzn-SearchBot",
            "Amzn-User"
          ]
        },
        "classification": {
          "enum": [
            "claimed",
            "unclassified"
          ]
        }
      }
    },
    "representation": {
      "enum": [
        "html",
        "markdown",
        "artifact",
        "redirect",
        "other"
      ]
    },
    "cache": {
      "enum": [
        "not-modified",
        "unknown"
      ]
    },
    "surface": {
      "enum": [
        "development",
        "preview",
        "node",
        "deno",
        "astro",
        "cloudflare",
        "netlify",
        "vercel"
      ]
    },
    "sampleRate": {
      "type": "number",
      "exclusiveMinimum": 0,
      "maximum": 1
    },
    "scope": {
      "enum": [
        "agents",
        "all"
      ]
    },
    "coverage": {
      "const": "observable-only"
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "path": {
            "const": "(unlisted)"
          }
        }
      },
      "then": {
        "properties": {
          "pathKind": {
            "const": "unlisted"
          }
        }
      },
      "else": {
        "properties": {
          "pathKind": {
            "enum": [
              "inventory",
              "artifact",
              "pattern"
            ]
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "crawler": {
            "properties": {
              "identity": {
                "const": "unknown"
              }
            }
          }
        }
      },
      "then": {
        "properties": {
          "crawler": {
            "properties": {
              "classification": {
                "const": "unclassified"
              }
            }
          }
        }
      },
      "else": {
        "properties": {
          "crawler": {
            "properties": {
              "classification": {
                "const": "claimed"
              }
            }
          }
        }
      }
    }
  ]
}
