/** * The telemetry WIRE SCHEMA (spec: "Monetization Gates / Usage telemetry"; * public doc: docs/telemetry.md — keep all three in sync). Deliberately a * types-only module with zero DOM/browser references: the ingestion Worker * (cloud/workers/telemetry, WebWorker lib) type-imports this same file, so * client and server can never drift apart silently — a schema change breaks * the other side's typecheck in the same commit. */ export interface TelemetryLayerSnapshot { type: string; rows: number; streaming: boolean; refresh: boolean; } /** Library-caused error report (spec: "Monetization Gates / Usage telemetry" — library-error reporting). Scrubbed: no manifest content, no layer data, no page paths. */ export interface TelemetryErrorReport { event: "library_error"; pageLoadId: string; version: string; /** Hostname only — never the path. Carries the packaged-app id instead when a native adapter declares one (a WebView's loopback hostname identifies nothing). */ origin: string; /** The runtime's host platform; "web" unless a native adapter declares otherwise (see configureTelemetry). */ platform: "web" | "ios" | "android"; /** Trusted packaged-app identity from a native adapter's build metadata, or null on the web. */ appId: string | null; dev: boolean; /** Hash of message + top own-code frame — the dedup/grouping key. */ signature: string; message: string; /** Top stack lines from the library's own code, query strings stripped. */ frames: string[]; ua: string; } export interface TelemetrySnapshot { event: "map_ready"; /** Random per page load — dedups beacon retries & multi-map pages. NOT persistent, NOT a visitor id. */ pageLoadId: string; /** The authored `map-id` attribute — identifies the map artifact, not the visitor. */ mapId: string | null; version: string; /** "free" until the license module (monetization M1) exists. */ plan: string; keyId: string | null; /** Hostname only — never the path. Carries the packaged-app id instead when a native adapter declares one (a WebView's loopback hostname identifies nothing). */ origin: string; /** The runtime's host platform; "web" unless a native adapter declares otherwise (see configureTelemetry). */ platform: "web" | "ios" | "android"; /** Trusted packaged-app identity from a native adapter's build metadata, or null on the web. */ appId: string | null; frontend: "html" | "react" | "programmatic"; renderer: "maplibre" | "standalone"; /** Dev context (localhost et al.) — the only beacons the server may GeoIP (country code, IP discarded). */ dev: boolean; layers: TelemetryLayerSnapshot[]; story: { steps: number; } | null; widgets: string[]; draw: boolean; undoRedo: boolean; }