@cross-deck/web 1.9.1 → 1.10.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.
- package/CHANGELOG.md +66 -0
- package/README.md +5 -3
- package/dist/crossdeck.umd.min.js +2 -2
- package/dist/crossdeck.umd.min.js.map +1 -1
- package/dist/error-codes.json +1 -1
- package/dist/index.cjs +91 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.mjs +91 -30
- package/dist/index.mjs.map +1 -1
- package/dist/react.cjs +91 -30
- package/dist/react.cjs.map +1 -1
- package/dist/react.mjs +91 -30
- package/dist/react.mjs.map +1 -1
- package/dist/vue.cjs +91 -30
- package/dist/vue.cjs.map +1 -1
- package/dist/vue.mjs +91 -30
- package/dist/vue.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react.mjs
CHANGED
|
@@ -72,7 +72,7 @@ function typeMapForStatus(status) {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
// src/_version.ts
|
|
75
|
-
var SDK_VERSION = "1.
|
|
75
|
+
var SDK_VERSION = "1.10.3";
|
|
76
76
|
var SDK_NAME = "@cross-deck/web";
|
|
77
77
|
|
|
78
78
|
// src/http.ts
|
|
@@ -1636,24 +1636,32 @@ var AutoTracker = class {
|
|
|
1636
1636
|
this.emitSessionStart();
|
|
1637
1637
|
}
|
|
1638
1638
|
const onVisChange = () => {
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
} else if (doc2.visibilityState === "visible") {
|
|
1645
|
-
const idleFor = Date.now() - this.session.lastActivityAt;
|
|
1646
|
-
if (idleFor >= SESSION_RESUME_THRESHOLD_MS) {
|
|
1647
|
-
this.pageviewId = null;
|
|
1648
|
-
this.session = this.startNewSession();
|
|
1639
|
+
try {
|
|
1640
|
+
if (!this.session) return;
|
|
1641
|
+
const doc2 = globalThis.document;
|
|
1642
|
+
if (doc2.visibilityState === "hidden") {
|
|
1643
|
+
this.session.hiddenAt = Date.now();
|
|
1649
1644
|
this.persistSession();
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1645
|
+
} else if (doc2.visibilityState === "visible") {
|
|
1646
|
+
const idleFor = Date.now() - this.session.lastActivityAt;
|
|
1647
|
+
if (idleFor >= SESSION_RESUME_THRESHOLD_MS) {
|
|
1648
|
+
this.pageviewId = null;
|
|
1649
|
+
this.session = this.startNewSession();
|
|
1650
|
+
this.persistSession();
|
|
1651
|
+
this.emitSessionStart();
|
|
1652
|
+
} else {
|
|
1653
|
+
this.session.hiddenAt = null;
|
|
1654
|
+
}
|
|
1653
1655
|
}
|
|
1656
|
+
} catch {
|
|
1657
|
+
}
|
|
1658
|
+
};
|
|
1659
|
+
const onPageHide = () => {
|
|
1660
|
+
try {
|
|
1661
|
+
this.persistSession();
|
|
1662
|
+
} catch {
|
|
1654
1663
|
}
|
|
1655
1664
|
};
|
|
1656
|
-
const onPageHide = () => this.persistSession();
|
|
1657
1665
|
const w = globalThis.window;
|
|
1658
1666
|
const doc = globalThis.document;
|
|
1659
1667
|
doc.addEventListener("visibilitychange", onVisChange);
|
|
@@ -2517,17 +2525,20 @@ var WebVitalsTracker = class {
|
|
|
2517
2525
|
} catch {
|
|
2518
2526
|
}
|
|
2519
2527
|
const flush = () => {
|
|
2520
|
-
|
|
2521
|
-
this.flushed.
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
this.flushed.
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
this.flushed.
|
|
2530
|
-
|
|
2528
|
+
try {
|
|
2529
|
+
if (lcpValue > 0 && !this.flushed.has("lcp")) {
|
|
2530
|
+
this.flushed.add("lcp");
|
|
2531
|
+
this.report("webvitals.lcp", { valueMs: Math.round(lcpValue) });
|
|
2532
|
+
}
|
|
2533
|
+
if (this.cls > 0 && !this.flushed.has("cls")) {
|
|
2534
|
+
this.flushed.add("cls");
|
|
2535
|
+
this.report("webvitals.cls", { value: Math.round(this.cls * 1e3) / 1e3 });
|
|
2536
|
+
}
|
|
2537
|
+
if (this.inp > 0 && !this.flushed.has("inp")) {
|
|
2538
|
+
this.flushed.add("inp");
|
|
2539
|
+
this.report("webvitals.inp", { valueMs: Math.round(this.inp) });
|
|
2540
|
+
}
|
|
2541
|
+
} catch {
|
|
2531
2542
|
}
|
|
2532
2543
|
};
|
|
2533
2544
|
const onHidden = () => {
|
|
@@ -3790,6 +3801,8 @@ function buildFrame(input) {
|
|
|
3790
3801
|
function isInAppFrame(filename) {
|
|
3791
3802
|
if (!filename) return true;
|
|
3792
3803
|
if (/^(?:chrome|moz|safari|webkit)-extension:\/\//.test(filename)) return false;
|
|
3804
|
+
if (/^iabjs:\/\//.test(filename)) return false;
|
|
3805
|
+
if (/^(?:webview|inappbrowser):\/\//i.test(filename)) return false;
|
|
3793
3806
|
if (/\bcdn\.jsdelivr\.net\b/.test(filename)) return false;
|
|
3794
3807
|
if (/\bunpkg\.com\b/.test(filename)) return false;
|
|
3795
3808
|
if (/\bgoogletagmanager\.com\b/.test(filename)) return false;
|
|
@@ -3798,7 +3811,18 @@ function isInAppFrame(filename) {
|
|
|
3798
3811
|
if (/\/crossdeck\.umd\.min\.js$/.test(filename)) return false;
|
|
3799
3812
|
return true;
|
|
3800
3813
|
}
|
|
3814
|
+
var BROWSER_INJECTED_GLOBAL = /(__firefox__|__gCrWeb|zaloJSV2)/;
|
|
3815
|
+
function injectedGlobalName(message) {
|
|
3816
|
+
const m = BROWSER_INJECTED_GLOBAL.exec(message ?? "");
|
|
3817
|
+
return m ? m[1] : null;
|
|
3818
|
+
}
|
|
3819
|
+
function demoteVendorInjectedFrames(frames, message) {
|
|
3820
|
+
if (!injectedGlobalName(message)) return frames;
|
|
3821
|
+
return frames.map((f) => f.in_app ? { ...f, in_app: false } : f);
|
|
3822
|
+
}
|
|
3801
3823
|
function fingerprintError(message, frames, location2) {
|
|
3824
|
+
const injected = injectedGlobalName(message);
|
|
3825
|
+
if (injected) return djb2Hex(`injected-global:${injected}`);
|
|
3802
3826
|
const inAppFrames = frames.filter((f) => f.in_app).slice(0, 3);
|
|
3803
3827
|
const parts = [
|
|
3804
3828
|
(message || "").slice(0, 200),
|
|
@@ -4155,7 +4179,7 @@ var ErrorTracker = class {
|
|
|
4155
4179
|
const payload = coerceErrorPayload(err);
|
|
4156
4180
|
const message = (payload.message || event.message || "Unknown error").slice(0, 1024);
|
|
4157
4181
|
const stack = err instanceof Error ? err.stack ?? null : null;
|
|
4158
|
-
const frames = parseStack(stack);
|
|
4182
|
+
const frames = demoteVendorInjectedFrames(parseStack(stack), message);
|
|
4159
4183
|
const errorType = payload.errorType ?? null;
|
|
4160
4184
|
const context = payload.extras ? { ...this.opts.getContext(), __error_extras: payload.extras } : this.opts.getContext();
|
|
4161
4185
|
return {
|
|
@@ -4187,7 +4211,7 @@ var ErrorTracker = class {
|
|
|
4187
4211
|
const payload = coerceErrorPayload(err);
|
|
4188
4212
|
const message = (payload.message || "Unknown error").slice(0, 1024);
|
|
4189
4213
|
const stack = err instanceof Error ? err.stack ?? null : null;
|
|
4190
|
-
const frames = parseStack(stack);
|
|
4214
|
+
const frames = demoteVendorInjectedFrames(parseStack(stack), message);
|
|
4191
4215
|
const errorType = payload.errorType ?? null;
|
|
4192
4216
|
const context = payload.extras ? { ...this.opts.getContext(), __error_extras: payload.extras } : this.opts.getContext();
|
|
4193
4217
|
return {
|
|
@@ -4751,6 +4775,9 @@ var CrossdeckClient = class {
|
|
|
4751
4775
|
if (opts.autoHeartbeat && !localDevMode) {
|
|
4752
4776
|
void this.heartbeat().catch(() => void 0);
|
|
4753
4777
|
}
|
|
4778
|
+
if (!localDevMode) {
|
|
4779
|
+
void this.captureCampaignArrival().catch(() => void 0);
|
|
4780
|
+
}
|
|
4754
4781
|
if (options.disableContractAssertions !== true) {
|
|
4755
4782
|
const debugDefault = defaultDebugModeFlag();
|
|
4756
4783
|
this.verifierCtx = buildVerifierContext({
|
|
@@ -4848,6 +4875,32 @@ var CrossdeckClient = class {
|
|
|
4848
4875
|
}
|
|
4849
4876
|
this.init(options);
|
|
4850
4877
|
}
|
|
4878
|
+
/**
|
|
4879
|
+
* Campaign-arrival connect. If the landing URL carries a Crossdeck tag
|
|
4880
|
+
* (`cd_ref`), post it to the arrival endpoint so the backend binds this
|
|
4881
|
+
* anonymous session to the tagged person and pulls their integration
|
|
4882
|
+
* record (deals, pipeline) onto their journey. Browser-only; fire-and-
|
|
4883
|
+
* forget (never throws); backend-idempotent so a re-fire is harmless.
|
|
4884
|
+
*/
|
|
4885
|
+
async captureCampaignArrival() {
|
|
4886
|
+
const s = this.state;
|
|
4887
|
+
if (!s) return;
|
|
4888
|
+
const loc = globalThis.location;
|
|
4889
|
+
if (!loc || typeof loc.search !== "string" || loc.search.length === 0) return;
|
|
4890
|
+
let ref = null;
|
|
4891
|
+
try {
|
|
4892
|
+
ref = new URLSearchParams(loc.search).get("cd_ref");
|
|
4893
|
+
} catch {
|
|
4894
|
+
return;
|
|
4895
|
+
}
|
|
4896
|
+
if (!ref) return;
|
|
4897
|
+
try {
|
|
4898
|
+
await s.http.request("POST", "/integrations/hubspot/arrival", {
|
|
4899
|
+
body: { anonymousId: s.identity.anonymousId, ref }
|
|
4900
|
+
});
|
|
4901
|
+
} catch {
|
|
4902
|
+
}
|
|
4903
|
+
}
|
|
4851
4904
|
/**
|
|
4852
4905
|
* Link the anonymous device to a developer-supplied user ID. Cache
|
|
4853
4906
|
* the resolved Crossdeck customer for follow-up calls.
|
|
@@ -5736,9 +5789,17 @@ function installUnloadFlush(onUnload) {
|
|
|
5736
5789
|
const doc = globalThis.document;
|
|
5737
5790
|
if (!w || !doc) return () => void 0;
|
|
5738
5791
|
const onVisChange = () => {
|
|
5739
|
-
|
|
5792
|
+
try {
|
|
5793
|
+
if (doc.visibilityState === "hidden") onUnload();
|
|
5794
|
+
} catch {
|
|
5795
|
+
}
|
|
5796
|
+
};
|
|
5797
|
+
const onTerminal = () => {
|
|
5798
|
+
try {
|
|
5799
|
+
onUnload();
|
|
5800
|
+
} catch {
|
|
5801
|
+
}
|
|
5740
5802
|
};
|
|
5741
|
-
const onTerminal = () => onUnload();
|
|
5742
5803
|
doc.addEventListener("visibilitychange", onVisChange);
|
|
5743
5804
|
w.addEventListener("pagehide", onTerminal);
|
|
5744
5805
|
w.addEventListener("beforeunload", onTerminal);
|