@openreplay/tracker 17.2.2 → 17.2.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/lib/index.js CHANGED
@@ -434,6 +434,23 @@ function deprecationWarn(nameOfFeature, useInstead, docsPath = '/') {
434
434
  console.warn(`OpenReplay: ${nameOfFeature} is deprecated. ${useInstead ? `Please, use ${useInstead} instead.` : ''} Visit ${DOCS_HOST}${docsPath} for more information.`);
435
435
  warnedFeatures[nameOfFeature] = true;
436
436
  }
437
+ function getCustomAttributeLabel(e, customAttributes) {
438
+ if (!customAttributes || customAttributes.length === 0)
439
+ return '';
440
+ const parts = [];
441
+ for (const attr of customAttributes) {
442
+ const value = e.getAttribute(attr);
443
+ if (value !== null) {
444
+ parts.push(`[${attr}=${value}]`);
445
+ }
446
+ }
447
+ return parts.join('');
448
+ }
449
+ function getClassSelector(e) {
450
+ if (!e.classList || e.classList.length === 0)
451
+ return '';
452
+ return '.' + Array.from(e.classList).join('.');
453
+ }
437
454
  function getLabelAttribute(e) {
438
455
  let value = e.getAttribute('data-openreplay-label');
439
456
  if (value !== null) {
@@ -3405,7 +3422,10 @@ class TopObserver extends Observer {
3405
3422
  this.app.debug.info('doc already observed for', id);
3406
3423
  return;
3407
3424
  }
3408
- const observer = new IFrameObserver(this.app, false, {});
3425
+ const observer = new IFrameObserver(this.app, false, {
3426
+ disableSprites: this.options.disableSprites,
3427
+ ...getInlineOptions(this.options.inlineCss, console.warn),
3428
+ });
3409
3429
  this.iframeObservers.set(iframe, observer);
3410
3430
  this.docObservers.set(currentDoc, observer);
3411
3431
  this.iframeObserversArr.push(observer);
@@ -3427,7 +3447,10 @@ class TopObserver extends Observer {
3427
3447
  handle();
3428
3448
  }
3429
3449
  handleShadowRoot(shRoot) {
3430
- const observer = new ShadowRootObserver(this.app);
3450
+ const observer = new ShadowRootObserver(this.app, false, {
3451
+ disableSprites: this.options.disableSprites,
3452
+ ...getInlineOptions(this.options.inlineCss, console.warn),
3453
+ });
3431
3454
  this.shadowRootObservers.set(shRoot, observer);
3432
3455
  observer.observe(shRoot.host);
3433
3456
  }
@@ -3463,7 +3486,10 @@ class TopObserver extends Observer {
3463
3486
  };
3464
3487
  this.app.nodes.clear();
3465
3488
  this.app.nodes.crossdomainMode(frameLevel, frameOder);
3466
- const iframeObserver = new IFrameObserver(this.app);
3489
+ const iframeObserver = new IFrameObserver(this.app, false, {
3490
+ disableSprites: this.options.disableSprites,
3491
+ ...getInlineOptions(this.options.inlineCss, console.warn),
3492
+ });
3467
3493
  this.iframeObservers.set(window.document, iframeObserver);
3468
3494
  iframeObserver.syntheticObserve(rootNodeId, window.document);
3469
3495
  }
@@ -3822,7 +3848,7 @@ class App {
3822
3848
  this.stopCallbacks = [];
3823
3849
  this.commitCallbacks = [];
3824
3850
  this.activityState = ActivityState.NotActive;
3825
- this.version = '17.2.2'; // TODO: version compatability check inside each plugin.
3851
+ this.version = '17.2.3'; // TODO: version compatability check inside each plugin.
3826
3852
  this.socketMode = false;
3827
3853
  this.compressionThreshold = 24 * 1000;
3828
3854
  this.bc = null;
@@ -4252,9 +4278,6 @@ class App {
4252
4278
  window.addEventListener('message', this.parentCrossDomainFrameListener);
4253
4279
  window.addEventListener('message', this.crossDomainIframeListener);
4254
4280
  setInterval(() => {
4255
- if (document.hidden) {
4256
- return;
4257
- }
4258
4281
  window.parent.postMessage({
4259
4282
  line: proto.polling,
4260
4283
  context: this.contextId,
@@ -5724,19 +5747,21 @@ const labelElementFor = IN_BROWSER && 'labels' in HTMLInputElement.prototype
5724
5747
  }
5725
5748
  }
5726
5749
  };
5727
- function getInputLabel(node) {
5728
- let label = getLabelAttribute(node);
5729
- if (label === null) {
5730
- const labelElement = labelElementFor(node);
5731
- label =
5732
- (labelElement && labelElement.innerText) ||
5733
- node.placeholder ||
5734
- node.name ||
5735
- node.id ||
5736
- node.className ||
5737
- node.type;
5738
- }
5739
- return normSpaces(label).slice(0, 100);
5750
+ function getInputLabel(node, customAttributes) {
5751
+ const openreplayLabel = getLabelAttribute(node);
5752
+ if (openreplayLabel !== null)
5753
+ return normSpaces(openreplayLabel).slice(0, 100);
5754
+ const customAttributeLabel = getCustomAttributeLabel(node, customAttributes);
5755
+ if (customAttributeLabel)
5756
+ return customAttributeLabel;
5757
+ if (node.id)
5758
+ return `#${node.id}`;
5759
+ const classLabel = getClassSelector(node);
5760
+ if (classLabel)
5761
+ return classLabel;
5762
+ const labelElement = labelElementFor(node);
5763
+ const label = node.name || node.placeholder || (labelElement && labelElement.innerText) || node.type;
5764
+ return normSpaces(label || '').slice(0, 100);
5740
5765
  }
5741
5766
  const InputMode = {
5742
5767
  Plain: 0,
@@ -5817,7 +5842,7 @@ function Input (app, opts) {
5817
5842
  }, 3);
5818
5843
  function sendInputChange(id, node, hesitationTime, inputTime) {
5819
5844
  const { value, mask } = getInputValue(id, node);
5820
- let label = getInputLabel(node);
5845
+ let label = getInputLabel(node, options.customAttributes);
5821
5846
  if (app.sanitizer.privateMode) {
5822
5847
  label = label.replaceAll(/./g, '*');
5823
5848
  }
@@ -5926,21 +5951,28 @@ function _getTarget(target, document) {
5926
5951
  return target === document.documentElement ? null : target;
5927
5952
  }
5928
5953
  function Mouse (app, options) {
5929
- const { disableClickmaps = false } = options || {};
5954
+ const { disableClickmaps = false, customAttributes } = options || {};
5930
5955
  function getTargetLabel(target) {
5931
5956
  const dl = getLabelAttribute(target);
5932
5957
  if (dl !== null) {
5933
5958
  return dl;
5934
5959
  }
5935
5960
  if (hasTag(target, 'input')) {
5936
- return getInputLabel(target);
5937
- }
5961
+ return getInputLabel(target, customAttributes);
5962
+ }
5963
+ const customAttributeLabel = getCustomAttributeLabel(target, customAttributes);
5964
+ if (customAttributeLabel)
5965
+ return customAttributeLabel;
5966
+ if (target.id)
5967
+ return `#${target.id}`;
5968
+ const classLabel = getClassSelector(target);
5969
+ if (classLabel)
5970
+ return classLabel;
5938
5971
  if (isClickable(target)) {
5939
5972
  let label = '';
5940
5973
  if (target instanceof HTMLElement) {
5941
5974
  label = app.sanitizer.getInnerTextSecure(target);
5942
5975
  }
5943
- label = label || target.id || target.className;
5944
5976
  return normSpaces(label).slice(0, 100);
5945
5977
  }
5946
5978
  return '';
@@ -6084,6 +6116,11 @@ function getCSSPath(el) {
6084
6116
  return false;
6085
6117
  if (el.id)
6086
6118
  return `#${cssEscape(el.id)}`;
6119
+ // if has data attributes - use them as they are more likely to be stable and unique
6120
+ const dataAttr = Array.from(el.attributes).find(attr => attr.name.startsWith('data-'));
6121
+ if (dataAttr) {
6122
+ return `[${dataAttr.name}="${cssEscape(dataAttr.value)}"]`;
6123
+ }
6087
6124
  const parts = [];
6088
6125
  while (el && el.nodeType === 1 && el !== el.ownerDocument) {
6089
6126
  if (el.id) {
@@ -6135,7 +6172,7 @@ function getUniqueSiblingClass(el) {
6135
6172
  return null;
6136
6173
  }
6137
6174
 
6138
- var e,o=-1,a=function(e){addEventListener("pageshow",(function(n){n.persisted&&(o=n.timeStamp,e(n));}),true);},c=function(){var e=self.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},u=function(){var e=c();return e&&e.activationStart||0},f=function(e,n){var t=c(),r="navigate";o>=0?r="back-forward-cache":t&&(document.prerendering||u()>0?r="prerender":document.wasDiscarded?r="restore":t.type&&(r=t.type.replace(/_/g,"-")));return {name:e,value:void 0===n?-1:n,rating:"good",delta:0,entries:[],id:"v4-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:r}},s=function(e,n,t){try{if(PerformanceObserver.supportedEntryTypes.includes(e)){var r=new PerformanceObserver((function(e){Promise.resolve().then((function(){n(e.getEntries());}));}));return r.observe(Object.assign({type:e,buffered:!0},t||{})),r}}catch(e){}},d=function(e,n,t,r){var i,o;return function(a){n.value>=0&&(a||r)&&((o=n.value-(i||0))||void 0===i)&&(i=n.value,n.delta=o,n.rating=function(e,n){return e>n[1]?"poor":e>n[0]?"needs-improvement":"good"}(n.value,t),e(n));}},l=function(e){requestAnimationFrame((function(){return requestAnimationFrame((function(){return e()}))}));},p=function(e){document.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState&&e();}));},v=function(e){var n=false;return function(){n||(e(),n=true);}},m=-1,h=function(){return "hidden"!==document.visibilityState||document.prerendering?1/0:0},g=function(e){"hidden"===document.visibilityState&&m>-1&&(m="visibilitychange"===e.type?e.timeStamp:0,T());},y=function(){addEventListener("visibilitychange",g,true),addEventListener("prerenderingchange",g,true);},T=function(){removeEventListener("visibilitychange",g,true),removeEventListener("prerenderingchange",g,true);},E=function(){return m<0&&(m=h(),y(),a((function(){setTimeout((function(){m=h(),y();}),0);}))),{get firstHiddenTime(){return m}}},C=function(e){document.prerendering?addEventListener("prerenderingchange",(function(){return e()}),true):e();},b=[1800,3e3],S=function(e,n){n=n||{},C((function(){var t,r=E(),i=f("FCP"),o=s("paint",(function(e){e.forEach((function(e){"first-contentful-paint"===e.name&&(o.disconnect(),e.startTime<r.firstHiddenTime&&(i.value=Math.max(e.startTime-u(),0),i.entries.push(e),t(true)));}));}));o&&(t=d(e,i,b,n.reportAllChanges),a((function(r){i=f("FCP"),t=d(e,i,b,n.reportAllChanges),l((function(){i.value=performance.now()-r.timeStamp,t(true);}));})));}));},L=[.1,.25],w=function(e,n){n=n||{},S(v((function(){var t,r=f("CLS",0),i=0,o=[],c=function(e){e.forEach((function(e){if(!e.hadRecentInput){var n=o[0],t=o[o.length-1];i&&e.startTime-t.startTime<1e3&&e.startTime-n.startTime<5e3?(i+=e.value,o.push(e)):(i=e.value,o=[e]);}})),i>r.value&&(r.value=i,r.entries=o,t());},u=s("layout-shift",c);u&&(t=d(e,r,L,n.reportAllChanges),p((function(){c(u.takeRecords()),t(true);})),a((function(){i=0,r=f("CLS",0),t=d(e,r,L,n.reportAllChanges),l((function(){return t()}));})),setTimeout(t,0));})));},A=0,I=1/0,P=0,M=function(e){e.forEach((function(e){e.interactionId&&(I=Math.min(I,e.interactionId),P=Math.max(P,e.interactionId),A=P?(P-I)/7+1:0);}));},k=function(){return e?A:performance.interactionCount||0},F=function(){"interactionCount"in performance||e||(e=s("event",M,{type:"event",buffered:true,durationThreshold:0}));},D=[],x=new Map,R=0,B=function(){var e=Math.min(D.length-1,Math.floor((k()-R)/50));return D[e]},H=[],q=function(e){if(H.forEach((function(n){return n(e)})),e.interactionId||"first-input"===e.entryType){var n=D[D.length-1],t=x.get(e.interactionId);if(t||D.length<10||e.duration>n.latency){if(t)e.duration>t.latency?(t.entries=[e],t.latency=e.duration):e.duration===t.latency&&e.startTime===t.entries[0].startTime&&t.entries.push(e);else {var r={id:e.interactionId,latency:e.duration,entries:[e]};x.set(r.id,r),D.push(r);}D.sort((function(e,n){return n.latency-e.latency})),D.length>10&&D.splice(10).forEach((function(e){return x.delete(e.id)}));}}},O=function(e){var n=self.requestIdleCallback||self.setTimeout,t=-1;return e=v(e),"hidden"===document.visibilityState?e():(t=n(e),p(e)),t},N=[200,500],j=function(e,n){"PerformanceEventTiming"in self&&"interactionId"in PerformanceEventTiming.prototype&&(n=n||{},C((function(){var t;F();var r,i=f("INP"),o=function(e){O((function(){e.forEach(q);var n=B();n&&n.latency!==i.value&&(i.value=n.latency,i.entries=n.entries,r());}));},c=s("event",o,{durationThreshold:null!==(t=n.durationThreshold)&&void 0!==t?t:40});r=d(e,i,N,n.reportAllChanges),c&&(c.observe({type:"first-input",buffered:true}),p((function(){o(c.takeRecords()),r(true);})),a((function(){R=k(),D.length=0,x.clear(),i=f("INP"),r=d(e,i,N,n.reportAllChanges);})));})));},_=[2500,4e3],z={},G=function(e,n){n=n||{},C((function(){var t,r=E(),i=f("LCP"),o=function(e){n.reportAllChanges||(e=e.slice(-1)),e.forEach((function(e){e.startTime<r.firstHiddenTime&&(i.value=Math.max(e.startTime-u(),0),i.entries=[e],t());}));},c=s("largest-contentful-paint",o);if(c){t=d(e,i,_,n.reportAllChanges);var m=v((function(){z[i.id]||(o(c.takeRecords()),c.disconnect(),z[i.id]=true,t(true));}));["keydown","click"].forEach((function(e){addEventListener(e,(function(){return O(m)}),{once:true,capture:true});})),p(m),a((function(r){i=f("LCP"),t=d(e,i,_,n.reportAllChanges),l((function(){i.value=performance.now()-r.timeStamp,z[i.id]=true,t(true);}));}));}}));},J=[800,1800],K=function e(n){document.prerendering?C((function(){return e(n)})):"complete"!==document.readyState?addEventListener("load",(function(){return e(n)}),true):setTimeout(n,0);},Q=function(e,n){n=n||{};var t=f("TTFB"),r=d(e,t,J,n.reportAllChanges);K((function(){var i=c();i&&(t.value=Math.max(i.responseStart-u(),0),t.entries=[i],r(true),a((function(){t=f("TTFB",0),(r=d(e,t,J,n.reportAllChanges))(true);})));}));};
6175
+ let e=-1;const t=t=>{addEventListener("pageshow",(n=>{n.persisted&&(e=n.timeStamp,t(n));}),true);},n=(e,t,n,i)=>{let s,o;return r=>{t.value>=0&&(r||i)&&(o=t.value-(s??0),(o||void 0===s)&&(s=t.value,t.delta=o,t.rating=((e,t)=>e>t[1]?"poor":e>t[0]?"needs-improvement":"good")(t.value,n),e(t)));}},i=e=>{requestAnimationFrame((()=>requestAnimationFrame((()=>e()))));},s=()=>{const e=performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},o=()=>{const e=s();return e?.activationStart??0},r=(t,n=-1)=>{const i=s();let r="navigate";e>=0?r="back-forward-cache":i&&(document.prerendering||o()>0?r="prerender":document.wasDiscarded?r="restore":i.type&&(r=i.type.replace(/_/g,"-")));return {name:t,value:n,rating:"good",delta:0,entries:[],id:`v5-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`,navigationType:r}},c=new WeakMap;function a(e,t){return c.get(e)||c.set(e,new t),c.get(e)}class d{t;i=0;o=[];h(e){if(e.hadRecentInput)return;const t=this.o[0],n=this.o.at(-1);this.i&&t&&n&&e.startTime-n.startTime<1e3&&e.startTime-t.startTime<5e3?(this.i+=e.value,this.o.push(e)):(this.i=e.value,this.o=[e]),this.t?.(e);}}const h=(e,t,n={})=>{try{if(PerformanceObserver.supportedEntryTypes.includes(e)){const i=new PerformanceObserver((e=>{Promise.resolve().then((()=>{t(e.getEntries());}));}));return i.observe({type:e,buffered:!0,...n}),i}}catch{}},f=e=>{let t=false;return ()=>{t||(e(),t=true);}};let u=-1;const l=new Set,m=()=>"hidden"!==document.visibilityState||document.prerendering?1/0:0,p=e=>{if("hidden"===document.visibilityState){if("visibilitychange"===e.type)for(const e of l)e();isFinite(u)||(u="visibilitychange"===e.type?e.timeStamp:0,removeEventListener("prerenderingchange",p,true));}},v=()=>{if(u<0){const e=o(),n=document.prerendering?void 0:globalThis.performance.getEntriesByType("visibility-state").filter((t=>"hidden"===t.name&&t.startTime>e))[0]?.startTime;u=n??m(),addEventListener("visibilitychange",p,true),addEventListener("prerenderingchange",p,true),t((()=>{setTimeout((()=>{u=m();}));}));}return {get firstHiddenTime(){return u},onHidden(e){l.add(e);}}},g=e=>{document.prerendering?addEventListener("prerenderingchange",(()=>e()),true):e();},y=[1800,3e3],E=(e,s={})=>{g((()=>{const c=v();let a,d=r("FCP");const f=h("paint",(e=>{for(const t of e)"first-contentful-paint"===t.name&&(f.disconnect(),t.startTime<c.firstHiddenTime&&(d.value=Math.max(t.startTime-o(),0),d.entries.push(t),a(true)));}));f&&(a=n(e,d,y,s.reportAllChanges),t((t=>{d=r("FCP"),a=n(e,d,y,s.reportAllChanges),i((()=>{d.value=performance.now()-t.timeStamp,a(true);}));})));}));},b=[.1,.25],L=(e,s={})=>{const o=v();E(f((()=>{let c,f=r("CLS",0);const u=a(s,d),l=e=>{for(const t of e)u.h(t);u.i>f.value&&(f.value=u.i,f.entries=u.o,c());},m=h("layout-shift",l);m&&(c=n(e,f,b,s.reportAllChanges),o.onHidden((()=>{l(m.takeRecords()),c(true);})),t((()=>{u.i=0,f=r("CLS",0),c=n(e,f,b,s.reportAllChanges),i((()=>c()));})),setTimeout(c));})));};let P=0,T=1/0,_=0;const M=e=>{for(const t of e)t.interactionId&&(T=Math.min(T,t.interactionId),_=Math.max(_,t.interactionId),P=_?(_-T)/7+1:0);};let w;const C=()=>w?P:performance.interactionCount??0,I=()=>{"interactionCount"in performance||w||(w=h("event",M,{type:"event",buffered:true,durationThreshold:0}));};let F=0;class k{u=[];l=new Map;m;p;v(){F=C(),this.u.length=0,this.l.clear();}L(){const e=Math.min(this.u.length-1,Math.floor((C()-F)/50));return this.u[e]}h(e){if(this.m?.(e),!e.interactionId&&"first-input"!==e.entryType)return;const t=this.u.at(-1);let n=this.l.get(e.interactionId);if(n||this.u.length<10||e.duration>t.P){if(n?e.duration>n.P?(n.entries=[e],n.P=e.duration):e.duration===n.P&&e.startTime===n.entries[0].startTime&&n.entries.push(e):(n={id:e.interactionId,entries:[e],P:e.duration},this.l.set(n.id,n),this.u.push(n)),this.u.sort(((e,t)=>t.P-e.P)),this.u.length>10){const e=this.u.splice(10);for(const t of e)this.l.delete(t.id);}this.p?.(n);}}}const A=e=>{const t=globalThis.requestIdleCallback||setTimeout;"hidden"===document.visibilityState?e():(e=f(e),addEventListener("visibilitychange",e,{once:true,capture:true}),t((()=>{e(),removeEventListener("visibilitychange",e,{capture:true});})));},B=[200,500],S=(e,i={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;const s=v();g((()=>{I();let o,c=r("INP");const d=a(i,k),f=e=>{A((()=>{for(const t of e)d.h(t);const t=d.L();t&&t.P!==c.value&&(c.value=t.P,c.entries=t.entries,o());}));},u=h("event",f,{durationThreshold:i.durationThreshold??40});o=n(e,c,B,i.reportAllChanges),u&&(u.observe({type:"first-input",buffered:true}),s.onHidden((()=>{f(u.takeRecords()),o(true);})),t((()=>{d.v(),c=r("INP"),o=n(e,c,B,i.reportAllChanges);})));}));};class N{m;h(e){this.m?.(e);}}const q=[2500,4e3],x=(e,s={})=>{g((()=>{const c=v();let d,u=r("LCP");const l=a(s,N),m=e=>{s.reportAllChanges||(e=e.slice(-1));for(const t of e)l.h(t),t.startTime<c.firstHiddenTime&&(u.value=Math.max(t.startTime-o(),0),u.entries=[t],d());},p=h("largest-contentful-paint",m);if(p){d=n(e,u,q,s.reportAllChanges);const o=f((()=>{m(p.takeRecords()),p.disconnect(),d(true);})),c=e=>{e.isTrusted&&(A(o),removeEventListener(e.type,c,{capture:true}));};for(const e of ["keydown","click","visibilitychange"])addEventListener(e,c,{capture:true});t((t=>{u=r("LCP"),d=n(e,u,q,s.reportAllChanges),i((()=>{u.value=performance.now()-t.timeStamp,d(true);}));}));}}));},H=[800,1800],O=e=>{document.prerendering?g((()=>O(e))):"complete"!==document.readyState?addEventListener("load",(()=>O(e)),true):setTimeout(e);},$=(e,i={})=>{let c=r("TTFB"),a=n(e,c,H,i.reportAllChanges);O((()=>{const d=s();d&&(c.value=Math.max(d.responseStart-o(),0),c.entries=[d],a(true),t((()=>{c=r("TTFB",0),a=n(e,c,H,i.reportAllChanges),a(true);})));}));};
6139
6176
 
6140
6177
  function getPaintBlocks(resources) {
6141
6178
  const paintBlocks = [];
@@ -6268,10 +6305,10 @@ function Timing (app, opts) {
6268
6305
  // onINP(): Chromium
6269
6306
  // onLCP(): Chromium, Firefox
6270
6307
  // onTTFB(): Chromium, Firefox, Safari
6271
- w(onVitalsSignal);
6272
- j(onVitalsSignal);
6273
- G(onVitalsSignal);
6274
- Q(onVitalsSignal);
6308
+ L(onVitalsSignal);
6309
+ S(onVitalsSignal);
6310
+ x(onVitalsSignal);
6311
+ $(onVitalsSignal);
6275
6312
  });
6276
6313
  app.attachStopCallback(function () {
6277
6314
  observer.disconnect();
@@ -7072,7 +7109,9 @@ class NetworkMessage {
7072
7109
  });
7073
7110
  if (!messageInfo)
7074
7111
  return null;
7075
- const isGraphql = messageInfo.url.includes("/graphql");
7112
+ const gqlHeader = "application/graphql-response";
7113
+ const isGraphql = messageInfo.url.includes("/graphql")
7114
+ || Object.values(messageInfo.request.headers).some(v => v.includes(gqlHeader));
7076
7115
  if (isGraphql && messageInfo.response.body && typeof messageInfo.response.body === 'string') {
7077
7116
  const isError = messageInfo.response.body.includes("errors");
7078
7117
  messageInfo.status = isError ? 400 : 200;
@@ -7378,6 +7417,7 @@ class FetchProxyHandler {
7378
7417
  this.tokenUrlMatcher = tokenUrlMatcher;
7379
7418
  }
7380
7419
  apply(target, _, argsList) {
7420
+ var _a;
7381
7421
  const input = argsList[0];
7382
7422
  const init = argsList[1];
7383
7423
  if (!input ||
@@ -7393,6 +7433,31 @@ class FetchProxyHandler {
7393
7433
  }
7394
7434
  const item = new NetworkMessage(this.ignoredHeaders, this.setSessionTokenHeader, this.sanitize);
7395
7435
  this.beforeFetch(item, input, init);
7436
+ const signal = (argsList[0] instanceof Request ? argsList[0].signal : undefined) ||
7437
+ ((_a = argsList[1]) === null || _a === void 0 ? void 0 : _a.signal);
7438
+ // guard to avoid double-send
7439
+ let abortedNotified = false;
7440
+ const notifyAbort = () => {
7441
+ if (abortedNotified)
7442
+ return;
7443
+ abortedNotified = true;
7444
+ item.endTime = performance.now();
7445
+ item.duration = item.endTime - (item.startTime || item.endTime);
7446
+ item.status = 0;
7447
+ item.statusText = "Aborted";
7448
+ item.readyState = 0;
7449
+ const msg = item.getMessage();
7450
+ if (msg)
7451
+ this.sendMessage(msg);
7452
+ };
7453
+ if (signal) {
7454
+ if (signal.aborted) {
7455
+ notifyAbort();
7456
+ }
7457
+ else {
7458
+ signal.addEventListener("abort", notifyAbort, { once: true });
7459
+ }
7460
+ }
7396
7461
  this.setSessionTokenHeader((name, value) => {
7397
7462
  if (this.tokenUrlMatcher !== undefined) {
7398
7463
  if (!this.tokenUrlMatcher(item.url)) {
@@ -7421,11 +7486,22 @@ class FetchProxyHandler {
7421
7486
  }
7422
7487
  });
7423
7488
  return target.apply(window, argsList)
7424
- .then(this.afterFetch(item))
7489
+ .then(this.afterFetch(item, () => {
7490
+ abortedNotified = true;
7491
+ }))
7425
7492
  .catch((e) => {
7426
- // mock finally
7427
7493
  item.endTime = performance.now();
7428
7494
  item.duration = item.endTime - (item.startTime || item.endTime);
7495
+ if (e && e.name === "AbortError") {
7496
+ item.status = 0;
7497
+ item.statusText = "Aborted";
7498
+ item.readyState = 0;
7499
+ if (!abortedNotified) {
7500
+ const msg = item.getMessage();
7501
+ if (msg)
7502
+ this.sendMessage(msg);
7503
+ }
7504
+ }
7429
7505
  throw e;
7430
7506
  });
7431
7507
  }
@@ -7477,8 +7553,10 @@ class FetchProxyHandler {
7477
7553
  item.requestData = genStringBody(init.body);
7478
7554
  }
7479
7555
  }
7480
- afterFetch(item) {
7556
+ afterFetch(item, onResolved) {
7481
7557
  return (resp) => {
7558
+ if (onResolved)
7559
+ onResolved === null || onResolved === void 0 ? void 0 : onResolved();
7482
7560
  item.endTime = performance.now();
7483
7561
  item.duration = item.endTime - (item.startTime || item.endTime);
7484
7562
  item.status = resp.status;
@@ -7514,7 +7592,15 @@ class FetchProxyHandler {
7514
7592
  }
7515
7593
  })
7516
7594
  .catch((e) => {
7517
- if (e.name !== "AbortError") {
7595
+ if (e.name === "AbortError") {
7596
+ item.status = 0;
7597
+ item.statusText = "Aborted";
7598
+ item.readyState = 0;
7599
+ const msg = item.getMessage();
7600
+ if (msg)
7601
+ this.sendMessage(msg);
7602
+ }
7603
+ else {
7518
7604
  throw e;
7519
7605
  }
7520
7606
  });
@@ -8615,7 +8701,7 @@ class ConstantProperties {
8615
8701
  user_id: this.user_id,
8616
8702
  distinct_id: this.deviceId,
8617
8703
  sdk_edition: 'web',
8618
- sdk_version: '17.2.2',
8704
+ sdk_version: '17.2.3',
8619
8705
  timezone: getUTCOffsetString(),
8620
8706
  search_engine: this.searchEngine,
8621
8707
  };
@@ -9267,7 +9353,7 @@ class API {
9267
9353
  this.signalStartIssue = (reason, missingApi) => {
9268
9354
  const doNotTrack = this.checkDoNotTrack();
9269
9355
  console.log("Tracker couldn't start due to:", JSON.stringify({
9270
- trackerVersion: '17.2.2',
9356
+ trackerVersion: '17.2.3',
9271
9357
  projectKey: this.options.projectKey,
9272
9358
  doNotTrack,
9273
9359
  reason: missingApi.length ? `missing api: ${missingApi.join(',')}` : reason,
@@ -9430,7 +9516,7 @@ class API {
9430
9516
  // no tabs in iframes yet
9431
9517
  Tabs(app);
9432
9518
  }
9433
- Mouse(app, options.mouse);
9519
+ Mouse(app, { ...options.mouse, customAttributes: options.customAttributes });
9434
9520
  // inside iframe, we ignore viewport scroll
9435
9521
  Scroll(app, this.crossdomainMode);
9436
9522
  CSSRules(app, options.css);