7 lines
24 KiB
JavaScript
7 lines
24 KiB
JavaScript
/*!
|
|
* 1DS JS SDK POST plugin, 3.2.13
|
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
* (Microsoft Internal Only)
|
|
*/
|
|
var e=this,n=function(e,n,t,ee){"use strict";function y(e){return e&&"object"==typeof e&&"default"in e?e["default"]:e}var o=y(t),ne="REAL_TIME",G="",Y="POST",Z="drop",t="requeue",$="application/x-json-stream",ye="cache-control",me="content-type",ge="kill-duration",be="time-delta-millis",te="client-version",Te="client-id",ie="time-delta-to-apply-millis",re="upload-time",ae="apikey",oe="AuthMsaDeviceTicket",i="AuthXToken",se="msfpc",Ee="trace",ue="user";function m(e){e=(e.ext||{}).intweb;return e&&ee.isValueAssigned(e[se])?e[se]:null}function g(e){for(var n=null,t=0;null===n&&t<e.length;t++)n=m(e[t]);return n}s.create=function(e,n){return new s(e,n)};var ce=s;function s(i,e){var r=e?[].concat(e):[],e=this,a=g(r);e.iKey=function(){return i},e.Msfpc=function(){return a||G},e.count=function(){return r.length},e.events=function(){return r},e.addEvent=function(e){return!!e&&(r.push(e),a=a||m(e),!0)},e.split=function(e,n){var t;return e<r.length&&(t=r.length-e,ee.isNullOrUndefined(n)||(t=n<t?n:t),t=r.splice(e,t),a=g(r)),new s(i,t)}}u.__ieDyn=1;var b=u;function u(){var n=!0,t=!0,i=!0,r="use-collector-delta",a=!1;o(u,this,function(e){e.allowRequestSending=function(){return n},e.firstRequestSent=function(){i&&(i=!1,a||(n=!1))},e.shouldAddClockSkewHeaders=function(){return t},e.getClockSkewHeaderValue=function(){return r},e.setClockSkew=function(e){a||(e?(r=e,a=t=!0):t=!1,n=!0)}})}r.__ieDyn=1;var T=r;function r(){var u={};o(r,this,function(e){e.setKillSwitchTenants=function(e,n){if(e&&n)try{a=e.split(","),o=[],a&&ee.arrForEach(a,function(e){o.push(ee.strTrim(e))});var t=o;if("this-request-only"===n)return t;for(var i=1e3*parseInt(n,10),r=0;r<t.length;++r)u[t[r]]=ee.dateNow()+i}catch(s){}var a,o;return[]},e.isTenantKilled=function(e){var n=u,e=ee.strTrim(e);return n[e]!==undefined&&n[e]>ee.dateNow()||(delete n[e],!1)}})}var E=.8,S=1.2,_=3e3,w=6e5;function Se(e){var n=_*E;return Math.min(Math.pow(2,e)*(Math.floor(Math.random()*(_*S-n))+n),w)}var R="metadata",c="f",P=/\./,_e=(l.__ieDyn=1,l);function l(n,e,b,t){var a="baseData",T=!!t,E=e,S={};o(l,this,function(m){function g(e,d,f,h,p,v,y){ee.objForEachKey(e,function(e,n){if(n||ee.isValueAssigned(n)){var t,i=f,r=e,a=p,o=d;if(T&&!h&&P.test(e)){var s=e.split("."),u=s.length;if(1<u){for(var a=a&&a.slice(),c=0;c<u-1;c++){var l=s[c],o=o[l]=o[l]||{};i+="."+l,a&&a.push(l)}r=s[u-1]}}(e=h&&((t=S[e=i])===undefined&&(7<=e.length&&(t=ee.strStartsWith(e,"ext.metadata")||ee.strStartsWith(e,"ext.web")),S[e]=t),t)||!E||!E.handleField(i,r)?ee.sanitizeProperty(r,n,b):E.value(i,r,n,b))&&(t=e.value,o[r]=t,v&&v(a,r,e),y)&&"object"==typeof t&&!ee.isArray(t)&&((e=a)&&(e=a.slice()).push(r),g(n,t,i+"."+r,h,e,v,y))}})}m.createPayload=function(e,n,t,i,r,a){return{apiKeys:[],payloadBlob:G,overflow:null,sizeExceed:[],failedEvts:[],batches:[],numEvents:0,retryCnt:e,isTeardown:n,isSync:t,isBeacon:i,sendType:a,sendReason:r}},m.appendPayload=function(p,v,y){var e=p&&v&&!p.overflow;return e&&ee.doPerf(n,function(){return"Serializer:appendPayload"},function(){for(var e=v.events(),n=p.payloadBlob,t=p.numEvents,i=!1,r=[],a=[],o=p.isBeacon,s=o?65e3:3984588,u=o?65e3:2e6,c=0,l=0;c<e.length;){var d=e[c];if(d){if(y<=t){p.overflow=v.split(c);break}var f=m.getEventBlob(d);if(f&&f.length<=u){var h=f.length;if(s<n.length+h){p.overflow=v.split(c);break}n&&(n+="\n"),n+=f,20<++l&&(n.substr(0,1),l=0),i=!0,t++}else(f?r:a).push(d),e.splice(c,1),c--}c++}r&&0<r.length&&p.sizeExceed.push(ce.create(v.iKey(),r)),a&&0<a.length&&p.failedEvts.push(ce.create(v.iKey(),a)),i&&(p.batches.push(v),p.payloadBlob=n,p.numEvents=t,o=v.iKey(),-1===ee.arrIndexOf(p.apiKeys,o))&&p.apiKeys.push(o)},function(){return{payload:p,theBatch:{iKey:v.iKey(),evts:v.events()},max:y}}),e},m.getEventBlob=function(r){try{return ee.doPerf(n,function(){return"Serializer.getEventBlob"},function(){var e={},i=(e.name=r.name,e.time=r.time,e.ver=r.ver,e.iKey="o:"+ee.getTenantId(r.iKey),{}),n=r.ext,n=(n&&(e.ext=i,ee.objForEachKey(n,function(e,n){g(n,i[e]={},"ext."+e,!0,null,null,!0)})),e.data={}),t=(n.baseType=r.baseType,n[a]={});return g(r.baseData,t,a,!1,[a],function(e,n,t){x(i,e,n,t)},!0),g(r.data,n,"data",!1,[],function(e,n,t){x(i,e,n,t)},!0),JSON.stringify(e)},function(){return{item:r}})}catch(e){return null}}})}function x(e,n,t,i){if(i&&e){var r=ee.getCommonSchemaMetaData(i.value,i.kind,i.propertyType);if(-1<r){var a=e[R],o=(o=(a=a||(e[R]={f:{}}))[c])||(a[c]={});if(n)for(var s=0;s<n.length;s++)var u=n[s],o=(o[u]||(o[u]={f:{}}),o[u][c]||(o[u][c]={}));o=o[t]={},ee.isArray(i.value)?o.a={t:r}:o.t=r}}}var le="sendAttempt",we="&NoResponseBody=true",Re=((v={})[1]=t,v[100]=t,v[200]="sent",v[8004]=Z,v[8003]=Z,v),a={},de={};function d(e,n,t){a[e]=n,!1!==t&&(de[n]=e)}function Pe(e){try{return e.responseText}catch(n){}return G}function xe(e,n){var t=!1;if(e&&n){var i=ee.objKeys(e);if(i&&0<i.length)for(var r=n.toLowerCase(),a=0;a<i.length;a++){var o=i[a];if(o&&ee.hasOwnProperty(n,o)&&o.toLowerCase()==r){t=!0;break}}}return t}function fe(e,n,t,i){n&&t&&0<t.length&&(i&&a[n]?(e.hdrs[a[n]]=t,e.useHdrs=!0):e.url+="&"+n+"="+t)}function Ke(e,n){return n&&(ee.isNumber(n)?e=[n].concat(e):ee.isArray(n)&&(e=n.concat(e))),e}d(oe,oe,!1),d(te,te),d(Te,"Client-Id"),d(ae,ae),d(ie,ie),d(re,re),d(i,i),h.__ieDyn=1;var Ce=h;function h(_,e,w,f,R){this._responseHandlers=[];var P,x,K,C,O,F,k,A,B,M,H="?cors=true&content-type="+$,L=new T,N=!1,j=new b,D=!1,q=0,I=!0,U=[],z={},X=[],Q=null,V=!1,W=!1,J=!1;o(h,this,function(y){var s=!0;function u(e,n){for(var t=0,i=null,r=0;null==i&&r<e.length;)1===(t=e[r])?ee.useXDomainRequest()?i=a:ee.isXhrSupported()&&(i=c):2!==t||!ee.isFetchSupported(n)||n&&A?D&&3===t&&ee.isBeaconsSupported()&&(i=l):i=o,r++;return i?{_transport:t,_isSync:n,sendPOST:i}:null}function a(e,n,t){var i=new XDomainRequest;i.open(Y,e.urlString),e.timeout&&(i.timeout=e.timeout),i.onload=function(){var e=Pe(i);m(n,200,{},e),d(e)},i.onerror=function(){m(n,400,{})},i.ontimeout=function(){m(n,500,{})},i.onprogress=function(){},t?i.send(e.data):R.set(function(){i.send(e.data)},0)}function o(e,r,n){var t,i=e.urlString,a=!1,o=!1;(t={body:e.data,method:Y}).Microsoft_ApplicationInsights_BypassAjaxInstrumentation=!0;n&&(t.keepalive=!0,2===e._sendReason)&&(a=!0,M)&&(i+=we),s&&(t.credentials="include"),e.headers&&0<ee.objKeys(e.headers).length&&(t.headers=e.headers),fetch(i,t).then(function(e){var t={},n=G,i=e.headers;i&&i.forEach(function(e,n){t[n]=e}),e.body&&e.text().then(function(e){n=e}),o||(o=!0,m(r,e.status,t,n),d(n))})["catch"](function(e){o||(o=!0,m(r,0,{}))}),a&&!o&&(o=!0,m(r,200,{})),!o&&0<e.timeout&&R.set(function(){o||(o=!0,m(r,500,{}))},e.timeout)}function c(e,a,n){var t=e.urlString;function o(e,n,t){return!e[t]&&n&&n.getResponseHeader&&(n=n.getResponseHeader(t))&&(e[t]=ee.strTrim(n)),e}function i(e,n){var t,i,r;m(a,e.status,(r={},(e=e).getAllResponseHeaders?(t=e.getAllResponseHeaders(),i={},ee.isString(t)&&(t=ee.strTrim(t).split(/[\r\n]+/),ee.arrForEach(t,function(e){var n,t;e&&(-1!=(t=e.indexOf(": "))?(n=ee.strTrim(e.substring(0,t)).toLowerCase(),t=ee.strTrim(e.substring(1+t)),i[n]=t):i[ee.strTrim(e)]=1)})),i):(r=o(r,e,be),r=o(r,e,ge),o(r,e,"kill-duration-seconds"))),n)}n&&e.disableXhrSync&&(n=!1);var r=ee.openXhr(Y,t,s,!0,n,e.timeout);ee.objForEachKey(e.headers,function(e,n){r.setRequestHeader(e,n)}),r.onload=function(){var e=Pe(r);i(r,e),d(e)},r.onerror=function(){i(r)},r.ontimeout=function(){i(r)},r.send(e.data)}function m(e,n,t,i){try{e(n,t,i)}catch(r){ee._throwInternal(x,2,518,ee.dumpObj(r))}}function l(e,n,t){var i=200,r=e._thePayload,a=e.urlString+(M?we:G);try{var o,s=ee.getNavigator();s.sendBeacon(a,e.data)||(r?(o=[],ee.arrForEach(r.batches,function(e){if(o&&e&&0<e.count()){for(var n=e.events(),t=0;t<n.length;t++)if(!s.sendBeacon(a,Q.getEventBlob(n[t]))){o.push(e.split(t));break}}else o.push(e.split(0))}),S(o,8003,r.sendType,!0)):i=0)}catch(u){ee._warnToConsole(x,"Failed to send telemetry using sendBeacon API. Ex:"+ee.dumpObj(u)),i=0}finally{m(n,i,{},G)}}function g(e){return 2===e||3===e}function i(e){return W&&g(e)?2:e}function r(){return!N&&q<e}function t(){var e=X;return X=[],e}function h(e,n,t){return e&&0<e.length&&!N&&K[n]&&Q&&(0!==n||r()&&(0<t||j.allowRequestSending()))}function p(e){var t={};return e&&ee.arrForEach(e,function(e,n){t[n]={iKey:e.iKey(),evts:e.events()}}),t}function b(s,u,c,l,d){if(s&&0!==s.length)if(N)S(s,1,l);else{l=i(l);try{var e=s,f=0!==l;ee.doPerf(C,function(){return"HttpManager:_sendBatches"},function(e){e&&(s=s.slice(0));for(var n=[],t=null,i=ee.getTime(),e=K[l]||(f?K[1]:K[0]),r=e&&e._transport,a=B&&(W||g(l)||3===r||e._isSync&&2===r);h(s,l,u);){var o=s.shift();o&&0<o.count()&&(L.isTenantKilled(o.iKey())?n.push(o):(t=t||Q.createPayload(u,c,f,a,d,l),Q.appendPayload(t,o,_)?null!==t.overflow&&(s=[t.overflow].concat(s),t.overflow=null,v(t,i,ee.getTime(),d),i=ee.getTime(),t=null):(v(t,i,ee.getTime(),d),i=ee.getTime(),s=[o].concat(s),t=null)))}t&&v(t,i,ee.getTime(),d),0<s.length&&(X=s.concat(X)),S(n,8004,l)},function(){return{batches:p(e),retryCount:u,isTeardown:c,isSynchronous:f,sendReason:d,useSendBeacon:g(l),sendType:l}},!f)}catch(n){ee._throwInternal(x,2,48,"Unexpected Exception sending batch: "+ee.dumpObj(n))}}}function T(e,n,t){e[n]=e[n]||{},e[n][P.identifier]=t}function v(h,s,u,p){var c,l,d,f,v;h&&h.payloadBlob&&0<h.payloadBlob.length&&(c=!!y.sendHook,l=K[h.sendType],!g(h.sendType)&&h.isBeacon&&2===h.sendReason&&(l=K[2]||K[3]||l),f=J,!h.isBeacon&&3!==l._transport||(f=!1),d=function(e,n){var t={url:H,hdrs:{},useHdrs:!1},i=(n?(t.hdrs=ee.extend(t.hdrs,z),t.useHdrs=0<ee.objKeys(t.hdrs).length):ee.objForEachKey(z,function(e,n){de[e]?fe(t,de[e],n,!1):(t.hdrs[e]=n,t.useHdrs=!0)}),fe(t,Te,"NO_AUTH",n),fe(t,te,ee.FullVersionString,n),G),e=(ee.arrForEach(e.apiKeys,function(e){0<i.length&&(i+=","),i+=e}),fe(t,ae,i,n),fe(t,re,ee.dateNow().toString(),n),function(e){for(var n=0;n<e.batches.length;n++){var t=e.batches[n].Msfpc();if(t)return encodeURIComponent(t)}return G}(e));ee.isValueAssigned(e)&&(t.url+="&ext.intweb.msfpc="+e),j.shouldAddClockSkewHeaders()&&fe(t,ie,j.getClockSkewHeaderValue(),n),C.getWParam&&0<=(e=C.getWParam())&&(t.url+="&w="+e);for(var r=0;r<U.length;r++)t.url+="&"+U[r].name+"="+U[r].value;return t}(h,f),f=f||d.useHdrs,v=ee.getTime(),ee.doPerf(C,function(){return"HttpManager:_doPayloadSend"},function(){for(var e=0;e<h.batches.length;e++)for(var n=h.batches[e].events(),t=0;t<n.length;t++){var i,r=n[t];V&&(T(i=r.timings=r.timings||{},"sendEventStart",v),T(i,"serializationStart",s),T(i,"serializationCompleted",u)),0<r[le]?r[le]++:r[le]=1}S(h.batches,1e3+(p||0),h.sendType,!0);var a={data:h.payloadBlob,urlString:d.url,headers:d.hdrs,_thePayload:h,_sendReason:p,timeout:F,disableXhrSync:k,disableFetchKeepAlive:A},o=(f&&(xe(a.headers,ye)||(a.headers[ye]="no-cache, no-store"),xe(a.headers,me)||(a.headers[me]=$)),null);l&&(o=function(e){j.firstRequestSent();var n=function(e,n){var t,i,r=h,a=p,o=9e3,s=null,u=!1,c=!1;try{var l,d=!0;if(typeof e!==ee.strUndefined){if(n&&(j.setClockSkew(n[be]),f=n[ge]||n["kill-duration-seconds"],ee.arrForEach(L.setKillSwitchTenants(n["kill-tokens"],f),function(n){ee.arrForEach(r.batches,function(e){e.iKey()===n&&(s=s||[],e=e.split(0),r.numEvents-=e.count(),s.push(e))})})),200==e||204==e)return void(o=200);(300<=e&&e<500&&408!=e&&429!=e||501==e||505==e||r.numEvents<=0)&&(d=!1),o=9e3+e%1e3}d&&(o=100,l=r.retryCnt,0===r.sendType)&&(l<w?(u=!0,E(function(){0===r.sendType&&q--,b(r.batches,l+1,r.isTeardown,W?2:r.sendType,5)},W,Se(l))):(c=!0,W&&(o=8001)))}finally{if(!u){j.setClockSkew();var n=r,f=o,e=a,d=c;try{d&&P._backOffTransmission(),200===f&&(d||n.isSync||P._clearBackOff(),t=n.batches,V)&&(i=ee.getTime(),ee.arrForEach(t,function(e){var n;e&&0<e.count()&&(e=e.events(),n=i,V)&&ee.arrForEach(e,function(e){T(e.timings=e.timings||{},"sendEventCompleted",n)})})),S(n.batches,f,n.sendType,!0)}finally{0===n.sendType&&(q--,5!==e)&&y.sendQueuedRequests(n.sendType,e)}}S(s,8004,r.sendType)}},t=h.isTeardown||h.isSync;try{l.sendPOST(e,n,t),y.sendListener&&y.sendListener(a,e,t,h.isBeacon)}catch(i){ee._warnToConsole(x,"Unexpected exception sending payload. Ex:"+ee.dumpObj(i)),m(n,0,{})}}),ee.doPerf(C,function(){return"HttpManager:_doPayloadSend.sender"},function(){var n,t;o&&(0===h.sendType&&q++,c&&!h.isBeacon&&3!==l._transport?(n={data:a.data,urlString:a.urlString,headers:ee.extend({},a.headers),timeout:a.timeout,disableXhrSync:a.disableXhrSync,disableFetchKeepAlive:a.disableFetchKeepAlive},t=!1,ee.doPerf(C,function(){return"HttpManager:_doPayloadSend.sendHook"},function(){try{y.sendHook(n,function(e){t=!0,I||e._thePayload||(e._thePayload=e._thePayload||a._thePayload,e._sendReason=e._sendReason||a._sendReason),o(e)},h.isSync||h.isTeardown)}catch(e){t||o(a)}})):o(a))})},function(){return{thePayload:h,serializationStart:s,serializationCompleted:u,sendReason:p}},h.isSync)),h.sizeExceed&&0<h.sizeExceed.length&&S(h.sizeExceed,8003,h.sendType),h.failedEvts&&0<h.failedEvts.length&&S(h.failedEvts,8002,h.sendType)}function E(e,n,t){n?e():R.set(e,t)}function d(e){var n=y._responseHandlers;try{for(var t,i=0;i<n.length;i++)try{n[i](e)}catch(r){ee._throwInternal(x,1,519,"Response handler failed: "+r)}e&&(t=JSON.parse(e),ee.isValueAssigned(t.webResult))&&ee.isValueAssigned(t.webResult[se])&&O.set("MSFPC",t.webResult[se],31536e3)}catch(a){}}function S(n,t,i,e){var r,a,o,s;n&&0<n.length&&f&&(r=f[s=Re[o=t],ee.isValueAssigned(s)||(s="oth",9e3<=o&&o<=9999?s="rspFail":8e3<=o&&o<=8999?s=Z:1e3<=o&&o<=1999&&(s="send")),s])&&ee.doPerf(C,function(){return"HttpManager:_sendBatchesNotification"},function(){E(function(){try{r.call(f,n,t,a,i)}catch(e){ee._throwInternal(x,1,74,"send request notification failed: "+e)}},e||a,0)},function(){return{batches:p(n),reason:t,isSync:a,sendSync:e,sendType:i}},!(a=0!==i))}y.initialize=function(e,n,t,i,r){H=e+H,J=!!ee.isUndefined((r=r||{}).avoidOptions)||!r.avoidOptions,O=(C=n).getCookieMgr(),V=!C.config.disableEventTimings;var a,e=!!C.config.enableCompoundKey,n=(x=(P=t).diagLog(),r.valueSanitizer),t=r.stringifyObjects,n=(ee.isUndefined(r.enableCompoundKey)||(e=!!r.enableCompoundKey),F=r.xhrTimeout,k=!!r.disableXhrSync,A=!!r.disableFetchKeepAlive,M=!1!==r.addNoResponse,D=!ee.isReactNative(),Q=new _e(C,n,t,e),ee.isNullOrUndefined(r.useSendBeacon)||(D=!!r.useSendBeacon),i),t=r.alwaysUseXhrOverride?i:null,e=r.alwaysUseXhrOverride?i:null,o=[3,2];i||(I=!1,(a=ee.getLocation())&&a.protocol&&"file:"==a.protocol.toLowerCase()&&(s=!1),a=[],ee.isReactNative()?(a=[2,1],o=[2,1,3]):a=[1,2,3],(i=u(a=Ke(a,r.transports),!1))||ee._warnToConsole(x,"No available transport to send events"),n=u(a,!0)),t=t||u(o=Ke(o,r.unloadTransports),!0),B=!I&&(D&&ee.isBeaconsSupported()||!A&&ee.isFetchSupported(!0)),(a={})[0]=i,a[1]=n||u([1,2,3],!0),a[2]=t||n||u([1],!0),a[3]=e||u([2,3],!0)||n||u([1],!0),K=a},y._getDbgPlgTargets=function(){return[K[0],L,Q,K]},y.addQueryStringParameter=function(e,n){for(var t=0;t<U.length;t++)if(U[t].name===e)return void(U[t].value=n);U.push({name:e,value:n})},y.addHeader=function(e,n){z[e]=n},y.canSendRequest=function(){return r()&&j.allowRequestSending()},y.sendQueuedRequests=function(e,n){ee.isUndefined(e)&&(e=0),W&&(e=i(e),n=2),h(X,e,0)&&b(t(),0,!1,e,n||0)},y.isCompletelyIdle=function(){return!N&&0===q&&0===X.length},y.setUnloading=function(e){W=e},y.addBatch=function(e){if(e&&0<e.count()){if(L.isTenantKilled(e.iKey()))return!1;X.push(e)}return!0},y.teardown=function(){0<X.length&&b(t(),0,!0,2,2)},y.pause=function(){N=!0},y.resume=function(){N=!1,y.sendQueuedRequests(0,4)},y.sendSynchronousBatch=function(e,n,t){e&&0<e.count()&&(ee.isNullOrUndefined(n)&&(n=1),W&&(n=i(n),t=2),b([e],0,!1,n,t||0))}})}function K(e,n){for(var t=[],i=2;i<arguments.length;i++)t[i-2]=arguments[i];return setTimeout(e,n,t)}function C(e){clearTimeout(e)}function he(e,n){return{set:e||K,clear:n||C}}var f,pe="eventsDiscarded",ve="overrideInstrumentationKey",Oe="maxEventRetryAttempts",Fe="maxUnloadEventRetryAttempts",t=(f=ee.BaseTelemetryPlugin,n.__extendsFn(p,f),p.__ieDyn=1,p);function p(){var P,x,K,C,O,F,k,A,e=f.call(this)||this,B=(e.identifier="PostChannel",e.priority=1011,!(e.version="3.2.13")),M=[],H=null,L=!1,N=0,j=500,D=0,q=1e4,I={},U=ne,z=null,X=null,Q=0,V=0,W={},J=-1,G=!0,Y=!1,Z=6,$=2;return o(p,e,function(c,l){function d(e){"beforeunload"!==(e||ee.getWindow().event).type&&(Y=!0,K.setUnloading(Y)),u(2,2)}function f(e){Y=!1,K.setUnloading(Y)}function r(e,n){if(e.sendAttempt||(e.sendAttempt=0),e.latency||(e.latency=1),e.ext&&e.ext[Ee]&&delete e.ext[Ee],e.ext&&e.ext[ue]&&e.ext[ue].id&&delete e.ext[ue].id,G&&(e.ext=ee.optimizeObject(e.ext),e.baseData&&(e.baseData=ee.optimizeObject(e.baseData)),e.data)&&(e.data=ee.optimizeObject(e.data)),e.sync)if(Q||L)e.latency=3,e.sync=!1;else if(K)return G&&(e=ee.optimizeObject(e)),K.sendSynchronousBatch(ce.create(e.iKey,[e]),!0===e.sync?1:e.sync,3);var t=e.latency,i=D,r=q,a=(4===t&&(i=N,r=j),!1);(a=i<r||(i=1,r=20,4===t&&(i=4,r=1),a=!0,function(e,n,t,i){for(;t<=n;){var r=h(e,n,!0);if(r&&0<r.count()){var r=r.split(0,i),a=r.count();if(0<a)return 4===t?N-=a:D-=a,b(pe,[r],ee.EventsDiscardedReason.QueueFull),1}t++}return v(),0}(e.iKey,e.latency,i,r))?(t=e,i=n,r=(t=G?ee.optimizeObject(t):t).latency,!((n=h(t.iKey,r,!0)).addEvent(t)&&(4!==r?(D++,i&&0===t.sendAttempt&&p(!t.sync,0<O&&n.count()>=O)):N++,1))):a)&&g(pe,[e],ee.EventsDiscardedReason.QueueFull)}function a(e,n,t){y(e,n,t),K.sendQueuedRequests(n,t)}function o(){0<=J&&y(J,0,F)&&K.sendQueuedRequests(0,F),0<N&&!X&&!L&&0<=(e=I[U][2])&&(X=s(function(){X=null,a(4,0,1),o()},e));var e=I[U][1];!z&&!H&&0<=e&&!L&&(0<D?z=s(function(){z=null,a(0===V?3:1,0,1),V++,V%=2,o()},e):V=0)}function t(){B=!1,L=!(M=[]),j=500,q=1e4,I={},U=ne,V=Q=D=N=0,x=X=z=H=P=null,W={},C=undefined,O=0,J=-1,Y=!(G=!(F=null)),Z=6,k=null,A=he(),K=new Ce(500,$=2,1,{requeue:e,send:T,sent:E,drop:S,rspFail:_,oth:w},A),n(),W[4]={batches:[],iKeyMap:{}},W[3]={batches:[],iKeyMap:{}},W[2]={batches:[],iKeyMap:{}},W[1]={batches:[],iKeyMap:{}},R()}function s(e,n){0===n&&Q&&(n=1);var t=1e3;return Q&&(t=Se(Q-1)),A.set(e,n*t)}function i(){return null!==z&&(A.clear(z),z=null,!(V=0))}function u(e,n){i(),H&&(A.clear(H),H=null),L||a(1,e,n)}function h(e,n,t){var i=W[n],n=(i=i||W[n=1]).iKeyMap[e];return!n&&t&&(n=ce.create(e),i.batches.push(n),i.iKeyMap[e]=n),n}function p(e,n){K.canSendRequest()&&!Q&&(n=0<C&&C<D||n)&&null==H&&c.flush(e,null,20)}function v(){for(var t=0,i=0,e=1;e<=4;e++)!function(n){var e=W[n];e&&e.batches&&ee.arrForEach(e.batches,function(e){4===n?t+=e.count():i+=e.count()})}(e);D=i,N=t}function y(i,e,n){var r=!1,t=0===e;return!t||K.canSendRequest()?ee.doPerf(c.core,function(){return"PostChannel._queueBatches"},function(){for(var n=[],t=4;i<=t;){var e=W[t];e&&e.batches&&0<e.batches.length&&(ee.arrForEach(e.batches,function(e){K.addBatch(e)?r=r||e&&0<e.count():n=n.concat(e.events()),4===t?N-=e.count():D-=e.count()}),e.batches=[],e.iKeyMap={}),t--}0<n.length&&g(pe,n,ee.EventsDiscardedReason.KillSwitch),r&&i<=J&&(J=-1,F=0)},function(){return{latency:i,sendType:e,sendReason:n}},!t):(J=0<=J?Math.min(J,i):i,F=Math.max(F,n)),r}function n(){I={REAL_TIME:[2,1,0],NEAR_REAL_TIME:[6,3,0],BEST_EFFORT:[18,9,0]}}function e(e,n){var t=[],i=Y?$:Z;ee.arrForEach(e,function(e){e&&0<e.count()&&ee.arrForEach(e.events(),function(e){e&&(e.sync&&(e.latency=4,e.sync=!1),e.sendAttempt<i?(ee.setProcessTelemetryTimings(e,c.identifier),r(e,!1)):t.push(e))})}),0<t.length&&g(pe,t,ee.EventsDiscardedReason.NonRetryableStatus),Y&&u(2,2)}function m(e,n){var t=c._notificationManager||{},i=t[e];if(i)try{i.apply(t,n)}catch(r){ee._throwInternal(c.diagLog(),1,74,e+" notification failed: "+r)}}function g(e,n){for(var t=[],i=2;i<arguments.length;i++)t[i-2]=arguments[i];n&&0<n.length&&m(e,[n].concat(t))}function b(n,e){for(var t=[],i=2;i<arguments.length;i++)t[i-2]=arguments[i];e&&0<e.length&&ee.arrForEach(e,function(e){e&&0<e.count()&&m(n,[e.events()].concat(t))})}function T(e,n,t){e&&0<e.length&&m("eventsSendRequest",[1e3<=n&&n<=1999?n-1e3:0,!0!==t])}function E(e,n){b("eventsSent",e,n),o()}function S(e,n){b(pe,e,8e3<=n&&n<=8999?n-8e3:ee.EventsDiscardedReason.Unknown)}function _(e){b(pe,e,ee.EventsDiscardedReason.NonRetryableStatus),o()}function w(e,n){b(pe,e,ee.EventsDiscardedReason.Unknown),o()}function R(){O=P&&P.disableAutoBatchFlushLimit?0:Math.max(1500,q/6)}t(),c._getDbgPlgTargets=function(){return[K]},c.initialize=function(o,s,u){ee.doPerf(s,function(){return"PostChannel:initialize"},function(){var n,e=s;l.initialize(o,s,u);try{s.addUnloadCb,k=ee.mergeEvtNamespace(ee.createUniqueNamespace(c.identifier),s.evtNamespace&&s.evtNamespace());var t=c._getTelCtx(),i=(o.extensionConfig[c.identifier]=o.extensionConfig[c.identifier]||{},P=t.getExtCfg(c.identifier),A=he(P.setTimeoutOverride,P.clearTimeoutOverride),G=!P.disableOptimizeObj&&ee.isChromium(),n=e.getWParam,e.getWParam=function(){var e=0;return P.ignoreMc1Ms0CookieProcessing&&(e|=2),e|n()},0<P.eventsLimitInMem&&(q=P.eventsLimitInMem),0<P.immediateEventLimit&&(j=P.immediateEventLimit),0<P.autoFlushEventsLimit&&(C=P.autoFlushEventsLimit),ee.isNumber(P[Oe])&&(Z=P[Oe]),ee.isNumber(P[Fe])&&($=P[Fe]),R(),P.httpXHROverride&&P.httpXHROverride.sendPOST&&(x=P.httpXHROverride),ee.isValueAssigned(o.anonCookieName)&&K.addQueryStringParameter("anoncknm",o.anonCookieName),K.sendHook=P.payloadPreprocessor,K.sendListener=P.payloadListener,P.overrideEndpointUrl||o.endpointUrl),r=(c._notificationManager=s.getNotifyMgr(),K.initialize(i,c.core,c,x,P),o.disablePageUnloadEvents||[]);ee.addPageUnloadEventListener(d,r,k),ee.addPageHideEventListener(d,r,k),ee.addPageShowEventListener(f,o.disablePageShowEvents,k)}catch(a){throw c.setInitialized(!1),a}},function(){return{coreConfig:o,core:s,extensions:u}})},c.processTelemetry=function(e,n){ee.setProcessTelemetryTimings(e,c.identifier);var t=(n=c._getTelCtx(n)).getExtCfg(c.identifier),i=!!P.disableTelemetry;(t?i||t.disableTelemetry:i)||B||(P[ve]&&(e.iKey=P[ve]),t&&t[ve]&&(e.iKey=t[ve]),r(e,!0),Y?u(2,2):o()),c.processNext(e,n)},c._doTeardown=function(e,n){u(2,2),B=!0,K.teardown(),ee.removePageUnloadEventListener(null,k),ee.removePageHideEventListener(null,k),ee.removePageShowEventListener(null,k),t()},c.setEventQueueLimits=function(e,n){q=0<e?e:1e4,C=0<n?n:0,R();var t=e<D;if(!t&&0<O)for(var i=1;!t&&i<=3;i++){var r=W[i];r&&r.batches&&ee.arrForEach(r.batches,function(e){e&&e.count()>=O&&(t=!0)})}p(!0,t)},c.pause=function(){i(),L=!0,K.pause()},c.resume=function(){L=!1,K.resume(),o()},c.addResponseHandler=function(e){K._responseHandlers.push(e)},c._loadTransmitProfiles=function(e){i(),n(),U=ne,o(),ee.objForEachKey(e,function(e,n){var t,i=n.length;2<=i&&(t=2<i?n[2]:0,n.splice(0,i-2),n[1]<0&&(n[0]=-1),0<n[1]&&0<n[0]&&(i=n[0]/n[1],n[0]=Math.ceil(i)*n[1]),0<=t&&0<=n[1]&&t>n[1]&&(t=n[1]),n.push(t),I[e]=n)})},c.flush=function(e,n,t){void 0===e&&(e=!0),L||(t=t||1,e?null==H?(i(),y(1,0,t),H=s(function(){H=null,function i(e,n){a(1,0,n),v(),function t(e){K.isCompletelyIdle()?e():H=s(function(){H=null,t(e)},.25)}(function(){e&&e(),0<M.length?H=s(function(){H=null,i(M.shift(),n)},0):(H=null,o())})}(n,t)},0)):M.push(n):(e=i(),a(1,1,t),null!==n&&n!==undefined&&n(),e&&o()))},c.setMsaAuthTicket=function(e){K.addHeader(oe,e)},c.hasEvents=function(){return 0<D},c._setTransmitProfile=function(e){U!==e&&I[e]!==undefined&&(i(),U=e,o())},c._backOffTransmission=function(){Q<4&&(Q++,i(),o())},c._clearBackOff=function(){Q&&(Q=0,i(),o())},ee.objDefineAccessors(c,"_setTimeoutOverride",function(){return A.set},function(e){A=he(e,A.clear)}),ee.objDefineAccessors(c,"_clearTimeoutOverride",function(){return A.clear},function(e){A=he(A.set,e)})}),e}e.BE_PROFILE="BEST_EFFORT",e.NRT_PROFILE="NEAR_REAL_TIME",e.PostChannel=t,e.RT_PROFILE=ne;var v=e,i="__esModule",n={value:!0},t=Object.defineProperty;if(t)try{return void t(v,i,n)}catch(O){}typeof n.value!==undefined&&(v[i]=n.value)};"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@microsoft/applicationinsights-shims"),require("@microsoft/dynamicproto-js"),require("@microsoft/1ds-core-js")):"function"==typeof define&&define.amd?define(["exports","@microsoft/applicationinsights-shims","@microsoft/dynamicproto-js","@microsoft/1ds-core-js"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).oneDS=e.oneDS||{},e.applicationinsightsShims,e.dynamicProto,e._1dsCoreJs);
|