@sailfish-ai/recorder 1.11.0 → 1.11.3

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.
Files changed (65) hide show
  1. package/README.md +94 -0
  2. package/dist/chunks/{chunkSerializer-ZzIoYlP2.js → chunkSerializer-CV4nkb5-.js} +1 -1
  3. package/dist/chunks/chunkSerializer-CV4nkb5-.js.br +0 -0
  4. package/dist/chunks/chunkSerializer-CV4nkb5-.js.gz +0 -0
  5. package/dist/chunks/{chunkSerializer-CRDpgzTs.js → chunkSerializer-jzbHv2wf.js} +1 -1
  6. package/dist/chunks/chunkSerializer-jzbHv2wf.js.br +0 -0
  7. package/dist/chunks/chunkSerializer-jzbHv2wf.js.gz +0 -0
  8. package/dist/chunks/{index-BQn1Q-2-.js → index-BP-kNUGS.js} +174 -134
  9. package/dist/chunks/index-BP-kNUGS.js.br +0 -0
  10. package/dist/chunks/index-BP-kNUGS.js.gz +0 -0
  11. package/dist/chunks/{index-Dq_tjmkZ.js → index-BynFTRFv.js} +130 -87
  12. package/dist/chunks/index-BynFTRFv.js.br +0 -0
  13. package/dist/chunks/index-BynFTRFv.js.gz +0 -0
  14. package/dist/chunks/rrweb-plugin-performance-record-BYWkWb25.js +188 -0
  15. package/dist/chunks/rrweb-plugin-performance-record-BYWkWb25.js.br +0 -0
  16. package/dist/chunks/rrweb-plugin-performance-record-BYWkWb25.js.gz +0 -0
  17. package/dist/chunks/rrweb-plugin-performance-record-Dekf6xUi.js +186 -0
  18. package/dist/chunks/rrweb-plugin-performance-record-Dekf6xUi.js.br +0 -0
  19. package/dist/chunks/rrweb-plugin-performance-record-Dekf6xUi.js.gz +0 -0
  20. package/dist/constants.js +1 -0
  21. package/dist/constants.js.br +0 -0
  22. package/dist/constants.js.gz +0 -0
  23. package/dist/inAppReportIssueModal/index.js +15 -14
  24. package/dist/inAppReportIssueModal/index.js.br +0 -0
  25. package/dist/inAppReportIssueModal/index.js.gz +0 -0
  26. package/dist/inAppReportIssueModal/integrations.js +56 -4
  27. package/dist/inAppReportIssueModal/integrations.js.br +0 -0
  28. package/dist/inAppReportIssueModal/integrations.js.gz +0 -0
  29. package/dist/index.js +68 -42
  30. package/dist/index.js.br +0 -0
  31. package/dist/index.js.gz +0 -0
  32. package/dist/recorder.cjs +2 -2
  33. package/dist/recorder.cjs.br +0 -0
  34. package/dist/recorder.cjs.gz +0 -0
  35. package/dist/recorder.js +27 -25
  36. package/dist/recorder.js.br +0 -0
  37. package/dist/recorder.js.gz +0 -0
  38. package/dist/recorder.umd.cjs +4994 -4776
  39. package/dist/recorder.umd.cjs.br +0 -0
  40. package/dist/recorder.umd.cjs.gz +0 -0
  41. package/dist/recording.js +33 -3
  42. package/dist/recording.js.br +0 -0
  43. package/dist/recording.js.gz +0 -0
  44. package/dist/sendSailfishMessages.js +4 -0
  45. package/dist/sendSailfishMessages.js.br +0 -0
  46. package/dist/sendSailfishMessages.js.gz +0 -0
  47. package/dist/snippet-auto-init.js +147 -18
  48. package/dist/snippet-auto-init.js.br +0 -0
  49. package/dist/snippet-auto-init.js.gz +0 -0
  50. package/dist/types/constants.d.ts +1 -0
  51. package/dist/types/inAppReportIssueModal/integrations.d.ts +7 -0
  52. package/dist/types/index.d.ts +23 -1
  53. package/dist/types/recording.d.ts +1 -0
  54. package/dist/types/sendSailfishMessages.d.ts +4 -0
  55. package/dist/types/snippet-auto-init.d.ts +30 -0
  56. package/dist/types/types.d.ts +1 -0
  57. package/package.json +7 -4
  58. package/dist/chunks/chunkSerializer-CRDpgzTs.js.br +0 -0
  59. package/dist/chunks/chunkSerializer-CRDpgzTs.js.gz +0 -0
  60. package/dist/chunks/chunkSerializer-ZzIoYlP2.js.br +0 -0
  61. package/dist/chunks/chunkSerializer-ZzIoYlP2.js.gz +0 -0
  62. package/dist/chunks/index-BQn1Q-2-.js.br +0 -0
  63. package/dist/chunks/index-BQn1Q-2-.js.gz +0 -0
  64. package/dist/chunks/index-Dq_tjmkZ.js.br +0 -0
  65. package/dist/chunks/index-Dq_tjmkZ.js.gz +0 -0
Binary file
Binary file
@@ -370,7 +370,7 @@ function initializeWebSocket(t2, n2, i2, o2, s2 = false) {
370
370
  const t3 = new URL(e2);
371
371
  return `${t3.hostname}${t3.port ? `:${t3.port}` : ""}`;
372
372
  })(t2);
