@microsoft/1ds-post-js 3.1.11 → 3.2.0
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/README.md +2 -2
- package/bundle/{ms.post-3.1.11.gbl.js → ms.post-3.2.0.gbl.js} +1486 -786
- package/bundle/ms.post-3.2.0.gbl.js.map +1 -0
- package/bundle/ms.post-3.2.0.gbl.min.js +7 -0
- package/bundle/ms.post-3.2.0.gbl.min.js.map +1 -0
- package/bundle/ms.post-3.2.0.integrity.json +46 -0
- package/bundle/{ms.post-3.1.11.js → ms.post-3.2.0.js} +1486 -786
- package/bundle/ms.post-3.2.0.js.map +1 -0
- package/bundle/ms.post-3.2.0.min.js +7 -0
- package/bundle/ms.post-3.2.0.min.js.map +1 -0
- package/bundle/ms.post.gbl.js +1485 -785
- package/bundle/ms.post.gbl.js.map +1 -1
- package/bundle/ms.post.gbl.min.js +2 -2
- package/bundle/ms.post.gbl.min.js.map +1 -1
- package/bundle/ms.post.integrity.json +17 -17
- package/bundle/ms.post.js +1485 -785
- package/bundle/ms.post.js.map +1 -1
- package/bundle/ms.post.min.js +2 -2
- package/bundle/ms.post.min.js.map +1 -1
- package/dist/ms.post.js +177 -116
- package/dist/ms.post.js.map +1 -1
- package/dist/ms.post.min.js +2 -2
- package/dist/ms.post.min.js.map +1 -1
- package/dist-esm/src/BatchNotificationActions.js +1 -1
- package/dist-esm/src/ClockSkewManager.js +1 -1
- package/dist-esm/src/Constants.js +1 -1
- package/dist-esm/src/DataModels.js +1 -1
- package/dist-esm/src/EventBatch.js +1 -1
- package/dist-esm/src/HttpManager.js +41 -36
- package/dist-esm/src/HttpManager.js.map +1 -1
- package/dist-esm/src/Index.js +1 -1
- package/dist-esm/src/KillSwitch.js +1 -1
- package/dist-esm/src/PostChannel.d.ts +0 -4
- package/dist-esm/src/PostChannel.js +136 -92
- package/dist-esm/src/PostChannel.js.map +1 -1
- package/dist-esm/src/RetryPolicy.d.ts +20 -25
- package/dist-esm/src/RetryPolicy.js +35 -44
- package/dist-esm/src/RetryPolicy.js.map +1 -1
- package/dist-esm/src/Serializer.js +1 -1
- package/dist-esm/src/typings/XDomainRequest.js +1 -1
- package/package.json +2 -2
- package/src/HttpManager.ts +43 -47
- package/src/PostChannel.ts +162 -114
- package/src/RetryPolicy.ts +33 -38
- package/bundle/ms.post-3.1.11.gbl.js.map +0 -1
- package/bundle/ms.post-3.1.11.gbl.min.js +0 -7
- package/bundle/ms.post-3.1.11.gbl.min.js.map +0 -1
- package/bundle/ms.post-3.1.11.integrity.json +0 -46
- package/bundle/ms.post-3.1.11.js.map +0 -1
- package/bundle/ms.post-3.1.11.min.js +0 -7
- package/bundle/ms.post-3.1.11.min.js.map +0 -1
package/dist/ms.post.min.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* 1DS JS SDK POST plugin, 3.
|
|
2
|
+
* 1DS JS SDK POST plugin, 3.2.0
|
|
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,ee,t){"use strict";function p(e){return e&&"object"==typeof e&&"default"in e?e["default"]:e}var o=p(t),ne="REAL_TIME",X="POST",Q="drop",t="requeue",V="application/x-json-stream",W="cache-control",J="content-type",G="kill-duration",Y="time-delta-millis",Z="client-version",fe="client-id",$="time-delta-to-apply-millis",te="upload-time",ie="apikey",re="AuthMsaDeviceTicket",i="AuthXToken",ae="msfpc";function y(e){e=(e.ext||{}).intweb;return e&&ee.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,ee.isNullOrUndefined(n)||(t=n<t?n:t),t=r.splice(e,t),a=g(r)),new s(i,t)}}var m="metadata",w=/\./,he=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){ee.objForEachKey(e,function(e,n){if(n||ee.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=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,p&&p(a,r,e),y&&"object"==typeof t&&!ee.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&&ee.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===ee.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 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){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){_(i,e,n,t)},!0),m(r.data,n,"data",!1,[],function(e,n,t){_(i,e,n,t)},!0),JSON.stringify(e)},function(){return{item:r}})}catch(e){return null}}})};function _(e,n,t,i){if(i&&e){var r=ee.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]={},ee.isArray(i.value)?o.a={t:r}:o.t=r}}}var b=.8,T=1.2,E=3e3,S=6e5;function ve(e){var n=E*b;return Math.min(Math.pow(2,e)*(Math.floor(Math.random()*(E*T-n))+n),S)}var pe=function f(){var u={};o(f,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){return[]}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)}})},ye=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",ge="&NoResponseBody=true",me=((l={})[1]=t,l[100]=t,l[200]="sent",l[8004]=Q,l[8003]=Q,l),r={},ue={};function a(e,n,t){r[e]=n,!1!==t&&(ue[n]=e)}function be(e){try{return e.responseText}catch(n){}return""}function Te(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 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(fe,"Client-Id"),a(ie,ie),a($,$),a(te,te),a(i,i);var u,Ee=function v(p,e,w,_){this._responseHandlers=[];var R,P,x,O,C,K,k="?cors=true&content-type="+V,F=new pe,M=!1,B=new ye,L=!1,A=0,H=!0,j=[],N={},q=[],I=null,U=!1,z=!1,D=!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])?ee.useXDomainRequest()?i=a:ee.isXhrSupported()&&(i=c):2===t&&ee.isFetchSupported(n)?i=u:L&&3===t&&ee.isBeaconsSupported()&&(i=l),r++;return i?{_transport:t,_isSync:n,sendPOST:i}:null}function a(e,n,t){var i=new XDomainRequest;i.open(X,e.urlString),e.timeout&&(i.timeout=e.timeout),i.onload=function(){var e=be(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):R._setTimeoutOverride(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:X}).Microsoft_ApplicationInsights_BypassAjaxInstrumentation=!0;n&&(t.keepalive=!0,2===e._sendReason&&(a=!0,r+=ge)),s&&(t.credentials="include"),e.headers&&0<ee.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&&R._setTimeoutOverride(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]=ee.strTrim(n)),e}function i(e,n){var t,i,r;g(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,Y),r=o(r,e,G),o(r,e,"kill-duration-seconds"))),n)}n&&e.disableXhrSync&&(n=!1);var r=ee.openXhr(X,t,s,!0,n,e.timeout);ee.objForEachKey(e.headers,function(e,n){r.setRequestHeader(e,n)}),r.onload=function(){var e=be(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){ee._throwInternal(R.diagLog(),2,518,ee.dumpObj(r))}}function l(e,n,t){var i=200,r=e._thePayload,a=e.urlString+ge;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,I.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){R.diagLog().warnToConsole("Failed to send telemetry using sendBeacon API. Ex:"+ee.dumpObj(u)),i=0}finally{g(n,i,{},"")}}function m(e){return 2===e||3===e}function i(e){return z&&m(e)?2:e}function r(){return!M&&A<e}function t(){var e=q;return q=[],e}function f(e,n,t){return e&&0<e.length&&!M&&P[n]&&I&&(0!==n||r()&&(0<t||B.allowRequestSending()))}function h(e){var t={};return e&&ee.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(M)S(o,1,c);else{c=i(c);try{var e=o,d=0!==c;ee.doPerf(x,function(){return"HttpManager:_sendBatches"},function(e){e&&(o=o.slice(0));for(var n=[],t=null,i=ee.getTime(),e=P[c]||(d?P[1]:P[0]),r=(z||m(c)||e&&3===e._transport)&&!H&&L&&ee.isBeaconsSupported();f(o,c,s);){var a=o.shift();a&&0<a.count()&&(F.isTenantKilled(a.iKey())?n.push(a):(t=t||I.createPayload(s,u,d,r,l,c),I.appendPayload(t,a,p)?null!==t.overflow&&(o=[t.overflow].concat(o),t.overflow=null,v(t,i,ee.getTime(),l),i=ee.getTime(),t=null):(v(t,i,ee.getTime(),l),i=ee.getTime(),o=[a].concat(o),t=null)))}t&&v(t,i,ee.getTime(),l),0<o.length&&(q=o.concat(q)),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){ee._throwInternal(R.diagLog(),2,48,"Unexpected Exception sending batch: "+ee.dumpObj(n))}}}function T(e,n,t){e[n]=e[n]||{},e[n][R.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=P[h.sendType],!m(h.sendType)&&h.isBeacon&&2===h.sendReason&&(l=P[2]||P[3]||l),f=D,!h.isBeacon&&3!==l._transport||(f=!1),d=function(e,n){var t={url:k,hdrs:{},useHdrs:!1},i=(n?(t.hdrs=ee.extend(t.hdrs,N),t.useHdrs=0<ee.objKeys(t.hdrs).length):ee.objForEachKey(N,function(e,n){ue[e]?ce(t,ue[e],n,!1):(t.hdrs[e]=n,t.useHdrs=!0)}),ce(t,fe,"NO_AUTH",n),ce(t,Z,ee.FullVersionString,n),""),e=(ee.arrForEach(e.apiKeys,function(e){0<i.length&&(i+=","),i+=e}),ce(t,ie,i,n),ce(t,te,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""}(e));ee.isValueAssigned(e)&&(t.url+="&ext.intweb.msfpc="+e),B.shouldAddClockSkewHeaders()&&ce(t,$,B.getClockSkewHeaderValue(),n),x.getWParam&&0<=(e=x.getWParam())&&(t.url+="&w="+e);for(var r=0;r<j.length;r++)t.url+="&"+j[r].name+"="+j[r].value;return t}(h,f),f=f||d.useHdrs,p=ee.getTime(),ee.doPerf(x,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];U&&(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:C},o=(ee.isUndefined(K)||(a.disableXhrSync=!!K),f&&(Te(a.headers,W)||(a.headers[W]="no-cache, no-store"),Te(a.headers,J)||(a.headers[J]=V)),null);l&&(o=function(e){B.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!==ee.strUndefined){if(n&&(B.setClockSkew(n[Y]),f=n[G]||n["kill-duration-seconds"],ee.arrForEach(F.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&&A--,b(r.batches,l+1,r.isTeardown,z?2:r.sendType,5)},z,ve(l))):(c=!0,z&&(o=8001))))}finally{if(!u){B.setClockSkew();var n=r,f=o,e=a,d=c;try{d&&R._backOffTransmission(),200===f&&(d||n.isSync||R._clearBackOff(),t=n.batches,U&&(i=ee.getTime(),ee.arrForEach(t,function(e){var n;e&&0<e.count()&&(e=e.events(),n=i,U&&ee.arrForEach(e,function(e){T(e.timings=e.timings||{},"sendEventCompleted",n)}))}))),S(n.batches,f,n.sendType,!0)}finally{0===n.sendType&&(A--,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){R.diagLog().warnToConsole("Unexpected exception sending payload. Ex:"+ee.dumpObj(i)),g(n,0,{})}}),ee.doPerf(x,function(){return"HttpManager:_doPayloadSend.sender"},function(){var n,t;o&&(0===h.sendType&&A++,c&&!h.isBeacon&&3!==l._transport?(n={data:a.data,urlString:a.urlString,headers:ee.extend({},a.headers),timeout:a.timeout,disableXhrSync:a.disableXhrSync},t=!1,ee.doPerf(x,function(){return"HttpManager:_doPayloadSend.sendHook"},function(){try{y.sendHook(n,function(e){t=!0,H||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():R._setTimeoutOverride(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(R.diagLog(),1,519,"Response handler failed: "+r)}e&&(t=JSON.parse(e),ee.isValueAssigned(t.webResult)&&ee.isValueAssigned(t.webResult[ae])&&O.set("MSFPC",t.webResult[ae],31536e3))}catch(a){}}function S(n,t,i,e){var r,a,o,s;n&&0<n.length&&_&&(r=_[s=me[o=t],ee.isValueAssigned(s)||(s="oth",9e3<=o&&o<=9999?s="rspFail":8e3<=o&&o<=8999?s=Q:1e3<=o&&o<=1999&&(s="send")),s])&&ee.doPerf(x,function(){return"HttpManager:_sendBatchesNotification"},function(){E(function(){try{r.call(_,n,t,a,i)}catch(e){ee._throwInternal(R.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){k=e+k,D=!!ee.isUndefined((r=r||{}).avoidOptions)||!r.avoidOptions,O=(x=n).getCookieMgr(),U=!x.config.disableEventTimings;var a,e=!!x.config.enableCompoundKey,n=(R=t,r.valueSanitizer),t=r.stringifyObjects,n=(ee.isUndefined(r.enableCompoundKey)||(e=!!r.enableCompoundKey),C=r.xhrTimeout,K=r.disableXhrSync,L=!ee.isReactNative(),I=new he(x,n,t,e),i),t=r.alwaysUseXhrOverride?i:null,e=r.alwaysUseXhrOverride?i:null;i||(H=!1,(a=ee.getLocation())&&a.protocol&&"file:"==a.protocol.toLowerCase()&&(s=!1),a=[],a=ee.isReactNative()?[2,1]:[1,2,3],(r=r.transports)&&(ee.isNumber(r)?a=[r].concat(a):ee.isArray(r)&&(a=r.concat(a))),i=o(a,!1),n=o(a,!0),i||R.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),P=r},y._getDbgPlgTargets=function(){return[P[0],F,I,P]},y.addQueryStringParameter=function(e,n){for(var t=0;t<j.length;t++)if(j[t].name===e)return void(j[t].value=n);j.push({name:e,value:n})},y.addHeader=function(e,n){N[e]=n},y.canSendRequest=function(){return r()&&B.allowRequestSending()},y.sendQueuedRequests=function(e,n){ee.isUndefined(e)&&(e=0),z&&(e=i(e),n=2),f(q,e,0)&&b(t(),0,!1,e,n||0)},y.isCompletelyIdle=function(){return!M&&0===A&&0===q.length},y.setUnloading=function(e){z=e},y.addBatch=function(e){if(e&&0<e.count()){if(F.isTenantKilled(e.iKey()))return!1;q.push(e)}return!0},y.teardown=function(){0<q.length&&b(t(),0,!0,2,2)},y.pause=function(){M=!0},y.resume=function(){M=!1,y.sendQueuedRequests(0,4)},y.sendSynchronousBatch=function(e,n,t){e&&0<e.count()&&(ee.isNullOrUndefined(n)&&(n=1),z&&(n=i(n),t=2),b([e],0,!1,n,t||0))}})},Se=ee.isWindowObjectAvailable?window:undefined,le="eventsDiscarded",de="overrideInstrumentationKey",we="maxEventRetryAttempts",_e="maxUnloadEventRetryAttempts",t=(u=ee.BaseTelemetryPlugin,n.__extendsFn(c,u),c);function c(){var x,O,C,K,k,F,M,e=u.call(this)||this,B=(e.identifier="PostChannel",e.priority=1011,!(e.version="3.2.0")),L=[],A=null,H=!1,j=0,N=500,q=0,I=1e4,U={},z=ne,D=null,X=null,Q=0,V=0,W={},J=-1,G=!0,Y=!1,Z=6,$=2;return o(c,e,function(c,l){function d(e){"beforeunload"!==(e||ee.getWindow().event).type&&(Y=!0,C.setUnloading(Y)),u(2,2)}function f(e){Y=!1,C.setUnloading(Y)}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,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||H)e.latency=3,e.sync=!1;else if(C)return G&&(e=ee.optimizeObject(e)),C.sendSynchronousBatch(oe.create(e.iKey,[e]),!0===e.sync?1:e.sync,3);var t=e.latency,i=q,r=I,a=(4===t&&(i=j,r=N),!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?j-=a:q-=a,T(le,[r],ee.EventsDiscardedReason.QueueFull),1}t++}return y(),0}(e.iKey,e.latency,i,r)&&(a=!p(e,n))),a&&b(le,[e],ee.EventsDiscardedReason.QueueFull)}function a(e,n,t){g(e,n,t),C.sendQueuedRequests(n,t)}function o(){0<=J&&g(J,0,F)&&C.sendQueuedRequests(0,F),0<j&&!X&&!H&&0<=(e=U[z][2])&&(X=s(function(){X=null,a(4,0,1),o()},e));var e=U[z][1];!D&&!A&&0<=e&&!H&&(0<q?D=s(function(){D=null,a(0===V?3:1,0,1),V++,V%=2,o()},e):V=0)}function t(){B=!1,H=!(L=[]),N=500,I=1e4,U={},z=ne,V=Q=q=j=0,O=X=D=A=x=null,W={},K=undefined,k=0,J=-1,Y=!(G=!(F=null)),Z=6,M=null,C=new Ee(500,$=2,1,{requeue:e,send:E,sent:S,drop:w,rspFail:_,oth:R}),n(),W[4]={batches:[],iKeyMap:{}},W[3]={batches:[],iKeyMap:{}},W[2]={batches:[],iKeyMap:{}},W[1]={batches:[],iKeyMap:{}},P()}function s(e,n){0===n&&Q&&(n=1);var t=1e3;return Q&&(t=ve(Q-1)),c._setTimeoutOverride(e,n*t)}function i(){null!==D&&(c._clearTimeoutOverride(D),D=null,V=0)}function u(e,n){i(),A&&(c._clearTimeoutOverride(A),A=null),H||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=oe.create(e),i.batches.push(n),i.iKeyMap[e]=n),n}function v(e,n){C.canSendRequest()&&!Q&&(n=0<K&&K<q||n)&&null==A&&c.flush(e,null,20)}function p(e,n){var t=(e=G?ee.optimizeObject(e):e).latency,i=h(e.iKey,t,!0);return i.addEvent(e)&&(4!==t?(q++,n&&0===e.sendAttempt&&v(!e.sync,0<k&&i.count()>=k)):j++,1)}function y(){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);q=i,j=t}function g(i,e,n){var r=!1,t=0===e;return!t||C.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){C.addBatch(e)?r=r||e&&0<e.count():n=n.concat(e.events()),4===t?j-=e.count():q-=e.count()}),e.batches=[],e.iKeyMap={}),t--}0<n.length&&b(le,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(){U={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&&b(le,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 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&&ee.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(le,e,8e3<=n&&n<=8999?n-8e3:ee.EventsDiscardedReason.Unknown)}function _(e){T(le,e,ee.EventsDiscardedReason.NonRetryableStatus),o()}function R(e,n){T(le,e,ee.EventsDiscardedReason.Unknown),o()}function P(){k=x&&x.disableAutoBatchFlushLimit?0:Math.max(1500,I/6)}t(),c._getDbgPlgTargets=function(){return[C]},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,M=ee.mergeEvtNamespace(ee.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),c._setTimeoutOverride=x.setTimeoutOverride||setTimeout.bind(Se),c._clearTimeoutOverride=x.clearTimeoutOverride||clearTimeout.bind(Se),G=!x.disableOptimizeObj&&ee.isChromium(),n=e.getWParam,e.getWParam=function(){var e=0;return x.ignoreMc1Ms0CookieProcessing&&(e|=2),e|n()},0<x.eventsLimitInMem&&(I=x.eventsLimitInMem),0<x.immediateEventLimit&&(N=x.immediateEventLimit),0<x.autoFlushEventsLimit&&(K=x.autoFlushEventsLimit),x.disableXhrSync,ee.isNumber(x[we])&&(Z=x[we]),ee.isNumber(x[_e])&&($=x[_e]),P(),x.httpXHROverride&&x.httpXHROverride.sendPOST&&(O=x.httpXHROverride),ee.isValueAssigned(o.anonCookieName)&&C.addQueryStringParameter("anoncknm",o.anonCookieName),C.sendHook=x.payloadPreprocessor,C.sendListener=x.payloadListener,x.overrideEndpointUrl||o.endpointUrl),r=(c._notificationManager=o.extensionConfig.NotificationManager,C.initialize(i,c.core,c,O,x),o.disablePageUnloadEvents||[]);ee.addPageUnloadEventListener(d,r,M),ee.addPageHideEventListener(d,r,M),ee.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){ee.setProcessTelemetryTimings(e,c.identifier);var t=(n=c._getTelCtx(n)).getExtCfg(c.identifier),i=!!x.disableTelemetry;(i=t?i||!!t.disableTelemetry:i)||B||(x[de]&&(e.iKey=x[de]),t&&t[de]&&(e.iKey=t[de]),r(e,!0),Y?u(2,2):o()),c.processNext(e,n)},c._doTeardown=function(e,n){u(2,2),B=!0,C.teardown(),ee.removePageUnloadEventListener(null,M),ee.removePageHideEventListener(null,M),ee.removePageShowEventListener(null,M),t()},c.setEventQueueLimits=function(e,n){I=0<e?e:1e4,K=0<n?n:0,P();var t=e<q;if(!t&&0<k)for(var i=1;!t&&i<=3;i++){var r=W[i];r&&r.batches&&ee.arrForEach(r.batches,function(e){e&&e.count()>=k&&(t=!0)})}v(!0,t)},c.pause=function(){i(),H=!0,C.pause()},c.resume=function(){H=!1,C.resume(),o()},c.addResponseHandler=function(e){C._responseHandlers.push(e)},c._loadTransmitProfiles=function(e){i(),n(),z=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),U[e]=n)})},c.flush=function(e,n,t){void 0===e&&(e=!0),H||(i(),t=t||1,e?(g(1,0,t),y(),null==A?A=s(function(){!function i(e,n){a(1,0,n),function t(e){C.isCompletelyIdle()?e():A=s(function(){t(e)},.25)}(function(){e&&e(),0<L.length?A=s(function(){return i(L.shift(),n)},0):(A=null,0<q&&o())})}(n,t)},0):L.push(n)):(a(1,1,t),null!==n&&n!==undefined&&n()))},c.setMsaAuthTicket=function(e){C.addHeader(re,e)},c.hasEvents=function(){return 0<q},c._setTransmitProfile=function(e){z!==e&&U[e]!==undefined&&(i(),z=e,o())},c._backOffTransmission=function(){Q<4&&(Q++,i(),o())},c._clearBackOff=function(){Q&&(Q=0,i(),o())}}),e}e.BE_PROFILE="BEST_EFFORT",e.NRT_PROFILE="NEAR_REAL_TIME",e.PostChannel=t,e.RT_PROFILE=ne;var l=e,i="__esModule",n={value:!0},t=Object.defineProperty;if(t)try{return void t(l,i,n)}catch(R){}typeof n.value!==undefined&&(l[i]=n.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);
|
|
7
7
|
//# sourceMappingURL=ms.post.min.js.map
|