@absolutejs/beacon 0.7.0-beta.5 → 0.7.0-beta.7

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.d.ts CHANGED
@@ -25,7 +25,7 @@ export type BeaconLevel = "fatal" | "error" | "warning" | "info";
25
25
  /** Response header used to correlate a browser signal with its server request. */
26
26
  export declare const BEACON_TRACE_HEADER = "x-absolute-trace-id";
27
27
  /** Beacon package version retained with every captured event. */
28
- export declare const BEACON_SDK_VERSION = "0.7.0-beta.5";
28
+ export declare const BEACON_SDK_VERSION = "0.7.0-beta.7";
29
29
  /** Arbitrary event tags, with Beacon's reserved `signal` tag type-checked. */
30
30
  export type BeaconTags = Record<string, string> & {
31
31
  signal?: BeaconSignal;
@@ -140,6 +140,10 @@ export type BeaconResourceFailure = {
140
140
  * `console.error`. Each detector is feature-gated and independently tunable.
141
141
  */
142
142
  export type BeaconSignals = {
143
+ /** Suppress synthetic watchdog findings for WebDriver and explicitly
144
+ * identified crawler/audit user agents. Explicit exceptions and messages
145
+ * are unaffected. Default false. */
146
+ suppressAutomatedBrowsers?: boolean;
143
147
  /** Back/forward navigations the browser could not restore from bfcache. */
144
148
  bfcacheBlocks?: boolean;
145
149
  /** Browser-specific bfcache reason strings that are inherent to an
package/dist/index.js CHANGED
@@ -199,7 +199,7 @@ var consumeEarlyLayoutShiftBuffer = () => {
199
199
 
200
200
  // src/index.ts
201
201
  var BEACON_TRACE_HEADER = "x-absolute-trace-id";
202
- var BEACON_SDK_VERSION = "0.7.0-beta.5";
202
+ var BEACON_SDK_VERSION = "0.7.0-beta.7";
203
203
  var inBrowser = () => typeof window !== "undefined";
204
204
  var newId = () => {
205
205
  if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
@@ -643,11 +643,17 @@ var VOLATILE_SIGNAL_TAGS = new Set([
643
643
  "responseMs",
644
644
  "shiftValue",
645
645
  "signal",
646
+ "scriptAttribution",
646
647
  "scriptCount",
647
648
  "scriptDurationMs",
649
+ "scriptFunction",
648
650
  "scriptForcedStyleAndLayoutMs",
651
+ "scriptInvoker",
652
+ "scriptInvokerType",
649
653
  "scriptPauseDurationMs",
654
+ "scriptSource",
650
655
  "scriptSourceCharPosition",
656
+ "scriptWindowAttribution",
651
657
  "spillPx",
652
658
  "stallCount",
653
659
  "styleAndLayoutDurationMs",
@@ -685,6 +691,8 @@ var signalGroupingKey = (signalTags) => {
685
691
  const hash = stableIdentityHash(identity, 2166136261) + stableIdentityHash(identity, 2654435769);
686
692
  return `beacon-signal:${signalTags.signal}:${hash}`;
687
693
  };
694
+ var AUTOMATED_BROWSER_USER_AGENT = /(?:\b(?:adsbot|bingbot|crawler|googlebot|headlesschrome|lighthouse|pagespeed|spider)\b|\b(?:bot|crawl|spider)\/)/iu;
695
+ var isAutomatedBrowser = () => typeof navigator !== "undefined" && (navigator.webdriver === true || AUTOMATED_BROWSER_USER_AGENT.test(navigator.userAgent));
688
696
  var isInvisibleAnchor = (anchor) => {
689
697
  if (anchor.target === "_blank" || anchor.hasAttribute("download"))
690
698
  return true;
@@ -1247,6 +1255,8 @@ var createBeacon = (options) => {
1247
1255
  push(event);
1248
1256
  };
1249
1257
  const emitSignal = (message, signalTags, traceId, extra, stackBoundary, fallbackFramesToDrop = 1, useDefaultFingerprint = false) => {
1258
+ if (signals?.suppressAutomatedBrowsers === true && isAutomatedBrowser())
1259
+ return;
1250
1260
  if (staleClientRelease && signalTags.signal !== BEACON_SIGNAL.STALE_RELEASE && signalTags.signal !== BEACON_SIGNAL.RELOAD_LOOP)
1251
1261
  return;
1252
1262
  const error = new Error(message);
@@ -2948,6 +2958,9 @@ var createBeacon = (options) => {
2948
2958
  };
2949
2959
  };
2950
2960
  const processLayoutShift = (entry) => {
2961
+ const firstContentfulPaint = performance.getEntriesByName("first-contentful-paint")[0]?.startTime;
2962
+ if (firstContentfulPaint !== undefined && entry.startTime < firstContentfulPaint)
2963
+ return;
2951
2964
  const interactionTimes = [
2952
2965
  ...earlyInteractionTimes,
2953
2966
  ...recentInteraction === undefined ? [] : [recentInteraction.performanceAt]
@@ -4074,6 +4087,9 @@ var createBeacon = (options) => {
4074
4087
  const restoredLifecycleClose = pageRestoredAt !== undefined && socketLifecycleGeneration < pageLifecycleGeneration && Date.now() - pageRestoredAt <= RESTORED_SOCKET_CLOSE_GRACE_MS;
4075
4088
  if (pageLifecycleEnding || applicationClose || restoredLifecycleClose)
4076
4089
  return;
4090
+ const expectedServerClose = typeof CloseEvent !== "undefined" && event instanceof CloseEvent && (event.wasClean || event.code === 1000 || event.code === 1001 || event.code === 1012);
4091
+ if (expectedServerClose)
4092
+ return;
4077
4093
  if (signals.socketAbnormalCloses !== false && typeof CloseEvent !== "undefined" && event instanceof CloseEvent && !event.wasClean && !recoverableSocket(socketUrl)) {
4078
4094
  const abnormalKey = `${label}|${event.code}`;
4079
4095
  if (!reportedAbnormalCloses.has(abnormalKey)) {
@@ -4812,5 +4828,5 @@ export {
4812
4828
  redactBeaconEvent
4813
4829
  };
4814
4830
 
4815
- //# debugId=69A1D614031FDB2864756E2164756E21
4831
+ //# debugId=024293C5A498559364756E2164756E21
4816
4832
  //# sourceMappingURL=index.js.map