@glassanalytics/browser
Advanced tools
+22
-0
@@ -138,2 +138,4 @@ import { randomToken, prefixedId, evaluateFlag, INGEST_AUTH_SCHEME, replaySegmentPath } from '@glassanalytics/core'; | ||
| encoder = new ReplayEncoder(); | ||
| /** rrweb's addCustomEvent, captured on start — lets us weave Glass events into the stream. */ | ||
| addCustom = null; | ||
| async start() { | ||
@@ -143,2 +145,4 @@ if (this.stop) return; | ||
| const { record } = await import('rrweb'); | ||
| const rec = record; | ||
| this.addCustom = typeof rec.addCustomEvent === "function" ? rec.addCustomEvent.bind(record) : null; | ||
| this.stop = record({ | ||
@@ -168,2 +172,15 @@ emit: (event) => { | ||
| } | ||
| /** | ||
| * Weave a Glass event into the rrweb stream as a Custom (type 5) event, so the | ||
| * player can render it as a timeline marker (`UI.md` §4.1). No-op unless we're | ||
| * actively recording. Payload is kept tiny (name + optional level) to avoid | ||
| * bloating replay segments. | ||
| */ | ||
| addEvent(name, payload) { | ||
| if (!this.stop || !this.addCustom) return; | ||
| try { | ||
| this.addCustom(name, payload); | ||
| } catch { | ||
| } | ||
| } | ||
| async flushSegment() { | ||
@@ -205,2 +222,3 @@ if (this.events.length === 0) return; | ||
| this.stop = null; | ||
| this.addCustom = null; | ||
| if (this.interval) { | ||
@@ -751,2 +769,6 @@ clearInterval(this.interval); | ||
| }); | ||
| if (this.cfg.replay) { | ||
| const name = event ?? type; | ||
| this.replay.addEvent(name, { event: name, ...type === "error" ? { level: "error" } : {} }); | ||
| } | ||
| } | ||
@@ -753,0 +775,0 @@ /** Device/screen context attached to EVERY event (`SDK.md` §4). */ |
+1
-1
| { | ||
| "name": "@glassanalytics/browser", | ||
| "version": "0.1.1", | ||
| "version": "0.1.2", | ||
| "description": "Glass browser SDK — session replay (rrweb), autocapture, identity, errors and edge-evaluated feature flags. Small, lazy, safe-by-default.", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
Sorry, the diff of this file is too big to display
124021
2.33%1220
1.84%