373
- let r2 = `${"https:" === new URL(t2).protocol ? "wss" : "ws"}://${a2}/ws/notify/?apiKey=${n2}&sessionId=${i2}&sender=JS%2FTS&version=1.11.0`;
373
+ let r2 = `${"https:" === new URL(t2).protocol ? "wss" : "ws"}://${a2}/ws/notify/?apiKey=${n2}&sessionId=${i2}&sender=JS%2FTS&version=1.11.3`;
374
374
  if (o2 && (r2 += `&envValue=${encodeURIComponent(o2)}`), k = s2 ? (function tryCreateWsWorker() {
375
375
  if ("undefined" == typeof Worker) return null;
376
376
  try {
@@ -426,37 +426,40 @@ function getFuncSpanHeader() {
426
426
  return { name: "X-Sf3-FunctionSpanCaptureOverride", value: "1-1-10-10-1-1.0-1-0-0" };
427
427
  }
428
428
  const O = Object.freeze(Object.defineProperty({ __proto__: null, clearStaleFuncSpanState, disableFunctionSpanTracking, enableFunctionSpanTracking, ensureHrefCache, flushBufferedEvents, getCachedHref, getCachedHrefNoQuery, getFuncSpanHeader, initializeFunctionSpanTrackingFromApi, initializeWebSocket, isFunctionSpanTrackingEnabled, onNavigationChange, restoreFuncSpanState, sendEvent, sendMessage }, Symbol.toStringTag, { value: "Module" }));
429
- let z = null, U = null;
429
+ let U = null, z = null;
430
+ function getIdentifiedUser() {
431
+ return U;
432
+ }
430
433
  function identify(e2, t2 = {}, n2 = false) {
431
434
  const i2 = { type: "identify", userId: e2, traits: t2 };
432
- z && z.userId === e2 && JSON.stringify(z.traits) === JSON.stringify(t2) || (z = { userId: e2, traits: t2, overwrite: n2 }, sendMessage(i2));
435
+ U && U.userId === e2 && JSON.stringify(U.traits) === JSON.stringify(t2) || (U = { userId: e2, traits: t2, overwrite: n2 }, sendMessage(i2));
433
436
  }
434
437
  function addOrUpdateMetadata(e2) {
435
438
  const t2 = { type: "addOrUpdateMetadata", metadata: e2 };
436
- U && JSON.stringify(U) === JSON.stringify(e2) || (U = e2, sendMessage(t2));
439
+ z && JSON.stringify(z) === JSON.stringify(e2) || (z = e2, sendMessage(t2));
437
440
  }
438
441
  function trackingEvent(e2) {
439
442
  sendMessage({ type: "trackingEvent", trackingData: e2, timestamp: w() });
440
443
  }
441
- let H = null;
442
- const q = ["https://api.ipify.org?format=json", "https://api.ip.sb/jsonip", "https://api4.my-ip.io/ip.json"];
444
+ let N = null;
445
+ const H = ["https://api.ipify.org?format=json", "https://api.ip.sb/jsonip", "https://api4.my-ip.io/ip.json"];
443
446
  function fetchAndSendIp(e2) {
444
- H !== e2 && (H = e2, (async () => {
445
- for (const e3 of q) try {
447
+ N !== e2 && (N = e2, (async () => {
448
+ for (const e3 of H) try {
446
449
  const t2 = new AbortController(), n2 = setTimeout(() => t2.abort(), 5e3), i2 = await fetch(e3, { signal: t2.signal });
447
450
  if (clearTimeout(n2), !i2.ok) continue;
448
451
  const o2 = await i2.json(), s2 = o2.ip || o2.origin || null;
449
452
  if (s2 && "string" == typeof s2 && s2.length <= 45) return void sendMessage({ type: "visitorIp", ip: s2, timestamp: w() });
450
453
  } catch {
451
454
  }
452
- H = null;
455
+ N = null;
453
456
  })().catch(() => {
454
- H = null;
457
+ N = null;
455
458
  }));
456
459
  }
457
- let N = null;
460
+ let q = null;
458
461
  async function getSourceMapModule() {
459
- return N || (N = await import("source-map-js")), N;
462
+ return q || (q = await import("source-map-js")), q;
460
463
  }
461
464
  const W = /* @__PURE__ */ new Map(), K = /(?:\(|\s|^)(https?:\/\/[^)\s]+|\/[^)\s]+|[^)\s]+)?\/?([^/]+\.js)(?:\?[^:)]*)?:(\d+):(\d+)/;
462
465
  async function getConsumerFor(e2, t2) {
@@ -658,6 +661,20 @@ function initializeDomContentEvents(e2) {
658
661
  sendEvent({ type: 24, data: { source: a }, timestamp: Date.now(), sessionId: e2, ...getUrlAndStoredUuids() });
659
662
  });
660
663
  }
664
+ async function initializePerformancePlugin(e2) {
665
+ var _a;
666
+ try {
667
+ const { getRecordPerformancePlugin: t2 } = await import("./rrweb-plugin-performance-record-BYWkWb25.js");
668
+ await yieldToMain();
669
+ const n2 = t2({ getPageVisitUuid: () => sessionStorage.getItem("pageVisitUUID") });
670
+ (_a = n2.observer) == null ? void 0 : _a.call(n2, (t3) => {
671
+ const i2 = t3;
672
+ sendEvent({ type: 28, timestamp: i2.timestamp, sessionId: e2, data: { plugin: n2.name, payload: i2 }, ...getUrlAndStoredUuids() });
673
+ }, window, n2.options);
674
+ } catch (e3) {
675
+ console.warn("[Sailfish] Performance plugin failed to initialize:", e3);
676
+ }
677
+ }
661
678
  async function initializeConsolePlugin(e2, n2) {
662
679
  const { getRecordConsolePlugin: i2 } = await import("@sailfish-rrweb/rrweb-plugin-console-record");
663
680
  await yieldToMain();
@@ -701,12 +718,12 @@ async function initializeRecording(e2, n2, i2, o2, s2, a2 = true, r2 = false, l2
701
718
  }
702
719
  const { record: n4 } = await import("@sailfish-rrweb/rrweb-record-only");
703
720
  if (J = n4, await yieldToMain(), l2) {
704
- const { chunkedSnapshot: i3 } = await import("./chunkSerializer-ZzIoYlP2.js"), o3 = n4.mirror;
721
+ const { chunkedSnapshot: i3 } = await import("./chunkSerializer-CV4nkb5-.js"), o3 = n4.mirror;
705
722
  let s3 = true;
706
723
  const a3 = [];
707
724
  n4({ emit(e3) {
708
725
  s3 ? a3.push(e3) : emitWithContext(e3);
709
- }, maskInputOptions: { text: true }, maskInputFn, maskTextClass: X, ...e2, recordDOM: false });
726
+ }, maskInputOptions: { text: true }, maskInputFn, ...e2, maskTextClass: e2.maskTextClass ?? X, recordDOM: false });
710
727
  const r3 = Date.now(), l3 = await i3(document, o3, { chunkSize: 500, maxChunkMs: 16, blockClass: e2.blockClass, blockSelector: e2.blockSelector, maskTextClass: e2.maskTextClass ?? X, maskTextSelector: e2.maskTextSelector });
711
728
  if (l3) {
712
729
  emitWithContext({ type: t.Meta, data: { href: window.location.href, width: document.documentElement.clientWidth || document.body.clientWidth, height: document.documentElement.clientHeight || document.body.clientHeight }, timestamp: r3 }), emitWithContext({ type: t.FullSnapshot, data: { node: l3, initialOffset: { left: void 0 !== window.pageXOffset ? window.pageXOffset : document.documentElement.scrollLeft, top: void 0 !== window.pageYOffset ? window.pageYOffset : document.documentElement.scrollTop } }, timestamp: r3 });
@@ -715,7 +732,7 @@ async function initializeRecording(e2, n2, i2, o2, s2, a2 = true, r2 = false, l2
715
732
  } else console.warn("[Sailfish] chunkSnapshot serialization failed; session continues without initial DOM snapshot"), s3 = false;
716
733
  } else n4({ emit(e3) {
717
734
  emitWithContext(e3);
718
- }, maskInputOptions: { text: true }, maskInputFn, maskTextClass: X, ...e2 });
735
+ }, maskInputOptions: { text: true }, maskInputFn, ...e2, maskTextClass: e2.maskTextClass ?? X });
719
736
  };
