@absolutejs/beacon 0.7.0-beta.0 → 0.7.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/dist/index.d.ts +1 -1
- package/dist/index.js +27 -11
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
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.
|
|
28
|
+
export declare const BEACON_SDK_VERSION = "0.7.0-beta.1";
|
|
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;
|
package/dist/index.js
CHANGED
|
@@ -79,7 +79,7 @@ var BEACON_ATTRIBUTE = {
|
|
|
79
79
|
|
|
80
80
|
// src/index.ts
|
|
81
81
|
var BEACON_TRACE_HEADER = "x-absolute-trace-id";
|
|
82
|
-
var BEACON_SDK_VERSION = "0.7.0-beta.
|
|
82
|
+
var BEACON_SDK_VERSION = "0.7.0-beta.1";
|
|
83
83
|
var inBrowser = () => typeof window !== "undefined";
|
|
84
84
|
var newId = () => {
|
|
85
85
|
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
@@ -486,6 +486,8 @@ var UUID_PATH_SEGMENT = /\b[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-
|
|
|
486
486
|
var LONG_IDENTIFIER_SEGMENT = /\b(?:[0-9a-f]{16,}|\d{8,})\b/giu;
|
|
487
487
|
var VOLATILE_SIGNAL_TAGS = new Set([
|
|
488
488
|
"actionId",
|
|
489
|
+
"actionTrusted",
|
|
490
|
+
"automation",
|
|
489
491
|
"attemptCount",
|
|
490
492
|
"blockingDurationMs",
|
|
491
493
|
"blockingFrameDurationMs",
|
|
@@ -496,9 +498,11 @@ var VOLATILE_SIGNAL_TAGS = new Set([
|
|
|
496
498
|
"durationMs",
|
|
497
499
|
"elapsedMs",
|
|
498
500
|
"errorCount",
|
|
501
|
+
"focusEventTrusted",
|
|
499
502
|
"inputDelayMs",
|
|
500
503
|
"interactionId",
|
|
501
504
|
"interactionAgeMs",
|
|
505
|
+
"lastFocused",
|
|
502
506
|
"loadCount",
|
|
503
507
|
"newestRelease",
|
|
504
508
|
"obscuredPx",
|
|
@@ -975,12 +979,13 @@ var createBeacon = (options) => {
|
|
|
975
979
|
let user;
|
|
976
980
|
let actionSequence = 0;
|
|
977
981
|
let activeAction;
|
|
978
|
-
const beginAction = (type, target) => {
|
|
982
|
+
const beginAction = (type, target, trusted) => {
|
|
979
983
|
actionSequence += 1;
|
|
980
984
|
activeAction = {
|
|
981
985
|
at: Date.now(),
|
|
982
986
|
id: `${sessionId}:${actionSequence}`,
|
|
983
987
|
target,
|
|
988
|
+
trusted,
|
|
984
989
|
type
|
|
985
990
|
};
|
|
986
991
|
};
|
|
@@ -1026,6 +1031,7 @@ var createBeacon = (options) => {
|
|
|
1026
1031
|
...action === undefined ? {} : {
|
|
1027
1032
|
actionId: action.id,
|
|
1028
1033
|
actionTarget: action.target,
|
|
1034
|
+
actionTrusted: String(action.trusted),
|
|
1029
1035
|
actionType: action.type
|
|
1030
1036
|
},
|
|
1031
1037
|
...event.tags
|
|
@@ -1949,7 +1955,7 @@ var createBeacon = (options) => {
|
|
|
1949
1955
|
if (!(target instanceof Element))
|
|
1950
1956
|
return;
|
|
1951
1957
|
const targetName = describeElement(target);
|
|
1952
|
-
beginAction("click", targetName);
|
|
1958
|
+
beginAction("click", targetName, event.isTrusted);
|
|
1953
1959
|
addBreadcrumb({ message: targetName, type: "click" });
|
|
1954
1960
|
if (signals === null)
|
|
1955
1961
|
return;
|
|
@@ -2005,7 +2011,7 @@ var createBeacon = (options) => {
|
|
|
2005
2011
|
if (!(event.target instanceof HTMLFormElement))
|
|
2006
2012
|
return;
|
|
2007
2013
|
const target = describeElement(event.target);
|
|
2008
|
-
beginAction("submit", target);
|
|
2014
|
+
beginAction("submit", target, event.isTrusted);
|
|
2009
2015
|
recentInteraction = {
|
|
2010
2016
|
at: Date.now(),
|
|
2011
2017
|
performanceAt: performance.now(),
|
|
@@ -2020,7 +2026,7 @@ var createBeacon = (options) => {
|
|
|
2020
2026
|
if (!(target instanceof Element))
|
|
2021
2027
|
return;
|
|
2022
2028
|
const targetName = describeElement(target);
|
|
2023
|
-
beginAction("keyboard", targetName);
|
|
2029
|
+
beginAction("keyboard", targetName, event.isTrusted);
|
|
2024
2030
|
recentInteraction = {
|
|
2025
2031
|
at: Date.now(),
|
|
2026
2032
|
performanceAt: performance.now(),
|
|
@@ -3527,19 +3533,29 @@ var createBeacon = (options) => {
|
|
|
3527
3533
|
};
|
|
3528
3534
|
const onFocusOut = (event) => {
|
|
3529
3535
|
const target = event.target;
|
|
3530
|
-
|
|
3531
|
-
if (candidate === null)
|
|
3536
|
+
if (!(target instanceof Element))
|
|
3532
3537
|
return;
|
|
3538
|
+
const dialog = target.closest(DIALOG_SELECTOR);
|
|
3539
|
+
if (dialog === null)
|
|
3540
|
+
return;
|
|
3541
|
+
const dialogDescriptor = describeElement(dialog);
|
|
3542
|
+
const focusEventTrusted = event.isTrusted === true;
|
|
3533
3543
|
setTimeout(() => {
|
|
3534
3544
|
const active = document.activeElement;
|
|
3535
3545
|
const focusDropped = active === null || active === document.body;
|
|
3536
|
-
if (!focusDropped ||
|
|
3546
|
+
if (!focusDropped || target.isConnected)
|
|
3537
3547
|
return;
|
|
3538
|
-
const descriptor = describeElement(
|
|
3548
|
+
const descriptor = describeElement(target);
|
|
3539
3549
|
if (reportedFocusLoss.has(descriptor))
|
|
3540
3550
|
return;
|
|
3541
3551
|
reportedFocusLoss.add(descriptor);
|
|
3542
|
-
emitSignal(`Focus lost — a dialog closed and dropped keyboard focus on body — ${shortUrl(location.href)}`, {
|
|
3552
|
+
emitSignal(`Focus lost — a dialog closed and dropped keyboard focus on body — ${shortUrl(location.href)}`, {
|
|
3553
|
+
dialog: dialogDescriptor,
|
|
3554
|
+
focusEventTrusted: String(focusEventTrusted),
|
|
3555
|
+
lastFocused: descriptor,
|
|
3556
|
+
signal: BEACON_SIGNAL.FOCUS_LOST,
|
|
3557
|
+
...navigator.webdriver === true ? { automation: "webdriver" } : {}
|
|
3558
|
+
});
|
|
3543
3559
|
}, 0);
|
|
3544
3560
|
};
|
|
3545
3561
|
document.addEventListener("focusin", onFocusIn, true);
|
|
@@ -4568,5 +4584,5 @@ export {
|
|
|
4568
4584
|
redactBeaconEvent
|
|
4569
4585
|
};
|
|
4570
4586
|
|
|
4571
|
-
//# debugId=
|
|
4587
|
+
//# debugId=5C89D1E136B8537164756E2164756E21
|
|
4572
4588
|
//# sourceMappingURL=index.js.map
|