@getpinax/widget 0.0.0-stage → 1.0.0-beta.1
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/LICENSE +21 -0
- package/README.md +267 -2
- package/dist/api.d.ts +62 -0
- package/dist/capture/breadcrumbs.d.ts +49 -0
- package/dist/capture/console.d.ts +17 -0
- package/dist/capture/env.d.ts +25 -0
- package/dist/capture/network.d.ts +23 -0
- package/dist/capture/ring.d.ts +14 -0
- package/dist/capture/signature.d.ts +2 -0
- package/dist/capture/text.d.ts +7 -0
- package/dist/capture/ua.d.ts +13 -0
- package/dist/chunks/editor-DbHLGwOA.mjs +1368 -0
- package/dist/chunks/privacy-DmU6v5Fr.mjs +39 -0
- package/dist/chunks/recorder-BUtEB_em.mjs +2859 -0
- package/dist/chunks/text-8QYEyRYs.mjs +18 -0
- package/dist/chunks/widget-CkR1Ptzb.mjs +961 -0
- package/dist/editor/annotator.d.ts +20 -0
- package/dist/editor/capture.d.ts +28 -0
- package/dist/editor/encode.d.ts +7 -0
- package/dist/editor/index.d.ts +5 -0
- package/dist/editor/mask.d.ts +29 -0
- package/dist/editor/pii.d.ts +22 -0
- package/dist/editor/shapes.d.ts +31 -0
- package/dist/editor-loader.d.ts +6 -0
- package/dist/editor-loader.embed.d.ts +5 -0
- package/dist/fixcheck.d.ts +31 -0
- package/dist/index.d.ts +46 -0
- package/dist/mount.d.ts +8 -0
- package/dist/navigation.d.ts +1 -0
- package/dist/paths.d.ts +4 -0
- package/dist/pinax-editor.js +1417 -0
- package/dist/pinax-recorder.js +2902 -0
- package/dist/pinax.js +113 -0
- package/dist/pinax.mjs +1041 -0
- package/dist/preview.d.ts +35 -0
- package/dist/preview.mjs +54 -0
- package/dist/privacy.d.ts +22 -0
- package/dist/queue.d.ts +9 -0
- package/dist/replay/buffer.d.ts +40 -0
- package/dist/replay/recorder.d.ts +15 -0
- package/dist/replay/sanitize.d.ts +13 -0
- package/dist/report.d.ts +109 -0
- package/dist/segment.d.ts +31 -0
- package/dist/settings.d.ts +31 -0
- package/dist/types.d.ts +137 -0
- package/dist/ui/color.d.ts +7 -0
- package/dist/ui/dom.d.ts +14 -0
- package/dist/ui/styles.d.ts +3 -0
- package/dist/ui/widget.d.ts +161 -0
- package/package.json +73 -4
package/dist/pinax.mjs
ADDED
|
@@ -0,0 +1,1041 @@
|
|
|
1
|
+
import { n as e, t } from "./chunks/text-8QYEyRYs.mjs";
|
|
2
|
+
import { a as n, c as r, i, l as a, o, s, t as c, u as l } from "./chunks/widget-CkR1Ptzb.mjs";
|
|
3
|
+
function u(e) {
|
|
4
|
+
return (e || "https://api.getpinax.com").replace(/\/+$/, "");
|
|
5
|
+
}
|
|
6
|
+
function d(e, t) {
|
|
7
|
+
let n = e ?? (t ? "" : "https://cdn.getpinax.com");
|
|
8
|
+
return n ? n.replace(/\/+$/, "") : null;
|
|
9
|
+
}
|
|
10
|
+
function f(e, t) {
|
|
11
|
+
return `${e}/config/${encodeURIComponent(t)}.json`;
|
|
12
|
+
}
|
|
13
|
+
function p(e, t, n) {
|
|
14
|
+
return `${e}/v1/widget/${encodeURIComponent(t)}/${n}`;
|
|
15
|
+
}
|
|
16
|
+
async function m(e, t) {
|
|
17
|
+
let n = await e(t, { credentials: "omit" });
|
|
18
|
+
if (!n.ok) return {
|
|
19
|
+
status: n.status,
|
|
20
|
+
config: null
|
|
21
|
+
};
|
|
22
|
+
let r = await n.json();
|
|
23
|
+
return {
|
|
24
|
+
status: n.status,
|
|
25
|
+
config: r?.data ?? null
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
async function ee(e, t, n, r = null) {
|
|
29
|
+
if (r) try {
|
|
30
|
+
let { config: t } = await m(e, f(r, n));
|
|
31
|
+
if (t) return t;
|
|
32
|
+
} catch {}
|
|
33
|
+
return (await m(e, p(t, n, "config"))).config;
|
|
34
|
+
}
|
|
35
|
+
function te(t, n, r, i) {
|
|
36
|
+
try {
|
|
37
|
+
if (!new URL(i).searchParams.has("pinax_verify")) return;
|
|
38
|
+
t(p(n, r, "ping"), {
|
|
39
|
+
method: "POST",
|
|
40
|
+
credentials: "omit",
|
|
41
|
+
headers: { "Content-Type": "application/json" },
|
|
42
|
+
body: JSON.stringify({ url: e(i) })
|
|
43
|
+
}).catch(() => {});
|
|
44
|
+
} catch {}
|
|
45
|
+
}
|
|
46
|
+
var ne = {
|
|
47
|
+
403: "Feedback isn't switched on for this website yet.",
|
|
48
|
+
404: "Feedback isn't switched on for this website yet.",
|
|
49
|
+
413: "That screenshot is too big to send. Remove it and try again.",
|
|
50
|
+
429: "Too many reports from this device. Please try again in a few minutes."
|
|
51
|
+
};
|
|
52
|
+
async function re(e, t, n, r) {
|
|
53
|
+
let i;
|
|
54
|
+
try {
|
|
55
|
+
i = await e(p(t, n, "reports"), {
|
|
56
|
+
method: "POST",
|
|
57
|
+
credentials: "omit",
|
|
58
|
+
headers: { "Content-Type": "application/json" },
|
|
59
|
+
body: JSON.stringify(r)
|
|
60
|
+
});
|
|
61
|
+
} catch {
|
|
62
|
+
return {
|
|
63
|
+
ok: !1,
|
|
64
|
+
retry: !0,
|
|
65
|
+
status: 0,
|
|
66
|
+
message: "You're offline. We'll send it when you're back."
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
let a = null;
|
|
70
|
+
try {
|
|
71
|
+
a = await i.json();
|
|
72
|
+
} catch {}
|
|
73
|
+
if (i.ok) return {
|
|
74
|
+
ok: !0,
|
|
75
|
+
id: a?.data?.id ?? ""
|
|
76
|
+
};
|
|
77
|
+
let o = i.status;
|
|
78
|
+
return {
|
|
79
|
+
ok: !1,
|
|
80
|
+
retry: o >= 500,
|
|
81
|
+
status: o,
|
|
82
|
+
message: ne[o] ?? (o === 400 && a?.message ? a.message : "Something went wrong. Please try again.")
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
var ie = 4e3;
|
|
86
|
+
async function ae(e, t, n, r, i = ie) {
|
|
87
|
+
let a = typeof AbortController == "function" ? new AbortController() : null, o, s = new Promise((e) => {
|
|
88
|
+
o = setTimeout(() => {
|
|
89
|
+
a?.abort(), e(null);
|
|
90
|
+
}, i);
|
|
91
|
+
}), c = (async () => {
|
|
92
|
+
try {
|
|
93
|
+
let i = await e(p(t, n, "follow-up"), {
|
|
94
|
+
method: "POST",
|
|
95
|
+
credentials: "omit",
|
|
96
|
+
headers: { "Content-Type": "application/json" },
|
|
97
|
+
body: JSON.stringify({
|
|
98
|
+
type: r.type,
|
|
99
|
+
message: r.message.trim().slice(0, 2e3),
|
|
100
|
+
pagePath: r.pagePath.slice(0, 500) || "/"
|
|
101
|
+
}),
|
|
102
|
+
signal: a?.signal
|
|
103
|
+
});
|
|
104
|
+
if (!i.ok) return null;
|
|
105
|
+
let o = (await i.json())?.data?.question;
|
|
106
|
+
return typeof o == "string" && o.trim() ? o.trim().slice(0, 300) : null;
|
|
107
|
+
} catch {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
})();
|
|
111
|
+
try {
|
|
112
|
+
return await Promise.race([c, s]);
|
|
113
|
+
} finally {
|
|
114
|
+
clearTimeout(o);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function oe(e, t, n, r) {
|
|
118
|
+
try {
|
|
119
|
+
e(p(t, n, "fix-check"), {
|
|
120
|
+
method: "POST",
|
|
121
|
+
credentials: "omit",
|
|
122
|
+
keepalive: !0,
|
|
123
|
+
headers: { "Content-Type": "application/json" },
|
|
124
|
+
body: JSON.stringify({
|
|
125
|
+
checkId: r.checkId.slice(0, 64),
|
|
126
|
+
signature: r.signature.slice(0, 300)
|
|
127
|
+
})
|
|
128
|
+
}).catch(() => {});
|
|
129
|
+
} catch {}
|
|
130
|
+
}
|
|
131
|
+
var h = "input,textarea,select,[contenteditable]:not([contenteditable=false]),[data-pinax-mask],.pinax-mask", g = "[data-pinax-mask],.pinax-mask", _ = "a[href],button,input,select,textarea,summary,[role=button],[role=link],[role=tab],[role=menuitem],[role=checkbox],[role=radio],[role=switch],[role=option],[contenteditable]:not([contenteditable=false])", se = {
|
|
132
|
+
button: "button",
|
|
133
|
+
submit: "button",
|
|
134
|
+
reset: "button",
|
|
135
|
+
image: "button",
|
|
136
|
+
checkbox: "checkbox",
|
|
137
|
+
radio: "radio",
|
|
138
|
+
range: "slider",
|
|
139
|
+
search: "searchbox"
|
|
140
|
+
};
|
|
141
|
+
function v(e, t) {
|
|
142
|
+
try {
|
|
143
|
+
return e.matches(t);
|
|
144
|
+
} catch {
|
|
145
|
+
return !1;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function y(e, t) {
|
|
149
|
+
try {
|
|
150
|
+
return e.closest(t);
|
|
151
|
+
} catch {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
var b = (e) => e.replace(/\s+/g, " ").trim();
|
|
156
|
+
function ce(e) {
|
|
157
|
+
if (e.tagName !== "INPUT") return !1;
|
|
158
|
+
let t = e, n = (t.getAttribute("autocomplete") ?? "").toLowerCase(), r = `${t.name} ${t.id}`.toLowerCase();
|
|
159
|
+
return t.type === "password" || n.includes("cc-") || n.includes("password") || /\b(card|cc|cvc|cvv|iban)/.test(r);
|
|
160
|
+
}
|
|
161
|
+
function x(e) {
|
|
162
|
+
let t = e.getAttribute("role")?.trim().split(/\s+/)[0];
|
|
163
|
+
if (t) return t;
|
|
164
|
+
let n = e.tagName.toLowerCase();
|
|
165
|
+
switch (n) {
|
|
166
|
+
case "a": return e.hasAttribute("href") ? "link" : "text";
|
|
167
|
+
case "button":
|
|
168
|
+
case "summary": return "button";
|
|
169
|
+
case "input": return se[e.type?.toLowerCase()] ?? "textbox";
|
|
170
|
+
case "textarea": return "textbox";
|
|
171
|
+
case "select": return "combobox";
|
|
172
|
+
case "img": return "image";
|
|
173
|
+
case "h1":
|
|
174
|
+
case "h2":
|
|
175
|
+
case "h3":
|
|
176
|
+
case "h4":
|
|
177
|
+
case "h5":
|
|
178
|
+
case "h6": return "heading";
|
|
179
|
+
default: return v(e, "[contenteditable]:not([contenteditable=false])") ? "textbox" : n;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function S(e, t = 120) {
|
|
183
|
+
if (v(e, h) || y(e, g)) return "";
|
|
184
|
+
let n = "", r = (e) => {
|
|
185
|
+
if (n.length > t) return;
|
|
186
|
+
if (e.nodeType === 3) {
|
|
187
|
+
n += e.nodeValue ?? "";
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
if (e.nodeType !== 1) return;
|
|
191
|
+
let i = e, a = i.tagName;
|
|
192
|
+
if (a !== "SCRIPT" && a !== "STYLE" && a !== "TEMPLATE" && !v(i, h) && i.getAttribute("aria-hidden") !== "true") {
|
|
193
|
+
if (a === "IMG") n += ` ${i.getAttribute("alt") ?? ""} `;
|
|
194
|
+
else {
|
|
195
|
+
for (let e of i.childNodes) r(e);
|
|
196
|
+
/^(P|DIV|LI|BR|TD|TH|DT|DD)$/.test(a) && (n += " ");
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
for (let t of e.childNodes) r(t);
|
|
201
|
+
return b(n);
|
|
202
|
+
}
|
|
203
|
+
function le(e) {
|
|
204
|
+
let t = e.getAttribute("aria-labelledby");
|
|
205
|
+
if (!t) return "";
|
|
206
|
+
let n = e.ownerDocument;
|
|
207
|
+
return b(t.split(/\s+/).map((e) => {
|
|
208
|
+
let t = n.getElementById(e);
|
|
209
|
+
return t ? S(t) : "";
|
|
210
|
+
}).join(" "));
|
|
211
|
+
}
|
|
212
|
+
function ue(e) {
|
|
213
|
+
let t = e;
|
|
214
|
+
return b((t.labels ? [...t.labels] : []).map((e) => S(e)).join(" ")) || b(t.getAttribute("placeholder") ?? "") || b(t.getAttribute("title") ?? "") || b(t.getAttribute("name") ?? "");
|
|
215
|
+
}
|
|
216
|
+
function de(e) {
|
|
217
|
+
if (y(e, g)) return "";
|
|
218
|
+
let t = b(e.getAttribute("aria-label") ?? "");
|
|
219
|
+
if (t) return t;
|
|
220
|
+
let n = le(e);
|
|
221
|
+
if (n) return n;
|
|
222
|
+
let r = e.tagName;
|
|
223
|
+
if (r === "INPUT") {
|
|
224
|
+
let t = e.type?.toLowerCase();
|
|
225
|
+
return t === "submit" || t === "button" || t === "reset" ? b(e.getAttribute("value") ?? "") : t === "image" ? b(e.getAttribute("alt") ?? "") : ue(e);
|
|
226
|
+
}
|
|
227
|
+
return r === "TEXTAREA" || r === "SELECT" ? ue(e) : v(e, "[contenteditable]:not([contenteditable=false])") ? b(e.getAttribute("title") ?? "") : r === "IMG" ? b(e.getAttribute("alt") ?? "") : S(e) || b(e.getAttribute("title") ?? "");
|
|
228
|
+
}
|
|
229
|
+
function fe(e) {
|
|
230
|
+
let n = y(e, _);
|
|
231
|
+
if (!n) return t(x(e), 200);
|
|
232
|
+
let r = n;
|
|
233
|
+
if (ce(r)) return r.type === "password" ? "password field" : "card field";
|
|
234
|
+
let i = x(r), a = t(de(r), 60).replace(/"/g, "'");
|
|
235
|
+
return t(a ? `${i} "${a}"` : i, 200);
|
|
236
|
+
}
|
|
237
|
+
function C(n = location.href) {
|
|
238
|
+
try {
|
|
239
|
+
let r = new URL(e(n));
|
|
240
|
+
return t(`${r.pathname}${r.search}`, 500);
|
|
241
|
+
} catch {
|
|
242
|
+
return "/";
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
function pe(e, t = {}) {
|
|
246
|
+
let n = t.doc ?? document, r = t.ignore ?? (() => !1), i = "", a = null, o = (t) => {
|
|
247
|
+
try {
|
|
248
|
+
e.push(t);
|
|
249
|
+
} catch {}
|
|
250
|
+
}, s = (e) => {
|
|
251
|
+
if (!e || typeof e.nodeType != "number") return null;
|
|
252
|
+
let t = e;
|
|
253
|
+
return t.nodeType === 1 ? t : t.parentElement;
|
|
254
|
+
}, c = (e) => {
|
|
255
|
+
try {
|
|
256
|
+
if (r(e.target)) return;
|
|
257
|
+
let t = s(e.target);
|
|
258
|
+
if (!t) return;
|
|
259
|
+
a = null, o({
|
|
260
|
+
kind: "click",
|
|
261
|
+
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
262
|
+
path: C(),
|
|
263
|
+
target: fe(t)
|
|
264
|
+
});
|
|
265
|
+
} catch {}
|
|
266
|
+
}, l = (e) => {
|
|
267
|
+
try {
|
|
268
|
+
if (r(e.target)) return;
|
|
269
|
+
let t = s(e.target);
|
|
270
|
+
if (!t) return;
|
|
271
|
+
let n = y(t, _) ?? t;
|
|
272
|
+
if (n.tagName === "INPUT" && /^(checkbox|radio)$/i.test(n.type) || n === a) return;
|
|
273
|
+
a = n, o({
|
|
274
|
+
kind: "input",
|
|
275
|
+
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
276
|
+
path: C(),
|
|
277
|
+
target: fe(n)
|
|
278
|
+
});
|
|
279
|
+
} catch {}
|
|
280
|
+
}, u = () => {
|
|
281
|
+
try {
|
|
282
|
+
let e = C();
|
|
283
|
+
if (e === i) return;
|
|
284
|
+
i = e, a = null, o({
|
|
285
|
+
kind: "navigation",
|
|
286
|
+
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
287
|
+
path: e
|
|
288
|
+
});
|
|
289
|
+
} catch {}
|
|
290
|
+
};
|
|
291
|
+
return n.addEventListener("click", c, !0), n.addEventListener("input", l, !0), u(), {
|
|
292
|
+
navigated: u,
|
|
293
|
+
stop: () => {
|
|
294
|
+
n.removeEventListener("click", c, !0), n.removeEventListener("input", l, !0);
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
// src/capture/console.ts
|
|
299
|
+
var me = [
|
|
300
|
+
"error",
|
|
301
|
+
"warn",
|
|
302
|
+
"log",
|
|
303
|
+
"info",
|
|
304
|
+
"debug"
|
|
305
|
+
], w = 2e3, T = 4e3;
|
|
306
|
+
function E(e, n = 0) {
|
|
307
|
+
if (typeof e == "string") return e;
|
|
308
|
+
if (e instanceof Error) return `${e.name}: ${e.message}`;
|
|
309
|
+
if (e == null) return String(e);
|
|
310
|
+
if (typeof e == "function") return `[function ${e.name || ""}]`;
|
|
311
|
+
if (typeof e != "object") return String(e);
|
|
312
|
+
if (typeof Node < "u" && e instanceof Node) return `[${e.nodeName.toLowerCase()}]`;
|
|
313
|
+
if (n > 0) return Array.isArray(e) ? "[…]" : "{…}";
|
|
314
|
+
try {
|
|
315
|
+
let n = /* @__PURE__ */ new WeakSet(), r = JSON.stringify(e, (e, t) => {
|
|
316
|
+
if (t && typeof t == "object") {
|
|
317
|
+
if (n.has(t)) return "[circular]";
|
|
318
|
+
n.add(t);
|
|
319
|
+
}
|
|
320
|
+
return t;
|
|
321
|
+
});
|
|
322
|
+
return t(r ?? String(e), w);
|
|
323
|
+
} catch {
|
|
324
|
+
return Object.prototype.toString.call(e);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
function he(e) {
|
|
328
|
+
return t(e.map((e) => E(e)).join(" "), w);
|
|
329
|
+
}
|
|
330
|
+
function ge(e) {
|
|
331
|
+
let n = e.find((e) => e instanceof Error);
|
|
332
|
+
return n?.stack ? t(n.stack, T) : void 0;
|
|
333
|
+
}
|
|
334
|
+
function _e() {
|
|
335
|
+
let e = (/* @__PURE__ */ Error()).stack;
|
|
336
|
+
if (!e) return;
|
|
337
|
+
let n = e.split("\n"), r = n[0].startsWith("Error") ? 3 : 2, i = n.slice(r).join("\n");
|
|
338
|
+
return i ? t(i, T) : void 0;
|
|
339
|
+
}
|
|
340
|
+
function ve(e, n = window) {
|
|
341
|
+
let r = n.console, i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = !1, s = (t) => {
|
|
342
|
+
try {
|
|
343
|
+
e.push(t);
|
|
344
|
+
} catch {}
|
|
345
|
+
};
|
|
346
|
+
for (let e of me) {
|
|
347
|
+
let t = r?.[e];
|
|
348
|
+
if (typeof t != "function") continue;
|
|
349
|
+
let n = function(...n) {
|
|
350
|
+
if (!o) {
|
|
351
|
+
o = !0;
|
|
352
|
+
try {
|
|
353
|
+
s({
|
|
354
|
+
level: e,
|
|
355
|
+
message: he(n),
|
|
356
|
+
stack: ge(n) ?? (e === "error" || e === "warn" ? _e() : void 0),
|
|
357
|
+
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
358
|
+
});
|
|
359
|
+
} catch {} finally {
|
|
360
|
+
o = !1;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
return t.apply(this, n);
|
|
364
|
+
};
|
|
365
|
+
n.__pinaxOriginal = t, i.set(e, t), a.set(e, n);
|
|
366
|
+
try {
|
|
367
|
+
r[e] = n;
|
|
368
|
+
} catch {}
|
|
369
|
+
}
|
|
370
|
+
let c = (e) => {
|
|
371
|
+
try {
|
|
372
|
+
if (!e.message && !e.error) return;
|
|
373
|
+
let n = e.error, r = e.filename ? ` (${e.filename}:${e.lineno}:${e.colno})` : "";
|
|
374
|
+
s({
|
|
375
|
+
level: "error",
|
|
376
|
+
message: t(`Uncaught ${n?.name ? `${n.name}: ${n.message}` : e.message}${r}`, w),
|
|
377
|
+
stack: n?.stack ? t(n.stack, T) : void 0,
|
|
378
|
+
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
379
|
+
});
|
|
380
|
+
} catch {}
|
|
381
|
+
}, l = (e) => {
|
|
382
|
+
try {
|
|
383
|
+
let n = e.reason;
|
|
384
|
+
s({
|
|
385
|
+
level: "error",
|
|
386
|
+
message: t(`Unhandled promise rejection: ${E(n)}`, w),
|
|
387
|
+
stack: n instanceof Error && n.stack ? t(n.stack, T) : void 0,
|
|
388
|
+
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
389
|
+
});
|
|
390
|
+
} catch {}
|
|
391
|
+
};
|
|
392
|
+
return n.addEventListener("error", c), n.addEventListener("unhandledrejection", l), () => {
|
|
393
|
+
n.removeEventListener("error", c), n.removeEventListener("unhandledrejection", l);
|
|
394
|
+
for (let [e, t] of i) try {
|
|
395
|
+
r[e] === a.get(e) && (r[e] = t);
|
|
396
|
+
} catch {}
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
// src/capture/ua.ts
|
|
400
|
+
var D = {
|
|
401
|
+
"10.0": "10/11",
|
|
402
|
+
"6.3": "8.1",
|
|
403
|
+
"6.2": "8",
|
|
404
|
+
"6.1": "7"
|
|
405
|
+
};
|
|
406
|
+
function O(e, t) {
|
|
407
|
+
return t.exec(e)?.[1];
|
|
408
|
+
}
|
|
409
|
+
function k(e) {
|
|
410
|
+
if (e) return e.replace(/_/g, ".").split(".").slice(0, 2).join(".");
|
|
411
|
+
}
|
|
412
|
+
function ye(e, t = 0) {
|
|
413
|
+
let n = { deviceType: "desktop" };
|
|
414
|
+
for (let [t, r] of [
|
|
415
|
+
["Edge", /Edg(?:e|A|iOS)?\/([\d.]+)/],
|
|
416
|
+
["Opera", /(?:OPR|OPiOS)\/([\d.]+)/],
|
|
417
|
+
["Samsung Internet", /SamsungBrowser\/([\d.]+)/],
|
|
418
|
+
["Firefox", /(?:Firefox|FxiOS)\/([\d.]+)/],
|
|
419
|
+
["Chrome", /(?:Chrome|CriOS)\/([\d.]+)/],
|
|
420
|
+
["Safari", /Version\/([\d.]+).*Safari\//]
|
|
421
|
+
]) {
|
|
422
|
+
let i = O(e, r);
|
|
423
|
+
if (i) {
|
|
424
|
+
n.browser = t, n.browserVersion = k(i);
|
|
425
|
+
break;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
!n.browser && /AppleWebKit/.test(e) && /Mobile\//.test(e) && (n.browser = "Safari (in-app)");
|
|
429
|
+
let r = /iPad/.test(e) || /Macintosh/.test(e) && t > 1;
|
|
430
|
+
if (/iPhone|iPod/.test(e)) n.os = `iOS ${k(O(e, /OS ([\d_]+) like Mac/)) ?? ""}`.trim(), n.deviceType = "mobile", n.deviceModel = /iPod/.test(e) ? "iPod" : "iPhone";
|
|
431
|
+
else if (r) {
|
|
432
|
+
let t = k(O(e, /OS ([\d_]+) like Mac/));
|
|
433
|
+
n.os = t ? `iPadOS ${t}` : "iPadOS", n.deviceType = "tablet", n.deviceModel = "iPad";
|
|
434
|
+
} else if (/Android/.test(e)) {
|
|
435
|
+
n.os = `Android ${O(e, /Android ([\d.]+)/) ?? ""}`.trim(), n.deviceType = /Mobile/.test(e) ? "mobile" : "tablet";
|
|
436
|
+
let t = O(e, /Android [\d.]+;(?: [a-z]{2}[-_][a-z]{2};)? ([^;)]+?)(?: Build\/[^;)]*)?\)/i);
|
|
437
|
+
t && t !== "K" && !/^wv$/.test(t) && (n.deviceModel = t.trim());
|
|
438
|
+
} else if (/CrOS/.test(e)) n.os = "ChromeOS";
|
|
439
|
+
else if (/Windows NT/.test(e)) {
|
|
440
|
+
let t = O(e, /Windows NT ([\d.]+)/);
|
|
441
|
+
n.os = t && D[t] ? `Windows ${D[t]}` : "Windows";
|
|
442
|
+
} else /Mac OS X/.test(e) ? n.os = `macOS ${k(O(e, /Mac OS X ([\d_.]+)/)) ?? ""}`.trim() : /Linux/.test(e) && (n.os = "Linux");
|
|
443
|
+
return n.deviceType === "desktop" && /Mobi|Tablet|Kindle|Silk/.test(e) && (n.deviceType = /Tablet|Kindle|Silk/.test(e) ? "tablet" : "mobile"), n;
|
|
444
|
+
}
|
|
445
|
+
// src/capture/env.ts
|
|
446
|
+
var A = (e) => typeof e == "number" && Number.isFinite(e) ? Math.max(0, Math.round(e)) : 0;
|
|
447
|
+
function be(e = /* @__PURE__ */ new Date()) {
|
|
448
|
+
let t = (e, t = 2) => String(Math.abs(e)).padStart(t, "0"), n = -e.getTimezoneOffset(), r = n >= 0 ? "+" : "-";
|
|
449
|
+
return `${e.getFullYear()}-${t(e.getMonth() + 1)}-${t(e.getDate())}T${t(e.getHours())}:${t(e.getMinutes())}:${t(e.getSeconds())}.${t(e.getMilliseconds(), 3)}${r}${t(Math.trunc(n / 60))}:${t(n % 60)}`;
|
|
450
|
+
}
|
|
451
|
+
function xe(e = window) {
|
|
452
|
+
let n = e.navigator, r = n?.userAgent ?? "", i = ye(r, n?.maxTouchPoints ?? 0), a = "UTC";
|
|
453
|
+
try {
|
|
454
|
+
a = Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
|
|
455
|
+
} catch {}
|
|
456
|
+
let o = (e, n) => e ? t(e, n) : void 0;
|
|
457
|
+
return {
|
|
458
|
+
userAgent: t(r, 1e3),
|
|
459
|
+
browser: o(i.browser, 100),
|
|
460
|
+
browserVersion: o(i.browserVersion, 50),
|
|
461
|
+
os: o(i.os, 100),
|
|
462
|
+
deviceType: i.deviceType,
|
|
463
|
+
deviceModel: o(i.deviceModel, 100),
|
|
464
|
+
screen: {
|
|
465
|
+
w: A(e.screen?.width),
|
|
466
|
+
h: A(e.screen?.height)
|
|
467
|
+
},
|
|
468
|
+
viewport: {
|
|
469
|
+
w: A(e.innerWidth),
|
|
470
|
+
h: A(e.innerHeight)
|
|
471
|
+
},
|
|
472
|
+
pixelRatio: Math.min(10, Math.max(0, e.devicePixelRatio || 1)),
|
|
473
|
+
timeZone: t(a, 100),
|
|
474
|
+
language: o(n?.language, 35),
|
|
475
|
+
occurredAt: be()
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
function Se(e, t) {
|
|
479
|
+
return e === 0 || e >= 400 || t > 2e3;
|
|
480
|
+
}
|
|
481
|
+
function Ce(n, r = window, i = {}) {
|
|
482
|
+
let a = i.now ?? (() => typeof performance < "u" ? performance.now() : Date.now()), o = r.location?.href, s = i.ignore ?? (() => !1), c = (r, i, c, l, u) => {
|
|
483
|
+
try {
|
|
484
|
+
let d = Math.max(0, Math.round(a() - l));
|
|
485
|
+
if (!Se(c, d)) return;
|
|
486
|
+
let f = e(i, o);
|
|
487
|
+
if (s(f)) return;
|
|
488
|
+
n.push({
|
|
489
|
+
method: t(r.toUpperCase(), 10),
|
|
490
|
+
url: t(f, 2e3),
|
|
491
|
+
status: Math.min(999, Math.max(0, c | 0)),
|
|
492
|
+
durationMs: Math.min(6e5, d),
|
|
493
|
+
at: u
|
|
494
|
+
});
|
|
495
|
+
} catch {}
|
|
496
|
+
}, l = [], u = r.fetch;
|
|
497
|
+
if (typeof u == "function") {
|
|
498
|
+
let e = (e, t) => {
|
|
499
|
+
let n = "GET", i = "", o = a(), s = (/* @__PURE__ */ new Date()).toISOString();
|
|
500
|
+
try {
|
|
501
|
+
typeof e == "string" ? i = e : e instanceof URL ? i = e.href : e && typeof e.url == "string" && (i = e.url, n = e.method || n), t?.method && (n = t.method);
|
|
502
|
+
} catch {}
|
|
503
|
+
let l = u.call(r, e, t);
|
|
504
|
+
try {
|
|
505
|
+
l.then((e) => c(n, i, e?.status ?? 0, o, s), () => c(n, i, 0, o, s));
|
|
506
|
+
} catch {}
|
|
507
|
+
return l;
|
|
508
|
+
};
|
|
509
|
+
try {
|
|
510
|
+
r.fetch = e, l.push(() => {
|
|
511
|
+
r.fetch === e && (r.fetch = u);
|
|
512
|
+
});
|
|
513
|
+
} catch {}
|
|
514
|
+
}
|
|
515
|
+
let d = r.XMLHttpRequest;
|
|
516
|
+
if (d?.prototype) {
|
|
517
|
+
let e = d.prototype, t = e.open, n = e.send, r = /* @__PURE__ */ new WeakMap(), i = /* @__PURE__ */ new WeakMap(), o = /* @__PURE__ */ new WeakSet(), s = function(e, n, ...i) {
|
|
518
|
+
try {
|
|
519
|
+
r.set(this, {
|
|
520
|
+
method: String(e),
|
|
521
|
+
url: String(n)
|
|
522
|
+
});
|
|
523
|
+
} catch {}
|
|
524
|
+
return t.call(this, e, n, ...i);
|
|
525
|
+
}, u = function(e) {
|
|
526
|
+
try {
|
|
527
|
+
let e = r.get(this);
|
|
528
|
+
e && (i.set(this, {
|
|
529
|
+
m: e,
|
|
530
|
+
start: a(),
|
|
531
|
+
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
532
|
+
aborted: !1
|
|
533
|
+
}), o.has(this) || (o.add(this), this.addEventListener("abort", () => {
|
|
534
|
+
let e = i.get(this);
|
|
535
|
+
e && (e.aborted = !0);
|
|
536
|
+
}), this.addEventListener("loadend", () => {
|
|
537
|
+
let e = i.get(this);
|
|
538
|
+
i.delete(this), e && !e.aborted && c(e.m.method, e.m.url, this.status, e.start, e.startedAt);
|
|
539
|
+
})));
|
|
540
|
+
} catch {}
|
|
541
|
+
return n.call(this, e);
|
|
542
|
+
};
|
|
543
|
+
e.open = s, e.send = u, l.push(() => {
|
|
544
|
+
e.open === s && (e.open = t), e.send === u && (e.send = n);
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
return () => {
|
|
548
|
+
for (let e of l) try {
|
|
549
|
+
e();
|
|
550
|
+
} catch {}
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
// src/capture/ring.ts
|
|
554
|
+
var j = class {
|
|
555
|
+
constructor(e) {
|
|
556
|
+
this.capacity = e, this.items = [], this.listeners = /* @__PURE__ */ new Set();
|
|
557
|
+
}
|
|
558
|
+
push(e) {
|
|
559
|
+
this.items.push(e), this.items.length > this.capacity && this.items.shift();
|
|
560
|
+
for (let t of this.listeners) try {
|
|
561
|
+
t(e);
|
|
562
|
+
} catch {}
|
|
563
|
+
}
|
|
564
|
+
subscribe(e) {
|
|
565
|
+
return this.listeners.add(e), () => this.listeners.delete(e);
|
|
566
|
+
}
|
|
567
|
+
toArray() {
|
|
568
|
+
return this.items.slice();
|
|
569
|
+
}
|
|
570
|
+
clear() {
|
|
571
|
+
this.items = [];
|
|
572
|
+
}
|
|
573
|
+
get size() {
|
|
574
|
+
return this.items.length;
|
|
575
|
+
}
|
|
576
|
+
};
|
|
577
|
+
// src/editor-loader.ts
|
|
578
|
+
function M() {
|
|
579
|
+
return import("./chunks/editor-DbHLGwOA.mjs");
|
|
580
|
+
}
|
|
581
|
+
function we() {
|
|
582
|
+
return import("./chunks/recorder-BUtEB_em.mjs");
|
|
583
|
+
}
|
|
584
|
+
// src/capture/signature.ts
|
|
585
|
+
function N(e) {
|
|
586
|
+
return e.replace(/https?:\/\/\S+/g, "<url>").replace(/\b[0-9a-f]{8,}\b/gi, "<id>").replace(/\d+/g, "<n>").replace(/\s+/g, " ").trim().slice(0, 200);
|
|
587
|
+
}
|
|
588
|
+
function P(e, t) {
|
|
589
|
+
let n = (Array.isArray(e) ? e : []).filter((e) => e.level === "error");
|
|
590
|
+
if (n[0]?.message) return `console:${N(n[0].message)}`;
|
|
591
|
+
let r = (Array.isArray(t) ? t : []).find((e) => e.status === 0 || e.status >= 500);
|
|
592
|
+
if (r) {
|
|
593
|
+
let e = r.url;
|
|
594
|
+
try {
|
|
595
|
+
e = new URL(r.url).pathname;
|
|
596
|
+
} catch {}
|
|
597
|
+
return `network:${r.method.toUpperCase()} ${N(e)} ${r.status === 0 ? "failed" : "5xx"}`;
|
|
598
|
+
}
|
|
599
|
+
return null;
|
|
600
|
+
}
|
|
601
|
+
// src/fixcheck.ts
|
|
602
|
+
function F(e) {
|
|
603
|
+
return e.level === "error" ? P([e], []) : null;
|
|
604
|
+
}
|
|
605
|
+
function I(e) {
|
|
606
|
+
return P([], [e]);
|
|
607
|
+
}
|
|
608
|
+
function Te(e) {
|
|
609
|
+
let t = e.path ?? (() => location.pathname), n = e.random ?? Math.random, r = e.now ?? Date.now, i = [], a = /* @__PURE__ */ new Set(), o = r(), s = null, c = (t) => {
|
|
610
|
+
if (t) {
|
|
611
|
+
for (let n of i) if (!(n.signature !== t || a.has(n.id))) {
|
|
612
|
+
a.add(n.id);
|
|
613
|
+
try {
|
|
614
|
+
e.report(n);
|
|
615
|
+
} catch {}
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
}, l = (e) => {
|
|
619
|
+
let t = Date.parse(e);
|
|
620
|
+
return Number.isNaN(t) || t >= o - 1;
|
|
621
|
+
}, u = (r) => {
|
|
622
|
+
let u = t();
|
|
623
|
+
if (s = u, o = r, a = /* @__PURE__ */ new Set(), i = e.checks.filter((t) => Ee(t.path, u) && e.sampleRate > 0 && n() < e.sampleRate), i.length) {
|
|
624
|
+
for (let t of e.console.toArray()) l(t.at) && c(F(t));
|
|
625
|
+
for (let t of e.network.toArray()) l(t.at) && c(I(t));
|
|
626
|
+
}
|
|
627
|
+
}, d = e.console.subscribe((e) => {
|
|
628
|
+
i.length && c(F(e));
|
|
629
|
+
}), f = e.network.subscribe((e) => {
|
|
630
|
+
i.length && c(I(e));
|
|
631
|
+
}), p = typeof performance < "u" && performance.timeOrigin ? performance.timeOrigin : r();
|
|
632
|
+
return u(Math.min(p, r())), {
|
|
633
|
+
navigated: () => {
|
|
634
|
+
t() !== s && u(r());
|
|
635
|
+
},
|
|
636
|
+
stop: () => {
|
|
637
|
+
d(), f(), i = [];
|
|
638
|
+
}
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
function Ee(e, t) {
|
|
642
|
+
let n = (e) => e.length > 1 ? e.replace(/\/+$/, "") : e;
|
|
643
|
+
return n(e) === n(t);
|
|
644
|
+
}
|
|
645
|
+
// src/mount.ts
|
|
646
|
+
var L = "pinax-widget-root";
|
|
647
|
+
function De(e = document) {
|
|
648
|
+
let t = e.getElementById(L);
|
|
649
|
+
if (t?.shadowRoot) return t.shadowRoot;
|
|
650
|
+
let n = e.createElement("div");
|
|
651
|
+
return n.id = L, n.className = "ph-no-capture fs-exclude", n.setAttribute("data-hj-suppress", ""), n.setAttribute("data-clarity-mask", "true"), n.setAttribute("data-private", ""), n.style.cssText = "all: initial; position: fixed; z-index: 2147483647;", e.body.appendChild(n), n.attachShadow({ mode: "open" });
|
|
652
|
+
}
|
|
653
|
+
function Oe(e = document) {
|
|
654
|
+
e.getElementById(L)?.remove();
|
|
655
|
+
}
|
|
656
|
+
// src/navigation.ts
|
|
657
|
+
function ke(e, t = window) {
|
|
658
|
+
let n = !0, r = !1, i = () => {
|
|
659
|
+
if (!n || r) return;
|
|
660
|
+
r = !0;
|
|
661
|
+
let t = () => {
|
|
662
|
+
if (r = !1, n) try {
|
|
663
|
+
e();
|
|
664
|
+
} catch {}
|
|
665
|
+
};
|
|
666
|
+
try {
|
|
667
|
+
queueMicrotask(t);
|
|
668
|
+
} catch {
|
|
669
|
+
setTimeout(t, 0);
|
|
670
|
+
}
|
|
671
|
+
}, a = [], o = t.history;
|
|
672
|
+
for (let e of ["pushState", "replaceState"]) {
|
|
673
|
+
let t = o?.[e];
|
|
674
|
+
if (typeof t != "function") continue;
|
|
675
|
+
let n = function(...e) {
|
|
676
|
+
let n = t.apply(this, e);
|
|
677
|
+
return i(), n;
|
|
678
|
+
};
|
|
679
|
+
try {
|
|
680
|
+
o[e] = n, a.push(() => {
|
|
681
|
+
o[e] === n && (o[e] = t);
|
|
682
|
+
});
|
|
683
|
+
} catch {}
|
|
684
|
+
}
|
|
685
|
+
return t.addEventListener("popstate", i), a.push(() => t.removeEventListener("popstate", i)), () => {
|
|
686
|
+
n = !1;
|
|
687
|
+
for (let e of a) try {
|
|
688
|
+
e();
|
|
689
|
+
} catch {}
|
|
690
|
+
};
|
|
691
|
+
}
|
|
692
|
+
// src/paths.ts
|
|
693
|
+
var R = /* @__PURE__ */ new Map();
|
|
694
|
+
function Ae(e) {
|
|
695
|
+
let t = R.get(e);
|
|
696
|
+
if (!t) {
|
|
697
|
+
let n = z(e.trim()).split("*").map((e) => e.replace(/[.+?^${}()|[\]\\]/g, "\\$&")).join(".*");
|
|
698
|
+
t = RegExp(`^${n}$`), R.size > 200 && R.clear(), R.set(e, t);
|
|
699
|
+
}
|
|
700
|
+
return t;
|
|
701
|
+
}
|
|
702
|
+
function z(e) {
|
|
703
|
+
return e.length > 1 ? e.replace(/\/+$/, "") || "/" : e;
|
|
704
|
+
}
|
|
705
|
+
function je(e) {
|
|
706
|
+
try {
|
|
707
|
+
return decodeURI(e);
|
|
708
|
+
} catch {
|
|
709
|
+
return e;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
function Me(e, t) {
|
|
713
|
+
if (typeof e != "string" || !e.trim()) return !1;
|
|
714
|
+
let n = Ae(e), r = z(t || "/"), i = [r, `${r === "/" ? "" : r}/`], a = je(r);
|
|
715
|
+
return a !== r && i.push(a, `${a}/`), i.some((e) => n.test(e));
|
|
716
|
+
}
|
|
717
|
+
function Ne(e, t) {
|
|
718
|
+
return e?.length ? e.some((e) => Me(e, t)) : !1;
|
|
719
|
+
}
|
|
720
|
+
// src/queue.ts
|
|
721
|
+
var Pe = 864e5, Fe = 8, B = (e) => `pinax:queue:${e}`;
|
|
722
|
+
function V(e, t) {
|
|
723
|
+
try {
|
|
724
|
+
let n = e.getItem(B(t)), r = n ? JSON.parse(n) : [];
|
|
725
|
+
return Array.isArray(r) ? r : [];
|
|
726
|
+
} catch {
|
|
727
|
+
return [];
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
function H(e, t, n) {
|
|
731
|
+
try {
|
|
732
|
+
return n.length ? e.setItem(B(t), JSON.stringify(n)) : e.removeItem(B(t)), !0;
|
|
733
|
+
} catch {
|
|
734
|
+
return !1;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
function U() {
|
|
738
|
+
try {
|
|
739
|
+
return window.localStorage;
|
|
740
|
+
} catch {
|
|
741
|
+
return null;
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
function Ie(e) {
|
|
745
|
+
let { user: t, console: n, screenshot: r, annotations: i, replay: a, ...o } = e;
|
|
746
|
+
return {
|
|
747
|
+
...o,
|
|
748
|
+
page: {
|
|
749
|
+
...o.page,
|
|
750
|
+
url: l(o.page.url)
|
|
751
|
+
}
|
|
752
|
+
};
|
|
753
|
+
}
|
|
754
|
+
function Le(e, t) {
|
|
755
|
+
let n = U();
|
|
756
|
+
return n ? H(n, e, [...V(n, e).slice(-4), {
|
|
757
|
+
body: Ie(t),
|
|
758
|
+
queuedAt: Date.now(),
|
|
759
|
+
tries: 0
|
|
760
|
+
}]) : !1;
|
|
761
|
+
}
|
|
762
|
+
function Re(e) {
|
|
763
|
+
let t = U();
|
|
764
|
+
return t ? V(t, e).length : 0;
|
|
765
|
+
}
|
|
766
|
+
var W = !1;
|
|
767
|
+
async function ze(e, t, n) {
|
|
768
|
+
let r = U();
|
|
769
|
+
if (r && !W && (typeof navigator > "u" || navigator.onLine !== !1)) {
|
|
770
|
+
W = !0;
|
|
771
|
+
try {
|
|
772
|
+
let i = V(r, n), a = [];
|
|
773
|
+
for (let r of i) {
|
|
774
|
+
if (Date.now() - r.queuedAt > Pe) continue;
|
|
775
|
+
let i = await re(e, t, n, r.body);
|
|
776
|
+
!i.ok && i.retry && r.tries + 1 < Fe && a.push({
|
|
777
|
+
...r,
|
|
778
|
+
tries: r.tries + 1
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
let o = V(r, n).slice(i.length);
|
|
782
|
+
H(r, n, [...a, ...o]);
|
|
783
|
+
} finally {
|
|
784
|
+
W = !1;
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
// src/segment.ts
|
|
789
|
+
var G = {
|
|
790
|
+
opened: "Pinax Widget Opened",
|
|
791
|
+
submitted: "Feedback Submitted"
|
|
792
|
+
};
|
|
793
|
+
function K(e = window) {
|
|
794
|
+
try {
|
|
795
|
+
let t = e.analytics;
|
|
796
|
+
return !t || typeof t != "object" && typeof t != "function" ? null : typeof t.track == "function" ? t : null;
|
|
797
|
+
} catch {
|
|
798
|
+
return null;
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
function Be(e, t) {
|
|
802
|
+
return typeof e == "boolean" ? e : t === !0;
|
|
803
|
+
}
|
|
804
|
+
function q(e, t) {
|
|
805
|
+
try {
|
|
806
|
+
K()?.track?.(e, t);
|
|
807
|
+
} catch {}
|
|
808
|
+
}
|
|
809
|
+
function Ve() {
|
|
810
|
+
q(G.opened, { source: "pinax" });
|
|
811
|
+
}
|
|
812
|
+
function He(e) {
|
|
813
|
+
let t = {
|
|
814
|
+
source: "pinax",
|
|
815
|
+
type: e.type.toLowerCase()
|
|
816
|
+
};
|
|
817
|
+
typeof e.rating == "number" && (t.rating = e.rating), e.reportId && (t.reportId = e.reportId), e.queued && (t.queued = !0), q(G.submitted, t);
|
|
818
|
+
}
|
|
819
|
+
function Ue() {
|
|
820
|
+
try {
|
|
821
|
+
let e = K()?.user?.()?.id?.();
|
|
822
|
+
return typeof e == "string" && e.trim() ? e.trim().slice(0, 200) : typeof e == "number" && Number.isFinite(e) ? String(e) : null;
|
|
823
|
+
} catch {
|
|
824
|
+
return null;
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
// src/index.ts
|
|
828
|
+
var J = null, Y, We, X = (e, t) => (We ?? window.fetch).call(window, e, t);
|
|
829
|
+
function Z(e, t) {
|
|
830
|
+
try {
|
|
831
|
+
(console.warn.__pinaxOriginal ?? console.warn).call(console, `Pinax: ${e}`, t ?? "");
|
|
832
|
+
} catch {}
|
|
833
|
+
}
|
|
834
|
+
function Q(e) {
|
|
835
|
+
try {
|
|
836
|
+
e();
|
|
837
|
+
} catch (e) {
|
|
838
|
+
Z("capture could not start", e);
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
function Ge(e) {
|
|
842
|
+
if (J) return;
|
|
843
|
+
if (!e?.key) throw Error("Pinax: init() needs a website key");
|
|
844
|
+
let t = u(e.apiUrl), r = d(e.cdnUrl, e.apiUrl);
|
|
845
|
+
We = typeof window.fetch == "function" ? window.fetch : void 0;
|
|
846
|
+
let a = {
|
|
847
|
+
options: e,
|
|
848
|
+
api: t,
|
|
849
|
+
root: De(),
|
|
850
|
+
user: Y,
|
|
851
|
+
console: new j(50),
|
|
852
|
+
network: new j(50),
|
|
853
|
+
breadcrumbs: new j(20),
|
|
854
|
+
stopCapture: {},
|
|
855
|
+
onNavigate: [],
|
|
856
|
+
cleanups: [],
|
|
857
|
+
openWhenReady: !1,
|
|
858
|
+
alive: !0
|
|
859
|
+
};
|
|
860
|
+
J = a, Y = void 0, Q(() => {
|
|
861
|
+
let e = $(ve(a.console));
|
|
862
|
+
a.stopCapture.console = e, a.cleanups.push(e);
|
|
863
|
+
}), Q(() => {
|
|
864
|
+
let n = $(Ce(a.network, window, { ignore: (n) => n.startsWith(`${t}/v1/widget/`) || r !== null && n.startsWith(f(r, e.key)) }));
|
|
865
|
+
a.stopCapture.network = n, a.cleanups.push(n);
|
|
866
|
+
});
|
|
867
|
+
let s = a.root.host;
|
|
868
|
+
Q(() => {
|
|
869
|
+
let e = pe(a.breadcrumbs, { ignore: (e) => e instanceof Node && s.contains(e) });
|
|
870
|
+
a.onNavigate.push(e.navigated), a.cleanups.push(e.stop);
|
|
871
|
+
}), Q(() => a.cleanups.push(ke(() => {
|
|
872
|
+
for (let e of a.onNavigate) try {
|
|
873
|
+
e();
|
|
874
|
+
} catch {}
|
|
875
|
+
})));
|
|
876
|
+
let l = () => {
|
|
877
|
+
ze(X, t, e.key).catch(() => {});
|
|
878
|
+
};
|
|
879
|
+
window.addEventListener("online", l), a.cleanups.push(() => window.removeEventListener("online", l)), ee(X, t, e.key, r).then((r) => {
|
|
880
|
+
if (!a.alive) return;
|
|
881
|
+
if (!r) {
|
|
882
|
+
Z("this website key was not found");
|
|
883
|
+
return;
|
|
884
|
+
}
|
|
885
|
+
let s = i(r.ai, r.samplingRate);
|
|
886
|
+
if (a.config = {
|
|
887
|
+
...r,
|
|
888
|
+
settings: o(r.settings),
|
|
889
|
+
branding: n(r.branding),
|
|
890
|
+
ai: s
|
|
891
|
+
}, Ke(a), te(X, t, e.key, location.href), Re(e.key) && l(), !r.enabled) return;
|
|
892
|
+
if (!nt(r.allowedDomains, location.hostname)) {
|
|
893
|
+
Z(`${location.hostname} isn't one of this website's allowed domains, so the button is hidden. Add it under Websites in Pinax.`);
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
896
|
+
qe(a);
|
|
897
|
+
let u = Be(e.segment, a.config.settings.segment);
|
|
898
|
+
s.replay && Math.random() < s.replaySampleRate && Ye(a);
|
|
899
|
+
let d = new c(a.root, a.config, {
|
|
900
|
+
takeScreenshot: async () => (await M()).takeScreenshot(a.root.host, { autoBlur: s.autoBlur }),
|
|
901
|
+
markUp: async (e) => (await M()).markUp(a.root, e),
|
|
902
|
+
submit: (e) => Ze(a, e, u),
|
|
903
|
+
user: () => a.user,
|
|
904
|
+
opened: u ? Ve : void 0,
|
|
905
|
+
followUp: s.followUp ? ({ type: n, message: r }) => ae(X, t, e.key, {
|
|
906
|
+
type: n,
|
|
907
|
+
message: r,
|
|
908
|
+
pagePath: location.pathname
|
|
909
|
+
}) : void 0
|
|
910
|
+
});
|
|
911
|
+
a.ui = d;
|
|
912
|
+
let { hidePaths: f, hideButton: p } = a.config.settings;
|
|
913
|
+
if (f.length && !p) {
|
|
914
|
+
let e = () => d.setPathHidden(Ne(f, location.pathname));
|
|
915
|
+
e(), a.onNavigate.push(e);
|
|
916
|
+
}
|
|
917
|
+
a.openWhenReady && d.open();
|
|
918
|
+
}).catch((e) => {
|
|
919
|
+
a.alive && Z("could not load widget settings", e);
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
function $(e) {
|
|
923
|
+
let t = !1;
|
|
924
|
+
return () => {
|
|
925
|
+
t || (t = !0, e());
|
|
926
|
+
};
|
|
927
|
+
}
|
|
928
|
+
function Ke(e) {
|
|
929
|
+
let t = e.config?.settings.capture;
|
|
930
|
+
t && (t.console || (Q(() => e.stopCapture.console?.()), e.console.clear()), t.network || (Q(() => e.stopCapture.network?.()), e.network.clear()));
|
|
931
|
+
}
|
|
932
|
+
function qe(e) {
|
|
933
|
+
let t = e.config?.ai;
|
|
934
|
+
!t?.fixChecks.length || t.fixCheckSampleRate <= 0 || Q(() => {
|
|
935
|
+
let n = Te({
|
|
936
|
+
checks: t.fixChecks,
|
|
937
|
+
sampleRate: t.fixCheckSampleRate,
|
|
938
|
+
console: e.console,
|
|
939
|
+
network: e.network,
|
|
940
|
+
report: (t) => oe(X, e.api, e.options.key, {
|
|
941
|
+
checkId: t.id,
|
|
942
|
+
signature: t.signature
|
|
943
|
+
})
|
|
944
|
+
});
|
|
945
|
+
e.onNavigate.push(n.navigated), e.cleanups.push(n.stop);
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
function Je(e) {
|
|
949
|
+
let t = () => {
|
|
950
|
+
let t = window.requestIdleCallback;
|
|
951
|
+
typeof t == "function" ? t(e, { timeout: 3e3 }) : setTimeout(e, 200);
|
|
952
|
+
};
|
|
953
|
+
document.readyState === "complete" ? t() : window.addEventListener("load", t, { once: !0 });
|
|
954
|
+
}
|
|
955
|
+
function Ye(e) {
|
|
956
|
+
Je(() => {
|
|
957
|
+
e.alive && we().then((t) => {
|
|
958
|
+
if (!e.alive) return;
|
|
959
|
+
let n = t.startRecorder({ exclude: `#${e.root.host.id}` });
|
|
960
|
+
e.recorder = n, e.cleanups.push(() => n.stop());
|
|
961
|
+
}).catch((e) => Z("session replay could not start", e));
|
|
962
|
+
});
|
|
963
|
+
}
|
|
964
|
+
async function Xe(e) {
|
|
965
|
+
if (!e.recorder) return null;
|
|
966
|
+
let t;
|
|
967
|
+
try {
|
|
968
|
+
return await Promise.race([e.recorder.exportReplay(s.replayChars).catch(() => null), new Promise((e) => {
|
|
969
|
+
t = setTimeout(() => e(null), 5e3);
|
|
970
|
+
})]);
|
|
971
|
+
} finally {
|
|
972
|
+
clearTimeout(t);
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
async function Ze(t, n, i = !1) {
|
|
976
|
+
let o = i && !t.user?.id ? Ue() : null, s = o ? {
|
|
977
|
+
...t.user,
|
|
978
|
+
id: o
|
|
979
|
+
} : t.user, c = t.config?.settings.capture, l = a({
|
|
980
|
+
type: n.type,
|
|
981
|
+
message: n.message,
|
|
982
|
+
rating: n.rating,
|
|
983
|
+
email: n.email,
|
|
984
|
+
user: s,
|
|
985
|
+
screenshot: n.shot?.dataUrl,
|
|
986
|
+
annotations: n.shot?.annotations,
|
|
987
|
+
followUp: n.followUp,
|
|
988
|
+
fields: n.fields,
|
|
989
|
+
hp: n.hp,
|
|
990
|
+
elapsedMs: n.elapsedMs
|
|
991
|
+
}, {
|
|
992
|
+
page: {
|
|
993
|
+
url: e(location.href),
|
|
994
|
+
title: document.title || void 0
|
|
995
|
+
},
|
|
996
|
+
environment: xe(),
|
|
997
|
+
console: c?.console === !1 ? [] : t.console.toArray(),
|
|
998
|
+
network: c?.network === !1 ? [] : t.network.toArray(),
|
|
999
|
+
breadcrumbs: t.breadcrumbs.toArray()
|
|
1000
|
+
});
|
|
1001
|
+
r(l, await Xe(t));
|
|
1002
|
+
let u = await re(X, t.api, t.options.key, l), d = (e, t) => {
|
|
1003
|
+
i && He({
|
|
1004
|
+
type: n.type,
|
|
1005
|
+
rating: n.rating,
|
|
1006
|
+
reportId: t,
|
|
1007
|
+
queued: e
|
|
1008
|
+
});
|
|
1009
|
+
};
|
|
1010
|
+
return u.ok ? (d(!1, u.id || void 0), { status: "sent" }) : u.retry && Le(t.options.key, l) ? (d(!0), { status: "queued" }) : {
|
|
1011
|
+
status: "error",
|
|
1012
|
+
message: u.message
|
|
1013
|
+
};
|
|
1014
|
+
}
|
|
1015
|
+
function Qe() {
|
|
1016
|
+
J ? J.ui ? J.ui.open() : J.config || (J.openWhenReady = !0) : Z("call init() before open()");
|
|
1017
|
+
}
|
|
1018
|
+
function $e(e) {
|
|
1019
|
+
let t = e ? { ...e } : void 0;
|
|
1020
|
+
J ? J.user = t : Y = t;
|
|
1021
|
+
}
|
|
1022
|
+
function et() {
|
|
1023
|
+
if (J) {
|
|
1024
|
+
J.alive = !1, J.ui?.destroy();
|
|
1025
|
+
for (let e of J.cleanups.reverse()) try {
|
|
1026
|
+
e();
|
|
1027
|
+
} catch {}
|
|
1028
|
+
}
|
|
1029
|
+
Oe(), J = null, Y = void 0;
|
|
1030
|
+
}
|
|
1031
|
+
function tt() {
|
|
1032
|
+
return J;
|
|
1033
|
+
}
|
|
1034
|
+
function nt(e, t) {
|
|
1035
|
+
if (!e) return !0;
|
|
1036
|
+
let n = t.toLowerCase();
|
|
1037
|
+
return e.some((e) => e.toLowerCase() === n);
|
|
1038
|
+
}
|
|
1039
|
+
export { et as destroy, tt as getState, $e as identify, Ge as init, Qe as open };
|
|
1040
|
+
|
|
1041
|
+
//# sourceMappingURL=pinax.mjs.map
|