@absolutejs/beacon 0.6.11 → 0.6.13

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
@@ -690,7 +690,7 @@ var createBeacon = (options) => {
690
690
  const KEYBOARD_VIEWPORT_HEIGHT_RATIO_MAX = 0.8;
691
691
  const SCROLL_JAIL_EVENT_COUNT = 8;
692
692
  const SCROLL_JAIL_WINDOW_MS = 2000;
693
- const SCROLL_JAIL_SETTLE_MS = 50;
693
+ const SCROLL_JAIL_SETTLE_MS = 500;
694
694
  const SCROLL_JAIL_BOUNDARY_TOLERANCE_PX = 2;
695
695
  const AUTH_FAILURE_STORM_DEFAULT_COUNT = 4;
696
696
  const AUTH_FAILURE_STORM_DEFAULT_WINDOW_MS = 30000;
@@ -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;
@@ -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)
@@ -2706,7 +2732,14 @@ var createBeacon = (options) => {
2706
2732
  let jailScroller = null;
2707
2733
  let jailSettleTimer;
2708
2734
  const reportedScrollers = new Set;
2735
+ const clearJailSettle = () => {
2736
+ if (jailSettleTimer === undefined)
2737
+ return;
2738
+ clearTimeout(jailSettleTimer);
2739
+ jailSettleTimer = undefined;
2740
+ };
2709
2741
  const onWheel = (event) => {
2742
+ clearJailSettle();
2710
2743
  if (event.ctrlKey || event.defaultPrevented || event.deltaY === 0) {
2711
2744
  jailBurst = [];
2712
2745
  return;
@@ -2734,14 +2767,14 @@ var createBeacon = (options) => {
2734
2767
  return;
2735
2768
  const first = jailBurst[0];
2736
2769
  const moved = first === undefined || jailBurst.some((entry) => entry.position !== first.position) || scroller.scrollTop !== first.position;
2737
- jailBurst = [];
2738
- if (moved)
2770
+ if (moved) {
2771
+ jailBurst = [];
2739
2772
  return;
2773
+ }
2740
2774
  const startingPosition = first.position;
2741
- if (jailSettleTimer !== undefined)
2742
- clearTimeout(jailSettleTimer);
2743
2775
  jailSettleTimer = setTimeout(() => {
2744
2776
  jailSettleTimer = undefined;
2777
+ jailBurst = [];
2745
2778
  if (!scroller.isConnected || scroller.scrollTop !== startingPosition)
2746
2779
  return;
2747
2780
  const canStillMove = scrollingDown ? scroller.scrollTop + scroller.clientHeight < scroller.scrollHeight - SCROLL_JAIL_BOUNDARY_TOLERANCE_PX : scroller.scrollTop > SCROLL_JAIL_BOUNDARY_TOLERANCE_PX;
@@ -2759,8 +2792,7 @@ var createBeacon = (options) => {
2759
2792
  document.addEventListener("wheel", onWheel, { passive: true });
2760
2793
  cleanups.push(() => {
2761
2794
  document.removeEventListener("wheel", onWheel);
2762
- if (jailSettleTimer !== undefined)
2763
- clearTimeout(jailSettleTimer);
2795
+ clearJailSettle();
2764
2796
  });
2765
2797
  }
2766
2798
  if (signals.thrashedCursors !== false) {
@@ -3701,5 +3733,5 @@ export {
3701
3733
  BEACON_ATTRIBUTE
3702
3734
  };
3703
3735
 
3704
- //# debugId=4A2076E84A38E88A64756E2164756E21
3736
+ //# debugId=67D5901DFC5C25F064756E2164756E21
3705
3737
  //# sourceMappingURL=index.js.map