3 lines
27 KiB
JavaScript
3 lines
27 KiB
JavaScript
|
|
import{s as w,n as q,b as X,r as u,k as G,f as Z}from"./mt-metricskit-utils-private.esm~DkzakSThTT.js";import{L as $,l as x}from"./mt-client-logger-core.esm~-rJfHcY8Zf.js";var Q=function(){};Q.prototype.setDelegate=function(e){return u.attachDelegate(this,e)};Q.prototype.localStorageObject=w.localStorageObject;Q.prototype.sessionStorageObject=w.sessionStorageObject;var M=function(){};M.prototype.setDelegate=function(e){return u.attachDelegate(this,e)};M.prototype.makeAjaxRequest=q.makeAjaxRequest;var C="noTopicConfig",B="_",V={configBaseUrl:"https://xp.apple.com/config/1/report",disabled:!0},k,H=function(e,r,n){if(n){e.push(n);var o=n[r];o&&u.hasAnyKeys(o)&&e.push(o)}},v=function(e){this.environment=new Q,this.network=new M,this.logger=new $("mt-client-config"),this._topic=e||C,this._debugSource=null,this._cachedSource=null,this._serviceSource=null,this._initCalled=!1,this._initialized=!1,this._showedDebugWarning=!1,this._showedNoProvidedSourceWarning=!1,this._keyPathsThatSuppressWarning={configBaseUrl:!0},this._configFetchPromise=null,this.DEBUG_SOURCE_KEY="mtClientConfig_debugSource"+B+this._topic,this.CACHED_SOURCE_KEY="mtClientConfig_cachedSource"+B+this._topic};v.defaultConfig=function(){return k||(k=new v(C)),k};v.prototype._defaults=function(){return V};v.prototype._setInitialized=function(e){this._initialized=e};v.prototype._setInitCalled=function(e){this._initCalled=e};v.prototype._setShowedDebugWarning=function(e){this._showedDebugWarning=e};v.prototype._setShowedNoProvidedSourceWarning=function(e){this._showedNoProvidedSourceWarning=e};v.prototype.setDelegate=function(e){return u.attachDelegate(this,e)};v.prototype.resetDelegate=function(){u.detachMethods(this),u.resetDelegates(this)};v.prototype.topic=function(){return this._topic};v.prototype.configHostname=function(){};v.prototype.configUrl=function(){var e=this.configHostname(),r;return e?r=Promise.resolve("https://"+e+"/config/1/report"):r=this.value("configBaseUrl"),r.then((function(n){return this._topic!==C?n+="/"+this.topic():this.logger.error("config.configUrl(): Topic must be provided"),n}).bind(this))};v.prototype.sources=function(){};v.prototype.value=function(e,r){var n=(function(){var i=this.cachedSource(),a=this.serviceSource(),c=this.sources(),f=this.debugSource(),d=i||a||c||f,h;return!c&&!a&&!(e in this._keyPathsThatSuppressWarning)&&(this._showedNoProvidedSourceWarning||(this._showedNoProvidedSourceWarning=!0,this.logger.warn("Metrics config: No config provided via delegate or fetched via init(), using cached config values."))),f&&(this._showedDebugWarning||(this._showedDebugWarning=!0,this.logger.warn('"debugSource" found.\nThis will override any same-named client-supplied configSource fields.\nThis setting "sticks" across session, use "setDebugSource(null)" to clear'))),u.isArray(c)||(c=[c]),e==="disabled"?d?h=[i,a,c,f]:h=[V]:h=[V,i,a,c,f],h=this.configSourcesWithOverrides(h,r||this.topic()),G.valueForKeyPath.apply(null,[e].concat(h))}).bind(this);if(this._configFetchPromise)return this._configFetchPromise.then(n);var o=n();return Promise.resolve(o)};v.prototype.configSourcesWithOverrides=function(e,r){var n=e;if(e&&e.length&&r){n=[];for(var o=0;o<e.length;o++){var i=e[o];if(i)if(u.isArray(i)&&i.length){for(var a=[],c=0;c<i.length;c++)H(a,r,i[c]);n.push(a)}else H(n,r,i)}}return n};v.prototype.setDebugSource=function(e){return this._debugSource=e||null,w.saveObjectToStorage(this.environment.localStorageObject(),this.DEBUG_SOURCE_KEY,this._debugSource)};v.prototype.debugSource=function(){return this._debugSource||(this._debugSource=w.objectFromStorage(this.environment.localStorageObject(),this.DEBUG_SOURCE_KEY)),this._debugSource};v.prototype.setCachedSource=function(e){return this._cachedSource=e||null,w.saveObjectToStorage(this.environment.localStorageObject(),this.CACHED_SOURCE_KEY,this._cachedSource)};v.prototype.cachedSource=function(){return this._cachedSource||(this._cachedSource=w.objectFromStorage(this.environment.localStorageObject(),this.CACHED_SOURCE_KEY)),this._cachedSource};v.prototype.setServiceSource=function(e){return this._
|
||
|
|
//# sourceMappingURL=mt-metricskit-delegates-web.esm~C4cdYnvnOP.js.map
|