@statsig/js-client 0.0.1-beta.28 → 0.0.1-beta.30
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/build/js-client+session-replay+web-analytics-stats.json +11400 -0
- package/build/js-client+web-analytics-stats.json +10787 -0
- package/build/js-client-stats.json +11024 -0
- package/build/statsig-js-client+session-replay+web-analytics.min.js +1 -1
- package/build/statsig-js-client+web-analytics.min.js +1 -1
- package/build/statsig-js-client.min.js +1 -1
- package/package.json +2 -2
- package/src/Network.js +3 -3
- package/src/StatsigClient.d.ts +0 -1
- package/src/StatsigClient.js +6 -9
- package/src/StatsigEvaluationsDataAdapter.d.ts +2 -2
- package/src/StatsigOptions.d.ts +11 -8
- package/src/index.d.ts +0 -1
- package/src/index.js +0 -1
- package/src/StatsigMetadataAdditions.d.ts +0 -1
- package/src/StatsigMetadataAdditions.js +0 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Statsig=e():t.Statsig=e()}(this,()=>(()=>{"use strict";var n={496:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0});var e="undefined"!=typeof window?window:{},n=void 0!==n.g?n.g:{},i="undefined"!=typeof globalThis?globalThis:{},o=null!=(o=null!=(o=null!=(o=e.__STATSIG__)?o:n.__STATSIG__)?o:i.__STATSIG__)?o:{};e.__STATSIG__=o,n.__STATSIG__=o,i.__STATSIG__=o},856:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},320:function(t,e,n){var s=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.DataAdapterCore=void 0;const i=n(512),o=n(780),r=n(104),u=n(283),l=n(296),a=n(444),c=n(412);e.DataAdapterCore=class{constructor(t,e){this.i=t,this.o=e,this.u=null,this.l=null,this.h={},this.v="statsig.last_modified_time."+e}attach(t,e){this.l=t,this.u=new i.ErrorBoundary(t),(0,r.monitorClass)(this.u,this)}getDataSync(t){var t=this._(t),e=this.h[t];return e||((e=this.m(t))?(this.p(t,e),this.h[t]):null)}getDataAsync(n,i){var o;return s(this,void 0,void 0,function*(){var t=null!=n?n:this.getDataSync(i),t=yield this.S(null!=(o=null==t?void 0:t.data)?o:null,i),e=this._(i);return t&&this.p(e,t),"Network"!==(null==t?void 0:t.source)&&"NetworkNotModified"!==(null==t?void 0:t.source)||(yield this.O(e,t)),t})}prefetchData(n){return s(this,void 0,void 0,function*(){var t=this._(n),e=yield this.getDataAsync(null,n);e&&this.p(t,Object.assign(Object.assign({},e),{source:"Prefetch"}))})}setData(t,e){e=this._(e);this.p(e,{source:"Bootstrap",data:t,receivedAt:Date.now()})}__primeInMemoryCache(t){this.h=Object.assign(Object.assign({},this.h),t)}S(n,i){return s(this,void 0,void 0,function*(){var t,e=yield this.j(n,i);return e?(t=(0,c.typedJsonParse)(e,"has_updates","Failure while attempting to persist latest value"),n&&!1===(null==t?void 0:t.has_updates)?{source:"NetworkNotModified",data:n,receivedAt:Date.now()}:!0!==(null==t?void 0:t.has_updates)?null:{source:"Network",data:e,receivedAt:Date.now()}):(o.Log.debug("No response returned for latest value"),null)})}T(){return null!=this.l?this.l:(o.Log.error(this.i+" is not attached to a Client"),"")}_(t){t=(0,l.getUserStorageKey)(this.T(),t);return`${u.DataAdapterCachePrefix}.${this.o}.`+t}p(t,e){var n=Object.entries(this.h);n.length<10||([n]=n.reduce((t,e)=>e[1]<t[1]?e:t),delete this.h[n]),this.h[t]=e}m(t){var e=null==(e=a.Storage.getItemSync)?void 0:e.call(a.Storage,t);return null!=e&&(t=(0,c.typedJsonParse)(e,"source","Failed to parse cached result"))?Object.assign(Object.assign({},t),{source:"Cache"}):null}O(t,e){return s(this,void 0,void 0,function*(){yield a.Storage.setItem(t,JSON.stringify(e)),yield this.I(t)})}I(n){var i;return s(this,void 0,void 0,function*(){var t=null!=(i=yield(0,a.getObjectFromStorage)(this.v))?i:{},e=(t[n]=Date.now(),Object.entries(t));e.length<=10||(delete t[(e=e.reduce((t,e)=>e[1]<t[1]?e:t))[0]],yield a.Storage.removeItem(e[0])),yield(0,a.setObjectInStorage)(this.v,t)})}}},280:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Diagnostics=e.captureDiagnostics=void 0;const i=n(780),o="undefined"!=typeof performance&&void 0!==performance.mark;let s=[];e.captureDiagnostics=function(t,e){r.mark(t+":start"),e=e();const n=()=>{r.mark(t+":end"),(t+":end").startsWith("initialize:")&&r.flush()};return e&&e instanceof Promise?e.finally(()=>n()):(n(),e)};class r{static mark(t,e){o&&(t=performance.mark(t,{detail:e}),s.push(t))}static flush(){var t=performance.getEntriesByType("resource").filter(t=>t.name.startsWith("https://api.statsig.com")),t={markers:s,resources:t};i.Log.debug("Diagnostics",t,JSON.stringify(t)),s=[]}}e.Diagnostics=r},512:function(t,u,e){var n=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};Object.defineProperty(u,"__esModule",{value:!0}),u.ErrorBoundary=u.EXCEPTION_ENDPOINT=void 0;const i=e(780),l=e(972);u.EXCEPTION_ENDPOINT="https://statsigapi.net/v1/sdk_exception";u.ErrorBoundary=class{constructor(t){this.l=t,this.A=new Set}capture(e,t,n){try{var i=t();return i&&i instanceof Promise?i.catch(t=>this.D(e,t,n)):i}catch(t){return this.D(e,t,n),null}}logError(t,e){this.D(t,e)}D(o,s,r){try{i.Log.warn("Caught error in "+o,{error:s});n(this,void 0,void 0,function*(){var t,e=null!=s?s:Error("[Statsig] Error was empty"),n=e instanceof Error,i=n?e.name:"No Name";this.A.has(i)||(this.A.add(i),t=l.StatsigMetadataProvider.get(),n=n?e.stack:function(t){try{return JSON.stringify(t)}catch(t){return"[Statsig] Failed to get string for error."}}(e),e=JSON.stringify(Object.assign({tag:o,exception:i,info:n},t)),yield fetch(u.EXCEPTION_ENDPOINT,{method:"POST",headers:{"STATSIG-API-KEY":this.l,"STATSIG-SDK-TYPE":String(t.sdkType),"STATSIG-SDK-VERSION":String(t.sdkVersion),"Content-Type":"application/json"},body:e}),null!=r&&r({name:"error",error:s}))}).then(()=>{}).catch(()=>{})}catch(t){}}}},500:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},788:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},728:function(t,e,n){var i=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.EventLogger=void 0;const o=n(832),s=n(780),r=n(876),u=n(444),l=n(412),a=n(84),c=n(408),d="https://api.statsig.com/v1";e.EventLogger=class{constructor(t,e,n,i){this.l=t,this.M=e,this.N=n,this.P=i,this.G=[],this.C={},this.F={},this.R=!1,this.L=Date.now(),this.U=!0===(null==i?void 0:i.disableLogging),this.J=null!=(t=null==i?void 0:i.loggingBufferMaxSize)?t:50;n=null!=(e=null==i?void 0:i.loggingIntervalMs)?e:1e4;this.K=setInterval(()=>this.V(),n),this.q=(0,a.$)(null==i?void 0:i.logEventUrl,null==i?void 0:i.api,"/rgstr",d),this.B=(0,a.$)(null==i?void 0:i.logEventBeaconUrl,null==i?void 0:i.api,"/log_event_beacon",d),c.VisibilityChangeObserver.add(this),this.H()}setLoggingDisabled(t){this.U=t}enqueue(t){this.W(t)&&(this.Y(t),this.X(),this.G.length>this.J)&&this.V()}incrementNonExposureCount(t){var e=null!=(e=this.F[t])?e:0;this.F[t]=e+1}reset(){this.C={}}onVisibilityChanged(t){"background"===t&&this.V()}shutdown(){return i(this,void 0,void 0,function*(){this.K&&(clearInterval(this.K),this.K=null),yield this.flush()})}flush(){return i(this,void 0,void 0,function*(){var t;this.Z(),0!==this.G.length&&(t=this.G,this.G=[],yield this.tt(t))})}X(){this.R||(this.R=!0,200<Date.now()-this.L)||setTimeout(()=>this.V(),200)}W(t){if((0,r.isExposureEvent)(t)){var t=[t.eventName,null==(e=t.user)?void 0:e.userID,null==(e=t.metadata)?void 0:e.gate,null==(e=t.metadata)?void 0:e.config,null==(e=t.metadata)?void 0:e.ruleID].join("|"),e=this.C[t],n=Date.now();if(e&&n-e<6e4)return!1;1e3<Object.keys(this.C).length&&(this.C={}),this.C[t]=n}return!0}V(){this.flush().catch(()=>{})}tt(t){return i(this,void 0,void 0,function*(){if(this.U)this.et(t);else try{(!c.VisibilityChangeObserver.isCurrentlyVisible()&&this.N.isBeaconSupported()?yield this.nt(t):yield this.it(t)).success?this.M({name:"logs_flushed",events:t}):this.et(t)}catch(t){s.Log.warn("Failed to flush events.")}})}it(e){return i(this,void 0,void 0,function*(){var t=yield this.N.post({sdkKey:this.l,data:{events:e},url:this.q,retries:3,params:{ec:String(e.length)}}),t=null!=t&&t.body?(0,l.typedJsonParse)(t.body,"success","Failed to parse SendEventsResponse"):null;return{success:!0===(null==t?void 0:t.success)}})}nt(t){return i(this,void 0,void 0,function*(){return{success:yield this.N.beacon({sdkKey:this.l,data:{events:t},url:this.B})}})}et(t){for(;500<t.length;)t.shift();var e=this.ot();(0,u.setObjectInStorage)(e,t).catch(()=>{s.Log.warn("Unable to save failed logs to storage")})}H(){const e=this.ot();i(this,void 0,void 0,function*(){var t=yield(0,u.getObjectFromStorage)(e);t&&(yield u.Storage.removeItem(e),yield this.tt(t))}).catch(()=>{s.Log.warn("Failed to flush stored logs")})}ot(){return"statsig.failed_logs."+(0,o.DJB2)(this.l)}Y(t){t.user&&(t.user=Object.assign({},t.user),delete t.user.privateAttributes);var e={},n=this.rt();n&&(e.statsigMetadata={currentPage:n}),this.G.push(Object.assign(Object.assign({},t),e))}Z(){0!==Object.keys(this.F).length&&(this.Y({eventName:"statsig::non_exposed_checks",user:null,time:Date.now(),metadata:{checks:Object.assign({},this.F)}}),this.F={})}rt(){var t;if(!1!==(null==(t=this.P)?void 0:t.includeCurrentPageUrlWithEvents)&&"undefined"!=typeof window&&"object"==typeof window.location)try{return window.location.href.split(/[?#]/)[0]}catch(t){}}}},832:(t,e)=>{function n(e){let n=0;for(let t=0;t<e.length;t++){var i=e.charCodeAt(t);n=(n<<5)-n+i,n&=n}return String(n>>>0)}Object.defineProperty(e,"__esModule",{value:!0}),e.DJB2Object=e.DJB2=void 0,e.DJB2=n,e.DJB2Object=function(t){return n(JSON.stringify(function n(i){if(null==i)return null;const t=Object.keys(i).sort();const o={};t.forEach(t=>{let e=i[t];e instanceof Object&&(e=n(e)),o[t]=e});return o}(t)))}},664:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},780:(t,e)=>{function n(t){return t.unshift("[Statsig]"),t}var i,o;Object.defineProperty(e,"__esModule",{value:!0}),e.Log=e.LogLevel=void 0,(o=i||(e.LogLevel=i={}))[o.None=0]="None",o[o.Error=1]="Error",o[o.Warn=2]="Warn",o[o.Info=3]="Info",o[o.Debug=4]="Debug";class s{static info(...t){this.level>=i.Info&&console.info(...n(t))}static debug(...t){this.level>=i.Debug&&console.debug(...n(t))}static warn(...t){this.level>=i.Warn&&console.warn(...n(t))}static error(...t){this.level>=i.Error&&console.error(...n(t))}}(e.Log=s).level=i.Error},104:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.monitorClass=void 0;const s=n(280),r=n(688);function c(t,e,n,i){var o=i instanceof r.StatsigClientBase?i.ut.bind(i):void 0;return t.capture(e,()=>(0,s.captureDiagnostics)(e,()=>n.apply(i)),o)}function d(t){return"object"==typeof t&&(t=Object.getPrototypeOf(t))&&"object"==typeof t?t:null}e.monitorClass=function(e,t){try{{var n=e;var i=t;var o;const s=i;for(const r of function(t){const e=new Set;let n=d(t);for(;n&&n!==Object.prototype;)Object.getOwnPropertyNames(n).filter(t=>"function"==typeof(null===n||void 0===n?void 0:n[t])).forEach(t=>e.add(t)),n=Object.getPrototypeOf(n);return Array.from(e)}(s))if("constructor"!==r){const u=s[r];s[r]=function(...t){return c(n,r,()=>u.apply(this,t),i)}}for(const l of function(t){const e=new Set,n=d(t);return Object.getOwnPropertyNames((null===n||void 0===n?void 0:n.constructor)||{}).filter(t=>{var e;return"caller"!==t&&"arguments"!==t&&"callee"!==t&&"function"==typeof(null==(e=null===n||void 0===n?void 0:n.constructor)?void 0:e[t])}).forEach(t=>e.add(t)),Array.from(e)}(s)){const a=null==(o=null===s||void 0===s?void 0:s.constructor)?void 0:o[l];(null===s||void 0===s?void 0:s.constructor)[l]=function(...t){return c(n,s.constructor.name+"."+l,()=>a.apply(s.constructor,t),i)}}return}}catch(t){e.logError("monitorClass",t)}}},188:function(t,e,n){var o=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.NetworkCore=void 0;const h=n(280),v=n(780),s=n(612),r=n(604),u=n(972);e.NetworkCore=class{constructor(t,e){this.P=t,this.M=e,this.lt=null!=(e=null==t?void 0:t.networkTimeoutMs)?e:1e4}post(e){return o(this,void 0,void 0,function*(){var t=yield this.ct(e);return this.dt(Object.assign({method:"POST",body:t},e))})}get(t){return o(this,void 0,void 0,function*(){return this.dt(Object.assign({method:"GET"},t))})}isBeaconSupported(){return"undefined"!=typeof navigator&&"function"==typeof(null===navigator||void 0===navigator?void 0:navigator.sendBeacon)}beacon(n){return o(this,void 0,void 0,function*(){var t=yield this.ht(n),e=yield this.ct(n);return navigator.sendBeacon(t,e)})}dt(c){var d;return o(this,void 0,void 0,function*(){var{method:e,body:n,retries:i}=c;const o=new AbortController;var t,s,r,u=setTimeout(()=>o.abort(`Timeout of ${this.lt}ms expired.`),this.lt),l=yield this.ht(c);let a=null;try{if(a=yield fetch(l,{method:e,body:n,headers:Object.assign({},c.headers),signal:o.signal}),clearTimeout(u),a.ok)return r=yield a.text(),h.Diagnostics.mark("_sendRequest:response-received",{status:a.status,contentLength:a.headers.get("content-length")}),{body:r,code:a.status};throw t=yield a.text().catch(()=>"No Text"),(s=new Error(`Failed to fetch: ${l} `+t)).name="NetworkError",s}catch(t){n=function(t,e){if(t.signal.aborted&&"string"==typeof t.signal.reason)return t.signal.reason;if("string"==typeof e)return e;if(e instanceof Error)return e.name+": "+e.message;return null}(o,t);return h.Diagnostics.mark("_sendRequest:error",{error:n,status:null===a||void 0===a?void 0:a.status,contentLength:null===a||void 0===a?void 0:a.headers.get("content-length")}),!i||i<=0?(null!=(d=this.M)&&d.call(this,{name:"error",error:t}),v.Log.error(`A networking error occured during ${e} request to ${l}.`,n,t),null):this.dt(Object.assign(Object.assign({},c),{retries:i-1}))}})}ht(e){return o(this,void 0,void 0,function*(){var t=u.StatsigMetadataProvider.get(),t=Object.assign({k:e.sdkKey,st:t.sdkType,sv:t.sdkVersion,t:String(Date.now()),sid:yield s.SessionID.get(e.sdkKey)},e.params),t=Object.entries(t).map(([t,e])=>encodeURIComponent(t)+"="+encodeURIComponent(e)).join("&");return e.url+(t?"?"+t:"")})}ct(i){return o(this,void 0,void 0,function*(){var t=i["data"],e=yield r.StableID.get(i.sdkKey),n=yield s.SessionID.get(i.sdkKey);return JSON.stringify(Object.assign(Object.assign({},t),{statsigMetadata:Object.assign(Object.assign({},u.StatsigMetadataProvider.get()),{stableID:e,sessionID:n})}))})}}},264:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CombinationOverrideAdapter=void 0;e.CombinationOverrideAdapter=class{constructor(t){this.providers=t}getGateOverride(n,i){return this.vt(t=>{var e;return null!=(e=null==(e=t.getGateOverride)?void 0:e.call(t,n,i))?e:null})}getDynamicConfigOverride(n,i){return this.vt(t=>{var e;return null!=(e=null==(e=t.getDynamicConfigOverride)?void 0:e.call(t,n,i))?e:null})}vt(t){for(const n of this.providers){var e=t(n);if(e)return e}return null}}},612:function(t,r,e){var n=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};Object.defineProperty(r,"__esModule",{value:!0}),r.SessionID=void 0;const i=e(832),u=e(780),l=e(444),a=e(556),c={},d={},h={};function v(t){return"statsig.session_id."+(0,i.DJB2)(t)}r.SessionID={get:t=>n(void 0,void 0,void 0,function*(){return null!=h[t]?h[t]:h[t]=r.SessionID.ft(t)}),ft:s=>n(void 0,void 0,void 0,function*(){let e=c[s];var n=Date.now();if(null==e){let t=yield function(t){t=v(t);return(0,l.getObjectFromStorage)(t)}(s);null==t&&(t={sessionID:(0,a.getUUID)(),startTime:n,lastUpdate:n}),e=t,c[s]=e}var t=null!=(t=d[s])?t:{ageTimeoutID:null,idleTimeoutID:null,emitFunction:()=>{}},i=((144e5<n-e.startTime||18e5<n-e.lastUpdate)&&(e.sessionID=(0,a.getUUID)(),e.startTime=n),e.lastUpdate=n,e),o=s;return o=v(s),(0,l.setObjectInStorage)(o,i).catch(()=>{u.Log.warn("Failed to save SessionID")}),t.idleTimeoutID=r.SessionID._t(t,t.idleTimeoutID,18e5),t.ageTimeoutID=r.SessionID._t(t,t.ageTimeoutID,144e5-(n-e.startTime)),c[s]=e,d[s]=t,h[s]=null,e.sessionID}),gt:(t,e)=>{var n=null!=(n=d[e])?n:{ageTimeoutID:null,idleTimeoutID:null,emitFunction:t};n.emitFunction=t,d[e]=n},_t:(t,e,n)=>(clearTimeout(null!=e?e:void 0),setTimeout(t.emitFunction,n))}},604:function(t,e,n){var i=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.StableID=void 0;const o=n(832),s=n(780),r=n(444),u=n(556),l={};function a(t){return"statsig.stable_id."+(0,o.DJB2)(t)}function c(t,e){e=a(e);(0,r.setObjectInStorage)(e,t).catch(()=>{s.Log.warn("Failed to save StableID")})}e.StableID={get:e=>i(void 0,void 0,void 0,function*(){return null==l[e]&&(l[e]=function(t){t=a(t);return(0,r.getObjectFromStorage)(t)}(e).then(t=>{return null!=t||c(t=(0,u.getUUID)(),e),t})),l[e]}),setOverride:(t,e)=>{l[e]=Promise.resolve(t),c(t,e)}}},688:function(t,e,n){var i=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.StatsigClientBase=void 0,n(496);const s=n(512),r=n(728),u=n(780),l=n(612),a=n(604),c=n(444);e.StatsigClientBase=class{constructor(t,e,n,i){this.loadingStatus="Uninitialized",this.yt={},this.l=t,this.P=null!=i?i:{},null!=i&&i.disableStorage&&c.Storage.setDisabled(!0),null!=i&&i.overrideStableID&&a.StableID.setOverride(i.overrideStableID,t),u.Log.level=null!=(o=null==i?void 0:i.logLevel)?o:u.LogLevel.Warn,this.bt=null!=(o=null==i?void 0:i.overrideAdapter)?o:null,this.wt=new r.EventLogger(t,this.ut.bind(this),n,i),l.SessionID.gt(()=>{this.ut({name:"session_expired"})},t),this.u=new s.ErrorBoundary(t);var o,n=null!=(o=(__STATSIG__=null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{}).instances)?o:{};n[t]=this,__STATSIG__.instances=n,(__STATSIG__.lastInstance=this).dataAdapter=e,this.dataAdapter.attach(t,i)}updateRuntimeOptions(t){null!=t.disableLogging&&(this.P.disableLogging=t.disableLogging,this.wt.setLoggingDisabled(t.disableLogging)),null!=t.disableStorage&&(this.P.disableStorage=t.disableStorage,c.Storage.setDisabled(t.disableStorage))}flush(){return this.wt.flush()}shutdown(){return i(this,void 0,void 0,function*(){this.ut({name:"pre_shutdown"}),yield this.wt.shutdown()})}on(t,e){this.yt[t]||(this.yt[t]=[]),this.yt[t].push(e)}off(t,e){this.yt[t]&&-1!==(e=this.yt[t].indexOf(e))&&this.yt[t].splice(e,1)}__on(t,e){e.__isInternal=!0,this.on(t,e)}ut(n){var t;const e=e=>{try{e(n)}catch(t){!0===e.__isInternal?this.u.logError("_emit:"+n.name,t):u.Log.error("An error occurred in a StatsigClientEvent listener. This is not an issue with Statsig.",n)}};this.yt[n.name]&&this.yt[n.name].forEach(t=>e(t)),null!=(t=this.yt["*"])&&t.forEach(e)}St(t,e){this.loadingStatus=t,this.ut({name:"values_updated",status:t,values:e})}Ot(t,e,n){!0===(null==n?void 0:n.disableExposureLog)?this.wt.incrementNonExposureCount(t):this.wt.enqueue(e)}}},808:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},283:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DataAdapterCachePrefix=void 0,e.DataAdapterCachePrefix="statsig.cached"},876:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createLayerParameterExposure=e.createConfigExposure=e.createGateExposure=e.isExposureEvent=void 0;const n="statsig::config_exposure",i="statsig::gate_exposure";function l(t,e,n,i,o){return{eventName:t,user:e,value:null,metadata:function(t,e){e.reason=t.reason,t.lcut&&(e.lcut=String(t.lcut));t.receivedAt&&(e.receivedAt=String(t.receivedAt));return e}(n,i),secondaryExposures:o,time:Date.now()}}e.isExposureEvent=function({eventName:t}){return t===i||t===n},e.createGateExposure=function(t,e){return l(i,t,e.details,{gate:e.name,gateValue:String(e.value),ruleID:e.ruleID},null!=(e=null==(t=e.__evaluation)?void 0:t.secondary_exposures)?e:[])},e.createConfigExposure=function(t,e){return l(n,t,e.details,{config:e.name,ruleID:e.ruleID},null!=(e=null==(t=e.__evaluation)?void 0:t.secondary_exposures)?e:[])},e.createLayerParameterExposure=function(t,e,n){var i,o=e.__evaluation,s=!0===(null==(s=null==o?void 0:o.explicit_parameters)?void 0:s.includes(n));let r="",u=null!=(i=null==o?void 0:o.undelegated_secondary_exposures)?i:[];return s&&(r=null!=(i=o.allocated_experiment_name)?i:"",u=o.secondary_exposures),l("statsig::layer_exposure",t,e.details,{config:e.name,parameterName:n,ruleID:e.ruleID,allocatedExperiment:r,isExplicitParameter:String(s)},u)}},972:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.StatsigMetadataProvider=e.SDK_VERSION=void 0,e.SDK_VERSION="0.0.1-beta.28";let n={sdkVersion:e.SDK_VERSION,sdkType:"js-mono"};e.StatsigMetadataProvider={get:()=>n,add:t=>{n=Object.assign(Object.assign({},n),t)}}},384:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},396:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.jt=e.Tt=e.It=e.At=void 0;const o="default";function s(s,r){return(t,e)=>{var n,i,o=null!=(o=null==s?void 0:s[t])?o:null;return null==o||null!=e&&(n=e,(i=t=>Array.isArray(t)?"array":typeof t)(o)!==i(n))?null!=e?e:null:(null!=r&&r(t),o)}}e.At=function(t,e,n){return{name:t,details:e,ruleID:null!=(t=null==n?void 0:n.rule_id)?t:o,value:!0===(null==n?void 0:n.value),__evaluation:n}},e.It=function(t,e,n){return{name:t,details:e,value:null!=(t=null==n?void 0:n.value)?t:{},ruleID:null!=(e=null==n?void 0:n.rule_id)?e:o,groupName:null,get:s(null==n?void 0:n.value),__evaluation:n}},e.Tt=function(t,e,n,i){return{name:t,details:e,get:s(null==n?void 0:n.value,i),ruleID:null!=(t=null==n?void 0:n.rule_id)?t:o,groupName:null!=(e=null==n?void 0:n.group_name)?e:null,__value:null!=(i=null==n?void 0:n.value)?i:{},__evaluation:n}},e.jt=function(t,e,n,i){return Object.assign(Object.assign(Object.assign({},t),e),{get:s(n,i)})}},136:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},296:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getUnitIDFromUser=e.getUserStorageKey=e.normalizeUser=void 0;const i=n(832);e.normalizeUser=function(t,e){try{var n=JSON.parse(JSON.stringify(t));return null!=e&&(n.statsigEnvironment=e),n}catch(t){throw new Error("User object must be convertable to JSON string.")}},e.getUserStorageKey=function(t,e){return(0,i.DJB2Object)({sdkKey:t,user:e})},e.getUnitIDFromUser=function(t,e){var n;return"string"==typeof e&&"userid"!==e.toLowerCase()?null!=(n=null==(n=t.customIDs)?void 0:n[e])?n:null==(n=null==t?void 0:t.customIDs)?void 0:n[e.toLowerCase()]:t.userID}},444:function(t,e,n){var i=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})},n=(Object.defineProperty(e,"__esModule",{value:!0}),e.setObjectInStorage=e.getObjectFromStorage=e.Storage=void 0,n(780));const o={},s={getProviderName:()=>"InMemory",getItemSync(t){return null!=(t=o[t])?t:null},getItem(t){return Promise.resolve(null!=(t=o[t])?t:null)},setItem(t,e){return o[t]=e,Promise.resolve()},removeItem(t){return delete o[t],Promise.resolve()},getAllKeys(){return Promise.resolve(Object.keys(o))}};let r=null;try{"undefined"!=typeof window&&"localStorage"in window&&(r={getProviderName:()=>"LocalStorage",getItemSync(t){return localStorage.getItem(t)},getItem(t){return Promise.resolve(localStorage.getItem(t))},setItem(t,e){return localStorage.setItem(t,e),Promise.resolve()},removeItem(t){return localStorage.removeItem(t),Promise.resolve()},getAllKeys(){var t=Object.keys(localStorage);return Promise.resolve(t)}})}catch(t){n.Log.warn("Failed to setup localStorageProvider.")}let u=null!==r&&void 0!==r?r:s,l=u;e.Storage={getProviderName:()=>l.getProviderName(),getItem:t=>l.getItem(t),setItem:(t,e)=>l.setItem(t,e),removeItem:t=>l.removeItem(t),getAllKeys:()=>l.getAllKeys(),getItemSync:t=>{var e;return null!=(e=null==(e=l.getItemSync)?void 0:e.call(l,t))?e:null},setProvider:t=>{u=t,l=t},setDisabled:t=>{l=t?s:u}},e.getObjectFromStorage=function(e){return i(this,void 0,void 0,function*(){var t=yield l.getItem(e);return JSON.parse(null!=t?t:"null")})},e.setObjectInStorage=function(t,e){return i(this,void 0,void 0,function*(){yield l.setItem(t,JSON.stringify(e))})}},412:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.typedJsonParse=void 0;const o=n(780);e.typedJsonParse=function(t,e,n){try{var i=JSON.parse(t);return"object"==typeof i&&0 in i,i}catch(t){}return o.Log.error(n),null}},556:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getUUID=void 0,e.getUUID=function(){if("undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID)return crypto.randomUUID();let n=(new Date).getTime(),i="undefined"!=typeof performance&&performance.now&&1e3*performance.now()||0;return`xxxxxxxx-xxxx-4xxx-${"89ab"[Math.floor(4*Math.random())]}xxx-xxxxxxxxxxxx`.replace(/[xy]/g,t=>{let e=16*Math.random();return 0<n?(e=(n+e)%16|0,n=Math.floor(n/16)):(e=(i+e)%16|0,i=Math.floor(i/16)),("x"===t?e:7&e|8).toString(16)})}},84:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.$=void 0,e.$=function(t,e,n,i){return t||(e?""+e+n:""+i+n)}},539:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},408:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.VisibilityChangeObserver=void 0;class n{static isCurrentlyVisible(){return"foreground"===this.xt}static add(t){this.yt.unshift(t)}static remove(t){t=this.yt.indexOf(t);-1!==t&&this.yt.splice(t,1)}static notify(e){e!==this.xt&&(this.xt=e,this.yt.forEach(t=>t.onVisibilityChanged(e)))}}(e.VisibilityChangeObserver=n).yt=[],n.xt="foreground","undefined"!=typeof window&&"function"==typeof window.addEventListener&&(window.addEventListener("focus",()=>n.notify("foreground")),window.addEventListener("blur",()=>n.notify("background")),window.addEventListener("beforeunload",()=>n.notify("background"))),"undefined"!=typeof document&&"function"==typeof document.addEventListener&&document.addEventListener("visibilitychange",()=>{n.notify("visible"===document.visibilityState?"foreground":"background")})},464:function(t,e,n){var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&("get"in o?e.__esModule:!o.writable&&!o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}:function(t,e,n,i){t[i=void 0===i?n:i]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.Log=e.Storage=e.EventLogger=void 0,n(496);const s=n(728),r=(Object.defineProperty(e,"EventLogger",{enumerable:!0,get:function(){return s.EventLogger}}),n(780));Object.defineProperty(e,"Log",{enumerable:!0,get:function(){return r.Log}});var u=n(972);const l=n(444);Object.defineProperty(e,"Storage",{enumerable:!0,get:function(){return l.Storage}});var a=n(556);o(n(496),e),o(n(856),e),o(n(320),e),o(n(512),e),o(n(500),e),o(n(788),e),o(n(832),e),o(n(664),e),o(n(780),e),o(n(104),e),o(n(188),e),o(n(264),e),o(n(612),e),o(n(604),e),o(n(688),e),o(n(808),e),o(n(283),e),o(n(876),e),o(n(972),e),o(n(384),e),o(n(396),e),o(n(136),e),o(n(296),e),o(n(444),e),o(n(412),e),o(n(84),e),o(n(539),e),o(n(556),e),o(n(408),e),__STATSIG__=Object.assign(Object.assign({},null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{}),{EventLogger:s.EventLogger,Log:r.Log,getUUID:a.getUUID,Storage:l.Storage,SDK_VERSION:u.SDK_VERSION})},696:function(t,e,n){var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&("get"in o?e.__esModule:!o.writable&&!o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}:function(t,e,n,i){t[i=void 0===i?n:i]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),o(n(208),e),e.default=__STATSIG__},96:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.resolveDeltasResponse=void 0;const i=n(464);function o(t,e){null!=t&&t.forEach(t=>{delete e[t]})}e.resolveDeltasResponse=function(t,e){var n;return(e=(0,i.typedJsonParse)(e,"checksum","Failed to parse DeltasEvaluationResponse"))?(t=t,n=e,t=Object.assign(Object.assign(Object.assign({},t),n),{feature_gates:Object.assign(Object.assign({},t.feature_gates),n.feature_gates),layer_configs:Object.assign(Object.assign({},t.layer_configs),n.layer_configs),dynamic_configs:Object.assign(Object.assign({},t.dynamic_configs),n.dynamic_configs)}),o((t=n=t).deleted_gates,t.feature_gates),delete t.deleted_gates,o(n.deleted_configs,t.dynamic_configs),delete t.deleted_configs,o(n.deleted_layers,t.layer_configs),delete t.deleted_layers,n=t,(t=(0,i.DJB2Object)({feature_gates:n.feature_gates,dynamic_configs:n.dynamic_configs,layer_configs:n.layer_configs}))===e.checksum?JSON.stringify(n):{hadBadDeltaChecksum:!0,badChecksum:t,badMergedConfigs:n,badFullResponse:e.deltas_full_response}):{hadBadDeltaChecksum:!0}}},536:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0});const i=n(464);e.default=class{constructor(){this.Dt=null,this.Mt=null,this.Et="Uninitialized",this.Nt=0,this.Pt=0}getValues(){return this.Dt?(0,i.typedJsonParse)(this.Dt,"has_updates","Failed to parse EvaluationStoreValues"):null}reset(){this.Mt=null,this.Dt=null,this.Et="Loading",this.Nt=0,this.Pt=0}finalize(){this.Mt||(this.Et="NoValues")}setValuesFromDataAdapter(t){var e;t&&!0===(null==(e=(0,i.typedJsonParse)(t.data,"has_updates","Failed to parse EvaluationResponse"))?void 0:e.has_updates)&&(this.Dt=t.data,this.Nt=e.time,this.Pt=t.receivedAt,this.Et=t.source,this.Mt=e)}getGate(t){var e,t=null!=(e=null==(e=this.Mt)?void 0:e.feature_gates[t])?e:null;return this.Gt(t)}getConfig(t){var e,t=null!=(e=null==(e=this.Mt)?void 0:e.dynamic_configs[t])?e:null;return this.Gt(t)}getLayer(t){var e,t=null!=(e=null==(e=this.Mt)?void 0:e.layer_configs[t])?e:null;return this.Gt(t)}Gt(t){return{evaluation:t,details:this.kt(null==t)}}kt(t){return"Uninitialized"===this.Et||"NoValues"===this.Et?{reason:this.Et}:{reason:this.Et+":"+(t?"Unrecognized":"Recognized"),lcut:this.Nt,receivedAt:this.Pt}}}},400:function(t,e,n){var s=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const r=n(464),u=n(96);class i extends r.NetworkCore{constructor(t,e){super(t,e),this.Ct=(0,r.$)(null==t?void 0:t.initializeUrl,null==t?void 0:t.api,"/initialize","https://api.statsig.com/v1")}fetchEvaluations(n,i,o){return s(this,void 0,void 0,function*(){var t=i?(0,r.typedJsonParse)(i,"has_updates","Failed to parse cached EvaluationResponse"):null;let e={user:o,hash:"djb2",deltasResponseRequested:!1};return null!=t&&t.has_updates&&(e=Object.assign(Object.assign({},e),{sinceTime:t.time,previousDerivedFields:"derived_fields"in t?t.derived_fields:{},deltasResponseRequested:!0})),this.Ft(n,t,e)})}Ft(e,n,i){var o;return s(this,void 0,void 0,function*(){var t=yield this.post({sdkKey:e,url:this.Ct,data:i,retries:2});return 204===(null==t?void 0:t.code)?'{"has_updates": false}':200!==(null==t?void 0:t.code)?null!=(o=null==t?void 0:t.body)?o:null:!0!==(null==n?void 0:n.has_updates)||!0!==(null==(o=t.body)?void 0:o.includes('"is_delta":true'))?t.body:"string"==typeof(t=(0,u.resolveDeltasResponse)(n,t.body))?t:this.Ft(e,n,Object.assign(Object.assign(Object.assign({},i),t),{deltasResponseRequested:!1}))})}}e.default=i},520:function(t,e,n){var i=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const r=n(464),o=n(536),s=n(400),u=n(364);n(807);class l extends r.StatsigClientBase{constructor(t,e,n=null){var i=new s.default(n,t=>{this.ut(t)});super(t,null!=(t=null==n?void 0:n.dataAdapter)?t:new u.StatsigEvaluationsDataAdapter,i,n),(0,r.monitorClass)(this.u,this),(0,r.monitorClass)(this.u,i),this.Rt=new o.default,this.Lt=e}static instance(t){var e;return __STATSIG__=null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{},null==t?__STATSIG__.lastInstance:null==(e=__STATSIG__.instances)?void 0:e[t]}initializeSync(){this.updateUserSync(this.Lt)}initializeAsync(){return this.updateUserAsync(this.Lt)}updateUserSync(t){this.Ut(t);t=this.dataAdapter.getDataSync(this.Lt);this.Rt.setValuesFromDataAdapter(t),this.Rt.finalize(),this.St("Ready",t),this.Jt(null!=t?t:null,this.Lt)}updateUserAsync(n){return i(this,void 0,void 0,function*(){this.Ut(n);var t=this.Lt,e=this.dataAdapter.getDataSync(t);this.St("Loading",e),this.Rt.setValuesFromDataAdapter(e),e=yield this.dataAdapter.getDataAsync(e,t),t===this.Lt&&this.Rt.setValuesFromDataAdapter(e),this.Rt.finalize(),this.St("Ready",e)})}getContext(){return{sdkKey:this.l,options:this.P,values:this.Rt.getValues(),user:JSON.parse(JSON.stringify(this.Lt))}}getAsyncContext(){return i(this,void 0,void 0,function*(){return Object.assign(Object.assign({},this.getContext()),{sessionID:yield r.SessionID.get(this.l),stableID:yield r.StableID.get(this.l)})})}checkGate(t,e){return this.getFeatureGate(t,e).value}getFeatureGate(t,e){var n=(0,r.DJB2)(t),{evaluation:n,details:i}=this.Rt.getGate(n),i=(0,r.At)(t,i,n),o=null==(o=null==(n=this.bt)?void 0:n.getGateOverride)?void 0:o.call(n,i,this.Lt,e),n=null!=o?o:i;return this.Ot(t,(0,r.createGateExposure)(this.Lt,n),e),this.ut({name:"gate_evaluation",gate:n}),n}getDynamicConfig(t,e){t=this.Kt("dynamic_config",t,e);return this.ut({name:"dynamic_config_evaluation",dynamicConfig:t}),t}getExperiment(t,e){t=this.Kt("experiment",t,e);return this.ut({name:"experiment_evaluation",experiment:t}),t}getLayer(e,n){var t=(0,r.DJB2)(e),{evaluation:t,details:i}=this.Rt.getLayer(t),i=(0,r.Tt)(e,i,t),o=null==(o=null==(t=this.bt)?void 0:t.getLayerOverride)?void 0:o.call(t,i,this.Lt,n);const s=(0,r.jt)(i,o,null!=(t=null==o?void 0:o.__value)?t:i.__value,t=>{this.Ot(e,(0,r.createLayerParameterExposure)(this.Lt,s,t),n)});return this.ut({name:"layer_evaluation",layer:s}),s}logEvent(t,e,n){this.wt.enqueue(Object.assign(Object.assign({},"string"==typeof t?{eventName:t,value:e,metadata:n}:t),{user:this.Lt,time:Date.now()}))}Jt(t,e){this.dataAdapter.getDataAsync(t,e).catch(t=>{r.Log.error("An error occurred after update.",t)})}Ut(t){this.wt.reset(),this.Rt.reset(),this.Lt=(0,r.normalizeUser)(t,this.P.environment)}Kt(t,e,n){var i=(0,r.DJB2)(e),{evaluation:i,details:o}=this.Rt.getConfig(i),o=(0,r.It)(e,o,i),i="experiment"===t?null==(t=null==(i=this.bt)?void 0:i.getExperimentOverride)?void 0:t.call(i,o,this.Lt,n):null==(i=null==(t=this.bt)?void 0:t.getDynamicConfigOverride)?void 0:i.call(t,o,this.Lt,n),t=null!=i?i:o;return this.Ot(e,(0,r.createConfigExposure)(this.Lt,t),n),t}}e.default=l},364:function(t,e,n){var o=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})},i=(Object.defineProperty(e,"__esModule",{value:!0}),e.StatsigEvaluationsDataAdapter=void 0,n(464));const s=n(400);class r extends i.DataAdapterCore{constructor(){super("EvaluationsDataAdapter","evaluations"),this.N=null}attach(t,e){super.attach(t,e),this.N=new s.default(null!=e?e:{})}j(e,n){var i;return o(this,void 0,void 0,function*(){var t=yield null==(i=this.N)?void 0:i.fetchEvaluations(this.T(),e,n);return null!=t?t:null})}}e.StatsigEvaluationsDataAdapter=r},807:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SDK_TYPE=void 0;n=n(464);e.SDK_TYPE="javascript-client",n.StatsigMetadataProvider.add({sdkType:e.SDK_TYPE})},208:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.StatsigClient=e.StatsigEvaluationsDataAdapter=void 0;var i=n(520);e.StatsigClient=i.default;const o=n(364);Object.defineProperty(e,"StatsigEvaluationsDataAdapter",{enumerable:!0,get:function(){return o.StatsigEvaluationsDataAdapter}}),n(807),__STATSIG__=Object.assign(Object.assign({},null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{}),{StatsigEvaluationsDataAdapter:o.StatsigEvaluationsDataAdapter,StatsigClient:i.default,instance:i.default.instance}),e.default=__STATSIG__}},i={};function o(t){var e=i[t];return void 0!==e||(e=i[t]={exports:{}},n[t].call(e.exports,e,e.exports,o)),e.exports}return o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),o(696).default})());
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Statsig=e():t.Statsig=e()}(this,()=>(()=>{"use strict";var $Q=(e)=>Object.defineProperty(e,"__esModule",{value:!0});var $P = (a,b) => Object.assign(a,b);var n={496:(t,e,n)=>{$Q(e),e.i=void 0;var i,o="__STATSIG__",s="undefined"!=typeof window?window:{},n=void 0!==n.g?n.g:{},r="undefined"!=typeof globalThis?globalThis:{};const u=null!=(i=null!=(i=null!=(i=s[o])?i:n[o])?i:r[o])?i:{};s[o]=u,n[o]=u,r[o]=u;e.i=()=>null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:u},856:(t,e)=>{$Q(e)},320:function(t,e,n){var s=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};$Q(e),e.DataAdapterCore=void 0;const i=n(512),o=n(780),r=n(104),u=n(283),l=n(296),a=n(444),c=n(412);e.DataAdapterCore=class{constructor(t,e){this.o=t,this.u=e,this.l=null,this.h=null,this.v={},this._="statsig.last_modified_time."+e}attach(t,e){this.h=t,this.l=new i.ErrorBoundary(t),(0,r.monitorClass)(this.l,this)}getDataSync(t){var t=this.m(t),e=this.v[t];return e||((e=this.p(t))?(this.S(t,e),this.v[t]):null)}getDataAsync(n,i){var o;return s(this,void 0,void 0,function*(){var t=null!=n?n:this.getDataSync(i),t=yield this.O(null!=(o=null==t?void 0:t.data)?o:null,i),e=this.m(i);return t&&this.S(e,t),"Network"!==(null==t?void 0:t.source)&&"NetworkNotModified"!==(null==t?void 0:t.source)||(yield this.j(e,t)),t})}prefetchData(n){return s(this,void 0,void 0,function*(){var t=this.m(n),e=yield this.getDataAsync(null,n);e&&this.S(t,$P($P({},e),{source:"Prefetch"}))})}setData(t,e){e=this.m(e);this.S(e,{source:"Bootstrap",data:t,receivedAt:Date.now()})}__primeInMemoryCache(t){this.v=$P($P({},this.v),t)}O(n,i){return s(this,void 0,void 0,function*(){var t,e=yield this.T(n,i);return e?(t=(0,c.typedJsonParse)(e,"has_updates","Failure while attempting to persist latest value"),n&&!1===(null==t?void 0:t.has_updates)?{source:"NetworkNotModified",data:n,receivedAt:Date.now()}:!0!==(null==t?void 0:t.has_updates)?null:{source:"Network",data:e,receivedAt:Date.now()}):(o.Log.debug("No response returned for latest value"),null)})}I(){return null!=this.h?this.h:(o.Log.error(this.o+" is not attached to a Client"),"")}m(t){t=(0,l.getUserStorageKey)(this.I(),t);return`${u.DataAdapterCachePrefix}.${this.u}.`+t}S(t,e){var n=Object.entries(this.v);n.length<10||([n]=n.reduce((t,e)=>e[1]<t[1]?e:t),delete this.v[n]),this.v[t]=e}p(t){var e=null==(e=a.Storage.A)?void 0:e.call(a.Storage,t);return null!=e&&(t=(0,c.typedJsonParse)(e,"source","Failed to parse cached result"))?$P($P({},t),{source:"Cache"}):null}j(t,e){return s(this,void 0,void 0,function*(){yield a.Storage.M(t,JSON.stringify(e)),yield this.D(t)})}D(n){var i;return s(this,void 0,void 0,function*(){var t=null!=(i=yield(0,a.N)(this._))?i:{},e=(t[n]=Date.now(),Object.entries(t));e.length<=10||(delete t[(e=e.reduce((t,e)=>e[1]<t[1]?e:t))[0]],yield a.Storage.P(e[0])),yield(0,a.R)(this._,t)})}}},280:(t,e,n)=>{$Q(e),e.Diagnostics=e.captureDiagnostics=void 0;const i=n(780),o=n(256),s="undefined"!=typeof performance&&void 0!==performance.mark;let r=[];e.captureDiagnostics=function(t,e){u.mark(t+":start"),e=e();const n=()=>{u.mark(t+":end"),(t+":end").startsWith("initialize:")&&u.flush()};return e&&e instanceof Promise?e.finally(()=>n()):(n(),e)};class u{static mark(t,e){s&&(t=performance.mark(t,{detail:e}),r.push(t))}static flush(){var t=performance.getEntriesByType("resource").filter(t=>t.name.startsWith(o.NetworkDefault.initializeApi)||t.name.startsWith(o.NetworkDefault.specsApi)||t.name.startsWith(o.NetworkDefault.eventsApi)),t={markers:r,resources:t};i.Log.debug("Diagnostics",t,JSON.stringify(t)),r=[]}}e.Diagnostics=u},184:(t,e)=>{$Q(e)},512:function(t,l,e){var n=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};Object.defineProperty(l,"__esModule",{value:!0}),l.ErrorBoundary=l.EXCEPTION_ENDPOINT=void 0;const i=e(780),a=e(360),c=e(972);l.EXCEPTION_ENDPOINT="https://statsigapi.net/v1/sdk_exception";l.ErrorBoundary=class{constructor(t){this.h=t,this.C=new Set}capture(e,t,n){try{var i=t();return i&&i instanceof Promise?i.catch(t=>this.G(e,t,n)):i}catch(t){return this.G(e,t,n),null}}logError(t,e){this.G(t,e)}G(s,r,u){try{i.Log.warn("Caught error in "+s,{error:r});n(this,void 0,void 0,function*(){var t,e,n=null!=r?r:Error("[Statsig] Error was empty"),i=n instanceof Error,o=i?n.name:"No Name";this.C.has(o)||(this.C.add(o),t=a.SDKType.F(this.h),e=c.StatsigMetadataProvider.get(),i=i?n.stack:function(t){try{return JSON.stringify(t)}catch(t){return"[Statsig] Failed to get string for error."}}(n),n=JSON.stringify($P({tag:s,exception:o,info:i},$P($P({},e),{sdkType:t}))),yield fetch(l.EXCEPTION_ENDPOINT,{method:"POST",headers:{"STATSIG-API-KEY":this.h,"STATSIG-SDK-TYPE":String(t),"STATSIG-SDK-VERSION":String(e.sdkVersion),"Content-Type":"application/json"},body:n}),null!=u&&u({name:"error",error:r}))}).then(()=>{}).catch(()=>{})}catch(t){}}}},500:(t,e)=>{$Q(e)},788:(t,e)=>{$Q(e)},728:function(t,e,n){var i=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};$Q(e),e.EventLogger=void 0;const o=n(832),s=n(780),r=n(256),u=n(452),l=n(876),a=n(444),c=n(412),d=n(84),h=n(100);e.EventLogger=class{constructor(t,e,n,i){this.h=t,this.L=e,this.U=n,this.J=i,this.K=[],this.q={},this.V={},this.B=!1,this.$=Date.now(),this.H=!0===(null==i?void 0:i.disableLogging),this.W=null!=(t=null==i?void 0:i.loggingBufferMaxSize)?t:50;n=null!=(e=null==i?void 0:i.loggingIntervalMs)?e:1e4,this.Y=setInterval(()=>this.X(),n),t=null==i?void 0:i.networkConfig;this.Z=(0,d.tt)(null==t?void 0:t.logEventUrl,null==t?void 0:t.api,"/rgstr",r.NetworkDefault.eventsApi),this.et=(0,d.tt)(null==t?void 0:t.logEventBeaconUrl,null==t?void 0:t.api,"/log_event_beacon",r.NetworkDefault.eventsApi),(0,h.nt)(this.it.bind(this)),this.ot()}setLoggingDisabled(t){this.H=t}enqueue(t){this.rt(t)&&(this.ut(t),this.lt(),this.K.length>this.W)&&this.X()}incrementNonExposureCount(t){var e=null!=(e=this.V[t])?e:0;this.V[t]=e+1}reset(){this.q={}}shutdown(){return i(this,void 0,void 0,function*(){this.Y&&(clearInterval(this.Y),this.Y=null),yield this.flush()})}flush(){return i(this,void 0,void 0,function*(){var t;this.ct(),0!==this.K.length&&(t=this.K,this.K=[],yield this.dt(t))})}it(t){"background"===t&&this.X()}lt(){this.B||(this.B=!0,200<Date.now()-this.$)||setTimeout(()=>this.X(),200)}rt(t){if((0,l.ht)(t)){var t=[t.eventName,null==(e=t.user)?void 0:e.userID,null==(e=t.metadata)?void 0:e.gate,null==(e=t.metadata)?void 0:e.config,null==(e=t.metadata)?void 0:e.ruleID].join("|"),e=this.q[t],n=Date.now();if(e&&n-e<6e4)return!1;1e3<Object.keys(this.q).length&&(this.q={}),this.q[t]=n}return!0}X(){this.flush().catch(()=>{})}dt(t){return i(this,void 0,void 0,function*(){if(this.H)this.vt(t);else try{(!(0,h._t)()&&this.U.isBeaconSupported()?yield this.ft(t):yield this.gt(t)).success?this.L({name:"logs_flushed",events:t}):this.vt(t)}catch(t){s.Log.warn("Failed to flush events.")}})}gt(e){return i(this,void 0,void 0,function*(){var t=yield this.U.post({sdkKey:this.h,data:{events:e},url:this.Z,retries:3,params:{[u.NetworkParam.EventCount]:String(e.length)}}),t=null!=t&&t.body?(0,c.typedJsonParse)(t.body,"success","Failed to parse SendEventsResponse"):null;return{success:!0===(null==t?void 0:t.success)}})}ft(t){return i(this,void 0,void 0,function*(){return{success:yield this.U.beacon({sdkKey:this.h,data:{events:t},url:this.et})}})}vt(t){for(;500<t.length;)t.shift();var e=this.bt();(0,a.R)(e,t).catch(()=>{s.Log.warn("Unable to save failed logs to storage")})}ot(){const e=this.bt();i(this,void 0,void 0,function*(){var t=yield(0,a.N)(e);t&&(yield a.Storage.P(e),yield this.dt(t))}).catch(()=>{s.Log.warn("Failed to flush stored logs")})}bt(){return"statsig.failed_logs."+(0,o.DJB2)(this.h)}ut(t){t.user&&(t.user=$P({},t.user),delete t.user.privateAttributes);var e={},n=this.yt();n&&(e.statsigMetadata={currentPage:n}),this.K.push($P($P({},t),e))}ct(){0!==Object.keys(this.V).length&&(this.ut({eventName:"statsig::non_exposed_checks",user:null,time:Date.now(),metadata:{checks:$P({},this.V)}}),this.V={})}yt(){var t;if(!1!==(null==(t=this.J)?void 0:t.includeCurrentPageUrlWithEvents)&&"undefined"!=typeof window&&"object"==typeof window.location)try{return window.location.href.split(/[?#]/)[0]}catch(t){}}}},832:(t,e)=>{$Q(e),e.DJB2Object=e.DJB2=void 0;e.DJB2=e=>{let n=0;for(let t=0;t<e.length;t++){var i=e.charCodeAt(t);n=(n<<5)-n+i,n&=n}return String(n>>>0)};e.DJB2Object=t=>(0,e.DJB2)(JSON.stringify(o(t)));const o=n=>{if(null==n)return null;var t=Object.keys(n).sort();const i={};return t.forEach(t=>{let e=n[t];e instanceof Object&&(e=o(e)),i[t]=e}),i}},664:(t,e)=>{$Q(e)},780:(t,e)=>{function n(t){return t.unshift("[Statsig]"),t}var i,o;$Q(e),e.Log=e.LogLevel=void 0,(o=i||(e.LogLevel=i={}))[o.None=0]="None",o[o.Error=1]="Error",o[o.Warn=2]="Warn",o[o.Info=3]="Info",o[o.Debug=4]="Debug";class s{static info(...t){this.level>=i.Info&&console.info(...n(t))}static debug(...t){this.level>=i.Debug&&console.debug(...n(t))}static warn(...t){this.level>=i.Warn&&console.warn(...n(t))}static error(...t){this.level>=i.Error&&console.error(...n(t))}}(e.Log=s).level=i.Error},104:(t,e,n)=>{$Q(e),e.monitorClass=void 0;const s=n(280),r=n(688);function c(t,e,n,i){var o=i instanceof r.StatsigClientBase?i.St.bind(i):void 0;return t.capture(e,()=>(0,s.captureDiagnostics)(e,()=>n.apply(i)),o)}function d(t){return"object"==typeof t&&(t=Object.getPrototypeOf(t))&&"object"==typeof t?t:null}e.monitorClass=function(e,t){try{{var n=e;var i=t;var o;const s=i;for(const r of function(t){const e=new Set;let n=d(t);for(;n&&n!==Object.prototype;)Object.getOwnPropertyNames(n).filter(t=>"function"==typeof(null===n||void 0===n?void 0:n[t])).forEach(t=>e.add(t)),n=Object.getPrototypeOf(n);return Array.from(e)}(s))if("constructor"!==r){const u=s[r];s[r]=function(...t){return c(n,r,()=>u.apply(this,t),i)}}for(const l of function(t){const e=new Set,n=d(t);return Object.getOwnPropertyNames((null===n||void 0===n?void 0:n.constructor)||{}).filter(t=>{var e;return"caller"!==t&&"arguments"!==t&&"callee"!==t&&"function"==typeof(null==(e=null===n||void 0===n?void 0:n.constructor)?void 0:e[t])}).forEach(t=>e.add(t)),Array.from(e)}(s)){const a=null==(o=null===s||void 0===s?void 0:s.constructor)?void 0:o[l];(null===s||void 0===s?void 0:s.constructor)[l]=function(...t){return c(n,s.constructor.name+"."+l,()=>a.apply(s.constructor,t),i)}}return}}catch(t){e.logError("monitorClass",t)}}},188:function(t,e,n){var i=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};$Q(e),e.NetworkCore=void 0,n(496);const h=n(280),v=n(780),o=n(452),s=n(360),r=n(612),u=n(604),l=n(972);e.NetworkCore=class{constructor(t,e){this.J=t,this.L=e,this.Ot=null!=(t=null==(e=null==t?void 0:t.networkConfig)?void 0:e.networkTimeoutMs)?t:1e4}post(e){return i(this,void 0,void 0,function*(){var t=yield this.jt(e);return this.Tt($P({method:"POST",body:this.t(e,t)},e))})}get(t){return this.Tt($P({method:"GET"},t))}isBeaconSupported(){return"undefined"!=typeof navigator&&"function"==typeof(null===navigator||void 0===navigator?void 0:navigator.sendBeacon)}beacon(n){return i(this,void 0,void 0,function*(){var t=yield this.wt(n),e=yield this.jt(n);return navigator.sendBeacon(t,e)})}Tt(c){var d;return i(this,void 0,void 0,function*(){var{method:e,body:n,retries:i}=c;const o=new AbortController;var t,s,r,u=setTimeout(()=>o.abort(`Timeout of ${this.Ot}ms expired.`),this.Ot),l=yield this.wt(c);let a=null;try{if(a=yield fetch(l,{method:e,body:n,headers:$P({},c.headers),signal:o.signal}),clearTimeout(u),a.ok)return r=yield a.text(),h.Diagnostics.mark("_sendRequest:response-received",{status:a.status,contentLength:a.headers.get("content-length")}),{body:r,code:a.status};throw t=yield a.text().catch(()=>"No Text"),(s=new Error(`Failed to fetch: ${l} `+t)).name="NetworkError",s}catch(t){n=function(t,e){if(t.signal.aborted&&"string"==typeof t.signal.reason)return t.signal.reason;if("string"==typeof e)return e;if(e instanceof Error)return e.name+": "+e.message;return null}(o,t);return h.Diagnostics.mark("_sendRequest:error",{error:n,status:null===a||void 0===a?void 0:a.status,contentLength:null===a||void 0===a?void 0:a.headers.get("content-length")}),!i||i<=0?(null!=(d=this.L)&&d.call(this,{name:"error",error:t}),v.Log.error(`A networking error occured during ${e} request to ${l}.`,n,t),null):this.Tt($P($P({},c),{retries:i-1}))}})}wt(e){return i(this,void 0,void 0,function*(){var t=$P({[o.NetworkParam.SdkKey]:e.sdkKey,[o.NetworkParam.SdkType]:s.SDKType.F(e.sdkKey),[o.NetworkParam.SdkVersion]:l.SDK_VERSION,[o.NetworkParam.Time]:String(Date.now()),[o.NetworkParam.SessionID]:yield r.SessionID.get(e.sdkKey)},e.params),t=Object.entries(t).map(([t,e])=>encodeURIComponent(t)+"="+encodeURIComponent(e)).join("&");return e.url+(t?"?"+t:"")})}jt(o){return i(this,void 0,void 0,function*(){var{data:t,sdkKey:e}=o,n=yield u.StableID.get(e),i=yield r.SessionID.get(e),e=s.SDKType.F(e);return JSON.stringify($P($P({},t),{statsigMetadata:$P($P({},l.StatsigMetadataProvider.get()),{stableID:n,sessionID:i,sdkType:e})}))})}t(t,e){var n;return!(null!=(null===__STATSIG__||void 0===__STATSIG__?void 0:__STATSIG__["no-encode"])||null!=(n=this.J)&&n.disableStatsigEncoding)&&t.isStatsigEncodable&&"undefined"!=typeof window&&window.btoa&&(t.params=$P($P({},null!=(n=t.params)?n:{}),{[o.NetworkParam.StatsigEncoded]:"1"}),null!=(t=window.btoa(e).split("").reverse().join("")))?t:e}}},256:(t,e)=>{$Q(e),e.NetworkDefault=void 0,e.NetworkDefault={eventsApi:"https://events.statsigapi.net/v1",initializeApi:"https://featuregates.org/v1",specsApi:"https://api.statsigcdn.com/v1"}},452:(t,e)=>{$Q(e),e.NetworkParam=void 0,e.NetworkParam={EventCount:"ec",SdkKey:"k",SdkType:"st",SdkVersion:"sv",Time:"t",SessionID:"sid",StatsigEncoded:"se"}},264:(t,e)=>{$Q(e)},360:(t,e)=>{$Q(e),e.SDKType=void 0;const n={};let i;e.SDKType={F:t=>{return(null!=(t=n[t])?t:"js-mono")+(null!==i&&void 0!==i?i:"")},It(t,e){n[t]=e},At(t){i&&"-react"!==i||(i="-"+t)}}},48:(t,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.xt=i.Mt=i.Dt=i.Et=void 0;i.Et=()=>"undefined"!=typeof window?window:null,i.Dt=()=>{var t=(0,i.Et)();return null!=(t=null==t?void 0:t.document)?t:null},i.Mt=(t,e)=>{var n=(0,i.Et)();"function"==typeof(null==n?void 0:n.addEventListener)&&n.addEventListener(t,e)};i.xt=(t,e)=>{var n=(0,i.Dt)();"function"==typeof(null==n?void 0:n.addEventListener)&&n.addEventListener(t,e)}},612:function(t,r,e){var n=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};Object.defineProperty(r,"__esModule",{value:!0}),r.SessionID=void 0;const i=e(832),u=e(780),l=e(444),a=e(556),c={},d={},h={};function v(t){return"statsig.session_id."+(0,i.DJB2)(t)}r.SessionID={get:t=>null!=h[t]?h[t]:h[t]=r.SessionID.Nt(t),Nt:s=>n(void 0,void 0,void 0,function*(){let e=c[s];var n=Date.now();if(null==e){let t=yield function(t){t=v(t);return(0,l.N)(t)}(s);null==t&&(t={sessionID:(0,a.getUUID)(),startTime:n,lastUpdate:n}),e=t,c[s]=e}var t=null!=(t=d[s])?t:{ageTimeoutID:null,idleTimeoutID:null,emitFunction:()=>{}},i=((144e5<n-e.startTime||18e5<n-e.lastUpdate)&&(e.sessionID=(0,a.getUUID)(),e.startTime=n),e.lastUpdate=n,e),o=s;return o=v(s),(0,l.R)(o,i).catch(()=>{u.Log.warn("Failed to save SessionID")}),t.idleTimeoutID=r.SessionID.kt(t,t.idleTimeoutID,18e5),t.ageTimeoutID=r.SessionID.kt(t,t.ageTimeoutID,144e5-(n-e.startTime)),c[s]=e,d[s]=t,h[s]=null,e.sessionID}),Pt:(t,e)=>{var n=null!=(n=d[e])?n:{ageTimeoutID:null,idleTimeoutID:null,emitFunction:t};n.emitFunction=t,d[e]=n},kt:(t,e,n)=>(clearTimeout(null!=e?e:void 0),setTimeout(t.emitFunction,n))}},604:function(t,e,n){var i=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};$Q(e),e.StableID=void 0;const o=n(832),s=n(780),r=n(444),u=n(556),l={};function a(t){return"statsig.stable_id."+(0,o.DJB2)(t)}function c(t,e){e=a(e);(0,r.R)(e,t).catch(()=>{s.Log.warn("Failed to save StableID")})}e.StableID={get:e=>i(void 0,void 0,void 0,function*(){return null==l[e]&&(l[e]=function(t){t=a(t);return(0,r.N)(t)}(e).then(t=>{return null!=t||c(t=(0,u.getUUID)(),e),t})),l[e]}),setOverride:(t,e)=>{l[e]=Promise.resolve(t),c(t,e)}}},688:function(t,e,n){var i=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};$Q(e),e.StatsigClientBase=void 0,n(496);const s=n(512),r=n(728),u=n(780),l=n(612),a=n(604),c=n(444);e.StatsigClientBase=class{constructor(t,e,n,i){this.loadingStatus="Uninitialized",this.Rt={},this.h=t,this.J=null!=i?i:{},null!=i&&i.disableStorage&&c.Storage.Ct(!0),null!=i&&i.overrideStableID&&a.StableID.setOverride(i.overrideStableID,t),u.Log.level=null!=(o=null==i?void 0:i.logLevel)?o:u.LogLevel.Warn,this.Gt=null!=(o=null==i?void 0:i.overrideAdapter)?o:null,this.Ft=new r.EventLogger(t,this.St.bind(this),n,i),l.SessionID.Pt(()=>{this.St({name:"session_expired"})},t),this.l=new s.ErrorBoundary(t);var o=null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{},n=null!=(n=o.instances)?n:{};n[t]=this,o.lastInstance=this,o.instances=n,__STATSIG__=o,this.dataAdapter=e,this.dataAdapter.attach(t,i)}updateRuntimeOptions(t){null!=t.disableLogging&&(this.J.disableLogging=t.disableLogging,this.Ft.setLoggingDisabled(t.disableLogging)),null!=t.disableStorage&&(this.J.disableStorage=t.disableStorage,c.Storage.Ct(t.disableStorage))}flush(){return this.Ft.flush()}shutdown(){return i(this,void 0,void 0,function*(){this.St({name:"pre_shutdown"}),yield this.Ft.shutdown()})}on(t,e){this.Rt[t]||(this.Rt[t]=[]),this.Rt[t].push(e)}off(t,e){this.Rt[t]&&-1!==(e=this.Rt[t].indexOf(e))&&this.Rt[t].splice(e,1)}__on(t,e){e.__isInternal=!0,this.on(t,e)}St(n){var t;const e=e=>{try{e(n)}catch(t){!0===e.__isInternal?this.l.logError("_emit:"+n.name,t):u.Log.error("An error occurred in a StatsigClientEvent listener. This is not an issue with Statsig.",n)}};this.Rt[n.name]&&this.Rt[n.name].forEach(t=>e(t)),null!=(t=this.Rt["*"])&&t.forEach(e)}Lt(t,e){this.loadingStatus=t,this.St({name:"values_updated",status:t,values:e})}Ut(t,e,n){!0===(null==n?void 0:n.disableExposureLog)?this.Ft.incrementNonExposureCount(t):this.Ft.enqueue(e)}}},808:(t,e)=>{$Q(e)},283:(t,e)=>{$Q(e),e.DataAdapterCachePrefix=void 0,e.DataAdapterCachePrefix="statsig.cached"},876:(t,e)=>{$Q(e),e.Jt=e.Kt=e.qt=e.ht=void 0;const n="statsig::config_exposure",i="statsig::gate_exposure",l=(t,e,n,i,o)=>({eventName:t,user:e,value:null,metadata:s(n,i),secondaryExposures:o,time:Date.now()});e.ht=({eventName:t})=>t===i||t===n,e.qt=(t,e)=>{return l(i,t,e.details,{gate:e.name,gateValue:String(e.value),ruleID:e.ruleID},null!=(e=null==(t=e.__evaluation)?void 0:t.secondary_exposures)?e:[])},e.Kt=(t,e)=>{return l(n,t,e.details,{config:e.name,ruleID:e.ruleID},null!=(e=null==(t=e.__evaluation)?void 0:t.secondary_exposures)?e:[])};e.Jt=(t,e,n)=>{var i,o=e.__evaluation,s=!0===(null==(s=null==o?void 0:o.explicit_parameters)?void 0:s.includes(n));let r="",u=null!=(i=null==o?void 0:o.undelegated_secondary_exposures)?i:[];return s&&(r=null!=(i=o.allocated_experiment_name)?i:"",u=o.secondary_exposures),l("statsig::layer_exposure",t,e.details,{config:e.name,parameterName:n,ruleID:e.ruleID,allocatedExperiment:r,isExplicitParameter:String(s)},u)};const s=(t,e)=>(e.reason=t.reason,t.lcut&&(e.lcut=String(t.lcut)),t.receivedAt&&(e.receivedAt=String(t.receivedAt)),e)},972:(t,e)=>{$Q(e),e.StatsigMetadataProvider=e.SDK_VERSION=void 0,e.SDK_VERSION="0.0.1-beta.30";let n={sdkVersion:e.SDK_VERSION,sdkType:"js-mono"};e.StatsigMetadataProvider={get:()=>n,add:t=>{n=$P($P({},n),t)}}},384:(t,e)=>{$Q(e)},396:(t,e)=>{$Q(e),e.Vt=e.zt=e.Bt=e.$t=void 0;const o="default";function s(t,e,n,i){return{name:t,details:e,ruleID:null!=(t=null==n?void 0:n.rule_id)?t:o,__evaluation:n,value:i}}function r(s,r){return(t,e)=>{var n,i,o=null!=(o=null==s?void 0:s[t])?o:null;return null==o||null!=e&&(n=e,(i=t=>Array.isArray(t)?"array":typeof t)(o)!==i(n))?null!=e?e:null:(null!=r&&r(t),o)}}e.$t=function(t,e,n){return s(t,e,n,!0===(null==n?void 0:n.value))},e.Bt=function(t,e,n){return $P($P({},s(t,e,n,null!=(t=null==n?void 0:n.value)?t:{})),{groupName:null,get:r(null==n?void 0:n.value)})},e.zt=function(t,e,n,i){return $P($P({},s(t,e,n,void 0)),{get:r(null==n?void 0:n.value,i),groupName:null!=(t=null==n?void 0:n.group_name)?t:null,__value:null!=(e=null==n?void 0:n.value)?e:{}})},e.Vt=function(t,e,n,i){return $P($P($P({},t),e),{get:r(n,i)})}},136:(t,e)=>{$Q(e)},296:(t,e,n)=>{$Q(e),e.getUnitIDFromUser=e.getUserStorageKey=e.normalizeUser=void 0;const i=n(832);e.normalizeUser=function(t,e){try{var n=JSON.parse(JSON.stringify(t));return null!=e&&(n.statsigEnvironment=e),n}catch(t){throw new Error("User object must be convertable to JSON string.")}},e.getUserStorageKey=function(t,e){return(0,i.DJB2Object)({sdkKey:t,user:e})},e.getUnitIDFromUser=function(t,e){var n;return"string"==typeof e&&"userid"!==e.toLowerCase()?null!=(n=null==(n=t.customIDs)?void 0:n[e])?n:null==(n=null==t?void 0:t.customIDs)?void 0:n[e.toLowerCase()]:t.userID}},444:function(t,e,n){var i=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})},n=($Q(e),e.R=e.N=e.Storage=void 0,n(780));const o={},s={Ht:()=>"InMemory",A(t){return null!=(t=o[t])?t:null},Wt(t){return Promise.resolve(null!=(t=o[t])?t:null)},M(t,e){return o[t]=e,Promise.resolve()},P(t){return delete o[t],Promise.resolve()},Yt(){return Promise.resolve(Object.keys(o))}};let r=null;try{"undefined"!=typeof window&&"localStorage"in window&&(r={Ht:()=>"LocalStorage",A(t){return localStorage.getItem(t)},Wt(t){return Promise.resolve(localStorage.getItem(t))},M(t,e){return localStorage.setItem(t,e),Promise.resolve()},P(t){return localStorage.removeItem(t),Promise.resolve()},Yt(){var t=Object.keys(localStorage);return Promise.resolve(t)}})}catch(t){n.Log.warn("Failed to setup localStorageProvider.")}let u=null!==r&&void 0!==r?r:s,l=u;e.Storage={Ht:()=>l.Ht(),Wt:t=>l.Wt(t),M:(t,e)=>l.M(t,e),P:t=>l.P(t),Yt:()=>l.Yt(),A:t=>{var e;return null!=(e=null==(e=l.A)?void 0:e.call(l,t))?e:null},Qt:t=>{u=t,l=t},Ct:t=>{l=t?s:u}},e.N=function(e){return i(this,void 0,void 0,function*(){var t=yield l.Wt(e);return JSON.parse(null!=t?t:"null")})},e.R=function(t,e){return i(this,void 0,void 0,function*(){yield l.M(t,JSON.stringify(e))})}},412:(t,e,n)=>{$Q(e),e.typedJsonParse=void 0;const o=n(780);e.typedJsonParse=function(t,e,n){try{var i=JSON.parse(t);return"object"==typeof i&&0 in i,i}catch(t){}return o.Log.error(n),null}},556:(t,e)=>{$Q(e),e.getUUID=void 0,e.getUUID=function(){if("undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID)return crypto.randomUUID();let n=(new Date).getTime(),i="undefined"!=typeof performance&&performance.now&&1e3*performance.now()||0;return`xxxxxxxx-xxxx-4xxx-${"89ab"[Math.floor(4*Math.random())]}xxx-xxxxxxxxxxxx`.replace(/[xy]/g,t=>{let e=16*Math.random();return 0<n?(e=(n+e)%16|0,n=Math.floor(n/16)):(e=(i+e)%16|0,i=Math.floor(i/16)),("x"===t?e:7&e|8).toString(16)})}},84:(t,e)=>{$Q(e),e.tt=void 0,e.tt=function(t,e,n,i){return t||(e?""+e+n:""+i+n)}},539:(t,e)=>{$Q(e)},100:(t,e,n)=>{$Q(e),e.Xt=e.nt=e._t=void 0;n=n(48);const i="foreground",o="background",s=[];let r=i;e._t=()=>r===i,e.nt=t=>{s.unshift(t)};e.Xt=e=>{e!==r&&(r=e,s.forEach(t=>t(e)))},(0,n.Mt)("focus",()=>(0,e.Xt)(i)),(0,n.Mt)("blur",()=>(0,e.Xt)(o)),(0,n.Mt)("beforeunload",()=>(0,e.Xt)(o)),(0,n.xt)("visibilitychange",()=>{(0,e.Xt)("visible"===document.visibilityState?i:o)})},464:function(t,e,n){var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&("get"in o?e.__esModule:!o.writable&&!o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}:function(t,e,n,i){t[i=void 0===i?n:i]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)};$Q(e),e.Log=e.Storage=e.EventLogger=void 0,n(496);const s=n(728),r=(Object.defineProperty(e,"EventLogger",{enumerable:!0,get:function(){return s.EventLogger}}),n(780));Object.defineProperty(e,"Log",{enumerable:!0,get:function(){return r.Log}});var u=n(972);const l=n(444);Object.defineProperty(e,"Storage",{enumerable:!0,get:function(){return l.Storage}});var a=n(556);o(n(496),e),o(n(856),e),o(n(320),e),o(n(184),e),o(n(512),e),o(n(500),e),o(n(788),e),o(n(832),e),o(n(664),e),o(n(780),e),o(n(104),e),o(n(452),e),o(n(188),e),o(n(256),e),o(n(264),e),o(n(48),e),o(n(360),e),o(n(612),e),o(n(604),e),o(n(688),e),o(n(808),e),o(n(283),e),o(n(876),e),o(n(972),e),o(n(384),e),o(n(396),e),o(n(136),e),o(n(296),e),o(n(444),e),o(n(412),e),o(n(84),e),o(n(539),e),o(n(556),e),o(n(100),e),__STATSIG__=$P($P({},null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{}),{EventLogger:s.EventLogger,Log:r.Log,getUUID:a.getUUID,Storage:l.Storage,SDK_VERSION:u.SDK_VERSION})},696:function(t,e,n){var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&("get"in o?e.__esModule:!o.writable&&!o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}:function(t,e,n,i){t[i=void 0===i?n:i]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)};$Q(e),o(n(208),e),e.default=__STATSIG__},96:(t,e,n)=>{$Q(e),e.resolveDeltasResponse=void 0;const i=n(464);function o(t,e){null!=t&&t.forEach(t=>{delete e[t]})}e.resolveDeltasResponse=function(t,e){var n;return(e=(0,i.typedJsonParse)(e,"checksum","Failed to parse DeltasEvaluationResponse"))?(t=t,n=e,t=$P($P($P({},t),n),{feature_gates:$P($P({},t.feature_gates),n.feature_gates),layer_configs:$P($P({},t.layer_configs),n.layer_configs),dynamic_configs:$P($P({},t.dynamic_configs),n.dynamic_configs)}),o((t=n=t).deleted_gates,t.feature_gates),delete t.deleted_gates,o(n.deleted_configs,t.dynamic_configs),delete t.deleted_configs,o(n.deleted_layers,t.layer_configs),delete t.deleted_layers,n=t,(t=(0,i.DJB2Object)({feature_gates:n.feature_gates,dynamic_configs:n.dynamic_configs,layer_configs:n.layer_configs}))===e.checksum?JSON.stringify(n):{hadBadDeltaChecksum:!0,badChecksum:t,badMergedConfigs:n,badFullResponse:e.deltas_full_response}):{hadBadDeltaChecksum:!0}}},536:(t,e,n)=>{$Q(e);const i=n(464);e.default=class{constructor(){this.Zt=null,this.te=null,this.ee="Uninitialized",this.ne=0,this.ie=0}getValues(){return this.Zt?(0,i.typedJsonParse)(this.Zt,"has_updates","Failed to parse EvaluationStoreValues"):null}reset(){this.te=null,this.Zt=null,this.ee="Loading",this.ne=0,this.ie=0}finalize(){this.te||(this.ee="NoValues")}setValuesFromDataAdapter(t){var e;t&&!0===(null==(e=(0,i.typedJsonParse)(t.data,"has_updates","Failed to parse EvaluationResponse"))?void 0:e.has_updates)&&(this.Zt=t.data,this.ne=e.time,this.ie=t.receivedAt,this.ee=t.source,this.te=e)}getGate(t){var e,t=null!=(e=null==(e=this.te)?void 0:e.feature_gates[t])?e:null;return this.se(t)}getConfig(t){var e,t=null!=(e=null==(e=this.te)?void 0:e.dynamic_configs[t])?e:null;return this.se(t)}getLayer(t){var e,t=null!=(e=null==(e=this.te)?void 0:e.layer_configs[t])?e:null;return this.se(t)}se(t){return{evaluation:t,details:this.oe(null==t)}}oe(t){return"Uninitialized"===this.ee||"NoValues"===this.ee?{reason:this.ee}:{reason:this.ee+":"+(t?"Unrecognized":"Recognized"),lcut:this.ne,receivedAt:this.ie}}}},400:function(t,e,n){var s=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};$Q(e);const r=n(464),u=n(96);class i extends r.NetworkCore{constructor(t,e){super(t,e);e=null==t?void 0:t.networkConfig;this.re=(0,r.tt)(null==e?void 0:e.initializeUrl,null==e?void 0:e.api,"/initialize",r.NetworkDefault.initializeApi)}fetchEvaluations(n,i,o){return s(this,void 0,void 0,function*(){var t=i?(0,r.typedJsonParse)(i,"has_updates","Failed to parse cached EvaluationResponse"):null;let e={user:o,hash:"djb2",deltasResponseRequested:!1};return null!=t&&t.has_updates&&(e=$P($P({},e),{sinceTime:t.time,previousDerivedFields:"derived_fields"in t?t.derived_fields:{},deltasResponseRequested:!0})),this.ue(n,t,e)})}ue(e,n,i){var o;return s(this,void 0,void 0,function*(){var t=yield this.post({sdkKey:e,url:this.re,data:i,retries:2,isStatsigEncodable:!0});return 204===(null==t?void 0:t.code)?'{"has_updates": false}':200!==(null==t?void 0:t.code)?null!=(o=null==t?void 0:t.body)?o:null:!0!==(null==n?void 0:n.has_updates)||!0!==(null==(o=t.body)?void 0:o.includes('"is_delta":true'))?t.body:"string"==typeof(t=(0,u.resolveDeltasResponse)(n,t.body))?t:this.ue(e,n,$P($P($P({},i),t),{deltasResponseRequested:!1}))})}}e.default=i},520:function(t,e,n){var i=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};$Q(e);const r=n(464),o=n(536),s=n(400),u=n(364);class l extends r.StatsigClientBase{constructor(t,e,n=null){r.SDKType.It(t,"javascript-client");var i=new s.default(n,t=>{this.St(t)});super(t,null!=(t=null==n?void 0:n.dataAdapter)?t:new u.StatsigEvaluationsDataAdapter,i,n),(0,r.monitorClass)(this.l,this),(0,r.monitorClass)(this.l,i),this.le=new o.default,this.ae=e}static instance(t){var e,n=(0,r.i)();return t?null==(e=n.instances)?void 0:e[t]:n.lastInstance}initializeSync(){this.updateUserSync(this.ae)}initializeAsync(){return this.updateUserAsync(this.ae)}updateUserSync(t){this.ce(t);t=this.dataAdapter.getDataSync(this.ae);this.le.setValuesFromDataAdapter(t),this.le.finalize(),this.Lt("Ready",t),this.de(null!=t?t:null,this.ae)}updateUserAsync(n){return i(this,void 0,void 0,function*(){this.ce(n);var t=this.ae,e=this.dataAdapter.getDataSync(t);this.Lt("Loading",e),this.le.setValuesFromDataAdapter(e),e=yield this.dataAdapter.getDataAsync(e,t),t===this.ae&&this.le.setValuesFromDataAdapter(e),this.le.finalize(),this.Lt("Ready",e)})}getContext(){return{sdkKey:this.h,options:this.J,values:this.le.getValues(),user:JSON.parse(JSON.stringify(this.ae))}}getAsyncContext(){return i(this,void 0,void 0,function*(){return $P($P({},this.getContext()),{sessionID:yield r.SessionID.get(this.h),stableID:yield r.StableID.get(this.h)})})}checkGate(t,e){return this.getFeatureGate(t,e).value}getFeatureGate(t,e){var n=(0,r.DJB2)(t),{evaluation:n,details:i}=this.le.getGate(n),i=(0,r.$t)(t,i,n),o=null==(o=null==(n=this.Gt)?void 0:n.getGateOverride)?void 0:o.call(n,i,this.ae,e),n=null!=o?o:i;return this.Ut(t,(0,r.qt)(this.ae,n),e),this.St({name:"gate_evaluation",gate:n}),n}getDynamicConfig(t,e){t=this.he("dynamic_config",t,e);return this.St({name:"dynamic_config_evaluation",dynamicConfig:t}),t}getExperiment(t,e){t=this.he("experiment",t,e);return this.St({name:"experiment_evaluation",experiment:t}),t}getLayer(e,n){var t=(0,r.DJB2)(e),{evaluation:t,details:i}=this.le.getLayer(t),i=(0,r.zt)(e,i,t),o=null==(o=null==(t=this.Gt)?void 0:t.getLayerOverride)?void 0:o.call(t,i,this.ae,n);const s=(0,r.Vt)(i,o,null!=(t=null==o?void 0:o.__value)?t:i.__value,t=>{this.Ut(e,(0,r.Jt)(this.ae,s,t),n)});return this.St({name:"layer_evaluation",layer:s}),s}logEvent(t,e,n){this.Ft.enqueue($P($P({},"string"==typeof t?{eventName:t,value:e,metadata:n}:t),{user:this.ae,time:Date.now()}))}de(t,e){this.dataAdapter.getDataAsync(t,e).catch(t=>{r.Log.error("An error occurred after update.",t)})}ce(t){this.Ft.reset(),this.le.reset(),this.ae=(0,r.normalizeUser)(t,this.J.environment)}he(t,e,n){var i=(0,r.DJB2)(e),{evaluation:i,details:o}=this.le.getConfig(i),o=(0,r.Bt)(e,o,i),i="experiment"===t?null==(t=null==(i=this.Gt)?void 0:i.getExperimentOverride)?void 0:t.call(i,o,this.ae,n):null==(i=null==(t=this.Gt)?void 0:t.getDynamicConfigOverride)?void 0:i.call(t,o,this.ae,n),t=null!=i?i:o;return this.Ut(e,(0,r.Kt)(this.ae,t),n),t}}e.default=l},364:function(t,e,n){var o=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})},i=($Q(e),e.StatsigEvaluationsDataAdapter=void 0,n(464));const s=n(400);class r extends i.DataAdapterCore{constructor(){super("EvaluationsDataAdapter","evaluations"),this.U=null}attach(t,e){super.attach(t,e),this.U=new s.default(null!=e?e:{})}T(e,n){var i;return o(this,void 0,void 0,function*(){var t=yield null==(i=this.U)?void 0:i.fetchEvaluations(this.I(),e,n);return null!=t?t:null})}}e.StatsigEvaluationsDataAdapter=r},208:(t,e,n)=>{$Q(e),e.StatsigClient=e.StatsigEvaluationsDataAdapter=void 0;var i=n(520);e.StatsigClient=i.default;const o=n(364);Object.defineProperty(e,"StatsigEvaluationsDataAdapter",{enumerable:!0,get:function(){return o.StatsigEvaluationsDataAdapter}}),__STATSIG__=$P($P({},null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{}),{StatsigEvaluationsDataAdapter:o.StatsigEvaluationsDataAdapter,StatsigClient:i.default,instance:i.default.instance}),e.default=__STATSIG__}},i={};function o(t){var e=i[t];return void 0!==e||(e=i[t]={exports:{}},n[t].call(e.exports,e,e.exports,o)),e.exports}return o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),o(696).default})());
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@statsig/js-client",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.30",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@statsig/client-core": "0.0.1-beta.
|
|
5
|
+
"@statsig/client-core": "0.0.1-beta.30"
|
|
6
6
|
},
|
|
7
7
|
"jsdelivr": "./build/statsig-js-client.min.js",
|
|
8
8
|
"type": "commonjs",
|
package/src/Network.js
CHANGED
|
@@ -11,12 +11,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const client_core_1 = require("@statsig/client-core");
|
|
13
13
|
const EvaluationResponseDeltas_1 = require("./EvaluationResponseDeltas");
|
|
14
|
-
const DEFAULT_API = 'https://api.statsig.com/v1';
|
|
15
|
-
const DEFAULT_ENDPOINT = '/initialize';
|
|
16
14
|
class StatsigNetwork extends client_core_1.NetworkCore {
|
|
17
15
|
constructor(options, emitter) {
|
|
18
16
|
super(options, emitter);
|
|
19
|
-
|
|
17
|
+
const config = options === null || options === void 0 ? void 0 : options.networkConfig;
|
|
18
|
+
this._initializeUrl = (0, client_core_1._getOverridableUrl)(config === null || config === void 0 ? void 0 : config.initializeUrl, config === null || config === void 0 ? void 0 : config.api, '/initialize', client_core_1.NetworkDefault.initializeApi);
|
|
20
19
|
}
|
|
21
20
|
fetchEvaluations(sdkKey, current, user) {
|
|
22
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -42,6 +41,7 @@ class StatsigNetwork extends client_core_1.NetworkCore {
|
|
|
42
41
|
url: this._initializeUrl,
|
|
43
42
|
data,
|
|
44
43
|
retries: 2,
|
|
44
|
+
isStatsigEncodable: true,
|
|
45
45
|
});
|
|
46
46
|
if ((response === null || response === void 0 ? void 0 : response.code) === 204) {
|
|
47
47
|
return '{"has_updates": false}';
|
package/src/StatsigClient.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { DynamicConfig, DynamicConfigEvaluationOptions, EvaluationsDataAdapter, Experiment, ExperimentEvaluationOptions, FeatureGate, FeatureGateEvaluationOptions, Layer, LayerEvaluationOptions, PrecomputedEvaluationsAsyncContext, PrecomputedEvaluationsContext, PrecomputedEvaluationsInterface, StatsigClientBase, StatsigEvent, StatsigUser } from '@statsig/client-core';
|
|
2
|
-
import './StatsigMetadataAdditions';
|
|
3
2
|
import type { StatsigOptions } from './StatsigOptions';
|
|
4
3
|
export default class StatsigClient extends StatsigClientBase<EvaluationsDataAdapter> implements PrecomputedEvaluationsInterface {
|
|
5
4
|
private _store;
|
package/src/StatsigClient.js
CHANGED
|
@@ -13,7 +13,6 @@ const client_core_1 = require("@statsig/client-core");
|
|
|
13
13
|
const EvaluationStore_1 = require("./EvaluationStore");
|
|
14
14
|
const Network_1 = require("./Network");
|
|
15
15
|
const StatsigEvaluationsDataAdapter_1 = require("./StatsigEvaluationsDataAdapter");
|
|
16
|
-
require("./StatsigMetadataAdditions");
|
|
17
16
|
class StatsigClient extends client_core_1.StatsigClientBase {
|
|
18
17
|
/**
|
|
19
18
|
* StatsigClient constuctor
|
|
@@ -24,6 +23,7 @@ class StatsigClient extends client_core_1.StatsigClientBase {
|
|
|
24
23
|
*/
|
|
25
24
|
constructor(sdkKey, user, options = null) {
|
|
26
25
|
var _a;
|
|
26
|
+
client_core_1.SDKType._setClientType(sdkKey, 'javascript-client');
|
|
27
27
|
const network = new Network_1.default(options, (e) => {
|
|
28
28
|
this._emit(e);
|
|
29
29
|
});
|
|
@@ -43,11 +43,8 @@ class StatsigClient extends client_core_1.StatsigClientBase {
|
|
|
43
43
|
*/
|
|
44
44
|
static instance(sdkKey) {
|
|
45
45
|
var _a;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return __STATSIG__.lastInstance;
|
|
49
|
-
}
|
|
50
|
-
return (_a = __STATSIG__.instances) === null || _a === void 0 ? void 0 : _a[sdkKey];
|
|
46
|
+
const sGlobal = (0, client_core_1._getStatsigGlobal)();
|
|
47
|
+
return (sdkKey ? (_a = sGlobal.instances) === null || _a === void 0 ? void 0 : _a[sdkKey] : sGlobal.lastInstance);
|
|
51
48
|
}
|
|
52
49
|
/**
|
|
53
50
|
* Initializes the StatsigClient using cached values. This method sets up the client synchronously by utilizing previously cached values.
|
|
@@ -162,7 +159,7 @@ class StatsigClient extends client_core_1.StatsigClientBase {
|
|
|
162
159
|
const gate = (0, client_core_1._makeFeatureGate)(name, details, evaluation);
|
|
163
160
|
const overridden = (_b = (_a = this._overrideAdapter) === null || _a === void 0 ? void 0 : _a.getGateOverride) === null || _b === void 0 ? void 0 : _b.call(_a, gate, this._user, options);
|
|
164
161
|
const result = overridden !== null && overridden !== void 0 ? overridden : gate;
|
|
165
|
-
this._enqueueExposure(name, (0, client_core_1.
|
|
162
|
+
this._enqueueExposure(name, (0, client_core_1._createGateExposure)(this._user, result), options);
|
|
166
163
|
this._emit({ name: 'gate_evaluation', gate: result });
|
|
167
164
|
return result;
|
|
168
165
|
}
|
|
@@ -204,7 +201,7 @@ class StatsigClient extends client_core_1.StatsigClientBase {
|
|
|
204
201
|
const layer = (0, client_core_1._makeLayer)(name, details, evaluation);
|
|
205
202
|
const overridden = (_b = (_a = this._overrideAdapter) === null || _a === void 0 ? void 0 : _a.getLayerOverride) === null || _b === void 0 ? void 0 : _b.call(_a, layer, this._user, options);
|
|
206
203
|
const result = (0, client_core_1._mergeOverride)(layer, overridden, (_c = overridden === null || overridden === void 0 ? void 0 : overridden.__value) !== null && _c !== void 0 ? _c : layer.__value, (param) => {
|
|
207
|
-
this._enqueueExposure(name, (0, client_core_1.
|
|
204
|
+
this._enqueueExposure(name, (0, client_core_1._createLayerParameterExposure)(this._user, result, param), options);
|
|
208
205
|
});
|
|
209
206
|
this._emit({ name: 'layer_evaluation', layer: result });
|
|
210
207
|
return result;
|
|
@@ -245,7 +242,7 @@ class StatsigClient extends client_core_1.StatsigClientBase {
|
|
|
245
242
|
? (_b = (_a = this._overrideAdapter) === null || _a === void 0 ? void 0 : _a.getExperimentOverride) === null || _b === void 0 ? void 0 : _b.call(_a, config, this._user, options)
|
|
246
243
|
: (_d = (_c = this._overrideAdapter) === null || _c === void 0 ? void 0 : _c.getDynamicConfigOverride) === null || _d === void 0 ? void 0 : _d.call(_c, config, this._user, options);
|
|
247
244
|
const result = overridden !== null && overridden !== void 0 ? overridden : config;
|
|
248
|
-
this._enqueueExposure(name, (0, client_core_1.
|
|
245
|
+
this._enqueueExposure(name, (0, client_core_1._createConfigExposure)(this._user, result), options);
|
|
249
246
|
return result;
|
|
250
247
|
}
|
|
251
248
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DataAdapterCore, EvaluationsDataAdapter,
|
|
1
|
+
import { AnyStatsigOptions, DataAdapterCore, EvaluationsDataAdapter, StatsigUser } from '@statsig/client-core';
|
|
2
2
|
export declare class StatsigEvaluationsDataAdapter extends DataAdapterCore implements EvaluationsDataAdapter {
|
|
3
3
|
private _network;
|
|
4
4
|
constructor();
|
|
5
|
-
attach(sdkKey: string, options:
|
|
5
|
+
attach(sdkKey: string, options: AnyStatsigOptions | null): void;
|
|
6
6
|
protected _fetchFromNetwork(current: string | null, user?: StatsigUser): Promise<string | null>;
|
|
7
7
|
}
|
package/src/StatsigOptions.d.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
import { EvaluationsDataAdapter, Flatten, StatsigOptionsCommon } from '@statsig/client-core';
|
|
2
|
-
|
|
1
|
+
import { EvaluationsDataAdapter, Flatten, NetworkConfigCommon, StatsigOptionsCommon } from '@statsig/client-core';
|
|
2
|
+
type UrlOverrideOptions = Flatten<NetworkConfigCommon & {
|
|
3
|
+
/**
|
|
4
|
+
* The URL used to fetch the latest evaluations for a given user. Takes precedence over {@link StatsigOptionsCommon.api}.
|
|
5
|
+
*
|
|
6
|
+
* default: `https://featuregates.org/v1/initialize`
|
|
7
|
+
*/
|
|
8
|
+
initializeUrl?: string;
|
|
9
|
+
}>;
|
|
10
|
+
export type StatsigOptions = Flatten<StatsigOptionsCommon<UrlOverrideOptions> & {
|
|
3
11
|
/**
|
|
4
12
|
* An implementor of {@link EvaluationsDataAdapter}, used to customize the initialization/update flow.
|
|
5
13
|
*
|
|
@@ -8,10 +16,5 @@ export type StatsigOptions = Flatten<StatsigOptionsCommon & {
|
|
|
8
16
|
* @see {@link https://docs.statsig.com/client/javascript-sdk/using-evaluations-data-adapter}
|
|
9
17
|
*/
|
|
10
18
|
dataAdapter?: EvaluationsDataAdapter;
|
|
11
|
-
/**
|
|
12
|
-
* The URL used to fetch the latest evaluations for a given user. Takes precedence over {@link StatsigOptionsCommon.api}.
|
|
13
|
-
*
|
|
14
|
-
* default: `https://api.statsig.com/v1/initialize`
|
|
15
|
-
*/
|
|
16
|
-
initializeUrl?: string;
|
|
17
19
|
}>;
|
|
20
|
+
export {};
|
package/src/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import StatsigClient from './StatsigClient';
|
|
2
2
|
import { StatsigEvaluationsDataAdapter } from './StatsigEvaluationsDataAdapter';
|
|
3
|
-
import './StatsigMetadataAdditions';
|
|
4
3
|
import type { StatsigOptions } from './StatsigOptions';
|
|
5
4
|
export type { StatsigEnvironment, StatsigEvent, StatsigUser, InitializeResponse, } from '@statsig/client-core';
|
|
6
5
|
export { StatsigEvaluationsDataAdapter, StatsigClient, StatsigOptions };
|
package/src/index.js
CHANGED
|
@@ -5,7 +5,6 @@ const StatsigClient_1 = require("./StatsigClient");
|
|
|
5
5
|
exports.StatsigClient = StatsigClient_1.default;
|
|
6
6
|
const StatsigEvaluationsDataAdapter_1 = require("./StatsigEvaluationsDataAdapter");
|
|
7
7
|
Object.defineProperty(exports, "StatsigEvaluationsDataAdapter", { enumerable: true, get: function () { return StatsigEvaluationsDataAdapter_1.StatsigEvaluationsDataAdapter; } });
|
|
8
|
-
require("./StatsigMetadataAdditions");
|
|
9
8
|
__STATSIG__ = Object.assign(Object.assign({}, (__STATSIG__ !== null && __STATSIG__ !== void 0 ? __STATSIG__ : {})), { StatsigEvaluationsDataAdapter: StatsigEvaluationsDataAdapter_1.StatsigEvaluationsDataAdapter,
|
|
10
9
|
StatsigClient: StatsigClient_1.default, instance: StatsigClient_1.default.instance });
|
|
11
10
|
exports.default = __STATSIG__;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const SDK_TYPE = "javascript-client";
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SDK_TYPE = void 0;
|
|
4
|
-
const client_core_1 = require("@statsig/client-core");
|
|
5
|
-
exports.SDK_TYPE = 'javascript-client';
|
|
6
|
-
client_core_1.StatsigMetadataProvider.add({
|
|
7
|
-
sdkType: exports.SDK_TYPE,
|
|
8
|
-
});
|