@absolutejs/beacon 0.6.10 → 0.6.12

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 CHANGED
@@ -716,6 +716,18 @@ var createBeacon = (options) => {
716
716
  const LAYOUT_SHIFT_RECENT_INTERACTION_MS = 500;
717
717
  const FORM_INVALID_BURST_GAP_MS = 100;
718
718
  const SIGNAL_TEXT_MAX = 180;
719
+ const NON_TEXT_ENTRY_INPUT_TYPES = new Set([
720
+ "button",
721
+ "checkbox",
722
+ "color",
723
+ "file",
724
+ "hidden",
725
+ "image",
726
+ "radio",
727
+ "range",
728
+ "reset",
729
+ "submit"
730
+ ]);
719
731
  const slowResponseMs = signals?.slowResponseMs ?? SLOW_RESPONSE_DEFAULT_MS;
720
732
  const navigationResponseMs = Math.max(DEAD_CLICK_WINDOW_MS, signals?.navigationResponseMs ?? NAVIGATION_RESPONSE_DEFAULT_MS);
721
733
  const rageCount = signals?.rageClickCount ?? RAGE_COUNT_DEFAULT;
@@ -727,6 +739,21 @@ var createBeacon = (options) => {
727
739
  let recentInteraction;
728
740
  let reportErrorClick = null;
729
741
  let reportFormAbandonmentOnNavigation = null;
742
+ const focusedEditable = () => {
743
+ const active = document.activeElement;
744
+ if (active instanceof HTMLTextAreaElement)
745
+ return active;
746
+ if (active instanceof HTMLInputElement) {
747
+ return NON_TEXT_ENTRY_INPUT_TYPES.has(active.type) ? null : active;
748
+ }
749
+ if (active instanceof HTMLElement && active.isContentEditable)
750
+ return active;
751
+ return null;
752
+ };
753
+ const mobileKeyboardViewportActive = () => {
754
+ const visualViewport = window.visualViewport;
755
+ return visualViewport !== undefined && visualViewport !== null && visualViewport.height > 0 && window.innerHeight > 0 && visualViewport.height < window.innerHeight * KEYBOARD_VIEWPORT_HEIGHT_RATIO_MAX && focusedEditable() !== null;
756
+ };
730
757
  let overflowScanOnNavigation = null;
731
758
  let recordRequestForStorm = null;
732
759
  const OVERLAY_VIEWPORT_COVERAGE_MIN = 0.9;
@@ -941,7 +968,7 @@ var createBeacon = (options) => {
941
968
  event.extra = context.extra;
942
969
  push(event);
943
970
  };
944
- const emitSignal = (message, signalTags, traceId, extra, stackBoundary, fallbackFramesToDrop = 1) => {
971
+ const emitSignal = (message, signalTags, traceId, extra, stackBoundary, fallbackFramesToDrop = 1, useDefaultFingerprint = false) => {
945
972
  const error = new Error(message);
946
973
  const captureStackTrace = Error.captureStackTrace;
947
974
  if (captureStackTrace !== undefined) {
@@ -959,7 +986,7 @@ var createBeacon = (options) => {
959
986
  `);
960
987
  }
961
988
  captureException(error, {
962
- groupingKey: signalGroupingKey(signalTags),
989
+ ...useDefaultFingerprint ? {} : { groupingKey: signalGroupingKey(signalTags) },
963
990
  level: "warning",
964
991
  tags: signalTags,
965
992
  ...traceId !== undefined ? { traceId } : {},
@@ -1543,7 +1570,7 @@ var createBeacon = (options) => {
1543
1570
  inSignalConsole = true;
1544
1571
  const text = args.map(String).join(" ").trim().slice(0, SIGNAL_TEXT_MAX);
1545
1572
  if (text !== "")
1546
- emitSignal(text, { signal: BEACON_SIGNAL.CONSOLE_ERROR }, undefined, undefined, wrappedConsole, 2);
1573
+ emitSignal(text, { signal: BEACON_SIGNAL.CONSOLE_ERROR }, undefined, undefined, wrappedConsole, 2, true);
1547
1574
  if (text !== "")
1548
1575
  reportErrorClick?.("ConsoleError");
1549
1576
  inSignalConsole = false;
@@ -2220,7 +2247,7 @@ var createBeacon = (options) => {
2220
2247
  const entry = raw;
2221
2248
  const interactionAgeMs = recentInteraction === undefined ? undefined : entry.startTime - recentInteraction.performanceAt;
2222
2249
  const beaconSawRecentInput = interactionAgeMs !== undefined && interactionAgeMs >= 0 && interactionAgeMs <= LAYOUT_SHIFT_RECENT_INTERACTION_MS;
2223
- if (entry.hadRecentInput === true || beaconSawRecentInput || (entry.value ?? 0) < minimum)
2250
+ if (entry.hadRecentInput === true || beaconSawRecentInput || mobileKeyboardViewportActive() || (entry.value ?? 0) < minimum)
2224
2251
  continue;
2225
2252
  const targets = (entry.sources ?? []).map(({ node }) => node instanceof Element ? describeElement(node) : undefined).filter((target) => target !== undefined).slice(0, 5);
2226
2253
  const key = targets.join(",") || "unknown";
@@ -2647,9 +2674,8 @@ var createBeacon = (options) => {
2647
2674
  if (pageLifecycleEnding || document.visibilityState === "hidden" || visualViewport.height >= window.innerHeight * KEYBOARD_VIEWPORT_HEIGHT_RATIO_MAX) {
2648
2675
  return;
2649
2676
  }
2650
- const active = document.activeElement;
2651
- const editable = active instanceof HTMLInputElement || active instanceof HTMLTextAreaElement || active instanceof HTMLElement && active.isContentEditable;
2652
- if (!editable || !(active instanceof HTMLElement))
2677
+ const active = focusedEditable();
2678
+ if (active === null)
2653
2679
  return;
2654
2680
  const rect = active.getBoundingClientRect();
2655
2681
  if (rect.width === 0 || rect.height === 0)
@@ -3701,5 +3727,5 @@ export {
3701
3727
  BEACON_ATTRIBUTE
3702
3728
  };
3703
3729
 
3704
- //# debugId=FB8AF5475A58E78864756E2164756E21
3730
+ //# debugId=43F4A921162661FF64756E2164756E21
3705
3731
  //# sourceMappingURL=index.js.map