{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://flagon.incubator.apache.org/log.schema.json",
    "title": "Log",
    "description": "A raw or custom log produced by userale",
    "type": "object",
    "properties": {
        "target": {
            "type": "string"
        },
        "path": {
            "type": "array",
            "items": {
                "type": "string"
            },
            "minItems": 1
        },
        "pageUrl": {
            "type": "string"
        },
        "pageTitle": {
            "type": "string"
        },
        "browser": {
            "type": "object",
            "properties": {
                "browser": {
                    "type": "string"
                },
                "version": {
                    "type": "string"
                }
            },
            "required" : ["browser", "version"]
        },
        "clientTime": {
            "type": "integer"
        },
        "microTime": {
            "type": "number",
            "minimum": 0,
            "maxmaximumi": 1
        },
        "location": {
          "type": "object",
          "properties": {
              "x": {
                  "type": ["integer", "null"]
              },
              "y": {
                  "type": ["integer", "null"]
              }
          },
          "required" : ["x", "y"]
        },
        "scrnRes": {
          "type": "object",
          "properties": {
              "height": {
                  "type": "integer"
              },
              "width": {
                  "type": "integer"
              }
          },
          "required" : ["height", "width"]
        },
        "type": {
          "type": "string"
        },
        "logType": {
          "type": "string",
          "enum": ["raw", "custom"]
        },
        "userAction": {
          "type": "boolean"
        },
        "details": {
          "type": "object"
        },
        "userId": {
          "type": "string"
        },
        "toolVersion": {
          "type": "string"
        },
        "toolName": {
          "type": "string"
        },
        "useraleVersion": {
          "type": "string"
        },
        "sessionID": {
          "type": "string"
        }
    },
    "required": [
        "pageUrl",
        "pageTitle",
        "pageReferrer",
        "browser",
        "clientTime",
        "scrnRes",
        "logType",
        "userAction",
        "details",
        "userId",
        "toolVersion",
        "toolName",
        "useraleVersion",
        "sessionID"
    ],
    "if": {
        "properties": { "logType": { "const": "raw" } }
    },
    "then": {
        "required": [
            "target",
            "path",
            "microTime",
            "location",
            "type"
        ]
    }
}