{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://schemas.sitecoreai.dev/v1/telemetry.schema.json",
  "title": "SitecoreAI CLI Telemetry",
  "type": "object",
  "required": ["schema_version", "nonce", "event", "command", "v"],
  "properties": {
    "schema_version": {
      "type": "string",
      "description": "Telemetry schema version."
    },
    "nonce": {
      "type": "string",
      "description": "Random nonce to reduce replay noise."
    },
    "event": {
      "type": "string",
      "description": "Event name.",
      "enum": ["command_start", "command_success", "command_error"]
    },
    "command": {
      "type": "string",
      "description": "Command name (flags removed, sensitive values redacted)."
    },
    "durationMs": {
      "type": "integer",
      "description": "Duration in milliseconds."
    },
    "error": {
      "type": "boolean",
      "description": "Error flag when an error occurred."
    },
    "v": {
      "type": "string",
      "description": "CLI version."
    },
    "ci": {
      "type": "boolean",
      "description": "CI flag when running in CI."
    },
    "region": {
      "type": "string",
      "description": "Server-derived region (e.g., US-CA) from CDN headers. Client-supplied values are ignored."
    },
    "metadata": {
      "type": "object",
      "description": "Optional metadata for future expansion.",
      "additionalProperties": true
    }
  },
  "additionalProperties": false
}
