{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://objectsgrid.com/.well-known/objects-catalog/LogEvent/v1/schema.json",
  "title": "LogEvent",
  "description": "One logged event of an application, with the app, session, device and environment it happened in. Searchable; created in batches with POST /log.",
  "x-objectsgrid-jsonLd": false,
  "$defs": {
    "AppInfo": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "Application name"
        },
        "version": {
          "type": "string",
          "description": "Application version"
        },
        "build": {
          "type": "string",
          "description": "Build identifier"
        },
        "releaseId": {
          "type": "string",
          "description": "Release identifier"
        }
      },
      "required": [
        "name",
        "version"
      ],
      "additionalProperties": false
    },
    "AuthInfo": {
      "type": "object",
      "properties": {
        "method": {
          "type": "string",
          "description": "Authentication method"
        },
        "state": {
          "type": "string",
          "description": "Authentication state"
        },
        "userId": {
          "type": "string",
          "description": "User identifier"
        }
      },
      "additionalProperties": false
    },
    "ClientInfo": {
      "type": "object",
      "properties": {
        "locale": {
          "type": "string",
          "description": "Client locale (e.g., en-US)"
        },
        "timezone": {
          "type": "string",
          "description": "Client timezone"
        },
        "userAgent": {
          "type": "string",
          "description": "User agent string"
        },
        "sdk": {
          "$ref": "#/$defs/SDKInfo"
        }
      },
      "additionalProperties": false
    },
    "DeviceInfo": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "description": "Device type"
        },
        "manufacturer": {
          "type": "string",
          "description": "Device manufacturer"
        },
        "model": {
          "type": "string",
          "description": "Device model"
        },
        "osName": {
          "type": "string",
          "description": "Operating system name"
        },
        "osVersion": {
          "type": "string",
          "description": "Operating system version"
        }
      },
      "additionalProperties": false
    },
    "DisplayInfo": {
      "type": "object",
      "properties": {
        "width": {
          "type": "integer",
          "description": "Display width in pixels",
          "minimum": 0
        },
        "height": {
          "type": "integer",
          "description": "Display height in pixels",
          "minimum": 0
        },
        "pixelRatio": {
          "type": "number",
          "description": "Device pixel ratio",
          "minimum": 0
        },
        "orientation": {
          "type": "string",
          "description": "Screen orientation"
        }
      },
      "additionalProperties": false
    },
    "ErrorObject": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "description": "Error type or class name"
        },
        "code": {
          "type": "string",
          "description": "Error code"
        },
        "message": {
          "type": "string",
          "description": "Error message"
        },
        "unhandled": {
          "type": "boolean",
          "description": "Whether error was unhandled"
        },
        "fatal": {
          "type": "boolean",
          "description": "Whether error was fatal"
        },
        "stack": {
          "type": "string",
          "description": "Stack trace"
        },
        "cause": {
          "$ref": "#/$defs/ErrorObject",
          "description": "Underlying cause of the error"
        }
      },
      "additionalProperties": false
    },
    "Extensions": {
      "type": "object",
      "description": "Namespaced extension bag for custom data",
      "additionalProperties": {
        "type": "object",
        "additionalProperties": true
      }
    },
    "Geo": {
      "type": "object",
      "properties": {
        "latitude": {
          "type": "number",
          "description": "Latitude coordinate",
          "minimum": -90,
          "maximum": 90
        },
        "longitude": {
          "type": "number",
          "description": "Longitude coordinate",
          "minimum": -180,
          "maximum": 180
        },
        "accuracyMeters": {
          "type": "number",
          "description": "Location accuracy in meters",
          "minimum": 0
        },
        "source": {
          "type": "string",
          "description": "Location source"
        },
        "capturedAt": {
          "type": "string",
          "format": "date-time",
          "description": "When location was captured"
        }
      },
      "additionalProperties": false
    },
    "HTTPInfo": {
      "type": "object",
      "properties": {
        "method": {
          "type": "string",
          "description": "HTTP method"
        },
        "status": {
          "type": "integer",
          "description": "HTTP status code",
          "minimum": 100,
          "maximum": 599
        },
        "urlTemplate": {
          "type": "string",
          "description": "URL template (with path parameters)"
        },
        "durationMs": {
          "type": "integer",
          "description": "Request duration in milliseconds",
          "minimum": 0
        },
        "retryCount": {
          "type": "integer",
          "description": "Number of retries",
          "minimum": 0
        }
      },
      "additionalProperties": false
    },
    "MobileInfo": {
      "type": "object",
      "properties": {
        "appState": {
          "type": "string",
          "description": "Application state"
        },
        "screenName": {
          "type": "string",
          "description": "Current screen name"
        },
        "permissions": {
          "type": "object",
          "description": "Permission states",
          "additionalProperties": {
            "type": "string"
          }
        }
      },
      "additionalProperties": false
    },
    "NetworkInfo": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "description": "Network type"
        },
        "effectiveType": {
          "type": "string",
          "description": "Effective network type"
        },
        "carrier": {
          "type": "string",
          "description": "Network carrier name"
        },
        "roaming": {
          "type": "boolean",
          "description": "Whether device is roaming"
        },
        "metered": {
          "type": "boolean",
          "description": "Whether connection is metered"
        }
      },
      "additionalProperties": false
    },
    "SDKInfo": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "SDK name"
        },
        "version": {
          "type": "string",
          "description": "SDK version"
        }
      },
      "additionalProperties": false
    },
    "SessionInfo": {
      "type": "object",
      "properties": {
        "sessionId": {
          "type": "string",
          "description": "Unique session identifier"
        },
        "installId": {
          "type": "string",
          "description": "Installation identifier"
        },
        "correlationId": {
          "type": "string",
          "description": "Correlation identifier for tracking across services"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier"
        },
        "traceId": {
          "type": "string",
          "description": "Distributed trace identifier"
        },
        "spanId": {
          "type": "string",
          "description": "Span identifier within a trace"
        }
      },
      "required": [
        "sessionId"
      ],
      "additionalProperties": false
    },
    "UIInfo": {
      "type": "object",
      "properties": {
        "screenName": {
          "type": "string",
          "description": "Screen or page name"
        },
        "component": {
          "type": "string",
          "description": "UI component identifier"
        },
        "route": {
          "type": "string",
          "description": "Route or navigation path"
        },
        "display": {
          "$ref": "#/$defs/DisplayInfo"
        }
      },
      "additionalProperties": false
    },
    "ViewportInfo": {
      "type": "object",
      "properties": {
        "width": {
          "type": "integer",
          "description": "Viewport width in pixels",
          "minimum": 0
        },
        "height": {
          "type": "integer",
          "description": "Viewport height in pixels",
          "minimum": 0
        }
      },
      "additionalProperties": false
    },
    "WebInfo": {
      "type": "object",
      "properties": {
        "browserName": {
          "type": "string",
          "description": "Browser name"
        },
        "browserVersion": {
          "type": "string",
          "description": "Browser version"
        },
        "pageUrl": {
          "type": "string",
          "format": "uri",
          "description": "Current page URL"
        },
        "referrer": {
          "type": "string",
          "format": "uri",
          "description": "Referrer URL"
        },
        "viewport": {
          "$ref": "#/$defs/ViewportInfo"
        },
        "userAgent": {
          "type": "string",
          "description": "User agent string"
        }
      },
      "additionalProperties": false
    }
  },
  "type": "object",
  "properties": {
    "at_type": {
      "description": "The object type",
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "LogEvent"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "at_id": {
      "description": "This LogEvent's ObjectsGrid URL, https://apis.objectsgrid.com/<path>/<id>: its JSON-LD @id, which References point to. Set by the service.",
      "type": [
        "string",
        "null"
      ],
      "format": "uri",
      "readOnly": true
    },
    "id": {
      "description": "The unique identifier for LogEvent. Assigned by the server.",
      "type": [
        "string",
        "null"
      ],
      "minLength": 0,
      "maxLength": 50,
      "readOnly": true
    },
    "identifier": {
      "description": "The unique identifier for LogEvent. Assigned by the server.",
      "type": [
        "string",
        "null"
      ],
      "minLength": 0,
      "maxLength": 50,
      "readOnly": true
    },
    "url": {
      "description": "This LogEvent URL. Assigned by the server.",
      "type": [
        "string",
        "null"
      ],
      "format": "uri",
      "minLength": 1,
      "readOnly": true
    },
    "schemaVersion": {
      "type": "string",
      "description": "Schema version identifier"
    },
    "app": {
      "$ref": "#/$defs/AppInfo"
    },
    "environment": {
      "type": "string",
      "description": "Environment name (e.g., production, staging, development)"
    },
    "platform": {
      "type": "string",
      "description": "Platform identifier"
    },
    "baseUrl": {
      "type": "string",
      "format": "uri",
      "description": "Base URL of the application"
    },
    "sentAt": {
      "type": "string",
      "format": "date-time",
      "description": "When the record was sent"
    },
    "session": {
      "$ref": "#/$defs/SessionInfo"
    },
    "auth": {
      "$ref": "#/$defs/AuthInfo"
    },
    "client": {
      "$ref": "#/$defs/ClientInfo"
    },
    "device": {
      "$ref": "#/$defs/DeviceInfo"
    },
    "network": {
      "$ref": "#/$defs/NetworkInfo"
    },
    "geo": {
      "$ref": "#/$defs/Geo"
    },
    "web": {
      "$ref": "#/$defs/WebInfo"
    },
    "mobile": {
      "$ref": "#/$defs/MobileInfo"
    },
    "extensions": {
      "$ref": "#/$defs/Extensions",
      "description": "Record-level extensions (namespaced)"
    },
    "timestamp": {
      "type": "string",
      "format": "date-time",
      "description": "When the log entry was created"
    },
    "severity": {
      "type": "string",
      "description": "Log severity level"
    },
    "message": {
      "type": "string",
      "description": "Log message"
    },
    "eventType": {
      "type": "string",
      "description": "Type of event"
    },
    "title": {
      "type": "string",
      "description": "Event title"
    },
    "error": {
      "$ref": "#/$defs/ErrorObject"
    },
    "stackTrace": {
      "type": "string",
      "description": "Stack trace if applicable"
    },
    "ui": {
      "$ref": "#/$defs/UIInfo"
    },
    "http": {
      "$ref": "#/$defs/HTTPInfo"
    },
    "context": {
      "type": "object",
      "description": "Free-form per-entry contextual data",
      "additionalProperties": true
    },
    "performance": {
      "type": "object",
      "description": "Performance metrics",
      "additionalProperties": true
    },
    "entryExtensions": {
      "$ref": "#/$defs/Extensions",
      "description": "Entry-level extensions (namespaced)"
    },
    "infoObject": {
      "type": "string",
      "description": "Optional informational object as a string"
    },
    "tags": {
      "description": "Tags an ABAC policy can decide on. A name may repeat; the same name and value appear once. Every stored object has them: created empty when not sent, kept by a replacement (PUT) that does not mention them, unchanged by a patch that does not mention them, cleared by null or [].",
      "type": "array",
      "default": [],
      "uniqueItems": true,
      "maxItems": 50,
      "items": {
        "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Tag/v1/schema.json"
      }
    },
    "meta": {
      "description": "System-managed metadata for the object (version, audit fields). Assigned by the server.",
      "$ref": "https://objectsgrid.com/.well-known/objects-catalog/ObjectMeta/v1/schema.json",
      "readOnly": true
    }
  },
  "required": [
    "schemaVersion",
    "app",
    "environment",
    "platform",
    "sentAt",
    "session",
    "timestamp",
    "severity",
    "message"
  ],
  "additionalProperties": false
}
