@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/dist/vue.cjs CHANGED
@@ -97,7 +97,7 @@ function typeMapForStatus(status) {
97
97
  }
98
98
 
99
99
  // src/_version.ts
100
- var SDK_VERSION = "1.9.1";
100
+ var SDK_VERSION = "1.10.3";
101
101
  var SDK_NAME = "@cross-deck/web";
102
102
 
103
103
  // src/http.ts
@@ -1661,24 +1661,32 @@ var AutoTracker = class {
1661
1661
  this.emitSessionStart();
1662
1662
  }
1663
1663
  const onVisChange = () => {
1664
- if (!this.session) return;
1665
- const doc2 = globalThis.document;
1666
- if (doc2.visibilityState === "hidden") {
1667
- this.session.hiddenAt = Date.now();
1668
- this.persistSession();
1669
- } else if (doc2.visibilityState === "visible") {
1670
- const idleFor = Date.now() - this.session.lastActivityAt;
1671
- if (idleFor >= SESSION_RESUME_THRESHOLD_MS) {
1672
- this.pageviewId = null;
1673
- this.session = this.startNewSession();
1664
+ try {
1665
+ if (!this.session) return;
1666
+ const doc2 = globalThis.document;
1667
+ if (doc2.visibilityState === "hidden") {
1668
+ this.session.hiddenAt = Date.now();
1674
1669
  this.persistSession();
1675
- this.emitSessionStart();
1676
- } else {
1677
- this.session.hiddenAt = null;
1670
+ } else if (doc2.visibilityState === "visible") {
1671
+ const idleFor = Date.now() - this.session.lastActivityAt;
1672
+ if (idleFor >= SESSION_RESUME_THRESHOLD_MS) {
1673
+ this.pageviewId = null;
1674
+ this.session = this.startNewSession();
1675
+ this.persistSession();
1676
+ this.emitSessionStart();
1677
+ } else {
1678
+ this.session.hiddenAt = null;
1679
+ }
1678
1680
  }
1681
+ } catch {
1682
+ }
1683
+ };
1684
+ const onPageHide = () => {
1685
+ try {
1686
+ this.persistSession();
1687
+ } catch {
1679
1688
  }
1680
1689
  };
1681
- const onPageHide = () => this.persistSession();
1682
1690
  const w = globalThis.window;
1683
1691
  const doc = globalThis.document;
1684
1692
  doc.addEventListener("visibilitychange", onVisChange);
@@ -2542,17 +2550,20 @@ var WebVitalsTracker = class {
2542
2550
  } catch {
2543
2551
  }
2544
2552
  const flush = () => {
2545
- if (lcpValue > 0 && !this.flushed.has("lcp")) {
2546
- this.flushed.add("lcp");
2547
- this.report("webvitals.lcp", { valueMs: Math.round(lcpValue) });
2548
- }
2549
- if (this.cls > 0 && !this.flushed.has("cls")) {
2550
- this.flushed.add("cls");
2551
- this.report("webvitals.cls", { value: Math.round(this.cls * 1e3) / 1e3 });
2552
- }
2553
- if (this.inp > 0 && !this.flushed.has("inp")) {
2554
- this.flushed.add("inp");
2555
- this.report("webvitals.inp", { valueMs: Math.round(this.inp) });
2553
+ try {
2554
+ if (lcpValue > 0 && !this.flushed.has("lcp")) {
2555
+ this.flushed.add("lcp");
2556
+ this.report("webvitals.lcp", { valueMs: Math.round(lcpValue) });
2557
+ }
2558
+ if (this.cls > 0 && !this.flushed.has("cls")) {
2559
+ this.flushed.add("cls");
2560
+ this.report("webvitals.cls", { value: Math.round(this.cls * 1e3) / 1e3 });
2561
+ }
2562
+ if (this.inp > 0 && !this.flushed.has("inp")) {
2563
+ this.flushed.add("inp");
2564
+ this.report("webvitals.inp", { valueMs: Math.round(this.inp) });
2565
+ }
2566
+ } catch {
2556
2567
  }
2557
2568
  };
2558
2569
  const onHidden = () => {
@@ -3815,6 +3826,8 @@ function buildFrame(input) {
3815
3826
  function isInAppFrame(filename) {
3816
3827
  if (!filename) return true;
3817
3828
  if (/^(?:chrome|moz|safari|webkit)-extension:\/\//.test(filename)) return false;
3829
+ if (/^iabjs:\/\//.test(filename)) return false;
3830
+ if (/^(?:webview|inappbrowser):\/\//i.test(filename)) return false;
3818
3831
  if (/\bcdn\.jsdelivr\.net\b/.test(filename)) return false;
3819
3832
  if (/\bunpkg\.com\b/.test(filename)) return false;
3820
3833
  if (/\bgoogletagmanager\.com\b/.test(filename)) return false;
@@ -3823,7 +3836,18 @@ function isInAppFrame(filename) {
3823
3836
  if (/\/crossdeck\.umd\.min\.js$/.test(filename)) return false;
3824
3837
  return true;
3825
3838
  }
3839
+ var BROWSER_INJECTED_GLOBAL = /(__firefox__|__gCrWeb|zaloJSV2)/;
3840
+ function injectedGlobalName(message) {
3841
+ const m = BROWSER_INJECTED_GLOBAL.exec(message ?? "");
3842
+ return m ? m[1] : null;
3843
+ }
3844
+ function demoteVendorInjectedFrames(frames, message) {
3845
+ if (!injectedGlobalName(message)) return frames;
3846
+ return frames.map((f) => f.in_app ? { ...f, in_app: false } : f);
3847
+ }
3826
3848
  function fingerprintError(message, frames, location2) {
3849
+ const injected = injectedGlobalName(message);
3850
+ if (injected) return djb2Hex(`injected-global:${injected}`);
3827
3851
  const inAppFrames = frames.filter((f) => f.in_app).slice(0, 3);
3828
3852
  const parts = [
3829
3853
  (message || "").slice(0, 200),
@@ -4180,7 +4204,7 @@ var ErrorTracker = class {
4180
4204
  const payload = coerceErrorPayload(err);
4181
4205
  const message = (payload.message || event.message || "Unknown error").slice(0, 1024);
4182
4206
  const stack = err instanceof Error ? err.stack ?? null : null;
4183
- const frames = parseStack(stack);
4207
+ const frames = demoteVendorInjectedFrames(parseStack(stack), message);
4184
4208
  const errorType = payload.errorType ?? null;
4185
4209
  const context = payload.extras ? { ...this.opts.getContext(), __error_extras: payload.extras } : this.opts.getContext();
4186
4210
  return {
@@ -4212,7 +4236,7 @@ var ErrorTracker = class {
4212
4236
  const payload = coerceErrorPayload(err);
4213
4237
  const message = (payload.message || "Unknown error").slice(0, 1024);
4214
4238
  const stack = err instanceof Error ? err.stack ?? null : null;
4215
- const frames = parseStack(stack);
4239
+ const frames = demoteVendorInjectedFrames(parseStack(stack), message);
4216
4240
  const errorType = payload.errorType ?? null;
4217
4241
  const context = payload.extras ? { ...this.opts.getContext(), __error_extras: payload.extras } : this.opts.getContext();
4218
4242
  return {
@@ -4776,6 +4800,9 @@ var CrossdeckClient = class {
4776
4800
  if (opts.autoHeartbeat && !localDevMode) {
4777
4801
  void this.heartbeat().catch(() => void 0);
4778
4802
  }
4803
+ if (!localDevMode) {
4804
+ void this.captureCampaignArrival().catch(() => void 0);
4805
+ }
4779
4806
  if (options.disableContractAssertions !== true) {
4780
4807
  const debugDefault = defaultDebugModeFlag();
4781
4808
  this.verifierCtx = buildVerifierContext({
@@ -4873,6 +4900,32 @@ var CrossdeckClient = class {
4873
4900
  }
4874
4901
  this.init(options);
4875
4902
  }
4903
+ /**
4904
+ * Campaign-arrival connect. If the landing URL carries a Crossdeck tag
4905
+ * (`cd_ref`), post it to the arrival endpoint so the backend binds this
4906
+ * anonymous session to the tagged person and pulls their integration
4907
+ * record (deals, pipeline) onto their journey. Browser-only; fire-and-
4908
+ * forget (never throws); backend-idempotent so a re-fire is harmless.
4909
+ */
4910
+ async captureCampaignArrival() {
4911
+ const s = this.state;
4912
+ if (!s) return;
4913
+ const loc = globalThis.location;
4914
+ if (!loc || typeof loc.search !== "string" || loc.search.length === 0) return;
4915
+ let ref2 = null;
4916
+ try {
4917
+ ref2 = new URLSearchParams(loc.search).get("cd_ref");
4918
+ } catch {
4919
+ return;
4920
+ }
4921
+ if (!ref2) return;
4922
+ try {
4923
+ await s.http.request("POST", "/integrations/hubspot/arrival", {
4924
+ body: { anonymousId: s.identity.anonymousId, ref: ref2 }
4925
+ });
4926
+ } catch {
4927
+ }
4928
+ }
4876
4929
  /**
4877
4930
  * Link the anonymous device to a developer-supplied user ID. Cache
4878
4931
  * the resolved Crossdeck customer for follow-up calls.
@@ -5761,9 +5814,17 @@ function installUnloadFlush(onUnload) {
5761
5814
  const doc = globalThis.document;
5762
5815
  if (!w || !doc) return () => void 0;
5763
5816
  const onVisChange = () => {
5764
- if (doc.visibilityState === "hidden") onUnload();
5817
+ try {
5818
+ if (doc.visibilityState === "hidden") onUnload();
5819
+ } catch {
5820
+ }
5821
+ };
5822
+ const onTerminal = () => {
5823
+ try {
5824
+ onUnload();
5825
+ } catch {
5826
+ }
5765
5827
  };
5766
- const onTerminal = () => onUnload();
5767
5828
  doc.addEventListener("visibilitychange", onVisChange);
5768
5829
  w.addEventListener("pagehide", onTerminal);
5769
5830
  w.addEventListener("beforeunload", onTerminal);