@embrace-io/web-sdk
Version:
3 lines (2 loc) • 6.27 kB
JavaScript
"use strict";require("uuid");var e=require("@opentelemetry/core"),t=require("@opentelemetry/api"),s=require("@opentelemetry/api-logs");const n=new class{logException(e,t){}message(e,t,s){}};class r{getDelegate(){var e;return null!==(e=this._delegate)&&void 0!==e?e:n}setDelegate(e){this._delegate=e}logException(e,t){this.getDelegate().logException(e,t)}message(e,t,s){this.getDelegate().message(e,t,s)}}class a{constructor({proxyLogManager:e}){this.getLogManager=()=>this._proxyLogManager,this._proxyLogManager=e}static getInstance(){return this._instance||(this._instance=new a({proxyLogManager:new r})),this._instance}setGlobalLogManager(e){this._proxyLogManager.setDelegate(e)}logException(e,t){this.getLogManager().logException(e,t)}message(e,t,s){this.getLogManager().message(e,t,s)}}const i=a.getInstance();const o=new class{constructor(){this.getSessionId=()=>null}addBreadcrumb(e){}addProperty(e,t){}endSessionSpan(){}endSessionSpanInternal(){}getSessionSpan(){return null}getSessionStartTime(){return null}startSessionSpan(){}addSessionStartedListener(e){return()=>{}}addSessionEndedListener(e){return()=>{}}};class g{getDelegate(){var e;return null!==(e=this._delegate)&&void 0!==e?e:o}setDelegate(e){this._delegate=e}addBreadcrumb(e){this.getDelegate().addBreadcrumb(e)}addProperty(e,t){this.getDelegate().addProperty(e,t)}endSessionSpan(){this.getDelegate().endSessionSpan()}endSessionSpanInternal(e){this.getDelegate().endSessionSpanInternal(e)}getSessionId(){return this.getDelegate().getSessionId()}getSessionSpan(){return this.getDelegate().getSessionSpan()}getSessionStartTime(){return this.getDelegate().getSessionStartTime()}startSessionSpan(){this.getDelegate().startSessionSpan()}addSessionStartedListener(e){return this.getDelegate().addSessionStartedListener(e)}addSessionEndedListener(e){return this.getDelegate().addSessionEndedListener(e)}}class S{constructor({proxySpanSessionManager:e}){this.getSpanSessionManager=()=>this._proxySpanSessionManager,this._proxySpanSessionManager=e}static getInstance(){return this._instance||(this._instance=new S({proxySpanSessionManager:new g})),this._instance}setGlobalSessionManager(e){this._proxySpanSessionManager.setDelegate(e)}addBreadcrumb(e){this.getSpanSessionManager().addBreadcrumb(e)}addProperty(e,t){this.getSpanSessionManager().addProperty(e,t)}endSessionSpan(){this.getSpanSessionManager().endSessionSpan()}endSessionSpanInternal(e){this.getSpanSessionManager().endSessionSpanInternal(e)}getSessionId(){return this.getSpanSessionManager().getSessionId()}getSessionSpan(){return this.getSpanSessionManager().getSessionSpan()}getSessionStartTime(){return this.getSpanSessionManager().getSessionStartTime()}startSessionSpan(){this.getSpanSessionManager().startSessionSpan()}addSessionStartedListener(e){return this.getSpanSessionManager().addSessionStartedListener(e)}addSessionEndedListener(e){return this.getSpanSessionManager().addSessionEndedListener(e)}}const _=S.getInstance();class d{constructor(t=e.otperformance){this.epochMillisFromOriginOffset=e=>this._clock.timeOrigin+e,this.getNowHRTime=()=>e.millisToHrTime(this.getNowMillis()),this.getNowMillis=()=>this.epochMillisFromOriginOffset(this._clock.now()),this._clock=t}}var p,c,l;exports.EMB_TYPES=void 0,(p=exports.EMB_TYPES||(exports.EMB_TYPES={})).Session="ux.session",p.View="ux.view",p.Network="perf.network_request",p.Perf="perf",p.SystemLog="sys.log",p.SystemException="sys.exception",p.WebVital="ux.web_vital",exports.EMB_STATES=void 0,(c=exports.EMB_STATES||(exports.EMB_STATES={})).Foreground="foreground",c.Background="background",exports.EMB_NAVIGATION_INSTRUMENTATIONS=void 0,(l=exports.EMB_NAVIGATION_INSTRUMENTATIONS||(exports.EMB_NAVIGATION_INSTRUMENTATIONS={})).DeclarativeLegacy="react_router_declarative_legacy",l.Declarative="react_router_declarative",l.Data="react_router_data",exports.EMB_ERROR_INSTRUMENTATIONS=void 0,(exports.EMB_ERROR_INSTRUMENTATIONS||(exports.EMB_ERROR_INSTRUMENTATIONS={})).ReactErrorBoundary="react_error_boundary";class u{constructor(e,n,r){this.instrumentationName=e,this.instrumentationVersion=n,this._config={},this.setConfig(r),this._diag=t.diag.createComponentLogger({namespace:e}),this._tracer=t.trace.getTracer(e,n),this._meter=t.metrics.getMeter(e,n),this._logger=s.logs.getLogger(e,n),this._updateMetricInstruments()}get tracer(){return this._tracer}get meter(){return this._meter}get logger(){return this._logger}getModuleDefinitions(){var e;const t=null!==(e=this.init())&&void 0!==e?e:[];return Array.isArray(t)?t:[t]}getConfig(){return this._config}setConfig(e){this._config=Object.assign({enabled:!0},e)}setLoggerProvider(e){this._logger=e.getLogger(this.instrumentationName,this.instrumentationVersion)}setMeterProvider(e){this._meter=e.getMeter(this.instrumentationName,this.instrumentationVersion),this._updateMetricInstruments()}setTracerProvider(e){this._tracer=e.getTracer(this.instrumentationName,this.instrumentationVersion)}_updateMetricInstruments(){}_runSpanCustomizationHook(e,t,s,n){if(e)try{e(s,n)}catch(e){this._diag.error("Error running span customization hook due to exception in handler",{triggerName:t},e)}}}exports.EmbraceInstrumentationBase=class extends u{constructor({instrumentationName:e,instrumentationVersion:t,config:s,diag:n,perf:r}){super(e,t,s),n&&(this._diag=n),this._perf=null!=r?r:new d,this._sessionManager=_.getSpanSessionManager(),this._logManager=i.getLogManager()}get sessionManager(){return this._sessionManager}get logManager(){return this._logManager}get perf(){return this._perf}init(){}},exports.KEY_EMB_APP_INSTANCE_ID="emb.app_instance_id",exports.KEY_EMB_ERROR_CODE="emb.error_code",exports.KEY_EMB_ERROR_LOG_COUNT="emb.error_log_count",exports.KEY_EMB_EXCEPTION_HANDLING="emb.exception_handling",exports.KEY_EMB_INSTRUMENTATION="emb.instrumentation",exports.KEY_EMB_JS_EXCEPTION_STACKTRACE="emb.stacktrace.js",exports.KEY_EMB_SESSION_REASON_ENDED="emb.session_end_type",exports.KEY_EMB_STATE="emb.state",exports.KEY_EMB_TYPE="emb.type",exports.KEY_EMB_UNHANDLED_EXCEPTIONS_COUNT="emb.unhandled_exceptions_count",exports.KEY_PREFIX_EMB_PROPERTIES="emb.properties.",exports.KEY_VIEW_NAME="view.name",exports.OTelPerformanceManager=d,exports.log=i,exports.session=_;
//# sourceMappingURL=EmbraceInstrumentationBase-CS1Yr6S5.js.map