@microsoft/1ds-post-js 3.1.10 → 3.1.11
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 +123 -5
- package/bundle/{ms.post-3.1.10.gbl.js → ms.post-3.1.11.gbl.js} +163 -86
- package/bundle/ms.post-3.1.11.gbl.js.map +1 -0
- package/bundle/ms.post-3.1.11.gbl.min.js +7 -0
- package/bundle/ms.post-3.1.11.gbl.min.js.map +1 -0
- package/bundle/ms.post-3.1.11.integrity.json +46 -0
- package/bundle/{ms.post-3.1.10.js → ms.post-3.1.11.js} +163 -86
- package/bundle/ms.post-3.1.11.js.map +1 -0
- package/bundle/ms.post-3.1.11.min.js +7 -0
- package/bundle/ms.post-3.1.11.min.js.map +1 -0
- package/bundle/ms.post.gbl.js +162 -85
- 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 +162 -85
- 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 +101 -47
- 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.d.ts +1 -0
- package/dist-esm/src/Constants.js +2 -1
- package/dist-esm/src/Constants.js.map +1 -1
- package/dist-esm/src/DataModels.d.ts +49 -0
- package/dist-esm/src/DataModels.js +1 -1
- package/dist-esm/src/EventBatch.js +1 -1
- package/dist-esm/src/HttpManager.d.ts +1 -1
- package/dist-esm/src/HttpManager.js +63 -24
- 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.js +51 -28
- package/dist-esm/src/PostChannel.js.map +1 -1
- package/dist-esm/src/RetryPolicy.js +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/Constants.ts +1 -0
- package/src/DataModels.ts +62 -1
- package/src/HttpManager.ts +67 -22
- package/src/PostChannel.ts +56 -28
- package/bundle/ms.post-3.1.10.gbl.js.map +0 -1
- package/bundle/ms.post-3.1.10.gbl.min.js +0 -7
- package/bundle/ms.post-3.1.10.gbl.min.js.map +0 -1
- package/bundle/ms.post-3.1.10.integrity.json +0 -46
- package/bundle/ms.post-3.1.10.js.map +0 -1
- package/bundle/ms.post-3.1.10.min.js +0 -7
- package/bundle/ms.post-3.1.10.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.1.
|
|
2
|
+
* 1DS JS SDK POST plugin, 3.1.11
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
* (Microsoft Internal Only)
|
|
5
5
|
*/
|
|
6
|
-
var e=this,n=function(e,i,D,n){"use strict";function a(e){return e&&"object"==typeof e&&"default"in e?e["default"]:e}var o=a(n),X="REAL_TIME",J="POST",G="drop",n="requeue",Y="application/x-json-stream",Z="cache-control",$="content-type",ee="kill-duration",ne="time-delta-millis",te="AuthMsaDeviceTicket",U="msfpc";function c(e){e=(e.ext||{}).intweb;return e&&D.isValueAssigned(e[U])?e[U]:null}function u(e){for(var n=null,t=0;null===n&&t<e.length;t++)n=c(e[t]);return n}s.create=function(e,n){return new s(e,n)};var Q=s;function s(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||c(e),!0)},e.split=function(e,n){var t;return e<a.length&&(t=a.length-e,D.isNullOrUndefined(n)||(t=n<t?n:t),t=a.splice(e,t),r=u(a)),new s(i,t)}}var l="metadata",R=/\./,ie=function g(n,e,E,t){var r="baseData",T=!!t,b=e,S={};o(g,this,function(g){function m(e,d,f,h,v,y,p){D.objForEachKey(e,function(e,n){if(n||D.isValueAssigned(n)){var t,i=f,a=e,r=v,o=d;if(T&&!h&&R.test(e)){var s=e.split("."),c=s.length;if(1<c){for(var r=r&&r.slice(),l=0;l<c-1;l++){var u=s[l],o=o[u]=o[u]||{};i+="."+u,r&&r.push(u)}a=s[c-1]}}(e=h&&((t=S[e=i])===undefined&&(7<=e.length&&(t=D.strStartsWith(e,"ext.metadata")||D.strStartsWith(e,"ext.web")),S[e]=t),t)||!b||!b.handleField(i,a)?D.sanitizeProperty(a,n,E):b.value(i,a,n,E))&&(t=e.value,o[a]=t,y&&y(r,a,e),p&&"object"==typeof t&&!D.isArray(t)&&((e=r)&&(e=r.slice()).push(a),m(n,t,i+"."+a,h,e,y,p)))}})}g.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}},g.appendPayload=function(v,y,p){var e=v&&y&&!v.overflow;return e&&D.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,l=o?65e3:3984588,d=o?65e3:2e6,s=0,f=0;s<e.length;){var c=e[s];if(c){if(p<=t){v.overflow=y.split(s);break}var u=g.getEventBlob(c);if(u&&u.length<=d){var h=u.length;if(l<n.length+h){v.overflow=y.split(s);break}n&&(n+="\n"),n+=u,20<++f&&(n.substr(0,1),f=0),i=!0,t++}else(u?a:r).push(c),e.splice(s,1),s--}s++}a&&0<a.length&&v.sizeExceed.push(Q.create(y.iKey(),a)),r&&0<r.length&&v.failedEvts.push(Q.create(y.iKey(),r)),i&&(v.batches.push(y),v.payloadBlob=n,v.numEvents=t,o=y.iKey(),-1===D.arrIndexOf(v.apiKeys,o)&&v.apiKeys.push(o))},function(){return{payload:v,theBatch:{iKey:y.iKey(),evts:y.events()},max:p}}),e},g.getEventBlob=function(a){try{return D.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:"+D.getTenantId(a.iKey),{}),n=a.ext,n=(n&&(e.ext=i,D.objForEachKey(n,function(e,n){m(n,i[e]={},"ext."+e,!0,null,null,!0)})),e.data={}),t=(n.baseType=a.baseType,n[r]={});return m(a.baseData,t,r,!1,[r],function(e,n,t){d(i,e,n,t)},!0),m(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=D.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 c=n[s],o=(o[c]||(o[c]={f:{}}),o[c].f||(o[c].f={}));o=o[t]={},D.isArray(i.value)?o.a={t:a}:o.t=a}}}r.shouldRetryForStatus=function(e){return!(300<=e&&e<500&&408!=e&&429!=e||501==e||505==e)},r.getMillisToBackoffForRetry=function(e){return Math.min(Math.pow(2,e)*(2400+Math.floor(1200*Math.random())),6e5)};var ae=r;function r(){}var f=function m(){var c={};o(m,this,function(e){e.setKillSwitchTenants=function(e,n){if(e&&n)try{r=e.split(","),o=[],r&&D.arrForEach(r,function(e){o.push(D.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)c[t[a]]=D.dateNow()+i}catch(s){return[]}var r,o;return[]},e.isTenantKilled=function(e){var n=c,e=D.strTrim(e);return n[e]!==undefined&&n[e]>D.dateNow()||(delete n[e],!1)}})},h=function E(){var n=!0,t=!0,i=!0,a="use-collector-delta",r=!1;o(E,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)}})},re=((t={})[1]=n,t[100]=n,t[200]="sent",t[8004]=G,t[8003]=G,t),v={};function oe(e){try{return e.responseText}catch(n){}return""}function se(e,n){var t=!1;if(e&&n){var i=D.objKeys(e);if(i&&0<i.length)for(var a=n.toLowerCase(),r=0;r<i.length;r++){var o=i[r];if(o&&D.hasOwnProperty(n,o)&&o.toLowerCase()==a){t=!0;break}}}return t}function V(e,n,t,i){n&&t&&0<t.length&&(i&&v[n]?(e.hdrs[v[n]]=t,e.useHdrs=!0):e.url+="&"+n+"="+t)}v.AuthMsaDeviceTicket="AuthMsaDeviceTicket";var y,ce=function T(O,e,k,K){this._responseHandlers=[];var L,_,w,F,B="?cors=true&content-type="+Y,A=new f,y=!1,P=new h,N=!1,x=0,H=!0,I=[],j={},p=[],C=null,z=!1,M=!1,q=!1;o(T,this,function(g){var s=!0;function r(e,n){for(var t=0,i=null,a=0;null==i&&a<e.length;)1===(t=e[a])?D.useXDomainRequest()?i=o:D.isXhrSupported()&&(i=u):2===t&&D.isFetchSupported(n)?i=c:N&&3===t&&D.isBeaconsSupported()&&(i=l),a++;return i?{_transport:t,_isSync:n,sendPOST:i}:null}function o(e,n,t){var i=new XDomainRequest;i.open(J,e.urlString),i.onload=function(){var e=oe(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):L._setTimeoutOverride(function(){i.send(e.data)},0)}function c(e,i,n){var t,a=!1,r=!1;(t={body:e.data,method:J}).Microsoft_ApplicationInsights_BypassAjaxInstrumentation=!0;n&&(t.keepalive=!0,2===e._sendReason&&(a=!0)),s&&(t.credentials="include"),e.headers&&0<D.objKeys(e.headers).length&&(t.headers=e.headers),fetch(e.urlString,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}),r||(r=!0,m(i,e.status,t,n),d(n))})["catch"](function(e){r||(r=!0,m(i,0,{}))}),a&&!r&&(r=!0,m(i,200,{}))}function u(e,r,n){function o(e,n,t){return e[t]||!n||!n.getResponseHeader||(n=n.getResponseHeader(t))&&(e[t]=D.strTrim(n)),e}function t(e,n){var t,i,a;m(r,e.status,(a={},(e=e).getAllResponseHeaders?(t=e.getAllResponseHeaders(),i={},D.isString(t)&&(t=D.strTrim(t).split(/[\r\n]+/),D.arrForEach(t,function(e){var n,t;e&&(-1!=(t=e.indexOf(": "))?(n=D.strTrim(e.substring(0,t)).toLowerCase(),t=D.strTrim(e.substring(1+t)),i[n]=t):i[D.strTrim(e)]=1)})),i):(a=o(a,e,ne),a=o(a,e,ee),o(a,e,"kill-duration-seconds"))),n)}var i=D.openXhr(J,e.urlString,s,!0,n);D.objForEachKey(e.headers,function(e,n){i.setRequestHeader(e,n)}),i.onload=function(){var e=oe(i);t(i,e),d(e)},i.onerror=function(){t(i)},i.ontimeout=function(){t(i)},i.send(e.data)}function m(e,n,t,i){try{e(n,t,i)}catch(a){L.diagLog().throwInternal(D.LoggingSeverity.WARNING,D._ExtendedInternalMessageId.SendPostOnCompleteFailure,D.dumpObj(a))}}function l(i,e,n){var t=200,a=i._thePayload;try{var r,o=D.getNavigator();o.sendBeacon(i.urlString,i.data)||(a?(r=[],D.arrForEach(a.batches,function(e){if(r&&e&&0<e.count()){for(var n=e.events(),t=0;t<n.length;t++)if(!o.sendBeacon(i.urlString,C.getEventBlob(n[t]))){r.push(e.split(t));break}}else r.push(e.split(0))}),S(r,8003,a.sendType,!0)):t=0)}catch(s){L.diagLog().warnToConsole("Failed to send telemetry using sendBeacon API. Ex:"+s),t=0}finally{m(e,t,{},"")}}function E(e){return 2===e||3===e}function i(e){return M&&E(e)?2:e}function a(){return!y&&x<e}function t(){var e=p;return p=[],e}function h(e,n,t){return e&&0<e.length&&!y&&_[n]&&C&&(0!==n||a()&&(0<t||P.allowRequestSending()))}function v(e){var t={};return e&&D.arrForEach(e,function(e,n){t[n]={iKey:e.iKey(),evts:e.events()}}),t}function T(o,s,c,u,l){if(o&&0!==o.length)if(y)S(o,1,u);else{u=i(u);try{var e=o,d=0!==u;D.doPerf(w,function(){return"HttpManager:_sendBatches"},function(e){e&&(o=o.slice(0));for(var n=[],t=null,i=D.getTime(),e=_[u]||(d?_[1]:_[0]),a=(M||E(u)||e&&3===e._transport)&&!H&&N&&D.isBeaconsSupported();h(o,u,s);){var r=o.shift();r&&0<r.count()&&(A.isTenantKilled(r.iKey())?n.push(r):(t=t||C.createPayload(s,c,d,a,l,u),C.appendPayload(t,r,O)?null!==t.overflow&&(o=[t.overflow].concat(o),t.overflow=null,f(t,i,D.getTime(),l),i=D.getTime(),t=null):(f(t,i,D.getTime(),l),i=D.getTime(),o=[r].concat(o),t=null)))}t&&f(t,i,D.getTime(),l),0<o.length&&(p=o.concat(p)),S(n,8004,u)},function(){return{batches:v(e),retryCount:s,isTeardown:c,isSynchronous:d,sendReason:l,useSendBeacon:E(u),sendType:u}},!d)}catch(n){L.diagLog().throwInternal(D.LoggingSeverity.WARNING,D._ExtendedInternalMessageId.CannotSerializeObject,"Unexpected Exception sending batch: "+D.dumpObj(n))}}}function b(e,n,t){e[n]=e[n]||{},e[n][L.identifier]=t}function f(h,s,c,v){var u,l,d,f,y,p;h&&h.payloadBlob&&0<h.payloadBlob.length&&(u=!!g.sendHook,l=_[h.sendType],!E(h.sendType)&&h.isBeacon&&2===h.sendReason&&(l=_[2]||_[3]||l),f=q,!h.isBeacon&&3!==l._transport||(f=!1),d=function(e,n){var t={url:B,hdrs:{},useHdrs:!1},i=(t.hdrs=D.extend(t.hdrs,j),t.useHdrs=0<D.objKeys(t.hdrs).length,V(t,"client-id","NO_AUTH",n),V(t,"client-version",D.FullVersionString,n),""),e=(D.arrForEach(e.apiKeys,function(e){0<i.length&&(i+=","),i+=e}),V(t,"apikey",i,n),V(t,"upload-time",D.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));D.isValueAssigned(e)&&(t.url+="&ext.intweb.msfpc="+e),P.shouldAddClockSkewHeaders()&&V(t,"time-delta-to-apply-millis",P.getClockSkewHeaderValue(),n),!w.getWParam||0<=(e=w.getWParam())&&(t.url+="&w="+e);for(var a=0;a<I.length;a++)t.url+="&"+I[a].name+"="+I[a].value;return t}(h,f),f=f||d.useHdrs,y=D.getTime(),p="sendAttempt",D.doPerf(w,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];z&&(b(i=a.timings=a.timings||{},"sendEventStart",y),b(i,"serializationStart",s),b(i,"serializationCompleted",c)),0<a[p]?a[p]++:a[p]=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},o=(f&&(se(r.headers,Z)||(r.headers[Z]="no-cache, no-store"),se(r.headers,$)||(r.headers[$]=Y)),null);l&&(o=function(e){P.firstRequestSent();var n=function(e,n){var t,i,a=h,l=v,r=9e3,o=null,d=!1,f=!1;try{var s,c=!0;if(typeof e!==D.strUndefined){if(n&&(P.setClockSkew(n[ne]),u=n[ee]||n["kill-duration-seconds"],D.arrForEach(A.setKillSwitchTenants(n["kill-tokens"],u),function(n){D.arrForEach(a.batches,function(e){e.iKey()===n&&(o=o||[],e=e.split(0),a.numEvents-=e.count(),o.push(e))})})),200==e)return void(r=200);(!ae.shouldRetryForStatus(e)||a.numEvents<=0)&&(c=!1),r=9e3+e%1e3}c&&(r=100,s=a.retryCnt,0===a.sendType&&(s<k?(d=!0,R(function(){0===a.sendType&&x--,T(a.batches,s+1,a.isTeardown,M?2:a.sendType,5)},M,ae.getMillisToBackoffForRetry(s))):f=!0))}finally{if(!d){P.setClockSkew();var n=a,u=r,e=l,c=f;try{c&&L._backOffTransmission(),200===u&&(c||n.isSync||L._clearBackOff(),t=n.batches,z&&(i=D.getTime(),D.arrForEach(t,function(e){var n;e&&0<e.count()&&(e=e.events(),n=i,z&&D.arrForEach(e,function(e){b(e.timings=e.timings||{},"sendEventCompleted",n)}))}))),S(n.batches,u,n.sendType,!0)}finally{0===n.sendType&&(x--,5!==e&&g.sendQueuedRequests(n.sendType,e))}}S(o,8004,a.sendType)}},t=h.isTeardown||h.isSync;try{l.sendPOST(e,n,t),g.sendListener&&g.sendListener(r,e,t,h.isBeacon)}catch(i){L.diagLog().warnToConsole("Unexpected exception sending payload. Ex:"+D.dumpObj(i)),m(n,0,{})}}),D.doPerf(w,function(){return"HttpManager:_doPayloadSend.sender"},function(){var n,t;o&&(0===h.sendType&&x++,u&&!h.isBeacon&&3!==l._transport?(n={data:r.data,urlString:r.urlString,headers:D.extend({},r.headers)},t=!1,D.doPerf(w,function(){return"HttpManager:_doPayloadSend.sendHook"},function(){try{g.sendHook(n,function(e){t=!0,H||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:c,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 R(e,n,t){n?e():L._setTimeoutOverride(e,t)}function d(e){var n=g._responseHandlers;try{for(var t,i=0;i<n.length;i++)try{n[i](e)}catch(a){L.diagLog().throwInternal(D.LoggingSeverity.CRITICAL,D._ExtendedInternalMessageId.PostResponseHandler,"Response handler failed: "+a)}e&&(t=JSON.parse(e),D.isValueAssigned(t.webResult)&&D.isValueAssigned(t.webResult[U])&&F.set("MSFPC",t.webResult[U],31536e3))}catch(r){}}function S(n,t,i,e){var a,r,o,s;n&&0<n.length&&K&&(a=K[s=re[o=t],D.isValueAssigned(s)||(s="oth",9e3<=o&&o<=9999?s="rspFail":8e3<=o&&o<=8999?s=G:1e3<=o&&o<=1999&&(s="send")),s])&&D.doPerf(w,function(){return"HttpManager:_sendBatchesNotification"},function(){R(function(){try{a.call(K,n,t,r,i)}catch(e){L.diagLog().throwInternal(D.LoggingSeverity.CRITICAL,D._ExtendedInternalMessageId.NotificationException,"send request notification failed: "+e)}},e||r,0)},function(){return{batches:v(n),reason:t,isSync:r,sendSync:e,sendType:i}},!(r=0!==i))}g.initialize=function(e,n,t,i,a){B=e+B,q=!D.isUndefined((a=a||{}).avoidOptions)&&!a.avoidOptions,F=(w=n).getCookieMgr(),z=!w.config.disableEventTimings;var e=!!w.config.enableCompoundKey,n=(L=t,a.valueSanitizer),t=a.stringifyObjects,n=(D.isUndefined(a.enableCompoundKey)||(e=!!a.enableCompoundKey),N=!D.isReactNative(),C=new ie(w,n,t,e),i);i||(H=!1,(t=D.getLocation())&&t.protocol&&"file:"==t.protocol.toLowerCase()&&(s=!1),e=[],e=D.isReactNative()?[2,1]:[1,2,3],(t=a.transports)&&(D.isNumber(t)?e=[t].concat(e):D.isArray(t)&&(e=t.concat(e))),i=r(e,!1),n=r(e,!0),i||L.diagLog().warnToConsole("No available transport to send events")),(a={})[0]=i,a[1]=n||r([1,2,3],!0),a[2]=r([3,2,1],!0)||n,a[3]=r([2,3,1],!0)||n,_=a},g._getDbgPlgTargets=function(){return[_[0],A,C,_]},g.addQueryStringParameter=function(e,n){for(var t=0;t<I.length;t++)if(I[t].name===e)return void(I[t].value=n);I.push({name:e,value:n})},g.addHeader=function(e,n){j[e]=n},g.canSendRequest=function(){return a()&&P.allowRequestSending()},g.sendQueuedRequests=function(e,n){D.isUndefined(e)&&(e=0),M&&(e=i(e),n=2),h(p,e,0)&&T(t(),0,!1,e,n||0)},g.isCompletelyIdle=function(){return!y&&0===x&&0===p.length},g.setUnloading=function(e){M=e},g.addBatch=function(e){if(e&&0<e.count()){if(A.isTenantKilled(e.iKey()))return!1;p.push(e)}return!0},g.teardown=function(){0<p.length&&T(t(),0,!0,2,2)},g.pause=function(){y=!0},g.resume=function(){y=!1,g.sendQueuedRequests(0,4)},g.sendSynchronousBatch=function(e,n,t){e&&0<e.count()&&(D.isNullOrUndefined(n)&&(n=1),M&&(n=i(n),t=2),T([e],0,!1,n,t||0))}})},ue=D.isWindowObjectAvailable?window:undefined,W="eventsDiscarded",le="overrideInstrumentationKey",n=(y=D.BaseTelemetryPlugin,i.__extendsFn(p,y),p);function p(){var T,I,b,C,M,O,e=y.call(this)||this,k=(e.identifier="PostChannel",e.priority=1011,!(e.version="3.1.10")),K=[],S=null,R=!1,L=0,F=500,_=0,B=1e4,A={},N=X,t=null,H=null,w=0,j=0,P={},x=-1,z=!0,q=!1;return o(p,e,function(s,h){function v(e,n){if(e.sendAttempt||(e.sendAttempt=0),e.latency||(e.latency=D.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,z&&(e.ext=D.optimizeObject(e.ext),e.baseData&&(e.baseData=D.optimizeObject(e.baseData)),e.data&&(e.data=D.optimizeObject(e.data))),e.sync)if(w||R)e.latency=D.EventLatency.RealTime,e.sync=!1;else if(b)return z&&(e=D.optimizeObject(e)),b.sendSynchronousBatch(Q.create(e.iKey,[e]),!0===e.sync?1:e.sync,3),0;var t=e.latency,i=_,a=B,r=(t===D.EventLatency.Immediate&&(i=L,a=F),!1);i<a?r=!g(e,n):(i=D.EventLatency.Normal,a=20,t===D.EventLatency.Immediate&&(i=D.EventLatency.Immediate,a=1),r=!0,function(e,n,t,i){for(;t<=n;){var a=y(e,n,!0);if(a&&0<a.count()){var a=a.split(0,i),r=a.count();if(0<r)return t===D.EventLatency.Immediate?L-=r:_-=r,f(W,[a],D.EventsDiscardedReason.QueueFull),1}t++}return m(),0}(e.iKey,e.latency,i,a)&&(r=!g(e,n))),r&&d(W,[e],D.EventsDiscardedReason.QueueFull)}function a(e,n,t){e=u(e,n,t);return b.sendQueuedRequests(n,t),e}function r(){0<=x&&u(x,0,O)&&b.sendQueuedRequests(0,O),!(0<L)||H||R||0<=(e=A[N][2])&&(H=o(function(){H=null,a(D.EventLatency.Immediate,0,1),r()},e));var e=A[N][1];!t&&!S&&0<=e&&!R&&(0<_?t=o(function(){t=null,a(0===j?D.EventLatency.RealTime:D.EventLatency.Normal,0,1),j++,j%=2,r()},e):j=0)}function o(e,n){0===n&&w&&(n=1);var t=1e3;return w&&(t=ae.getMillisToBackoffForRetry(w-1)),s._setTimeoutOverride(e,n*t)}function i(){null!==t&&(s._clearTimeoutOverride(t),t=null,j=0)}function c(e,n){i(),S&&(s._clearTimeoutOverride(S),S=null),R||a(D.EventLatency.Normal,e,n)}function y(e,n,t){var i=P[n],n=(i||(n=D.EventLatency.Normal,i=P[n]),i.iKeyMap[e]);return!n&&t&&(n=Q.create(e),i.batches.push(n),i.iKeyMap[e]=n),n}function p(e,n){b.canSendRequest()&&!w&&(n=0<C&&C<_||n)&&null==S&&s.flush(e,null,20)}function g(e,n){var t=(e=z?D.optimizeObject(e):e).latency,i=y(e.iKey,t,!0);return i.addEvent(e)&&(t!==D.EventLatency.Immediate?(_++,n&&0===e.sendAttempt&&p(!e.sync,0<M&&i.count()>=M)):L++,1)}function m(){for(var t=0,i=0,e=D.EventLatency.Normal;e<=D.EventLatency.Immediate;e++)!function(n){var e=P[n];e&&e.batches&&D.arrForEach(e.batches,function(e){n===D.EventLatency.Immediate?t+=e.count():i+=e.count()})}(e);_=i,L=t}function u(i,e,n){var a=!1,t=0===e;return!t||b.canSendRequest()?D.doPerf(s.core,function(){return"PostChannel._queueBatches"},function(){for(var n=[],t=D.EventLatency.Immediate;i<=t;){var e=P[t];e&&e.batches&&0<e.batches.length&&(D.arrForEach(e.batches,function(e){b.addBatch(e)?a=a||e&&0<e.count():n=n.concat(e.events()),t===D.EventLatency.Immediate?L-=e.count():_-=e.count()}),e.batches=[],e.iKeyMap={}),t--}0<n.length&&d(W,n,D.EventsDiscardedReason.KillSwitch),a&&i<=x&&(x=-1,O=0)},function(){return{latency:i,sendType:e,sendReason:n}},!t):(x=0<=x?Math.min(x,i):i,O=Math.max(O,n)),a}function n(){A={REAL_TIME:[2,1,0],NEAR_REAL_TIME:[6,3,0],BEST_EFFORT:[18,9,0]}}function l(e,n){var t=s._notificationManager||{},i=t[e];if(i)try{i.apply(t,n)}catch(a){s.diagLog().throwInternal(D.LoggingSeverity.CRITICAL,D._ExtendedInternalMessageId.NotificationException,e+" notification failed: "+a)}}function d(e,n){for(var t=[],i=2;i<arguments.length;i++)t[i-2]=arguments[i];n&&0<n.length&&l(e,[n].concat(t))}function f(n,e){for(var t=[],i=2;i<arguments.length;i++)t[i-2]=arguments[i];e&&0<e.length&&D.arrForEach(e,function(e){e&&0<e.count()&&l(n,[e.events()].concat(t))})}function E(){M=T&&T.disableAutoBatchFlushLimit?0:Math.max(1500,B/6)}n(),P[D.EventLatency.Immediate]={batches:[],iKeyMap:{}},P[D.EventLatency.RealTime]={batches:[],iKeyMap:{}},P[D.EventLatency.CostDeferred]={batches:[],iKeyMap:{}},P[D.EventLatency.Normal]={batches:[],iKeyMap:{}},E(),b=new ce(500,2,1,{requeue:function(e,n){var t=[];D.arrForEach(e,function(e){e&&0<e.count()&&D.arrForEach(e.events(),function(e){e&&(e.sync&&(e.latency=D.EventLatency.Immediate,e.sync=!1),e.sendAttempt<6?(D.setProcessTelemetryTimings(e,s.identifier),v(e,!1)):t.push(e))})}),0<t.length&&d(W,t,D.EventsDiscardedReason.NonRetryableStatus),q&&c(2,2)},send:function(e,n,t){e&&0<e.length&&l("eventsSendRequest",[1e3<=n&&n<=1999?n-1e3:0,!0!==t])},sent:function(e,n){f("eventsSent",e,n),r()},drop:function(e,n){f(W,e,8e3<=n&&n<=8999?n-8e3:D.EventsDiscardedReason.Unknown)},rspFail:function(e){f(W,e,D.EventsDiscardedReason.NonRetryableStatus),r()},oth:function(e,n){f(W,e,D.EventsDiscardedReason.Unknown),r()}}),s._getDbgPlgTargets=function(){return[b]},s.initialize=function(a,r,o){D.doPerf(r,function(){return"PostChannel:initialize"},function(){var e=r,n=(h.initialize(a,r,o),s.setInitialized(!1),s._getTelCtx()),t=(a.extensionConfig[s.identifier]=a.extensionConfig[s.identifier]||{},T=n.getExtCfg(s.identifier),s._setTimeoutOverride=T.setTimeoutOverride||setTimeout.bind(ue),s._clearTimeoutOverride=T.clearTimeoutOverride||clearTimeout.bind(ue),z=!T.disableOptimizeObj&&D.isChromium(),e.getWParam),n=(e.getWParam=function(){var e=0;return T.ignoreMc1Ms0CookieProcessing&&(e|=2),e|t()},0<T.eventsLimitInMem&&(B=T.eventsLimitInMem),0<T.immediateEventLimit&&(F=T.immediateEventLimit),0<T.autoFlushEventsLimit&&(C=T.autoFlushEventsLimit),E(),T.httpXHROverride&&T.httpXHROverride.sendPOST&&(I=T.httpXHROverride),D.isValueAssigned(a.anonCookieName)&&b.addQueryStringParameter("anoncknm",a.anonCookieName),b.sendHook=T.payloadPreprocessor,b.sendListener=T.payloadListener,T.overrideEndpointUrl||a.endpointUrl);function i(e){"beforeunload"!==(e||D.getWindow().event).type&&(q=!0,b.setUnloading(q)),c(2,2)}s._notificationManager=a.extensionConfig.NotificationManager,b.initialize(n,s.core,s,I,T);e=a.disablePageUnloadEvents||[];D.addPageUnloadEventListener(i,e),D.addPageHideEventListener(i,e),D.addPageShowEventListener(function(e){q=!1,b.setUnloading(q)},a.disablePageShowEvents),s.setInitialized(!0)},function(){return{coreConfig:a,core:r,extensions:o}})},s.processTelemetry=function(e,n){D.setProcessTelemetryTimings(e,s.identifier);var t=(n=s._getTelCtx(n)).getExtCfg(s.identifier),i=!!T.disableTelemetry;(i=t?i||!!t.disableTelemetry:i)||k||(T[le]&&(e.iKey=T[le]),t&&t[le]&&(e.iKey=t[le]),v(e,!0),q?c(2,2):r()),s.processNext(e,n)},s.setEventQueueLimits=function(e,n){B=0<e?e:1e4,C=0<n?n:0,E();var t=e<_;if(!t&&0<M)for(var i=D.EventLatency.Normal;!t&&i<=D.EventLatency.RealTime;i++){var a=P[i];a&&a.batches&&D.arrForEach(a.batches,function(e){e&&e.count()>=M&&(t=!0)})}p(!0,t)},s.teardown=function(){c(2,2),k=!0,b.teardown()},s.pause=function(){i(),R=!0,b.pause()},s.resume=function(){R=!1,b.resume(),r()},s.addResponseHandler=function(e){b._responseHandlers.push(e)},s._loadTransmitProfiles=function(e){i(),n(),N=X,r(),D.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),A[e]=n)})},s.flush=function(e,n,t){void 0===e&&(e=!0),R||(i(),t=t||1,e?(u(D.EventLatency.Normal,0,t),m(),null==S?S=o(function(){!function i(e,n){a(D.EventLatency.Normal,0,n),function t(e){b.isCompletelyIdle()?e():S=o(function(){t(e)},.25)}(function(){e&&e(),0<K.length?S=o(function(){return i(K.shift(),n)},0):(S=null,0<_&&r())})}(n,t)},0):K.push(n)):(a(D.EventLatency.Normal,1,t),null!==n&&n!==undefined&&n()))},s.setMsaAuthTicket=function(e){b.addHeader(te,e)},s.hasEvents=function(){return 0<_},s._setTransmitProfile=function(e){N!==e&&A[e]!==undefined&&(i(),N=e,r())},s._backOffTransmission=function(){w<4&&(w++,i(),r())},s._clearBackOff=function(){w&&(w=0,i(),r())}}),e}e.BE_PROFILE="BEST_EFFORT",e.NRT_PROFILE="NEAR_REAL_TIME",e.PostChannel=n,e.RT_PROFILE=X;var t=e,i="__esModule",n={value:!0},e=Object.defineProperty;if(e)try{return void e(t,i,n)}catch(b){}typeof n.value!==undefined&&(t[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);
|
|
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);
|
|
7
7
|
//# sourceMappingURL=ms.post.min.js.map
|