@launchdarkly/o11y 0.0.0-stage → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,1657 @@
1
+ var qe = Object.defineProperty, Ge = Object.defineProperties;
2
+ var je = Object.getOwnPropertyDescriptors;
3
+ var $ = Object.getOwnPropertySymbols;
4
+ var fe = Object.prototype.hasOwnProperty, me = Object.prototype.propertyIsEnumerable;
5
+ var pe = (i) => {
6
+ throw TypeError(i);
7
+ };
8
+ var q = (i, e, t) => e in i ? qe(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, w = (i, e) => {
9
+ for (var t in e || (e = {}))
10
+ fe.call(e, t) && q(i, t, e[t]);
11
+ if ($)
12
+ for (var t of $(e))
13
+ me.call(e, t) && q(i, t, e[t]);
14
+ return i;
15
+ }, y = (i, e) => Ge(i, je(e));
16
+ var G = (i, e) => {
17
+ var t = {};
18
+ for (var s in i)
19
+ fe.call(i, s) && e.indexOf(s) < 0 && (t[s] = i[s]);
20
+ if (i != null && $)
21
+ for (var s of $(i))
22
+ e.indexOf(s) < 0 && me.call(i, s) && (t[s] = i[s]);
23
+ return t;
24
+ };
25
+ var a = (i, e, t) => q(i, typeof e != "symbol" ? e + "" : e, t), we = (i, e, t) => e.has(i) || pe("Cannot " + t);
26
+ var Se = (i, e, t) => (we(i, e, "read from private field"), t ? t.call(i) : e.get(i)), ye = (i, e, t) => e.has(i) ? pe("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(i) : e.set(i, t), be = (i, e, t, s) => (we(i, e, "write to private field"), s ? s.call(i, t) : e.set(i, t), t);
27
+ var _ = (i, e, t) => new Promise((s, n) => {
28
+ var o = (d) => {
29
+ try {
30
+ l(t.next(d));
31
+ } catch (c) {
32
+ n(c);
33
+ }
34
+ }, r = (d) => {
35
+ try {
36
+ l(t.throw(d));
37
+ } catch (c) {
38
+ n(c);
39
+ }
40
+ }, l = (d) => d.done ? s(d.value) : Promise.resolve(d.value).then(o, r);
41
+ l((t = t.apply(i, e)).next());
42
+ });
43
+ import { W as Je, M as L, r as j, I as ve, a as ke, S as Qe, C as Ye, F as Xe, b as Ze, P as et, c as _e, g as tt, p as st, d as it, e as nt, f as rt, s as ot, h as at } from "./record-C_yieA7u.js";
44
+ import { R as os } from "./record-C_yieA7u.js";
45
+ import { s as x, G as O, g as M, S as E, r as Re, a as J, b as ct, c as lt, d as Q, e as Y, f as U, F as De, V as dt, P as ht, h as gt, H as X, M as ut, i as ft, L as Ue, j as We, p as mt, k as Ie, l as Ce, m as pt, n as wt, o as St, q as yt, t as bt, u as vt, v as kt, w as _t, x as Rt } from "./common-DQ61tUu9.js";
46
+ import { X as Dt, F as It, A as Ct, C as Lt, E as Et, s as ze, D as Nt, a as Ot, m as Le, d as Be, b as Ee, c as Ne, r as Me, e as Tt, p as Pt, f as Ht, g as Ut, M as D, h as N, W as Wt, N as zt, P as Bt, J as Mt, i as V, j as A, k as Ft, l as $t, n as Vt, o as Oe } from "./observe-CFB6c1lu.js";
47
+ import { O as cs } from "./observe-CFB6c1lu.js";
48
+ import { L as At } from "./buffer-DIFxvF2Q.js";
49
+ import { g as Te } from "./LDObserve-CHIjcqIn.js";
50
+ import { L as ds } from "./LDObserve-CHIjcqIn.js";
51
+ import { LDRecord as gs } from "./LDRecord.js";
52
+ const xt = (i, e, t) => {
53
+ const s = window._highlightWebSocketRequestCallback;
54
+ window._highlightWebSocketRequestCallback = i;
55
+ const n = window._highlightWebSocketEventCallback;
56
+ return window._highlightWebSocketEventCallback = (o) => {
57
+ const h = o, { message: r, size: l } = h, d = G(h, ["message", "size"]), g = t.some(
58
+ (f) => o.name.toLowerCase().includes(f)
59
+ ) ? d : o;
60
+ e(g);
61
+ }, () => {
62
+ window._highlightWebSocketRequestCallback = s, window._highlightWebSocketEventCallback = n;
63
+ };
64
+ }, Kt = ({
65
+ xhrCallback: i,
66
+ fetchCallback: e,
67
+ webSocketRequestCallback: t,
68
+ webSocketEventCallback: s,
69
+ disableWebSocketRecording: n,
70
+ bodyKeysToRedact: o,
71
+ highlightEndpoints: r,
72
+ tracingOrigins: l,
73
+ urlBlocklist: d,
74
+ bodyKeysToRecord: c
75
+ }) => {
76
+ const g = Dt(
77
+ i,
78
+ r,
79
+ l,
80
+ d,
81
+ o,
82
+ c
83
+ ), h = It(
84
+ e,
85
+ r,
86
+ l,
87
+ d,
88
+ o,
89
+ c
90
+ ), f = n ? () => {
91
+ } : xt(
92
+ t,
93
+ s,
94
+ d
95
+ );
96
+ return () => {
97
+ g(), h(), f();
98
+ };
99
+ };
100
+ class I {
101
+ constructor(e) {
102
+ a(this, "disableConsoleRecording");
103
+ a(this, "reportConsoleErrors");
104
+ a(this, "enablePromisePatch");
105
+ a(this, "consoleMethodsToRecord");
106
+ a(this, "listeners");
107
+ a(this, "errors");
108
+ a(this, "messages");
109
+ // The properties below were added in 4.0.0 (Feb 2022), and are patched in by client via setupNetworkListeners()
110
+ a(this, "options");
111
+ a(this, "hasNetworkRecording", !0);
112
+ a(this, "disableNetworkRecording");
113
+ a(this, "enableRecordingNetworkContents");
114
+ a(this, "xhrNetworkContents");
115
+ a(this, "fetchNetworkContents");
116
+ a(this, "disableRecordingWebSocketContents");
117
+ a(this, "webSocketNetworkContents");
118
+ a(this, "webSocketEventContents");
119
+ a(this, "tracingOrigins");
120
+ a(this, "networkHeadersToRedact");
121
+ a(this, "networkBodyKeysToRedact");
122
+ a(this, "networkBodyKeysToRecord");
123
+ a(this, "networkHeaderKeysToRecord");
124
+ a(this, "lastNetworkRequestTimestamp");
125
+ a(this, "urlBlocklist");
126
+ a(this, "highlightEndpoints");
127
+ a(this, "requestResponseSanitizer");
128
+ var t, s;
129
+ this.options = e, this.disableConsoleRecording = !!e.disableConsoleRecording, this.reportConsoleErrors = (t = e.reportConsoleErrors) != null ? t : !1, this.enablePromisePatch = (s = e.enablePromisePatch) != null ? s : !1, this.consoleMethodsToRecord = e.consoleMethodsToRecord || [
130
+ ...Ct
131
+ ], this.listeners = [], this.errors = [], this.messages = [], this.lastNetworkRequestTimestamp = 0;
132
+ }
133
+ isListening() {
134
+ return this.listeners.length > 0;
135
+ }
136
+ startListening() {
137
+ if (this.isListening()) return;
138
+ const e = this;
139
+ this.disableConsoleRecording || this.listeners.push(
140
+ Lt(
141
+ (t) => {
142
+ var s, n, o;
143
+ if (this.reportConsoleErrors && (t.type === "Error" || t.type === "error") && t.value && t.trace) {
144
+ const r = x(t.value);
145
+ if (Ee.includes(r) || Ne.some(
146
+ (l) => r.includes(l)
147
+ ))
148
+ return;
149
+ e.errors.push({
150
+ event: r,
151
+ type: "console.error",
152
+ url: window.location.href,
153
+ source: (s = t.trace[0]) != null && s.fileName ? t.trace[0].fileName : "",
154
+ lineNumber: (n = t.trace[0]) != null && n.lineNumber ? t.trace[0].lineNumber : 0,
155
+ columnNumber: (o = t.trace[0]) != null && o.columnNumber ? t.trace[0].columnNumber : 0,
156
+ stackTrace: t.trace,
157
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
158
+ id: Me()
159
+ });
160
+ }
161
+ e.messages.push(t);
162
+ },
163
+ y(w({}, Be), {
164
+ level: this.consoleMethodsToRecord
165
+ })
166
+ )
167
+ ), this.listeners.push(
168
+ Et(
169
+ (t) => {
170
+ Ee.includes(t.event) || Ne.some(
171
+ (s) => t.event.includes(s)
172
+ ) || e.errors.push(t);
173
+ },
174
+ { enablePromisePatch: this.enablePromisePatch }
175
+ )
176
+ ), this.listeners.push(ze), I.setupNetworkListener(this, this.options);
177
+ }
178
+ stopListening() {
179
+ this.listeners.forEach((e) => e()), this.listeners = [];
180
+ }
181
+ // We define this as a static method because versions earlier than 4.0.0 (Feb 2022) don't have this code.
182
+ // For those versions, calling this from client will monkey-patch the network listeners onto the old FirstLoadListener object.
183
+ static setupNetworkListener(e, t) {
184
+ var o, r, l, d, c, g, h, f, m, R, v, C;
185
+ const s = (t == null ? void 0 : t.backendUrl) || void 0 || "https://pub.highlight.io", n = t.otlpEndpoint || "https://otel.highlight.io";
186
+ e.highlightEndpoints = [
187
+ s,
188
+ `${n}/v1/traces`,
189
+ `${n}/v1/logs`,
190
+ `${n}/v1/metrics`
191
+ ], e.xhrNetworkContents = [], e.fetchNetworkContents = [], e.webSocketNetworkContents = [], e.webSocketEventContents = [], e.networkHeadersToRedact = [], e.urlBlocklist = [], e.tracingOrigins = t.tracingOrigins || [], (t == null ? void 0 : t.disableNetworkRecording) !== void 0 ? (e.disableNetworkRecording = t == null ? void 0 : t.disableNetworkRecording, e.enableRecordingNetworkContents = !1, e.disableRecordingWebSocketContents = !0, e.networkHeadersToRedact = [], e.networkBodyKeysToRedact = [], e.urlBlocklist = [], e.networkBodyKeysToRecord = []) : typeof (t == null ? void 0 : t.networkRecording) == "boolean" ? (e.disableNetworkRecording = !t.networkRecording, e.enableRecordingNetworkContents = !1, e.disableRecordingWebSocketContents = !0, e.networkHeadersToRedact = [], e.networkBodyKeysToRedact = [], e.urlBlocklist = []) : (((o = t.networkRecording) == null ? void 0 : o.enabled) !== void 0 ? e.disableNetworkRecording = !t.networkRecording.enabled : e.disableNetworkRecording = !1, e.enableRecordingNetworkContents = ((r = t.networkRecording) == null ? void 0 : r.recordHeadersAndBody) || !1, e.disableRecordingWebSocketContents = ((l = t.networkRecording) == null ? void 0 : l.disableWebSocketEventRecordings) || !1, e.networkHeadersToRedact = ((c = (d = t.networkRecording) == null ? void 0 : d.networkHeadersToRedact) == null ? void 0 : c.map(
192
+ (S) => S.toLowerCase()
193
+ )) || [], e.networkBodyKeysToRedact = ((h = (g = t.networkRecording) == null ? void 0 : g.networkBodyKeysToRedact) == null ? void 0 : h.map(
194
+ (S) => S.toLowerCase()
195
+ )) || [], e.urlBlocklist = ((m = (f = t.networkRecording) == null ? void 0 : f.urlBlocklist) == null ? void 0 : m.map(
196
+ (S) => S.toLowerCase()
197
+ )) || [], e.urlBlocklist = [
198
+ ...e.urlBlocklist,
199
+ ...Nt
200
+ ], e.requestResponseSanitizer = (R = t.networkRecording) == null ? void 0 : R.requestResponseSanitizer, e.networkHeaderKeysToRecord = (v = t.networkRecording) == null ? void 0 : v.headerKeysToRecord, e.networkHeaderKeysToRecord && (e.networkHeadersToRedact = [], e.networkHeaderKeysToRecord = e.networkHeaderKeysToRecord.map(
201
+ (S) => S.toLocaleLowerCase()
202
+ )), e.networkBodyKeysToRecord = (C = t.networkRecording) == null ? void 0 : C.bodyKeysToRecord, e.networkBodyKeysToRecord && (e.networkBodyKeysToRedact = [], e.networkBodyKeysToRecord = e.networkBodyKeysToRecord.map(
203
+ (S) => S.toLocaleLowerCase()
204
+ ))), !e.disableNetworkRecording && e.enableRecordingNetworkContents && (e.hasNetworkRecording = !0, e.listeners.push(
205
+ Kt({
206
+ xhrCallback: (S) => {
207
+ e.xhrNetworkContents.push(S);
208
+ },
209
+ fetchCallback: (S) => {
210
+ e.fetchNetworkContents.push(S);
211
+ },
212
+ webSocketRequestCallback: (S) => {
213
+ e.webSocketNetworkContents && e.webSocketNetworkContents.push(S);
214
+ },
215
+ webSocketEventCallback: (S) => {
216
+ e.webSocketEventContents.push(S);
217
+ },
218
+ disableWebSocketRecording: e.disableRecordingWebSocketContents,
219
+ bodyKeysToRedact: e.networkBodyKeysToRedact,
220
+ highlightEndpoints: e.highlightEndpoints,
221
+ tracingOrigins: e.tracingOrigins,
222
+ urlBlocklist: e.urlBlocklist,
223
+ bodyKeysToRecord: e.networkBodyKeysToRecord
224
+ })
225
+ ));
226
+ }
227
+ static getRecordedNetworkResources(e, t) {
228
+ var o, r;
229
+ let s = [], n = [];
230
+ if (!e.disableNetworkRecording) {
231
+ const l = ((o = window == null ? void 0 : window.performance) == null ? void 0 : o.timeOrigin) || 0;
232
+ s = performance.getEntriesByType(
233
+ "resource"
234
+ );
235
+ const d = (t - l) * 2;
236
+ if (s = s.filter((c) => c.responseEnd < e.lastNetworkRequestTimestamp ? !1 : Ot(
237
+ c.name,
238
+ e.highlightEndpoints
239
+ )).map((c) => y(w({}, c.toJSON()), {
240
+ offsetStartTime: c.startTime - d,
241
+ offsetResponseEnd: c.responseEnd - d,
242
+ offsetFetchStart: c.fetchStart - d
243
+ })), e.lastNetworkRequestTimestamp = ((r = s.at(-1)) == null ? void 0 : r.responseEnd) || e.lastNetworkRequestTimestamp, e.enableRecordingNetworkContents) {
244
+ const c = {
245
+ headersToRedact: e.networkHeadersToRedact,
246
+ headersToRecord: e.networkHeaderKeysToRecord,
247
+ requestResponseSanitizer: e.requestResponseSanitizer
248
+ };
249
+ s = Le(
250
+ s,
251
+ e.xhrNetworkContents,
252
+ "xmlhttprequest",
253
+ c
254
+ ), s = Le(
255
+ s,
256
+ e.fetchNetworkContents,
257
+ "fetch",
258
+ c
259
+ );
260
+ }
261
+ }
262
+ return e.disableRecordingWebSocketContents || (n = e.webSocketNetworkContents || []), [...s, ...n];
263
+ }
264
+ static getRecordedWebSocketEvents(e) {
265
+ let t = [];
266
+ return !e.disableNetworkRecording && !e.disableRecordingWebSocketContents && (t = e.webSocketEventContents), t;
267
+ }
268
+ static clearRecordedNetworkResources(e) {
269
+ e.disableNetworkRecording || (e.xhrNetworkContents = [], e.fetchNetworkContents = [], e.webSocketNetworkContents = [], e.webSocketEventContents = [], performance.clearResourceTimings());
270
+ }
271
+ }
272
+ const W = (i, e) => {
273
+ console.warn(`Highlight Warning: (${i}): `, { output: e });
274
+ };
275
+ var F;
276
+ const te = class te {
277
+ constructor(e, t) {
278
+ a(this, "options");
279
+ /** Determines if the client is running on a Highlight property (e.g. frontend). */
280
+ a(this, "isRunningOnHighlight");
281
+ /** Verbose project ID that is exposed to users. Legacy users may still be using ints. */
282
+ a(this, "organizationID");
283
+ // ECMAScript-private (#) so the internal GraphQL SDK type — which
284
+ // references graphql-request / graphql — does not leak into the published
285
+ // declaration file and break consumer type-checking.
286
+ ye(this, F);
287
+ a(this, "events");
288
+ a(this, "sessionData");
289
+ a(this, "ready");
290
+ a(this, "manualStopped");
291
+ a(this, "state");
292
+ a(this, "logger");
293
+ a(this, "enableSegmentIntegration");
294
+ a(this, "privacySetting");
295
+ a(this, "enableCanvasRecording");
296
+ a(this, "enablePerformanceRecording");
297
+ a(this, "samplingStrategy");
298
+ a(this, "inlineImages");
299
+ a(this, "inlineVideos");
300
+ a(this, "inlineStylesheet");
301
+ a(this, "styleSheetResyncInterval");
302
+ a(this, "debugOptions");
303
+ a(this, "listeners");
304
+ a(this, "firstloadVersion");
305
+ a(this, "environment");
306
+ a(this, "sessionShortcut");
307
+ /** The end-user's app version. This isn't Highlight's version. */
308
+ a(this, "appVersion");
309
+ a(this, "serviceName");
310
+ a(this, "_worker");
311
+ a(this, "_optionsInternal");
312
+ a(this, "_backendUrl");
313
+ a(this, "_recordingStartTime");
314
+ a(this, "_isOnLocalHost");
315
+ a(this, "_onToggleFeedbackFormVisibility");
316
+ a(this, "_firstLoadListeners");
317
+ a(this, "_isCrossOriginIframe");
318
+ a(this, "_eventBytesSinceSnapshot");
319
+ a(this, "_lastSnapshotTime");
320
+ a(this, "_lastVisibilityChangeTime");
321
+ a(this, "pushPayloadTimerId");
322
+ a(this, "hasSessionUnloaded");
323
+ a(this, "hasPushedData");
324
+ a(this, "reloaded");
325
+ a(this, "_hasPreviouslyInitialized");
326
+ a(this, "_recordStop");
327
+ a(this, "_gauges", /* @__PURE__ */ new Map());
328
+ a(this, "_counters", /* @__PURE__ */ new Map());
329
+ a(this, "_histograms", /* @__PURE__ */ new Map());
330
+ a(this, "_up_down_counters", /* @__PURE__ */ new Map());
331
+ a(this, "_integrations", []);
332
+ var n, o, r, l, d;
333
+ e.sessionSecureID || (e.sessionSecureID = O()), this.options = e, typeof ((n = this.options) == null ? void 0 : n.debug) == "boolean" ? this.debugOptions = this.options.debug ? { clientInteractions: !0 } : {} : this.debugOptions = (r = (o = this.options) == null ? void 0 : o.debug) != null ? r : {}, this.logger = new At(this.debugOptions.clientInteractions), e.storageMode && (this.logger.log(
334
+ `initializing in ${e.storageMode} session mode`
335
+ ), pt(e.storageMode)), We(!!(e != null && e.sessionCookie)), this._worker = new Je(), this._worker.onmessage = (c) => {
336
+ var g, h, f;
337
+ ((g = c.data.response) == null ? void 0 : g.type) === L.AsyncEvents ? (this._eventBytesSinceSnapshot += c.data.response.eventsSize, this.logger.log(
338
+ `Web worker sent payloadID ${c.data.response.id} size ${c.data.response.eventsSize} bytes, compression ratio ${c.data.response.eventsSize / c.data.response.compressedSize}.
339
+ Total since snapshot: ${(this._eventBytesSinceSnapshot / 1e6).toFixed(1)}MB`
340
+ )) : ((h = c.data.response) == null ? void 0 : h.type) === L.CustomEvent ? this.addCustomEvent(
341
+ c.data.response.tag,
342
+ c.data.response.payload
343
+ ) : ((f = c.data.response) == null ? void 0 : f.type) === L.Stop && (W(
344
+ "Stopping recording due to worker failure",
345
+ c.data.response
346
+ ), this.stopRecording(!1));
347
+ };
348
+ let s = M();
349
+ if (this.reloaded = !1, !((l = this.sessionData) != null && l.sessionSecureID) && (s != null && s.sessionSecureID))
350
+ this.sessionData = s, this.options.sessionSecureID = s.sessionSecureID, this.reloaded = !0, this.logger.log(
351
+ `Tab reloaded, continuing previous session: ${this.sessionData.sessionSecureID}`
352
+ );
353
+ else {
354
+ for (const c of Object.values(E))
355
+ Re(c);
356
+ this.sessionData = {
357
+ sessionSecureID: this.options.sessionSecureID,
358
+ projectID: 0,
359
+ sessionStartTime: Date.now()
360
+ };
361
+ }
362
+ this._hasPreviouslyInitialized = !1, this._firstLoadListeners = t || new I(this.options);
363
+ try {
364
+ window.parent.document && (this._isCrossOriginIframe = !1);
365
+ } catch (c) {
366
+ this._isCrossOriginIframe = (d = this.options.recordCrossOriginIframe) != null ? d : !0;
367
+ }
368
+ this._initMembers(this.options);
369
+ }
370
+ static create(e) {
371
+ return new te(e);
372
+ }
373
+ // Start a new session
374
+ _reset(s) {
375
+ return _(this, arguments, function* ({
376
+ forceNew: e,
377
+ sessionKey: t
378
+ }) {
379
+ this.pushPayloadTimerId && (clearTimeout(this.pushPayloadTimerId), this.pushPayloadTimerId = void 0);
380
+ let n, o;
381
+ if (!e)
382
+ try {
383
+ n = J(E.USER_IDENTIFIER);
384
+ const r = J(
385
+ E.USER_OBJECT
386
+ );
387
+ r && (o = JSON.parse(r));
388
+ } catch (r) {
389
+ }
390
+ for (const r of Object.values(E))
391
+ Re(r);
392
+ this.sessionData.sessionSecureID = t ? O(`${this.organizationID}-${t}`) : O(), this.sessionData.sessionKey = t, this.sessionData.sessionStartTime = Date.now(), this.options.sessionSecureID = this.sessionData.sessionSecureID, this.stopRecording(), this._firstLoadListeners.stopListening(), this._firstLoadListeners = new I(this.options), yield this.initialize(), n && o && this.identify(n, o);
393
+ });
394
+ }
395
+ _initMembers(e) {
396
+ var o, r, l, d, c, g, h, f, m, R, v;
397
+ this.sessionShortcut = !1, this._recordingStartTime = 0, this._isOnLocalHost = window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" || window.location.hostname === "", this.ready = !1, this.state = "NotRecording", this.manualStopped = !1, this.enableSegmentIntegration = !!e.enableSegmentIntegration, this.privacySetting = (o = e.privacySetting) != null ? o : "default", this.enableCanvasRecording = (r = e.enableCanvasRecording) != null ? r : !1, this.enablePerformanceRecording = (l = e.enablePerformanceRecording) != null ? l : !0, this.inlineImages = (d = e.inlineImages) != null ? d : this._isOnLocalHost, this.inlineVideos = (c = e.inlineVideos) != null ? c : this._isOnLocalHost, this.inlineStylesheet = (g = e.inlineStylesheet) != null ? g : this._isOnLocalHost, this.styleSheetResyncInterval = (h = e.styleSheetResyncInterval) != null ? h : 2e3, this.samplingStrategy = w({
398
+ canvasFactor: 0.5,
399
+ canvasMaxSnapshotDimension: 360,
400
+ canvasClearWebGLBuffer: !0,
401
+ dataUrlOptions: ct()
402
+ }, (f = e.samplingStrategy) != null ? f : {
403
+ canvas: 2
404
+ }), this._backendUrl = (m = e == null ? void 0 : e.backendUrl) != null ? m : "https://pub.highlight.io", this._backendUrl[0] === "/" && (this._backendUrl = new URL(this._backendUrl, document.baseURI).href);
405
+ const t = new St(`${this._backendUrl}`, {
406
+ headers: {}
407
+ });
408
+ be(this, F, lt(t, wt())), this.environment = (R = e.environment) != null ? R : "production", this.appVersion = e.appVersion, this.serviceName = (v = e.serviceName) != null ? v : "", typeof e.organizationID == "string" ? this.organizationID = e.organizationID : this.organizationID = e.organizationID.toString(), this.isRunningOnHighlight = this.organizationID === "1" || this.organizationID === "1jdkoe52", this.firstloadVersion = e.firstloadVersion || "unknown", this.sessionShortcut = e.sessionShortcut || !1, this._onToggleFeedbackFormVisibility = () => {
409
+ };
410
+ const C = e, { firstloadVersion: s } = C, n = G(C, ["firstloadVersion"]);
411
+ this._optionsInternal = n, this.listeners = [], this.events = [], this.hasSessionUnloaded = !1, this.hasPushedData = !1, window.Intercom && window.Intercom("onShow", () => {
412
+ window.Intercom("update", {
413
+ highlightSessionURL: this.getCurrentSessionURLWithTimestamp()
414
+ }), this.addProperties({ event: "Intercom onShow" });
415
+ }), this._eventBytesSinceSnapshot = 0, this._lastSnapshotTime = (/* @__PURE__ */ new Date()).getTime(), this._lastVisibilityChangeTime = (/* @__PURE__ */ new Date()).getTime();
416
+ }
417
+ identify(e, t = {}, s) {
418
+ if (!e || e === "") {
419
+ console.warn(
420
+ "Highlight's identify() call was passed an empty identifier.",
421
+ { user_identifier: e, user_object: t }
422
+ );
423
+ return;
424
+ }
425
+ this.sessionData.userIdentifier = e.toString(), this.sessionData.userObject = t, Q(
426
+ E.USER_IDENTIFIER,
427
+ e.toString()
428
+ ), Q(E.USER_OBJECT, JSON.stringify(t)), this._worker.postMessage({
429
+ message: {
430
+ type: L.Identify,
431
+ userIdentifier: e,
432
+ userObject: t,
433
+ source: s
434
+ }
435
+ });
436
+ for (const n of this._integrations)
437
+ n.identify(
438
+ this.sessionData.sessionSecureID,
439
+ e,
440
+ t,
441
+ s
442
+ );
443
+ }
444
+ log(e, t, s) {
445
+ this._firstLoadListeners.messages.push(
446
+ Tt(t, Be, e, s)
447
+ );
448
+ }
449
+ pushCustomError(e, t) {
450
+ return this.consumeCustomError(new Error(e), void 0, t);
451
+ }
452
+ consumeCustomError(e, t, s) {
453
+ let n = {};
454
+ if (s)
455
+ try {
456
+ n = w(w({}, JSON.parse(s)), n);
457
+ } catch (o) {
458
+ }
459
+ return this.consumeError(e, {
460
+ message: t,
461
+ payload: n
462
+ });
463
+ }
464
+ consumeError(e, {
465
+ message: t,
466
+ payload: s,
467
+ source: n,
468
+ type: o
469
+ }) {
470
+ var c, g, h, f;
471
+ e.cause && (s = y(w({}, s), { "exception.cause": e.cause }));
472
+ let r = t ? t + ":" + e.message : e.message;
473
+ o === "React.ErrorBoundary" && (r = "ErrorBoundary: " + r);
474
+ const l = Pt(e), d = {
475
+ event: r,
476
+ type: o != null ? o : "custom",
477
+ url: window.location.href,
478
+ source: n != null ? n : "",
479
+ lineNumber: (c = l[0]) != null && c.lineNumber ? (g = l[0]) == null ? void 0 : g.lineNumber : 0,
480
+ columnNumber: (h = l[0]) != null && h.columnNumber ? (f = l[0]) == null ? void 0 : f.columnNumber : 0,
481
+ stackTrace: l,
482
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
483
+ payload: JSON.stringify(s),
484
+ id: Me()
485
+ };
486
+ this._firstLoadListeners.errors.push(d);
487
+ for (const m of this._integrations)
488
+ m.error(this.sessionData.sessionSecureID, d);
489
+ }
490
+ addProperties(e = {}, t) {
491
+ const s = w({}, e);
492
+ Object.entries(s).forEach(([n, o]) => {
493
+ try {
494
+ structuredClone(o);
495
+ } catch (r) {
496
+ delete s[n];
497
+ }
498
+ }), this._worker.postMessage({
499
+ message: {
500
+ type: L.Properties,
501
+ propertiesObject: s,
502
+ propertyType: t
503
+ }
504
+ });
505
+ for (const n of this._integrations)
506
+ n.track(this.sessionData.sessionSecureID, w({
507
+ sessionSecureID: this.sessionData.sessionSecureID,
508
+ propertyType: t
509
+ }, e));
510
+ }
511
+ initialize(e) {
512
+ return _(this, null, function* () {
513
+ var t, s, n, o, r, l, d, c, g, h, f, m, R, v, C, S, se, ie, ne, re, oe, ae, ce, le, de;
514
+ if (navigator != null && navigator.webdriver && !window.Cypress || (t = navigator == null ? void 0 : navigator.userAgent) != null && t.includes("Googlebot") || (s = navigator == null ? void 0 : navigator.userAgent) != null && s.includes("AdsBot")) {
515
+ (n = this._firstLoadListeners) == null || n.stopListening();
516
+ return;
517
+ }
518
+ try {
519
+ if (e != null && e.forceNew) {
520
+ yield this._reset(e);
521
+ return;
522
+ }
523
+ if (e != null && e.sessionKey && (e == null ? void 0 : e.sessionKey) !== this.sessionData.sessionKey) {
524
+ yield this._reset(y(w({}, e), { forceNew: !0 }));
525
+ return;
526
+ }
527
+ const T = new Ut();
528
+ Ht(
529
+ {
530
+ backendUrl: (r = (o = this.options) == null ? void 0 : o.backendUrl) != null ? r : "https://pub.highlight.io",
531
+ otlpEndpoint: (d = (l = this.options) == null ? void 0 : l.otlpEndpoint) != null ? d : "https://otel.highlight.io",
532
+ projectId: (c = this.options) == null ? void 0 : c.organizationID,
533
+ sessionSecureId: (g = this.options) == null ? void 0 : g.sessionSecureID,
534
+ environment: (f = (h = this.options) == null ? void 0 : h.environment) != null ? f : "production",
535
+ networkRecordingOptions: typeof ((m = this.options) == null ? void 0 : m.networkRecording) == "object" ? this.options.networkRecording : void 0,
536
+ tracingOrigins: (R = this.options) == null ? void 0 : R.tracingOrigins,
537
+ serviceName: (C = (v = this.options) == null ? void 0 : v.serviceName) != null ? C : "highlight-browser",
538
+ instrumentations: (se = (S = this.options) == null ? void 0 : S.otel) == null ? void 0 : se.instrumentations,
539
+ getIntegrations: () => [...this._integrations],
540
+ productAnalyticsEvents: this._productAnalyticsEvents()
541
+ },
542
+ T
543
+ ), this._gauges.clear(), this._counters.clear(), this._histograms.clear(), this._up_down_counters.clear(), this.logger.log(
544
+ "Initializing...",
545
+ e,
546
+ this.sessionData,
547
+ this.options
548
+ ), this.sessionData = (ie = M(this.sessionData.sessionSecureID)) != null ? ie : this.sessionData, (ne = this.sessionData) != null && ne.sessionStartTime ? this._recordingStartTime = (re = this.sessionData) == null ? void 0 : re.sessionStartTime : (this._recordingStartTime = (/* @__PURE__ */ new Date()).getTime(), this.sessionData.sessionStartTime = this._recordingStartTime), Y(""), U(this.sessionData);
549
+ let P = J(Ce.CLIENT_ID);
550
+ P || (P = O(), Q(Ce.CLIENT_ID, P));
551
+ let H;
552
+ this.options.disableSessionRecording || this.options.disableNetworkRecording !== void 0 || typeof this.options.networkRecording == "boolean" ? H = !1 : H = ((oe = this.options.networkRecording) == null ? void 0 : oe.recordHeadersAndBody) || !1;
553
+ let he = [];
554
+ if (typeof this.options.networkRecording == "object" && ((ae = this.options.networkRecording.destinationDomains) != null && ae.length) && (he = this.options.networkRecording.destinationDomains), this._isCrossOriginIframe)
555
+ yield this._setupCrossOriginIframe();
556
+ else {
557
+ const k = yield Se(this, F).initializeSession({
558
+ organization_verbose_id: this.organizationID,
559
+ enable_strict_privacy: this.privacySetting === "strict",
560
+ privacy_setting: this.privacySetting,
561
+ enable_recording_network_contents: H,
562
+ clientVersion: this.firstloadVersion,
563
+ firstloadVersion: this.firstloadVersion,
564
+ clientConfig: JSON.stringify(this._optionsInternal),
565
+ environment: this.environment,
566
+ id: P,
567
+ appVersion: this.appVersion,
568
+ serviceName: this.serviceName,
569
+ session_secure_id: this.sessionData.sessionSecureID,
570
+ session_key: this.sessionData.sessionKey,
571
+ client_id: P,
572
+ network_recording_domains: he,
573
+ disable_session_recording: this.options.disableSessionRecording
574
+ });
575
+ if (k.initializeSession.secure_id !== this.sessionData.sessionSecureID && this.logger.log(
576
+ `Unexpected secure id returned by initializeSession: ${k.initializeSession.secure_id}, expected ${this.sessionData.sessionSecureID}`
577
+ ), this.sessionData.sessionSecureID = k.initializeSession.secure_id, this.sessionData.projectID = parseInt(
578
+ ((ce = k == null ? void 0 : k.initializeSession) == null ? void 0 : ce.project_id) || "0"
579
+ ), T.setConfig(k.initializeSession.sampling), !this.sessionData.projectID || !this.sessionData.sessionSecureID) {
580
+ console.error(
581
+ "Failed to initialize Highlight; an error occurred on our end.",
582
+ this.sessionData
583
+ );
584
+ return;
585
+ }
586
+ }
587
+ this.logger.log(
588
+ `Loaded Highlight
589
+ Remote: ${this._backendUrl}
590
+ Project ID: ${this.sessionData.projectID}
591
+ SessionSecureID: ${this.sessionData.sessionSecureID}`
592
+ ), this.options.sessionSecureID = this.sessionData.sessionSecureID, this._worker.postMessage({
593
+ message: {
594
+ type: L.Initialize,
595
+ sessionSecureID: this.sessionData.sessionSecureID,
596
+ backend: this._backendUrl,
597
+ debug: !!this.debugOptions.clientInteractions,
598
+ recordingStartTime: this._recordingStartTime
599
+ }
600
+ });
601
+ for (const k of this._integrations)
602
+ k.init(this.sessionData.sessionSecureID);
603
+ if (this.sessionData.userIdentifier && this.identify(
604
+ this.sessionData.userIdentifier,
605
+ this.sessionData.userObject
606
+ ), this._firstLoadListeners.isListening() ? this._firstLoadListeners.hasNetworkRecording || I.setupNetworkListener(
607
+ this._firstLoadListeners,
608
+ this.options
609
+ ) : this._firstLoadListeners.startListening(), this.pushPayloadTimerId && (clearTimeout(this.pushPayloadTimerId), this.pushPayloadTimerId = void 0), this._isCrossOriginIframe || (this.pushPayloadTimerId = setTimeout(() => {
610
+ this._save();
611
+ }, De)), this.options.disableSessionRecording) {
612
+ this.logger.log(
613
+ "Highlight is NOT RECORDING a session replay per H.init setting."
614
+ ), this.ready = !0, this.state = "Recording", this.manualStopped = !1;
615
+ return;
616
+ }
617
+ const { getDeviceDetails: ge } = Ft();
618
+ ge && this.recordGauge({
619
+ name: N.DeviceMemory,
620
+ value: ge().deviceMemory,
621
+ category: D.Device,
622
+ group: window.location.href
623
+ });
624
+ const ue = (k, Ke) => {
625
+ Ke && this.logger.log("received isCheckout emit", { event: k }), this.events.push(k);
626
+ };
627
+ ue.bind(this);
628
+ const Ve = !!this._recordStop;
629
+ this._recordStop && (this._recordStop(), this._recordStop = void 0);
630
+ const [Ae, xe] = rt(
631
+ this.privacySetting,
632
+ this.options.maskAllInputs,
633
+ this.options.maskInputOptions
634
+ );
635
+ this._recordStop = j({
636
+ ignoreClass: (le = this.options.ignoreClass) != null ? le : "highlight-ignore",
637
+ ignoreSelector: this.options.ignoreSelector,
638
+ blockClass: (de = this.options.blockClass) != null ? de : "highlight-block",
639
+ blockSelector: this.options.blockSelector,
640
+ emit: ue,
641
+ recordCrossOriginIframes: this.options.recordCrossOriginIframe,
642
+ privacySetting: this.privacySetting,
643
+ maskAllInputs: Ae,
644
+ maskInputOptions: xe,
645
+ maskTextClass: this.options.maskTextClass,
646
+ maskTextSelector: this.options.maskTextSelector,
647
+ recordCanvas: this.enableCanvasRecording,
648
+ sampling: {
649
+ canvas: {
650
+ fps: this.samplingStrategy.canvas,
651
+ fpsManual: this.samplingStrategy.canvasManualSnapshot,
652
+ resizeFactor: this.samplingStrategy.canvasFactor,
653
+ clearWebGLBuffer: this.samplingStrategy.canvasClearWebGLBuffer,
654
+ initialSnapshotDelay: this.samplingStrategy.canvasInitialSnapshotDelay,
655
+ dataURLOptions: this.samplingStrategy.dataUrlOptions,
656
+ maxSnapshotDimension: this.samplingStrategy.canvasMaxSnapshotDimension
657
+ }
658
+ },
659
+ keepIframeSrcFn: (k) => !this.options.recordCrossOriginIframe,
660
+ inlineImages: this.inlineImages,
661
+ inlineVideos: this.inlineVideos,
662
+ collectFonts: this.inlineImages,
663
+ inlineStylesheet: this.inlineStylesheet,
664
+ styleSheetResyncInterval: this.styleSheetResyncInterval,
665
+ plugins: [nt()],
666
+ logger: typeof this.options.debug == "boolean" && this.options.debug || typeof this.options.debug == "object" && this.options.debug.domRecording ? {
667
+ debug: this.logger.log,
668
+ warn: W
669
+ } : void 0
670
+ }), Ve || this.options.recordCrossOriginIframe && this._setupCrossOriginIframeParent(), document.referrer && (window && document.referrer.includes(window.location.origin) || (this.addCustomEvent("Referrer", document.referrer), this.addProperties(
671
+ { referrer: document.referrer },
672
+ { type: "session" }
673
+ ))), this.sessionData.sessionKey && this.addProperties(
674
+ {
675
+ sessionKey: this.sessionData.sessionKey
676
+ },
677
+ { type: "session" }
678
+ ), this._setupWindowListeners(), this.ready = !0, this.state = "Recording", this.manualStopped = !1;
679
+ } catch (T) {
680
+ this._isOnLocalHost && (console.error(T), W("initializeSession", T));
681
+ }
682
+ });
683
+ }
684
+ _productAnalyticsEvents() {
685
+ var s;
686
+ const e = (s = this.options) == null ? void 0 : s.productAnalytics;
687
+ if (e === !1)
688
+ return {};
689
+ const t = {
690
+ clicks: !0,
691
+ pageViews: !0,
692
+ trackEvents: !0
693
+ };
694
+ if (e === void 0 || e === !0)
695
+ return t;
696
+ for (const n of Object.keys(e))
697
+ e[n] === !1 && (t[n] = !1);
698
+ return t;
699
+ }
700
+ _visibilityHandler(e) {
701
+ return _(this, null, function* () {
702
+ if (this.manualStopped) {
703
+ this.logger.log("Ignoring visibility event due to manual stop.");
704
+ return;
705
+ }
706
+ (/* @__PURE__ */ new Date()).getTime() - this._lastVisibilityChangeTime < dt || (this._lastVisibilityChangeTime = (/* @__PURE__ */ new Date()).getTime(), this.logger.log(`Detected window ${e ? "hidden" : "visible"}.`), e ? (this.addCustomEvent("TabHidden", !0), this.options.disableBackgroundRecording && this.stopRecording()) : (this.options.disableBackgroundRecording && (yield this.initialize()), this.addCustomEvent("TabHidden", !1)));
707
+ });
708
+ }
709
+ _setupCrossOriginIframe() {
710
+ return _(this, null, function* () {
711
+ this.logger.log("highlight in cross-origin iframe is waiting "), yield new Promise((e) => {
712
+ const t = (s) => {
713
+ if (s.data.highlight === ve) {
714
+ const n = s.data;
715
+ this.logger.log("highlight got window message ", n), this.sessionData.projectID = n.projectID, this.sessionData.sessionSecureID = n.sessionSecureID, window.parent.postMessage(
716
+ {
717
+ highlight: ke
718
+ },
719
+ "*"
720
+ ), window.removeEventListener("message", t), e();
721
+ }
722
+ };
723
+ window.addEventListener("message", t);
724
+ });
725
+ });
726
+ }
727
+ _setupCrossOriginIframeParent() {
728
+ this.logger.log(
729
+ "highlight setting up cross origin iframe parent notification"
730
+ ), setInterval(() => {
731
+ window.document.querySelectorAll("iframe").forEach((e) => {
732
+ var t;
733
+ (t = e.contentWindow) == null || t.postMessage(
734
+ {
735
+ highlight: ve,
736
+ projectID: this.sessionData.projectID,
737
+ sessionSecureID: this.sessionData.sessionSecureID
738
+ },
739
+ "*"
740
+ );
741
+ });
742
+ }, De), window.addEventListener("message", (e) => {
743
+ e.data.highlight === ke && this.logger.log(
744
+ "highlight got response from initialized iframe"
745
+ );
746
+ });
747
+ }
748
+ _setupWindowListeners() {
749
+ var s;
750
+ try {
751
+ const n = this;
752
+ this.enableSegmentIntegration && this.listeners.push(
753
+ Qe((r) => {
754
+ if (r.type === "track") {
755
+ const l = {};
756
+ l["segment-event"] = r.event, n.addProperties(l, {
757
+ type: "track",
758
+ source: "segment"
759
+ });
760
+ } else if (r.type === "identify") {
761
+ const l = r.userId.replace(
762
+ /^"(.*)"$/,
763
+ "$1"
764
+ );
765
+ n.identify(
766
+ l,
767
+ r.traits,
768
+ "segment"
769
+ );
770
+ }
771
+ })
772
+ ), this.listeners.push(
773
+ ht((r) => {
774
+ this.reloaded ? (this.addCustomEvent("Reload", r), this.reloaded = !1, n.addProperties(
775
+ { reload: !0 },
776
+ { type: "session" }
777
+ )) : this.addCustomEvent("Navigate", r);
778
+ })
779
+ ), this.listeners.push(
780
+ gt(
781
+ (r) => {
782
+ this.addCustomEvent("Viewport", r), this.submitViewportMetrics(r);
783
+ }
784
+ )
785
+ ), this.listeners.push(
786
+ Ye((r, l) => {
787
+ let d = null, c = null;
788
+ if (l && l.target) {
789
+ const g = l.target;
790
+ d = yt(g), c = g.textContent, c && c.length > 2e3 && (c = c.substring(0, 2e3));
791
+ }
792
+ this.addCustomEvent("Click", {
793
+ clickTarget: r,
794
+ clickTextContent: c,
795
+ clickSelector: d
796
+ });
797
+ })
798
+ ), this.listeners.push(
799
+ Xe((r) => {
800
+ r && this.addCustomEvent("Focus", r);
801
+ })
802
+ ), this.listeners.push(
803
+ Wt((r) => {
804
+ const { name: l, value: d } = r, c = [], g = (h, f) => {
805
+ f && c.push({ name: h, value: f });
806
+ };
807
+ switch (r.name) {
808
+ case "LCP": {
809
+ const h = r.attribution;
810
+ g("web_vital.element", h.element), g(
811
+ "web_vital.attribution.url",
812
+ h.url ? $t(h.url) : void 0
813
+ );
814
+ break;
815
+ }
816
+ case "CLS": {
817
+ const h = r.attribution;
818
+ g("web_vital.element", h.largestShiftTarget), g("web_vital.load_state", h.loadState);
819
+ break;
820
+ }
821
+ case "INP": {
822
+ const h = r.attribution;
823
+ g("web_vital.element", h.eventTarget), g("web_vital.event_type", h.eventType), g("web_vital.load_state", h.loadState);
824
+ break;
825
+ }
826
+ case "FID": {
827
+ const h = r.attribution;
828
+ g("web_vital.element", h.eventTarget), g("web_vital.event_type", h.eventType);
829
+ break;
830
+ }
831
+ case "FCP": {
832
+ const h = r.attribution;
833
+ g("web_vital.load_state", h.loadState);
834
+ break;
835
+ }
836
+ }
837
+ this.recordGauge({
838
+ name: l,
839
+ value: d,
840
+ group: window.location.href,
841
+ category: D.WebVital,
842
+ tags: c.length ? c : void 0
843
+ });
844
+ })
845
+ ), this.listeners.push(
846
+ zt(
847
+ (r) => {
848
+ const l = [];
849
+ r.saveData !== void 0 && l.push({
850
+ name: "saveData",
851
+ value: r.saveData.toString()
852
+ }), r.effectiveType !== void 0 && l.push({
853
+ name: "effectiveType",
854
+ value: r.effectiveType.toString()
855
+ }), r.type !== void 0 && l.push({
856
+ name: "type",
857
+ value: r.type.toString()
858
+ }), Object.entries(r).forEach(([d, c]) => {
859
+ bt(c) && this.recordGauge({
860
+ name: d,
861
+ value: c,
862
+ category: D.Performance,
863
+ group: window.location.href,
864
+ tags: l
865
+ });
866
+ });
867
+ },
868
+ this._recordingStartTime
869
+ )
870
+ ), this.sessionShortcut && this.listeners.push(
871
+ Ze(this.sessionShortcut, () => {
872
+ window.open(
873
+ this.getCurrentSessionURLWithTimestamp(),
874
+ "_blank"
875
+ );
876
+ })
877
+ ), this.enablePerformanceRecording && (this.listeners.push(
878
+ Bt((r) => {
879
+ this.addCustomEvent("Performance", x(r)), Object.entries(r).filter(([l]) => l !== "relativeTimestamp").forEach(
880
+ ([l, d]) => d && this.recordGauge({
881
+ name: l,
882
+ value: d,
883
+ category: D.Performance,
884
+ group: window.location.href
885
+ })
886
+ );
887
+ }, this._recordingStartTime)
888
+ ), this.listeners.push(
889
+ Mt((r) => {
890
+ this.addCustomEvent("Jank", x(r)), this.recordGauge({
891
+ name: "Jank",
892
+ value: r.jankAmount,
893
+ category: D.WebVital,
894
+ group: r.querySelector
895
+ });
896
+ }, this._recordingStartTime)
897
+ )), this._hasPreviouslyInitialized || ((s = window.electron) != null && s.ipcRenderer ? (window.electron.ipcRenderer.on(
898
+ "highlight.run",
899
+ ({ visible: r }) => {
900
+ this._visibilityHandler(!r);
901
+ }
902
+ ), this.logger.log("Set up Electron highlight.run events.")) : (et(
903
+ (r) => this._visibilityHandler(r)
904
+ ), this.logger.log("Set up document visibility listener.")), this._hasPreviouslyInitialized = !0);
905
+ const o = () => {
906
+ this.hasSessionUnloaded = !0, this.pushPayloadTimerId && (clearTimeout(this.pushPayloadTimerId), this.pushPayloadTimerId = void 0);
907
+ };
908
+ window.addEventListener("beforeunload", o), this.listeners.push(
909
+ () => window.removeEventListener("beforeunload", o)
910
+ );
911
+ } catch (n) {
912
+ this._isOnLocalHost && (console.error(n), W("initializeSession _setupWindowListeners", n));
913
+ }
914
+ const e = () => {
915
+ this.addCustomEvent("Page Unload", ""), Y(this.sessionData.sessionSecureID), U(this.sessionData);
916
+ };
917
+ if (window.addEventListener("beforeunload", e), this.listeners.push(
918
+ () => window.removeEventListener("beforeunload", e)
919
+ ), navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPhone/i)) {
920
+ const n = () => {
921
+ this.addCustomEvent("Page Unload", ""), Y(this.sessionData.sessionSecureID), U(this.sessionData);
922
+ };
923
+ window.addEventListener("pagehide", n), this.listeners.push(
924
+ () => window.removeEventListener("pagehide", n)
925
+ );
926
+ }
927
+ }
928
+ submitViewportMetrics({
929
+ height: e,
930
+ width: t,
931
+ availHeight: s,
932
+ availWidth: n
933
+ }) {
934
+ this.recordGauge({
935
+ name: N.ViewportHeight,
936
+ value: e,
937
+ category: D.Device,
938
+ group: window.location.href
939
+ }), this.recordGauge({
940
+ name: N.ViewportWidth,
941
+ value: t,
942
+ category: D.Device,
943
+ group: window.location.href
944
+ }), this.recordGauge({
945
+ name: N.ScreenHeight,
946
+ value: s,
947
+ category: D.Device,
948
+ group: window.location.href
949
+ }), this.recordGauge({
950
+ name: N.ScreenWidth,
951
+ value: n,
952
+ category: D.Device,
953
+ group: window.location.href
954
+ }), this.recordGauge({
955
+ name: N.ViewportArea,
956
+ value: e * t,
957
+ category: D.Device,
958
+ group: window.location.href
959
+ });
960
+ }
961
+ recordGauge(e) {
962
+ var s, n;
963
+ let t = this._gauges.get(e.name);
964
+ if (!t) {
965
+ if (t = (s = V()) == null ? void 0 : s.createGauge(
966
+ e.name,
967
+ A(e.name, e.unit)
968
+ ), !t) return;
969
+ this._gauges.set(e.name, t);
970
+ }
971
+ t.record(e.value, y(w({}, (n = e.tags) == null ? void 0 : n.reduce((o, r) => y(w({}, o), { [r.name]: r.value }), {})), {
972
+ group: e.group,
973
+ category: e.category,
974
+ "highlight.session_id": this.sessionData.sessionSecureID
975
+ }));
976
+ for (const o of this._integrations)
977
+ o.recordGauge(this.sessionData.sessionSecureID, e);
978
+ }
979
+ recordCount(e) {
980
+ var s, n;
981
+ let t = this._counters.get(e.name);
982
+ if (!t) {
983
+ if (t = (s = V()) == null ? void 0 : s.createCounter(
984
+ e.name,
985
+ A(e.name, e.unit)
986
+ ), !t) return;
987
+ this._counters.set(e.name, t);
988
+ }
989
+ t.add(e.value, y(w({}, (n = e.tags) == null ? void 0 : n.reduce((o, r) => y(w({}, o), { [r.name]: r.value }), {})), {
990
+ group: e.group,
991
+ category: e.category,
992
+ "highlight.session_id": this.sessionData.sessionSecureID
993
+ }));
994
+ }
995
+ recordIncr(e) {
996
+ this.recordCount(y(w({}, e), { value: 1 }));
997
+ }
998
+ recordHistogram(e) {
999
+ var s, n;
1000
+ let t = this._histograms.get(e.name);
1001
+ if (!t) {
1002
+ if (t = (s = V()) == null ? void 0 : s.createHistogram(
1003
+ e.name,
1004
+ A(e.name, e.unit)
1005
+ ), !t) return;
1006
+ this._histograms.set(e.name, t);
1007
+ }
1008
+ t.record(e.value, y(w({}, (n = e.tags) == null ? void 0 : n.reduce((o, r) => y(w({}, o), { [r.name]: r.value }), {})), {
1009
+ group: e.group,
1010
+ category: e.category,
1011
+ "highlight.session_id": this.sessionData.sessionSecureID
1012
+ }));
1013
+ }
1014
+ recordUpDownCounter(e) {
1015
+ var s, n;
1016
+ let t = this._up_down_counters.get(e.name);
1017
+ if (!t) {
1018
+ if (t = (s = V()) == null ? void 0 : s.createUpDownCounter(
1019
+ e.name,
1020
+ A(e.name, e.unit)
1021
+ ), !t) return;
1022
+ this._up_down_counters.set(e.name, t);
1023
+ }
1024
+ t.add(e.value, y(w({}, (n = e.tags) == null ? void 0 : n.reduce((o, r) => y(w({}, o), { [r.name]: r.value }), {})), {
1025
+ group: e.group,
1026
+ category: e.category,
1027
+ "highlight.session_id": this.sessionData.sessionSecureID
1028
+ }));
1029
+ }
1030
+ /**
1031
+ * Stops Highlight from recording.
1032
+ * @param manual The end user requested to stop recording.
1033
+ */
1034
+ stopRecording(e) {
1035
+ this.manualStopped = !!e, this.manualStopped && this.addCustomEvent(
1036
+ "Stop",
1037
+ "H.stop() was called which stops Highlight from recording."
1038
+ ), this.state = "NotRecording", e && this._recordStop && (this._recordStop(), this._recordStop = void 0), this.listeners.forEach((t) => t()), this.listeners = [], ze();
1039
+ }
1040
+ getCurrentSessionTimestamp() {
1041
+ return this._recordingStartTime;
1042
+ }
1043
+ /**
1044
+ * Returns the current timestamp for the current session.
1045
+ */
1046
+ getCurrentSessionURLWithTimestamp() {
1047
+ const e = (/* @__PURE__ */ new Date()).getTime(), { projectID: t, sessionSecureID: s } = this.sessionData, n = (e - this._recordingStartTime) / 1e3;
1048
+ return `https://${X}/${t}/sessions/${s}?ts=${n}`;
1049
+ }
1050
+ getCurrentSessionURL() {
1051
+ const e = this.sessionData.projectID, t = this.sessionData.sessionSecureID;
1052
+ return e && t ? `https://${X}/${e}/sessions/${t}` : null;
1053
+ }
1054
+ snapshot(e) {
1055
+ return _(this, null, function* () {
1056
+ yield j.snapshotCanvas(e);
1057
+ });
1058
+ }
1059
+ addSessionFeedback({
1060
+ timestamp: e,
1061
+ verbatim: t,
1062
+ user_email: s,
1063
+ user_name: n
1064
+ }) {
1065
+ var o;
1066
+ this._worker.postMessage({
1067
+ message: {
1068
+ type: L.Feedback,
1069
+ verbatim: t,
1070
+ timestamp: e,
1071
+ userName: n || this.sessionData.userIdentifier,
1072
+ userEmail: s || ((o = this.sessionData.userObject) == null ? void 0 : o.name)
1073
+ }
1074
+ });
1075
+ }
1076
+ // Reset the events array and push to a backend.
1077
+ _save() {
1078
+ return _(this, null, function* () {
1079
+ var e;
1080
+ try {
1081
+ this.state === "Recording" && this.listeners && !this.sessionData.sessionKey && this.sessionData.sessionStartTime && Date.now() - this.sessionData.sessionStartTime > ut && (this.logger.log("Resetting session", {
1082
+ start: this.sessionData.sessionStartTime
1083
+ }), yield this._reset({}));
1084
+ let t;
1085
+ ((e = this.options) == null ? void 0 : e.sendMode) === "local" && (t = (s) => _(this, null, function* () {
1086
+ let n = new Blob(
1087
+ [
1088
+ JSON.stringify({
1089
+ query: mt(vt),
1090
+ variables: s
1091
+ })
1092
+ ],
1093
+ {
1094
+ type: "application/json"
1095
+ }
1096
+ );
1097
+ return yield window.fetch(`${this._backendUrl}`, {
1098
+ method: "POST",
1099
+ body: n
1100
+ }), 0;
1101
+ })), yield this._sendPayload({ sendFn: t }), this.hasPushedData = !0, this.sessionData.lastPushTime = Date.now(), U(this.sessionData);
1102
+ } catch (t) {
1103
+ this._isOnLocalHost && (console.error(t), W("_save", t));
1104
+ }
1105
+ this.state === "Recording" && (this.pushPayloadTimerId && (clearTimeout(this.pushPayloadTimerId), this.pushPayloadTimerId = void 0), this.pushPayloadTimerId = setTimeout(() => {
1106
+ this._save();
1107
+ }, ft));
1108
+ });
1109
+ }
1110
+ /**
1111
+ * This proxy should be used instead of rrweb's native addCustomEvent.
1112
+ * The proxy makes sure recording has started before emitting a custom event.
1113
+ */
1114
+ addCustomEvent(e, t) {
1115
+ if (this.state === "NotRecording") {
1116
+ let s;
1117
+ const n = () => {
1118
+ clearInterval(s), this.state === "Recording" && this.events.length > 0 ? _e(e, t) : s = setTimeout(n, 500);
1119
+ };
1120
+ s = setTimeout(n, 500);
1121
+ } else this.state === "Recording" && (this.events.length > 0 || this.hasPushedData) && _e(e, t);
1122
+ }
1123
+ _sendPayload(t) {
1124
+ return _(this, arguments, function* ({
1125
+ sendFn: e
1126
+ }) {
1127
+ const s = I.getRecordedNetworkResources(
1128
+ this._firstLoadListeners,
1129
+ this._recordingStartTime
1130
+ ), n = I.getRecordedWebSocketEvents(
1131
+ this._firstLoadListeners
1132
+ ), o = [...this.events], r = [...this._firstLoadListeners.messages], l = [...this._firstLoadListeners.errors], { bytes: d, time: c } = this.enableCanvasRecording ? Ie.canvas : Ie.normal;
1133
+ this._eventBytesSinceSnapshot >= d && (/* @__PURE__ */ new Date()).getTime() - this._lastSnapshotTime >= c && this.takeFullSnapshot(), this.logger.log(
1134
+ `Sending: ${o.length} events, ${r.length} messages, ${s.length} network resources, ${l.length} errors
1135
+ To: ${this._backendUrl}
1136
+ Org: ${this.organizationID}
1137
+ SessionSecureID: ${this.sessionData.sessionSecureID}`
1138
+ );
1139
+ const g = (/* @__PURE__ */ new Date()).getTime(), h = tt();
1140
+ if (e) {
1141
+ const f = {
1142
+ session_secure_id: this.sessionData.sessionSecureID,
1143
+ payload_id: g.toString(),
1144
+ events: { events: o },
1145
+ messages: x({ messages: r }),
1146
+ resources: JSON.stringify({ resources: s }),
1147
+ web_socket_events: JSON.stringify({ webSocketEvents: n }),
1148
+ errors: l,
1149
+ is_beacon: !1,
1150
+ has_session_unloaded: this.hasSessionUnloaded,
1151
+ highlight_logs: h || void 0
1152
+ }, { compressedBase64: m } = yield st(f);
1153
+ yield e({
1154
+ session_secure_id: this.sessionData.sessionSecureID,
1155
+ payload_id: (/* @__PURE__ */ new Date()).getTime().toString(),
1156
+ data: m
1157
+ });
1158
+ } else
1159
+ this._worker.postMessage({
1160
+ message: {
1161
+ type: L.AsyncEvents,
1162
+ id: g,
1163
+ events: o,
1164
+ messages: r,
1165
+ errors: l,
1166
+ resourcesString: JSON.stringify({ resources: s }),
1167
+ webSocketEventsString: JSON.stringify({
1168
+ webSocketEvents: n
1169
+ }),
1170
+ hasSessionUnloaded: this.hasSessionUnloaded,
1171
+ highlightLogs: h
1172
+ }
1173
+ });
1174
+ U(this.sessionData), I.clearRecordedNetworkResources(
1175
+ this._firstLoadListeners
1176
+ ), this.events = this.events.slice(o.length), this._firstLoadListeners.messages = this._firstLoadListeners.messages.slice(r.length), this._firstLoadListeners.errors = this._firstLoadListeners.errors.slice(
1177
+ l.length
1178
+ ), it(h);
1179
+ });
1180
+ }
1181
+ takeFullSnapshot() {
1182
+ if (!this._recordStop) {
1183
+ this.logger.log("skipping full snapshot as rrweb is not running");
1184
+ return;
1185
+ }
1186
+ this.logger.log("taking full snapshot", {
1187
+ bytesSinceSnapshot: this._eventBytesSinceSnapshot,
1188
+ lastSnapshotTime: this._lastSnapshotTime
1189
+ }), j.takeFullSnapshot(), this._eventBytesSinceSnapshot = 0, this._lastSnapshotTime = (/* @__PURE__ */ new Date()).getTime();
1190
+ }
1191
+ registerLD(e) {
1192
+ this._integrations.length || this._integrations.push(new Ue(e));
1193
+ }
1194
+ };
1195
+ F = new WeakMap();
1196
+ let Z = te;
1197
+ const qt = () => {
1198
+ var i, e;
1199
+ typeof chrome != "undefined" && ((i = chrome == null ? void 0 : chrome.runtime) != null && i.onMessage) && ((e = chrome == null ? void 0 : chrome.runtime) == null || e.onMessage.addListener(
1200
+ (t, s, n) => {
1201
+ const o = t.action;
1202
+ switch (console.log(
1203
+ `[highlight] received '${o}' event from extension.`
1204
+ ), o) {
1205
+ case "init": {
1206
+ p.init(1, {
1207
+ debug: !0
1208
+ }), p.getSessionURL().then((r) => {
1209
+ n({ url: r });
1210
+ });
1211
+ break;
1212
+ }
1213
+ case "stop": {
1214
+ p.stop(), n({ success: !0 });
1215
+ break;
1216
+ }
1217
+ }
1218
+ return !0;
1219
+ }
1220
+ ));
1221
+ };
1222
+ function ts(i) {
1223
+ var e;
1224
+ i.on && ((e = i.webContents) != null && e.send) && (i.on("focus", () => {
1225
+ i.webContents.send("highlight.run", { visible: !0 });
1226
+ }), i.on("blur", () => {
1227
+ i.webContents.send("highlight.run", { visible: !1 });
1228
+ }), i.on("close", () => {
1229
+ i.webContents.send("highlight.run", { visible: !1 });
1230
+ }));
1231
+ }
1232
+ const ss = ({
1233
+ next: i,
1234
+ payload: e
1235
+ }) => {
1236
+ if (typeof window != "undefined" && typeof document != "undefined" && "H" in window) {
1237
+ if (e.obj.type === "track") {
1238
+ const t = e.obj.event, s = e.obj.properties;
1239
+ window.H.track(t, s);
1240
+ } else if (e.obj.type === "identify") {
1241
+ const t = e.obj.userId;
1242
+ if (t != null && t.length) {
1243
+ const s = e.obj.traits;
1244
+ window.H.identify(t, s);
1245
+ }
1246
+ }
1247
+ }
1248
+ i(e);
1249
+ }, Fe = () => {
1250
+ if (typeof window != "undefined") {
1251
+ if (typeof window._highlightFetchPatch != "undefined")
1252
+ return;
1253
+ window._originalFetch = window.fetch, window._fetchProxy = (i, e) => window._originalFetch(i, e), window._highlightFetchPatch = (i, e) => window._fetchProxy.call(window || global, i, e), window.fetch = window._highlightFetchPatch;
1254
+ }
1255
+ }, Pe = () => null, $e = () => {
1256
+ if (typeof window != "undefined") {
1257
+ if (typeof window._highlightWebSocketRequestCallback != "undefined")
1258
+ return;
1259
+ window._highlightWebSocketRequestCallback = Pe, window._highlightWebSocketEventCallback = Pe;
1260
+ const i = new Proxy(window.WebSocket, {
1261
+ construct(e, t) {
1262
+ const [, s] = Vt(), n = new e(...t), o = (g) => {
1263
+ window._highlightWebSocketRequestCallback({
1264
+ socketId: s,
1265
+ initiatorType: "websocket",
1266
+ type: "open",
1267
+ name: n.url,
1268
+ startTimeAbs: performance.timeOrigin + g.timeStamp
1269
+ });
1270
+ }, r = (g) => {
1271
+ window._highlightWebSocketRequestCallback({
1272
+ socketId: s,
1273
+ initiatorType: "websocket",
1274
+ type: "close",
1275
+ name: n.url,
1276
+ responseEndAbs: performance.timeOrigin + g.timeStamp
1277
+ }), n.removeEventListener("open", o), n.removeEventListener("error", d), n.removeEventListener("message", l), n.removeEventListener("close", r);
1278
+ }, l = (g) => {
1279
+ const { data: h } = g, f = typeof h == "string" ? g.data : void 0;
1280
+ let m;
1281
+ typeof h == "string" ? m = h.length : h instanceof Blob ? m = h.size : m = h.byteLength || 0, window._highlightWebSocketEventCallback({
1282
+ socketId: s,
1283
+ type: "received",
1284
+ name: n.url,
1285
+ timeStamp: performance.timeOrigin + g.timeStamp,
1286
+ size: m,
1287
+ message: f
1288
+ });
1289
+ }, d = (g) => {
1290
+ window._highlightWebSocketEventCallback({
1291
+ socketId: s,
1292
+ type: "error",
1293
+ name: n.url,
1294
+ timeStamp: performance.timeOrigin + g.timeStamp,
1295
+ size: 0
1296
+ });
1297
+ };
1298
+ n.addEventListener("open", o), n.addEventListener("error", d), n.addEventListener("message", l), n.addEventListener("close", r);
1299
+ const c = new Proxy(n.send, {
1300
+ apply: function(g, h, f) {
1301
+ const m = f[0], R = typeof m == "string" ? m : void 0;
1302
+ let v;
1303
+ typeof m == "string" ? v = m.length : m instanceof Blob ? v = m.size : v = m.byteLength || 0, window._highlightWebSocketEventCallback({
1304
+ socketId: s,
1305
+ type: "sent",
1306
+ name: n.url,
1307
+ timeStamp: performance.timeOrigin + performance.now(),
1308
+ size: v,
1309
+ message: R
1310
+ }), g.apply(h, f);
1311
+ }
1312
+ });
1313
+ return n.send = c, n;
1314
+ }
1315
+ });
1316
+ window.WebSocket = i;
1317
+ }
1318
+ };
1319
+ var Gt = /* @__PURE__ */ ((i) => (i.Device = "Device", i.WebVital = "WebVital", i.Frontend = "Frontend", i.Backend = "Backend", i))(Gt || {});
1320
+ const b = (i, e) => {
1321
+ console.warn(`highlight.run warning: (${i}): `, e);
1322
+ }, jt = 200;
1323
+ let z = [], K, u, B, He = [], ee = !1;
1324
+ const p = {
1325
+ options: void 0,
1326
+ init: (i, e) => {
1327
+ var t, s, n, o, r, l, d, c;
1328
+ try {
1329
+ if (p.options = e, typeof window == "undefined" || typeof document == "undefined")
1330
+ return;
1331
+ if (!i) {
1332
+ console.info(
1333
+ "Highlight is not initializing because projectID was passed undefined."
1334
+ );
1335
+ return;
1336
+ }
1337
+ e != null && e.sessionCookie ? _t() : We(!1);
1338
+ const g = M();
1339
+ let h = O();
1340
+ if (e != null && e.sessionKey ? h = O(
1341
+ `${i}-${e.sessionKey}`
1342
+ ) : g != null && g.sessionSecureID && (h = g.sessionSecureID), ee)
1343
+ return { sessionSecureID: h };
1344
+ ee = !0, Fe(), $e();
1345
+ const f = y(w({}, e), {
1346
+ organizationID: i,
1347
+ firstloadVersion: Rt,
1348
+ environment: (e == null ? void 0 : e.environment) || "production",
1349
+ appVersion: e == null ? void 0 : e.version,
1350
+ sessionSecureID: h
1351
+ });
1352
+ return B = new I(f), e != null && e.manualStart || B.startListening(), u = u != null ? u : new Z(f, B), e != null && e.manualStart || u.initialize(), !((s = (t = e == null ? void 0 : e.integrations) == null ? void 0 : t.mixpanel) != null && s.disabled) && ((o = (n = e == null ? void 0 : e.integrations) == null ? void 0 : n.mixpanel) != null && o.projectToken) && ot(e.integrations.mixpanel), !((l = (r = e == null ? void 0 : e.integrations) == null ? void 0 : r.amplitude) != null && l.disabled) && ((c = (d = e == null ? void 0 : e.integrations) == null ? void 0 : d.amplitude) != null && c.apiKey) && at(e.integrations.amplitude), { sessionSecureID: h };
1353
+ } catch (g) {
1354
+ b("init", g);
1355
+ }
1356
+ },
1357
+ snapshot: (i) => _(void 0, null, function* () {
1358
+ try {
1359
+ if (u && u.ready)
1360
+ return yield u.snapshot(i);
1361
+ } catch (e) {
1362
+ b("snapshot", e);
1363
+ }
1364
+ }),
1365
+ addSessionFeedback: ({
1366
+ verbatim: i,
1367
+ userName: e,
1368
+ userEmail: t,
1369
+ timestampOverride: s
1370
+ }) => {
1371
+ try {
1372
+ p.onHighlightReady(
1373
+ () => u.addSessionFeedback({
1374
+ verbatim: i,
1375
+ timestamp: s || (/* @__PURE__ */ new Date()).toISOString(),
1376
+ user_email: t,
1377
+ user_name: e
1378
+ })
1379
+ );
1380
+ } catch (n) {
1381
+ b("error", n);
1382
+ }
1383
+ },
1384
+ consumeError: (i, e, t) => {
1385
+ try {
1386
+ p.onHighlightReady(
1387
+ () => u.consumeCustomError(
1388
+ i,
1389
+ e,
1390
+ JSON.stringify(t)
1391
+ )
1392
+ );
1393
+ } catch (s) {
1394
+ b("error", s);
1395
+ }
1396
+ },
1397
+ consume: (i, e) => {
1398
+ try {
1399
+ p.onHighlightReady(() => u.consumeError(i, e));
1400
+ } catch (t) {
1401
+ b("error", t);
1402
+ }
1403
+ },
1404
+ error: (i, e) => {
1405
+ try {
1406
+ p.onHighlightReady(
1407
+ () => u.pushCustomError(i, JSON.stringify(e))
1408
+ );
1409
+ } catch (t) {
1410
+ b("error", t);
1411
+ }
1412
+ },
1413
+ track: (i, e = {}) => {
1414
+ var t, s, n, o, r, l, d, c, g, h, f;
1415
+ try {
1416
+ p.onHighlightReady(() => {
1417
+ u.addProperties(y(w({}, e), { event: i })), u.log("H.track", "INFO", y(w({}, e != null ? e : {}), {
1418
+ event: i
1419
+ }));
1420
+ });
1421
+ const m = u == null ? void 0 : u.getCurrentSessionURL();
1422
+ (n = (s = (t = p.options) == null ? void 0 : t.integrations) == null ? void 0 : s.mixpanel) != null && n.disabled || (o = window.mixpanel) != null && o.track && window.mixpanel.track(i, y(w({}, e), {
1423
+ highlightSessionURL: m
1424
+ })), (d = (l = (r = p.options) == null ? void 0 : r.integrations) == null ? void 0 : l.amplitude) != null && d.disabled || (c = window.amplitude) != null && c.getInstance && window.amplitude.getInstance().logEvent(i, y(w({}, e), {
1425
+ highlightSessionURL: m
1426
+ })), (f = (h = (g = p.options) == null ? void 0 : g.integrations) == null ? void 0 : h.intercom) != null && f.disabled || window.Intercom && window.Intercom("trackEvent", i, e);
1427
+ } catch (m) {
1428
+ b("track", m);
1429
+ }
1430
+ },
1431
+ log: (i, e, t) => {
1432
+ try {
1433
+ p.onHighlightReady(
1434
+ () => u.log(i, e, t != null ? t : {})
1435
+ );
1436
+ } catch (s) {
1437
+ b("log", s);
1438
+ }
1439
+ },
1440
+ start: (i) => {
1441
+ var e;
1442
+ (u == null ? void 0 : u.state) === "Recording" && !(i != null && i.forceNew) ? i != null && i.silent || console.warn(
1443
+ "Highlight is already recording. Please `H.stop()` the current session before starting a new one."
1444
+ ) : (((e = u == null ? void 0 : u._firstLoadListeners) != null ? e : B).startListening(), p.onHighlightReady(
1445
+ () => _(void 0, null, function* () {
1446
+ yield u.initialize(i);
1447
+ }),
1448
+ { waitForReady: !1 }
1449
+ ));
1450
+ },
1451
+ stop: (i) => {
1452
+ (u == null ? void 0 : u.state) !== "Recording" ? i != null && i.silent || console.warn(
1453
+ "Highlight is already stopped. Please call `H.start()`."
1454
+ ) : p.onHighlightReady(() => u.stopRecording(!0));
1455
+ },
1456
+ identify: (i, e = {}, t) => {
1457
+ var s, n, o, r, l, d, c, g;
1458
+ try {
1459
+ p.onHighlightReady(
1460
+ () => u.identify(i, e, t)
1461
+ );
1462
+ } catch (h) {
1463
+ b("identify", h);
1464
+ }
1465
+ if ((o = (n = (s = p.options) == null ? void 0 : s.integrations) == null ? void 0 : n.mixpanel) != null && o.disabled || (r = window.mixpanel) != null && r.identify && (window.mixpanel.identify(
1466
+ typeof (e == null ? void 0 : e.email) == "string" ? e == null ? void 0 : e.email : i
1467
+ ), e && (window.mixpanel.track("identify", e), window.mixpanel.people.set(e))), !((c = (d = (l = p.options) == null ? void 0 : l.integrations) == null ? void 0 : d.amplitude) != null && c.disabled) && (g = window.amplitude) != null && g.getInstance && (window.amplitude.getInstance().setUserId(i), Object.keys(e).length > 0)) {
1468
+ const h = Object.keys(
1469
+ e
1470
+ ).reduce((f, m) => (f.set(m, e[m]), f), new window.amplitude.Identify());
1471
+ window.amplitude.getInstance().identify(h);
1472
+ }
1473
+ },
1474
+ metrics: (i) => {
1475
+ try {
1476
+ for (const e of i)
1477
+ p.recordMetric(e);
1478
+ } catch (e) {
1479
+ b("metrics", e);
1480
+ }
1481
+ },
1482
+ recordMetric: (i) => {
1483
+ try {
1484
+ p.onHighlightReady(() => {
1485
+ var e;
1486
+ u.recordGauge(y(w({}, i), {
1487
+ tags: (e = i.tags) != null ? e : [],
1488
+ group: window.location.href,
1489
+ category: "Frontend"
1490
+ /* Frontend */
1491
+ }));
1492
+ });
1493
+ } catch (e) {
1494
+ b("recordMetric", e);
1495
+ }
1496
+ },
1497
+ recordCount: (i) => {
1498
+ try {
1499
+ p.onHighlightReady(() => {
1500
+ u.recordCount(i);
1501
+ });
1502
+ } catch (e) {
1503
+ b("recordCount", e);
1504
+ }
1505
+ },
1506
+ recordIncr: (i) => {
1507
+ try {
1508
+ p.onHighlightReady(() => {
1509
+ u.recordIncr(i);
1510
+ });
1511
+ } catch (e) {
1512
+ b("recordIncr", e);
1513
+ }
1514
+ },
1515
+ recordHistogram: (i) => {
1516
+ try {
1517
+ p.onHighlightReady(() => {
1518
+ u.recordHistogram(i);
1519
+ });
1520
+ } catch (e) {
1521
+ b("recordHistogram", e);
1522
+ }
1523
+ },
1524
+ recordUpDownCounter: (i) => {
1525
+ try {
1526
+ p.onHighlightReady(() => {
1527
+ u.recordUpDownCounter(i);
1528
+ });
1529
+ } catch (e) {
1530
+ b("recordUpDownCounter", e);
1531
+ }
1532
+ },
1533
+ startSpan: (i, e, t, s) => {
1534
+ const n = Oe();
1535
+ if (!n) {
1536
+ const r = Te();
1537
+ return s === void 0 && t === void 0 ? e(r) : s === void 0 ? t(r) : s(r);
1538
+ }
1539
+ const o = (r, l) => {
1540
+ const d = l(r);
1541
+ return d instanceof Promise ? d.finally(() => r.end()) : (r.end(), d);
1542
+ };
1543
+ return s === void 0 && t === void 0 ? n.startActiveSpan(
1544
+ i,
1545
+ (r) => o(r, e)
1546
+ ) : s === void 0 ? n.startActiveSpan(
1547
+ i,
1548
+ e,
1549
+ (r) => o(r, t)
1550
+ ) : n.startActiveSpan(
1551
+ i,
1552
+ e,
1553
+ t,
1554
+ (r) => o(r, s)
1555
+ );
1556
+ },
1557
+ startManualSpan: (i, e, t, s) => {
1558
+ const n = Oe();
1559
+ if (!n) {
1560
+ const o = Te();
1561
+ return s === void 0 && t === void 0 ? e(o) : s === void 0 ? t(o) : s(o);
1562
+ }
1563
+ return s === void 0 && t === void 0 ? n.startActiveSpan(i, e) : s === void 0 ? n.startActiveSpan(
1564
+ i,
1565
+ e,
1566
+ t
1567
+ ) : n.startActiveSpan(
1568
+ i,
1569
+ e,
1570
+ t,
1571
+ s
1572
+ );
1573
+ },
1574
+ getSessionURL: () => new Promise((i, e) => {
1575
+ p.onHighlightReady(() => {
1576
+ const t = u.sessionData.sessionSecureID, s = M(t);
1577
+ s ? i(
1578
+ `https://${X}/${s.projectID}/sessions/${t}`
1579
+ ) : e(new Error(`Unable to get session URL: ${t}`));
1580
+ });
1581
+ }),
1582
+ getSessionDetails: () => new Promise((i, e) => {
1583
+ p.onHighlightReady(() => _(void 0, null, function* () {
1584
+ try {
1585
+ const t = yield p.getSessionURL();
1586
+ if (!t)
1587
+ throw new Error("Could not get session URL");
1588
+ const s = u.sessionData.sessionSecureID, n = M(s), o = n == null ? void 0 : n.sessionStartTime;
1589
+ if (!o)
1590
+ throw new Error("Could not get session start timestamp");
1591
+ const r = (/* @__PURE__ */ new Date()).getTime(), l = new URL(t), d = new URL(t);
1592
+ d.searchParams.set(
1593
+ "ts",
1594
+ ((r - o) / 1e3).toString()
1595
+ ), i({
1596
+ url: l.toString(),
1597
+ urlWithTimestamp: d.toString(),
1598
+ sessionSecureID: s
1599
+ });
1600
+ } catch (t) {
1601
+ e(t);
1602
+ }
1603
+ }));
1604
+ }),
1605
+ getRecordingState: () => {
1606
+ var i;
1607
+ return (i = u == null ? void 0 : u.state) != null ? i : "NotRecording";
1608
+ },
1609
+ onHighlightReady: (i, e) => {
1610
+ if (u && u.ready) {
1611
+ i();
1612
+ return;
1613
+ }
1614
+ if (z.push({ options: e, func: i }), K !== void 0)
1615
+ return;
1616
+ const t = () => {
1617
+ z = z.filter((n) => {
1618
+ var o;
1619
+ return !u || ((o = n.options) == null ? void 0 : o.waitForReady) !== !1 && !u.ready ? !0 : (n.func(), !1);
1620
+ }), K = void 0, z.length > 0 && (K = setTimeout(
1621
+ t,
1622
+ jt
1623
+ ));
1624
+ };
1625
+ t();
1626
+ },
1627
+ registerLD(i) {
1628
+ He.length || (p.onHighlightReady(() => {
1629
+ u.registerLD(i);
1630
+ }), kt(this, i, p.options), He.push(new Ue(i)));
1631
+ }
1632
+ };
1633
+ typeof window != "undefined" && (window.H = p);
1634
+ qt();
1635
+ Fe();
1636
+ $e();
1637
+ const is = {
1638
+ reset: () => {
1639
+ ee = !1, u = void 0, z = [], K = void 0, B = void 0;
1640
+ },
1641
+ setHighlightObj: (i) => {
1642
+ u = i;
1643
+ }
1644
+ };
1645
+ export {
1646
+ O as GenerateSecureID,
1647
+ p as H,
1648
+ ss as HighlightSegmentMiddleware,
1649
+ ds as LDObserve,
1650
+ gs as LDRecord,
1651
+ Gt as MetricCategory,
1652
+ cs as Observe,
1653
+ os as Record,
1654
+ is as __testing,
1655
+ ts as configureElectronHighlight
1656
+ };
1657
+ //# sourceMappingURL=index.js.map