Derive a fallback key when session_id is missing.
(event: TelemetryEvent)
| 77 | |
| 78 | /** Derive a fallback key when session_id is missing. */ |
| 79 | function deriveSessionKey(event: TelemetryEvent): string { |
| 80 | const raw = JSON.stringify(event) |
| 81 | let h = 0 |
| 82 | for (let i = 0; i < raw.length; i++) { |
| 83 | h = ((h << 5) - h + raw.charCodeAt(i)) | 0 |
| 84 | } |
| 85 | return `__derived_${Math.abs(h).toString(36)}` |
| 86 | } |
| 87 | |
| 88 | // ── Event Schema Validation ────────────────────────────────────────── |
| 89 |