@embrace-io/web-sdk
Version:
3 lines (2 loc) • 1.14 kB
JavaScript
import{__extends as t}from"tslib";import{EmbraceInstrumentationBase as e}from"../../EmbraceInstrumentationBase/EmbraceInstrumentationBase.js";import{getHTMLElementFriendlyName as n}from"./utils.js";var i=function(e){function i(t){var i=void 0===t?{}:t,r=i.diag,o=i.perf,a=e.call(this,{instrumentationName:"SpanSessionBrowserActivityInstrumentation",instrumentationVersion:"1.0.0",diag:r,perf:o,config:{}})||this;return a._onClickHandler=function(t){var e=t.target;if(e instanceof HTMLElement&&!e.hasAttribute("disabled"))try{var i=a.sessionManager.getSessionSpan();i&&i.addEvent("click",{"emb.type":"ux.tap","view.name":n(e),"tap.coords":"".concat(t.x.toString(),",").concat(t.y.toString())},a.perf.epochMillisFromOriginOffset(t.timeStamp))}catch(t){a._diag.error("failed to create new user interaction span event",t)}},a._config.enabled&&a.enable(),a}return t(i,e),i.prototype.disable=function(){document.removeEventListener("click",this._onClickHandler)},i.prototype.enable=function(){document.addEventListener("click",this._onClickHandler)},i}(e);export{i as ClicksInstrumentation};
//# sourceMappingURL=ClicksInstrumentation.js.map