720
737
  if (a2) {
721
738
  let e3 = false;
@@ -930,12 +947,26 @@ function updateIssueTypeOptions(e2, t2) {
930
947
  }
931
948
  function getFieldsForProject(e2, t2) {
932
949
  if (!(re == null ? void 0 : re.fieldConfigurations) || !e2) return [];
933
- const n2 = Array.isArray(re.fieldConfigurations) ? re.fieldConfigurations.find((n3) => n3.project_key === e2 && (!t2 || n3.issue_type_id === t2)) : re.fieldConfigurations[e2];
950
+ const n2 = Array.isArray(re.fieldConfigurations) ? re.fieldConfigurations.find((n3) => !(n3.project_key !== e2 && String(n3.project_id) !== String(e2) || t2 && String(n3.issue_type_id) !== String(t2))) : re.fieldConfigurations[e2];
934
951
  return n2 && n2.fields ? n2.fields : [];
935
952
  }
936
953
  function getUsers() {
937
954
  return (re == null ? void 0 : re.users) ? re.users : [];
938
955
  }
956
+ function getDefaultReporterAccountId() {
957
+ const e2 = getUsers(), t2 = getIdentifiedUser();
958
+ if (!e2.length || !t2) return null;
959
+ const n2 = t2.traits || {}, i2 = (n2.email || t2.userId || "").toLowerCase().trim(), o2 = (n2.name || n2.displayName || n2.fullName || n2.full_name || (n2.firstName || n2.first_name ? `${n2.firstName || n2.first_name} ${n2.lastName || n2.last_name || ""}`.trim() : "") || "").toLowerCase().trim(), findUnique = (t3) => {
960
+ const n3 = e2.filter(t3);
961
+ return 1 === n3.length ? n3[0] : null;
962
+ };
963
+ let s2 = i2 ? findUnique((e3) => (e3.email || e3.emailAddress || "").toLowerCase().trim() === i2) : null;
964
+ if (!s2 && o2 && (s2 = findUnique((e3) => (e3.name || e3.displayName || "").toLowerCase().trim() === o2)), !s2 && i2) {
965
+ const e3 = i2.split("@")[0];
966
+ e3.length >= 3 && (s2 = findUnique((t3) => (t3.name || t3.displayName || "").toLowerCase().trim().includes(e3)));
967
+ }
968
+ return s2 && (s2.id || s2.accountId) || null;
969
+ }
939
970
  function getProjectsForTeam(e2) {
940
971
  if (!re) return [];
941
972
  const t2 = re.teams && Array.isArray(re.teams) && re.teams.length > 0;
@@ -968,7 +999,7 @@ const ce = Object.freeze(Object.defineProperty({ __proto__: null, fetchIntegrati
968
999
  } catch (e3) {
969
1000
  console.error("Error fetching integration data:", e3), re = null;
970
1001
  }
971
- }, getFieldsForProject, getIntegrationData, getProjectsForTeam, getSprintFieldId, getUsers, hasValidIntegration, populatePriorityOptions, populateSelectOptions, populateSprintOptions, refreshIntegrationData, updateFormWithIntegrationData, updateIssueTypeOptions }, Symbol.toStringTag, { value: "Module" })), de = "sf-create-issue-preference", ue = "sf-create-eng-ticket-preference";
1002
+ }, getDefaultReporterAccountId, getFieldsForProject, getIntegrationData, getProjectsForTeam, getSprintFieldId, getUsers, hasValidIntegration, populatePriorityOptions, populateSelectOptions, populateSprintOptions, refreshIntegrationData, updateFormWithIntegrationData, updateIssueTypeOptions }, Symbol.toStringTag, { value: "Module" })), de = "sf-create-issue-preference", ue = "sf-create-eng-ticket-preference";
972
1003
  function getInitialState() {
973
1004
  const e2 = (function loadUserPreferences() {
974
1005
  return { createIssue: f && "true" === localStorage.getItem(de), createEngTicket: f && "true" === localStorage.getItem(ue) };
@@ -1558,8 +1589,11 @@ function injectModalHTML(e2 = "lookback") {
1558
1589
  if (!hasValidIntegration()) return l2.checked = false, pe.createEngTicket = false, localStorage.setItem(ue, "false"), c2 && (c2.style.display = "none"), void alert("No engineering ticket integration found. Please install and configure an integration (Jira, Linear, or Zendesk) first.");
1559
1590
  const e5 = getIntegrationData();
1560
1591
  if (e5) {
1561
- if (!pe.engTicketTeam && e5.defaultTeam && (pe.engTicketTeam = e5.defaultTeam), !pe.engTicketProject && e5.defaultProject && (pe.engTicketProject = e5.defaultProject), !pe.engTicketPriority && e5.defaultPriority && (pe.engTicketPriority = e5.defaultPriority), updateFormWithIntegrationData(pe), "jira" === ((_a = e5.provider) == null ? void 0 : _a.toLowerCase()) && e5.jiraReporterAccountId && pe.engTicketProject) {
1562
- getFieldsForProject(pe.engTicketProject, pe.engTicketIssueType).find((e6) => "reporter" === e6.fieldId) && !pe.engTicketCustomFields.reporter && (pe.engTicketCustomFields.reporter = e5.jiraReporterAccountId);
1592
+ if (!pe.engTicketTeam && e5.defaultTeam && (pe.engTicketTeam = e5.defaultTeam), !pe.engTicketProject && e5.defaultProject && (pe.engTicketProject = e5.defaultProject), !pe.engTicketPriority && e5.defaultPriority && (pe.engTicketPriority = e5.defaultPriority), updateFormWithIntegrationData(pe), "jira" === ((_a = e5.provider) == null ? void 0 : _a.toLowerCase()) && pe.engTicketProject && !pe.engTicketCustomFields.reporter) {
1593
+ if (getFieldsForProject(pe.engTicketProject, pe.engTicketIssueType).find((e6) => "reporter" === e6.fieldId)) {
1594
+ const t5 = getDefaultReporterAccountId();
1595
+ pe.engTicketCustomFields.reporter = t5 || e5.jiraReporterAccountId || "";
1596
+ }
1563
1597
  }
1564
1598
  const t4 = document.getElementById("sf-eng-ticket-project"), n3 = document.getElementById("sf-eng-ticket-type");
1565
1599
  t4 && t4.value && renderDynamicFields(t4.value, n3 == null ? void 0 : n3.value);
@@ -1693,8 +1727,11 @@ function initializeEngTicketForm() {
1693
1727
  var _a;
1694
1728
  const e2 = be.integrationData;
1695
1729
  if (e2) {
1696
- if (!pe.engTicketTeam && e2.defaultTeam && (pe.engTicketTeam = e2.defaultTeam), !pe.engTicketProject && e2.defaultProject && (pe.engTicketProject = e2.defaultProject), !pe.engTicketPriority && e2.defaultPriority && (pe.engTicketPriority = e2.defaultPriority), updateFormWithIntegrationData(pe), "jira" === ((_a = e2.provider) == null ? void 0 : _a.toLowerCase()) && e2.jiraReporterAccountId && pe.engTicketProject) {
1697
- getFieldsForProject(pe.engTicketProject, pe.engTicketIssueType).find((e3) => "reporter" === e3.fieldId) && !pe.engTicketCustomFields.reporter && (pe.engTicketCustomFields.reporter = e2.jiraReporterAccountId);
1730
+ if (!pe.engTicketTeam && e2.defaultTeam && (pe.engTicketTeam = e2.defaultTeam), !pe.engTicketProject && e2.defaultProject && (pe.engTicketProject = e2.defaultProject), !pe.engTicketPriority && e2.defaultPriority && (pe.engTicketPriority = e2.defaultPriority), updateFormWithIntegrationData(pe), "jira" === ((_a = e2.provider) == null ? void 0 : _a.toLowerCase()) && pe.engTicketProject && !pe.engTicketCustomFields.reporter) {
1731
+ if (getFieldsForProject(pe.engTicketProject, pe.engTicketIssueType).find((e3) => "reporter" === e3.fieldId)) {
1732
+ const t2 = getDefaultReporterAccountId();
1733
+ pe.engTicketCustomFields.reporter = t2 || e2.jiraReporterAccountId || "";
1734
+ }
1698
1735
  }
1699
1736
  pe.engTicketProject && renderDynamicFields(pe.engTicketProject, pe.engTicketIssueType);
1700
1737
  }
@@ -1732,8 +1769,11 @@ function bindEngTicketListeners() {
1732
1769
  var _a;
1733
1770
  pe.engTicketProject = t2.value, t2.style.color = t2.value ? "" : "#9ca3af", pe.engTicketCustomFields = {};
1734
1771
  const e3 = getIntegrationData();
1735
- if (e3 && o2 && (updateIssueTypeOptions(o2, t2.value), pe.engTicketIssueType = o2.value), e3 && "jira" === ((_a = e3.provider) == null ? void 0 : _a.toLowerCase()) && e3.jiraReporterAccountId && t2.value) {
1736
- getFieldsForProject(t2.value, pe.engTicketIssueType).find((e4) => "reporter" === e4.fieldId) && (pe.engTicketCustomFields.reporter = e3.jiraReporterAccountId);
1772
+ if (e3 && o2 && (updateIssueTypeOptions(o2, t2.value), pe.engTicketIssueType = o2.value), e3 && "jira" === ((_a = e3.provider) == null ? void 0 : _a.toLowerCase()) && t2.value) {
1773
+ if (getFieldsForProject(t2.value, pe.engTicketIssueType).find((e4) => "reporter" === e4.fieldId)) {
1774
+ const t3 = getDefaultReporterAccountId();
1775
+ pe.engTicketCustomFields.reporter = t3 || e3.jiraReporterAccountId || "";
1776
+ }
1737
1777
  }
1738
1778
  renderDynamicFields(t2.value, pe.engTicketIssueType);
1739
1779
  }), s2 && s2.addEventListener("change", () => {
@@ -1985,39 +2025,40 @@ function _ensureModuleSideEffects() {
1985
2025
  clearPageVisitDataFromSessionStorage();
1986
2026
  }));
1987
2027
  }
1988
- function matchUrlWithWildcard(e2, t2) {
1989
- let n2, i2;
1990
- if ("string" == typeof e2 ? n2 = e2 : "undefined" != typeof URL && e2 instanceof URL ? n2 = e2.href : "undefined" != typeof Request && e2 instanceof Request ? n2 = e2.url : null != e2 && "function" == typeof e2.toString && (n2 = e2.toString()), !n2) return false;
1991
- try {
1992
- const e3 = "undefined" != typeof window ? window.location.href : "http://localhost/";
1993
- i2 = new URL(n2, e3);
1994
- } catch {
1995
- return false;
1996
- }
1997
- const { hostname: o2, pathname: s2, port: a2, protocol: r2 } = i2;
1998
- if (!/^https?:$/.test(r2)) return false;
1999
- const l2 = o2.startsWith("www.") ? o2.slice(4).toLowerCase() : o2.toLowerCase();
2028
+ function matchParsedUrlAgainstPatterns(e2, t2) {
2029
+ const { hostname: n2, pathname: i2, port: o2 } = e2, s2 = n2.startsWith("www.") ? n2.slice(4).toLowerCase() : n2.toLowerCase();
2000
2030
  return t2.some((e3) => {
2001
2031
  const t3 = String(e3 || "").replace(/^[a-zA-Z]+:\/\//, "");
2002
- let [n3, i3] = t3.split("/", 2), o3 = "";
2003
- n3.includes(":") && ([n3, o3] = n3.split(":"));
2004
- const r3 = getCachedRegex(`^${n3.replace(/\./g, "\\.").replace(/\*/g, ".*")}$`, "i"), c2 = l2.startsWith("www.") ? l2.slice(4) : l2;
2005
- if (o3 && "*" !== o3 && a2 !== o3) return false;
2032
+ let [n3, a2] = t3.split("/", 2), r2 = "";
2033
+ n3.includes(":") && ([n3, r2] = n3.split(":"));
2034
+ const l2 = getCachedRegex(`^${n3.replace(/\./g, "\\.").replace(/\*/g, ".*")}$`, "i"), c2 = s2.startsWith("www.") ? s2.slice(4) : s2;
2035
+ if (r2 && "*" !== r2 && o2 !== r2) return false;
2006
2036
  if (n3.startsWith("*.")) {
2007
2037
  const e4 = n3.slice(2).toLowerCase();
2008
- if (!(l2 === e4 || c2 === e4 || l2.endsWith("." + e4))) return false;
2009
- if (i3) {
2010
- return getCachedRegex(`^/${i3.replace(/\*/g, ".*").replace(/\/$/, "")}`, "i").test(s2);
2038
+ if (!(s2 === e4 || c2 === e4 || s2.endsWith("." + e4))) return false;
2039
+ if (a2) {
2040
+ return getCachedRegex(`^/${a2.replace(/\*/g, ".*").replace(/\/$/, "")}`, "i").test(i2);
2011
2041
  }
2012
2042
  return true;
2013
2043
  }
2014
- if (!r3.test(c2) && !r3.test(l2)) return false;
2015
- if (i3) {
2016
- return getCachedRegex(`^/${i3.replace(/\*/g, ".*").replace(/\/$/, "")}`, "i").test(s2);
2044
+ if (!l2.test(c2) && !l2.test(s2)) return false;
2045
+ if (a2) {
2046
+ return getCachedRegex(`^/${a2.replace(/\*/g, ".*").replace(/\/$/, "")}`, "i").test(i2);
2017
2047
  }
2018
2048
  return true;
2019
2049
  });
2020
2050
  }
2051
+ function matchUrlWithWildcard(e2, t2) {
2052
+ let n2, i2;
2053
+ if ("string" == typeof e2 ? n2 = e2 : "undefined" != typeof URL && e2 instanceof URL ? n2 = e2.href : "undefined" != typeof Request && e2 instanceof Request ? n2 = e2.url : null != e2 && "function" == typeof e2.toString && (n2 = e2.toString()), !n2) return false;
2054
+ try {
2055
+ const e3 = "undefined" != typeof window ? window.location.href : "http://localhost/";
2056
+ i2 = new URL(n2, e3);
2057
+ } catch {
2058
+ return false;
2059
+ }
2060
+ return matchParsedUrlAgainstPatterns(i2, t2);
2061
+ }
2021
2062
  function createSkipHeadersPropagationChecker(e2 = [], t2 = []) {
2022
2063
  const n2 = [...Te, ...e2], i2 = t2.length > 0;
2023
2064
  return function shouldSkipHeadersPropagation(e3) {
@@ -2028,7 +2069,7 @@ function createSkipHeadersPropagationChecker(e2 = [], t2 = []) {
2028
2069
  return true;
2029
2070
  }
2030
2071
  const s2 = o2.pathname.toLowerCase(), a2 = s2.lastIndexOf(".");
2031
- return !(-1 === a2 || !Ie.has(s2.slice(a2))) || (!(!i2 || matchUrlWithWildcard(e3, t2)) || !!matchUrlWithWildcard(e3, n2));
2072
+ return !(-1 === a2 || !Ie.has(s2.slice(a2))) || (!(!i2 || matchParsedUrlAgainstPatterns(o2, t2)) || !!matchParsedUrlAgainstPatterns(o2, n2));
2032
2073
  };
2033
2074
  }
2034
2075
  function setupFetchInterceptor(e2 = [], t2 = { captureStreamingResponseBody: true, captureResponseBodyMaxMb: 10, captureStreamPrefixKb: 64, captureStreamTimeoutMs: 1e4 }, i2 = []) {
@@ -2201,9 +2242,9 @@ function setupFetchInterceptor(e2 = [], t2 = { captureStreamingResponseBody: tru
2201
2242
  })(e3, i3, o3, d2, u2, s2, c2);
2202
2243
  } });
2203
2244
  }
2204
- async function startRecording({ apiKey: e2, backendApi: t2 = "https://api-service.sailfishqa.com", domainsToPropagateHeaderTo: i2 = [], domainsToNotPropagateHeaderTo: o2 = [], serviceVersion: s2, serviceIdentifier: a2, gitSha: r2, serviceAdditionalMetadata: l2, enableIpTracking: c2, captureStreamingResponseBody: d2 = true, captureResponseBodyMaxMb: u2 = 10, captureStreamPrefixKb: p2 = 64, captureStreamTimeoutMs: f2 = 1e4, enableFiberTracking: m2 = false, deferRecording: h2, deferRecordingStart: y2, chunkSnapshot: b2, useWsWorker: w2 = true, library: v2 }) {
2245
+ async function startRecording({ apiKey: e2, backendApi: t2 = "https://api-service.sailfishqa.com", domainsToPropagateHeaderTo: i2 = ["*"], domainsToNotPropagateHeaderTo: o2 = [], serviceVersion: s2, serviceIdentifier: a2, gitSha: r2, serviceAdditionalMetadata: l2, enableIpTracking: c2, captureStreamingResponseBody: d2 = true, captureResponseBodyMaxMb: u2 = 10, captureStreamPrefixKb: p2 = 64, captureStreamTimeoutMs: f2 = 1e4, enableFiberTracking: m2 = false, deferRecording: h2, deferRecordingStart: y2, chunkSnapshot: b2, useWsWorker: w2 = true, capturePerformanceMetrics: v2 = true, maskTextClass: S2, library: k2, headlessRecording: x2 = false }) {
2205
2246
  var _a, _b;
2206
- if ((function isHeadlessOrLighthouse() {
2247
+ if (!x2 && (function isHeadlessOrLighthouse() {
2207
2248
  try {
2208
2249
  if ("undefined" == typeof navigator) return false;
2209
2250
  const e3 = navigator;
@@ -2214,10 +2255,10 @@ async function startRecording({ apiKey: e2, backendApi: t2 = "https://api-servic
2214
2255
  return false;
2215
2256
  }
2216
2257
  })()) return;
2217
- const S2 = h2 ?? y2 ?? true, k2 = getOrSetSessionId(), x2 = window.__sailfish_recorder || (window.__sailfish_recorder = {});
2218
- if (x2.sessionId = k2, x2.apiKey = e2, x2.backendApi = t2, x2.serviceAdditionalMetadata = l2, x2.initialized && x2.sessionId === k2 && x2.ws && 1 === x2.ws.readyState) return void trackDomainChangesOnce();
2219
- const I2 = { captureStreamingResponseBody: d2, captureResponseBodyMaxMb: u2, captureStreamPrefixKb: p2, captureStreamTimeoutMs: f2 };
2220
- sessionStorage.getItem("pageVisitUUID") || (sessionStorage.setItem("pageVisitUUID", uuidv4()), invalidateUrlCache()), x2.xhrPatched || (!(function setupXMLHttpRequestInterceptor(e3 = [], t3 = { captureStreamingResponseBody: true, captureResponseBodyMaxMb: 10, captureStreamPrefixKb: 64, captureStreamTimeoutMs: 1e4 }, i3 = []) {
2258
+ const I2 = h2 ?? y2 ?? true, T2 = getOrSetSessionId(), E2 = window.__sailfish_recorder || (window.__sailfish_recorder = {});
2259
+ if (E2.sessionId = T2, E2.apiKey = e2, E2.backendApi = t2, E2.serviceAdditionalMetadata = l2, E2.initialized && E2.sessionId === T2 && E2.ws && 1 === E2.ws.readyState) return void trackDomainChangesOnce();
2260
+ const C2 = { captureStreamingResponseBody: d2, captureResponseBodyMaxMb: u2, captureStreamPrefixKb: p2, captureStreamTimeoutMs: f2 };
2261
+ sessionStorage.getItem("pageVisitUUID") || (sessionStorage.setItem("pageVisitUUID", uuidv4()), invalidateUrlCache()), E2.xhrPatched || (!(function setupXMLHttpRequestInterceptor(e3 = [], t3 = { captureStreamingResponseBody: true, captureResponseBodyMaxMb: 10, captureStreamPrefixKb: 64, captureStreamTimeoutMs: 1e4 }, i3 = []) {
2221
2262
  const o3 = XMLHttpRequest.prototype.open, s3 = XMLHttpRequest.prototype.send, a3 = XMLHttpRequest.prototype.setRequestHeader, r3 = getOrSetSessionId(), l3 = createSkipHeadersPropagationChecker(e3, i3);
2222
2263
  XMLHttpRequest.prototype.setRequestHeader = function(e4, t4) {
2223
2264
  return this._capturedRequestHeaders || (this._capturedRequestHeaders = {}), this._capturedRequestHeaders[e4] = t4, a3.call(this, e4, t4);
@@ -2282,22 +2323,22 @@ async function startRecording({ apiKey: e2, backendApi: t2 = "https://api-servic
2282
2323
  emitFinished(false, e5, t4);
2283
2324
  }, { once: true }), s3.apply(this, e4);
2284
2325
  };
2285
- })(o2, I2, i2), x2.xhrPatched = true), x2.fetchPatched || (setupFetchInterceptor(o2, I2, i2), x2.fetchPatched = true), await yieldToMain(), x2.domEventsInit || (initializeDomContentEvents(k2), x2.domEventsInit = true), await yieldToMain(), x2.consoleInit || (initializeConsolePlugin(Ae, k2), x2.consoleInit = true), await yieldToMain(), x2.errorInit || (!(function initializeErrorInterceptor() {
2326
+ })(o2, C2, i2), E2.xhrPatched = true), E2.fetchPatched || (setupFetchInterceptor(o2, C2, i2), E2.fetchPatched = true), await yieldToMain(), E2.domEventsInit || (initializeDomContentEvents(T2), E2.domEventsInit = true), await yieldToMain(), E2.consoleInit || (initializeConsolePlugin(Ae, T2), E2.consoleInit = true), await yieldToMain(), E2.errorInit || (!(function initializeErrorInterceptor() {
2286
2327
  window.addEventListener("error", (e3) => {
2287
2328
  captureError(e3.error || e3.message);
2288
2329
  }), window.addEventListener("unhandledrejection", (e3) => {
2289
2330
  captureError(e3.reason, true);
2290
2331
  });
2291
- })(), x2.errorInit = true), await yieldToMain(), _ensureModuleSideEffects(), (function storeCredentialsAndConnection({ apiKey: e3, backendApi: t3 }) {
2332
+ })(), E2.errorInit = true), await yieldToMain(), !E2.perfInit && v2 && (initializePerformancePlugin(T2), E2.perfInit = true), await yieldToMain(), _ensureModuleSideEffects(), (function storeCredentialsAndConnection({ apiKey: e3, backendApi: t3 }) {
2292
2333
  g && (sessionStorage.setItem("sailfishApiKey", e3), sessionStorage.setItem("sailfishBackendApi", t3));
2293
- })({ apiKey: e2, backendApi: t2 }), !isFunctionSpanTrackingEnabled() || x2.ws && 1 === x2.ws.readyState || fetchFunctionSpanTrackingEnabled(e2, t2).then((e3) => {
2334
+ })({ apiKey: e2, backendApi: t2 }), !isFunctionSpanTrackingEnabled() || E2.ws && 1 === E2.ws.readyState || fetchFunctionSpanTrackingEnabled(e2, t2).then((e3) => {
2294
2335
  var _a2;
2295
2336
  ((_a2 = e3.data) == null ? void 0 : _a2.isFunctionSpanTrackingEnabledFromApiKey) ?? false ? ke && console.log("[Sailfish] Function span tracking state validated with backend: ACTIVE") : (clearStaleFuncSpanState(), ke && console.log("[Sailfish] Cleared stale function span tracking state - backend validation shows tracking is not active"));
2296
2337
  }).catch((e3) => {
2297
2338
  ke && console.warn("[Sailfish] Failed to validate function span tracking status with backend:", e3);
2298
- }), x2.sentDoNotPropagateOnce || (sendDomainsToNotPropagateHeaderTo(e2, [...o2, ...Te], t2).catch((e3) => console.error("Failed to send domains to not propagate header to:", e3)), x2.sentDoNotPropagateOnce = true), (async function gatherAndCacheDeviceInfo() {
2339
+ }), E2.sentDoNotPropagateOnce || (sendDomainsToNotPropagateHeaderTo(e2, [...o2, ...Te], t2).catch((e3) => console.error("Failed to send domains to not propagate header to:", e3)), E2.sentDoNotPropagateOnce = true), (async function gatherAndCacheDeviceInfo() {
2299
2340
  sendMessage({ type: "deviceInfo", data: { deviceInfo: { language: navigator.language, userAgent: navigator.userAgent } } });
2300
- })(), c2 && fetchAndSendIp(k2);
2341
+ })(), c2 && fetchAndSendIp(T2);
2301
2342
  try {
2302
2343
  const n2 = r2 ?? (function readGitSha() {
2303
2344
  var _a2;
@@ -2316,7 +2357,7 @@ async function startRecording({ apiKey: e2, backendApi: t2 = "https://api-servic
2316
2357
  if ("string" == typeof e3 && e3) return e3;
2317
2358
  } catch {
2318
2359
  }
2319
- })(), i3 = a2 ?? "", o3 = s2 ?? "", c3 = v2 ?? "JS/TS", d3 = (function getMapUuidFromWindow() {
2360
+ })(), i3 = a2 ?? "", o3 = s2 ?? "", c3 = k2 ?? "JS/TS", d3 = (function getMapUuidFromWindow() {
2320
2361
  try {
2321
2362
  const e3 = window;
2322
2363
  if (e3 && "string" == typeof e3.sfMapUuid && e3.sfMapUuid) return e3.sfMapUuid;
@@ -2336,15 +2377,15 @@ async function startRecording({ apiKey: e2, backendApi: t2 = "https://api-servic
2336
2377
  return { framework: i4[0] ?? null, additionalFrameworks: i4.slice(1), serviceRole: "frontend" };
2337
2378
  })(), f3 = { ...u3, serviceRole: p3.serviceRole, ...null !== p3.framework && { framework: p3.framework }, ...p3.additionalFrameworks.length > 0 && { additionalFrameworks: p3.additionalFrameworks } };
2338
2379
  await yieldToMain();
2339
- const [g2, h3] = await Promise.all([fetchCaptureSettings(e2, t2), startRecordingSession(e2, k2, t2, i3, o3, d3, n2, c3, f3)]), y3 = { ...Me, ...(_a = g2.data) == null ? void 0 : _a.captureSettingsFromApiKey, enableFiberTracking: m2 };
2340
- if (x2.ws && 1 === x2.ws.readyState) return;
2380
+ const [g2, h3] = await Promise.all([fetchCaptureSettings(e2, t2), startRecordingSession(e2, T2, t2, i3, o3, d3, n2, c3, f3)]), y3 = { ...Me, ...(_a = g2.data) == null ? void 0 : _a.captureSettingsFromApiKey, enableFiberTracking: m2, ...void 0 !== S2 ? { maskTextClass: S2 } : {} };
2381
+ if (E2.ws && 1 === E2.ws.readyState) return;
2341
2382
  if ((_b = h3.data) == null ? void 0 : _b.startRecordingSession) {
2342
2383
  const n3 = (l2 == null ? void 0 : l2.env) || (l2 == null ? void 0 : l2.environment);
2343
2384
  await yieldToMain();
2344
- const i4 = await initializeRecording(y3, t2, e2, k2, n3, S2, w2, b2 ?? false);
2345
- x2.ws = i4, x2.initialized = true, trackDomainChangesOnce(), x2.sentMapUuidOnce || (!(function sendMapUuidIfAvailable(e3 = "", t3 = "") {
2385
+ const i4 = await initializeRecording(y3, t2, e2, T2, n3, I2, w2, b2 ?? false);
2386
+ E2.ws = i4, E2.initialized = true, trackDomainChangesOnce(), E2.sentMapUuidOnce || (!(function sendMapUuidIfAvailable(e3 = "", t3 = "") {
2346
2387
  window.sfMapUuid && sendMessage({ type: "mapUuid", data: { mapUuid: window.sfMapUuid, serviceIdentifier: e3, serviceVersion: t3 } });
2347
- })(a2, s2), x2.sentMapUuidOnce = true);
2388
+ })(a2, s2), E2.sentMapUuidOnce = true);
2348
2389
  } else console.error("Failed to start recording session:", h3.errors || h3);
2349
2390
  } catch (e3) {
2350
2391
  console.error("Error starting recording:", e3);
@@ -2373,26 +2414,28 @@ const initRecorder = async (e2) => {
2373
2414
  })), t2.initPromise);
2374
2415
  };
2375
2416
  export {
2376
- initializeFunctionSpanTrackingFromApi as A,
2377
- initializeRecording as B,
2378
- initializeWebSocket as C,
2417
+ initializeDomContentEvents as A,
2418
+ initializeFunctionSpanTrackingFromApi as B,
2419
+ initializePerformancePlugin as C,
2379
2420
  Me as D,
2380
- invalidateUrlCache as E,
2381
- isFunctionSpanTrackingEnabled as F,
2382
- matchUrlWithWildcard as G,
2383
- w as H,
2384
- onNavigationChange as I,
2385
- openReportIssueModal as J,
2386
- restoreFuncSpanState as K,
2387
- sendDomainsToNotPropagateHeaderTo as L,
2388
- sendEvent as M,
2389
- sendGraphQLRequest as N,
2390
- sendMessage as O,
2391
- startRecording as P,
2392
- startRecordingSession as Q,
2393
- trackingEvent as R,
2421
+ initializeRecording as E,
2422
+ initializeWebSocket as F,
2423
+ invalidateUrlCache as G,
2424
+ isFunctionSpanTrackingEnabled as H,
2425
+ matchUrlWithWildcard as I,
2426
+ w as J,
2427
+ onNavigationChange as K,
2428
+ openReportIssueModal as L,
2429
+ restoreFuncSpanState as M,
2430
+ sendDomainsToNotPropagateHeaderTo as N,
2431
+ sendEvent as O,
2432
+ sendGraphQLRequest as P,
2433
+ sendMessage as Q,
2434
+ startRecording as R,
2394
2435
  $e as S,
2395
- withAppUrlMetadata as T,
2436
+ startRecordingSession as T,
2437
+ trackingEvent as U,
2438
+ withAppUrlMetadata as V,
2396
2439
  Ae as a,
2397
2440
  addOrUpdateMetadata as b,
2398
2441
  buildBatches as c,
@@ -2412,11 +2455,11 @@ export {
2412
2455
  getCachedHref as q,
2413
2456
  getCachedHrefNoQuery as r,
2414
2457
  getFuncSpanHeader as s,
2415
- getOrSetSessionId as t,
2416
- getUrlAndStoredUuids as u,
2417
- identify as v,
2418
- initRecorder as w,
2419
- initializeConsolePlugin as x,
2458
+ getIdentifiedUser as t,
2459
+ getOrSetSessionId as u,
2460
+ getUrlAndStoredUuids as v,
2461
+ identify as w,
2462
+ initRecorder as x,
2420
2463
  yieldToMain as y,
2421
- initializeDomContentEvents as z
2464
+ initializeConsolePlugin as z
2422
2465
  };
Binary file
Binary file
@@ -0,0 +1,188 @@
1
+ var e = -1, g = function(t2) {
2
+ addEventListener("pageshow", function(n2) {
3
+ n2.persisted && (e = n2.timeStamp, t2(n2));
4
+ }, true);
5
+ }, A = function() {
6
+ var e2 = self.performance && performance.getEntriesByType && performance.getEntriesByType("navigation")[0];
7
+ if (e2 && e2.responseStart > 0 && e2.responseStart < performance.now()) return e2;
8
+ }, h = function() {
9
+ var e2 = A();
10
+ return e2 && e2.activationStart || 0;
11
+ }, l = function(t2, n2) {
12
+ var r2 = A(), i2 = "navigate";
13
+ return e >= 0 ? i2 = "back-forward-cache" : r2 && (document.prerendering || h() > 0 ? i2 = "prerender" : document.wasDiscarded ? i2 = "restore" : r2.type && (i2 = r2.type.replace(/_/g, "-"))), { name: t2, value: -1, rating: "good", delta: 0, entries: [], id: "v4-".concat(Date.now(), "-").concat(Math.floor(8999999999999 * Math.random()) + 1e12), navigationType: i2 };
14
+ }, M = function(e2, t2, n2) {
15
+ try {
16
+ if (PerformanceObserver.supportedEntryTypes.includes(e2)) {
17
+ var r2 = new PerformanceObserver(function(e3) {
18
+ Promise.resolve().then(function() {
19
+ t2(e3.getEntries());
20
+ });
21
+ });
22
+ return r2.observe(Object.assign({ type: e2, buffered: true }, n2 || {})), r2;
23
+ }
24
+ } catch {
25
+ }
26
+ }, m = function(e2, t2, n2, r2) {
27
+ var i2, s2;
28
+ return function(d2) {
29
+ var f, p;
30
+ t2.value >= 0 && (d2 || r2) && ((s2 = t2.value - (i2 || 0)) || void 0 === i2) && (i2 = t2.value, t2.delta = s2, t2.rating = (f = t2.value) > (p = n2)[1] ? "poor" : f > p[0] ? "needs-improvement" : "good", e2(t2));
31
+ };
32
+ }, D = function(e2) {
33
+ requestAnimationFrame(function() {
34
+ return requestAnimationFrame(function() {
35
+ return e2();
36
+ });
37
+ });
38
+ }, U = function(e2) {
39
+ document.addEventListener("visibilitychange", function() {
40
+ "hidden" === document.visibilityState && e2();
41
+ });
42
+ }, V = function(e2) {
43
+ var t2 = false;
44
+ return function() {
45
+ t2 || (e2(), t2 = true);
46
+ };
47
+ }, t = -1, b = function() {
48
+ return "hidden" !== document.visibilityState || document.prerendering ? 1 / 0 : 0;
49
+ }, v = function(e2) {
50
+ "hidden" === document.visibilityState && t > -1 && (t = "visibilitychange" === e2.type ? e2.timeStamp : 0, _());
51
+ }, L = function() {
52
+ addEventListener("visibilitychange", v, true), addEventListener("prerenderingchange", v, true);
53
+ }, _ = function() {
54
+ removeEventListener("visibilitychange", v, true), removeEventListener("prerenderingchange", v, true);
55
+ }, k = function() {
56
+ return t < 0 && (t = b(), L(), g(function() {
57
+ setTimeout(function() {
58
+ t = b(), L();
59
+ }, 0);
60
+ })), { get firstHiddenTime() {
61
+ return t;
62
+ } };
63
+ }, B = function(e2) {
64
+ document.prerendering ? addEventListener("prerenderingchange", function() {
65
+ return e2();
66
+ }, true) : e2();
67
+ }, n = [1800, 3e3], r = [2500, 4e3], i = {}, x = function(e2, t2) {
68
+ t2 = t2 || {}, B(function() {
69
+ var n2, s2 = k(), d2 = l("LCP"), a = function(e3) {
70
+ t2.reportAllChanges || (e3 = e3.slice(-1)), e3.forEach(function(e4) {
71
+ e4.startTime < s2.firstHiddenTime && (d2.value = Math.max(e4.startTime - h(), 0), d2.entries = [e4], n2());
72
+ });
73
+ }, f = M("largest-contentful-paint", a);
74
+ if (f) {
75
+ n2 = m(e2, d2, r, t2.reportAllChanges);
76
+ var p = V(function() {
77
+ i[d2.id] || (a(f.takeRecords()), f.disconnect(), i[d2.id] = true, n2(true));
78
+ });
79
+ ["keydown", "click"].forEach(function(e3) {
80
+ addEventListener(e3, function() {
81
+ return (function(e4) {
82
+ var t3 = self.requestIdleCallback || self.setTimeout, n3 = -1;
83
+ return e4 = V(e4), "hidden" === document.visibilityState ? e4() : (n3 = t3(e4), U(e4)), n3;
84
+ })(p);
85
+ }, { once: true, capture: true });
86
+ }), U(p), g(function(s3) {
87
+ d2 = l("LCP"), n2 = m(e2, d2, r, t2.reportAllChanges), D(function() {
88
+ d2.value = performance.now() - s3.timeStamp, i[d2.id] = true, n2(true);
89
+ });
90
+ });
91
+ }
92
+ });
93
+ };
94
+ const s = "@sailfish-rrweb/rrweb/performance@1", d = { getPageVisitUuid: () => null, captureFCP: true, captureLCP: true, captureTBT: true, captureDOMLoaded: true };
95
+ function F(e2) {
96
+ return { ...d, ...e2 ?? {} };
97
+ }
98
+ function S(e2, t2, n2) {
99
+ return { metric: e2.name, value: e2.value, rating: e2.rating, navigationType: e2.navigationType, pageVisitUuid: n2.getPageVisitUuid(), href: t2.location.href, timestamp: Date.now() };
100
+ }
101
+ function I(e2, t2, r2) {
102
+ const i2 = F(r2);
103
+ let s2 = false;
104
+ const a = (t3) => {
105
+ if (!s2) try {
106
+ e2(t3);
107
+ } catch {
108
+ }
109
+ };
110
+ if (i2.captureFCP) try {
111
+ !(function(e3, t3) {
112
+ t3 = t3 || {}, B(function() {
113
+ var r3, i3 = k(), s3 = l("FCP"), d3 = M("paint", function(e4) {
114
+ e4.forEach(function(e5) {
115
+ "first-contentful-paint" === e5.name && (d3.disconnect(), e5.startTime < i3.firstHiddenTime && (s3.value = Math.max(e5.startTime - h(), 0), s3.entries.push(e5), r3(true)));
116
+ });
117
+ });
118
+ d3 && (r3 = m(e3, s3, n, t3.reportAllChanges), g(function(i4) {
119
+ s3 = l("FCP"), r3 = m(e3, s3, n, t3.reportAllChanges), D(function() {
120
+ s3.value = performance.now() - i4.timeStamp, r3(true);
121
+ });
122
+ }));
123
+ });
124
+ })((e3) => a(S(e3, t2, i2)), { reportAllChanges: false });
125
+ } catch {
126
+ }
127
+ if (i2.captureLCP) try {
128
+ x((e3) => a(S(e3, t2, i2)), { reportAllChanges: false });
129
+ } catch {
130
+ }
131
+ const d2 = i2.captureTBT ? (function H(e3, t3, n2) {
132
+ if (typeof t3.PerformanceObserver > "u") return () => {
133
+ };
134
+ let r3 = 0, i3 = false, s3 = null;
135
+ try {
136
+ s3 = new t3.PerformanceObserver((e4) => {
137
+ const t4 = e4.getEntries();
138
+ for (let e5 = 0; e5 < t4.length; e5 += 1) {
139
+ const n3 = t4[e5];
140
+ "longtask" === n3.entryType && (r3 += Math.max(0, n3.duration - 50));
141
+ }
142
+ }), s3.observe({ type: "longtask", buffered: true });
143
+ } catch {
144
+ return () => {
145
+ };
146
+ }
147
+ const u = () => {
148
+ i3 || (i3 = true, e3({ metric: "TBT", value: r3, pageVisitUuid: n2.getPageVisitUuid(), href: t3.location.href, timestamp: Date.now() }));
149
+ };
150
+ return "complete" === t3.document.readyState ? Promise.resolve().then(u) : t3.addEventListener("load", u, { once: true }), () => {
151
+ try {
152
+ null == s3 || s3.disconnect();
153
+ } catch {
154
+ }
155
+ t3.removeEventListener("load", u);
156
+ };
157
+ })(a, t2, i2) : () => {
158
+ }, f = i2.captureDOMLoaded ? (function G(e3, t3, n2) {
159
+ let r3 = false, i3 = 0;
160
+ const c = () => {
161
+ if (r3) return;
162
+ let s3;
163
+ try {
164
+ s3 = t3.performance.getEntriesByType("navigation");
165
+ } catch {
166
+ return;
167
+ }
168
+ const d3 = s3 && s3[0];
169
+ if (!d3) return void (i3 < 6 && (i3 += 1, setTimeout(c, 100)));
170
+ if (0 === d3.loadEventEnd && i3 < 6) return i3 += 1, void setTimeout(c, 100);
171
+ r3 = true;
172
+ const f2 = t3.location.href, p = Date.now(), y = n2.getPageVisitUuid();
173
+ e3({ metric: "DCL", value: d3.domContentLoadedEventEnd, pageVisitUuid: y, href: f2, timestamp: p }), e3({ metric: "LOAD", value: d3.loadEventEnd, pageVisitUuid: y, href: f2, timestamp: p });
174
+ }, o = () => setTimeout(c, 0);
175
+ return "complete" === t3.document.readyState ? o() : t3.addEventListener("load", o, { once: true }), () => {
176
+ t3.removeEventListener("load", o);
177
+ };
178
+ })(a, t2, i2) : () => {
179
+ };
180
+ return () => {
181
+ s2 = true, d2(), f();
182
+ };
183
+ }
184
+ const Y = (e2) => ({ name: s, observer: I, options: F(e2) });
185
+ export {
186
+ s as PERFORMANCE_PLUGIN_NAME,
187
+ Y as getRecordPerformancePlugin
188
+ };