@microsoft/1ds-post-js 3.1.11 → 3.2.2

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