Socket
Socket
Sign inDemoInstall

@microsoft/applicationinsights-core-js

Package Overview
Dependencies
Maintainers
4
Versions
561
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@microsoft/applicationinsights-core-js - npm Package Compare versions

Comparing version 2.3.0 to 2.3.1

255

browser/applicationinsights-core-js.js
/*!
* Application Insights JavaScript SDK - Core, 2.3.0
* Application Insights JavaScript SDK - Core, 2.3.1
* Copyright (c) Microsoft and contributors. All rights reserved.

@@ -40,3 +40,3 @@ */

*/
QueueFull: 5,
QueueFull: 5
};

@@ -73,2 +73,4 @@

// Added to help with minfication
var prototype = "prototype";
var CoreUtils = /** @class */ (function () {

@@ -81,2 +83,8 @@ function CoreUtils() {

/**
* Check if an object is of type Date
*/
CoreUtils.isDate = function (obj) {
return Object[prototype].toString.call(obj) === "[object Date]";
};
/**
* Creates a new GUID.

@@ -94,2 +102,197 @@ * @return {string} A GUID.

};
/**
* Convert a date to I.S.O. format in IE8
*/
CoreUtils.toISOString = function (date) {
if (CoreUtils.isDate(date)) {
var pad = function (num) {
var r = String(num);
if (r.length === 1) {
r = "0" + r;
}
return r;
};
return date.getUTCFullYear()
+ "-" + pad(date.getUTCMonth() + 1)
+ "-" + pad(date.getUTCDate())
+ "T" + pad(date.getUTCHours())
+ ":" + pad(date.getUTCMinutes())
+ ":" + pad(date.getUTCSeconds())
+ "." + String((date.getUTCMilliseconds() / 1000).toFixed(3)).slice(2, 5)
+ "Z";
}
};
/**
* Performs the specified action for each element in an array. This helper exists to avoid adding a polyfil for older browsers
* that do not define Array.prototype.xxxx (eg. ES3 only, IE8) just in case any page checks for presence/absence of the prototype
* implementation. Note: For consistency this will not use the Array.prototype.xxxx implementation if it exists as this would
* cause a testing requirement to test with and without the implementations
* @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.
* @param thisArg [Optional] An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
*/
CoreUtils.arrForEach = function (arr, callbackfn, thisArg) {
var len = arr.length;
for (var idx = 0; idx < len; ++idx) {
if (idx in arr) {
callbackfn.call(thisArg || arr, arr[idx], idx, arr);
}
}
};
/**
* Returns the index of the first occurrence of a value in an array. This helper exists to avoid adding a polyfil for older browsers
* that do not define Array.prototype.xxxx (eg. ES3 only, IE8) just in case any page checks for presence/absence of the prototype
* implementation. Note: For consistency this will not use the Array.prototype.xxxx implementation if it exists as this would
* cause a testing requirement to test with and without the implementations
* @param searchElement The value to locate in the array.
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.
*/
CoreUtils.arrIndexOf = function (arr, searchElement, fromIndex) {
var len = arr.length;
var from = fromIndex || 0;
for (var lp = Math.max(from >= 0 ? from : len - Math.abs(from), 0); lp < len; lp++) {
if (lp in arr && arr[lp] === searchElement) {
return lp;
}
}
return -1;
};
/**
* Calls a defined callback function on each element of an array, and returns an array that contains the results. This helper exists
* to avoid adding a polyfil for older browsers that do not define Array.prototype.xxxx (eg. ES3 only, IE8) just in case any page
* checks for presence/absence of the prototype implementation. Note: For consistency this will not use the Array.prototype.xxxx
* implementation if it exists as this would cause a testing requirement to test with and without the implementations
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
*/
CoreUtils.arrMap = function (arr, callbackfn, thisArg) {
var len = arr.length;
var _this = thisArg || arr;
var results = new Array(len);
for (var lp = 0; lp < len; lp++) {
if (lp in arr) {
results[lp] = callbackfn.call(_this, arr[lp], arr);
}
}
return results;
};
/**
* Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is
* provided as an argument in the next call to the callback function. This helper exists to avoid adding a polyfil for older browsers that do not define
* Array.prototype.xxxx (eg. ES3 only, IE8) just in case any page checks for presence/absence of the prototype implementation. Note: For consistency
* this will not use the Array.prototype.xxxx implementation if it exists as this would cause a testing requirement to test with and without the implementations
* @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.
* @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
*/
CoreUtils.arrReduce = function (arr, callbackfn, initialValue) {
var len = arr.length;
var lp = 0;
var value;
// Specifically checking the number of passed arguments as the value could be anything
if (arguments.length >= 3) {
value = arguments[2];
}
else {
while (lp < len && !(lp in arr)) {
lp++;
}
value = arr[lp++];
}
while (lp < len) {
if (lp in arr) {
value = callbackfn(value, arr[lp], lp, arr);
}
lp++;
}
return value;
};
/**
* Creates an object that has the specified prototype, and that optionally contains specified properties. This helper exists to avoid adding a polyfil
* for older browsers that do not define Object.create (eg. ES3 only, IE8) just in case any page checks for presence/absence of the prototype implementation.
* Note: For consistency this will not use the Object.create implementation if it exists as this would cause a testing requirement to test with and without the implementations
* @param obj Object to use as a prototype. May be null
*/
CoreUtils.objCreate = function (obj) {
if (obj == null) {
return {};
}
var type = typeof obj;
if (type !== 'object' && type !== 'function') {
throw new TypeError('Object prototype may only be an Object: ' + obj);
}
function tmpFunc() { }
tmpFunc[prototype] = obj;
return new tmpFunc();
};
/**
* Returns the names of the enumerable string properties and methods of an object. This helper exists to avoid adding a polyfil for older browsers
* that do not define Object.create (eg. ES3 only, IE8) just in case any page checks for presence/absence of the prototype implementation.
* Note: For consistency this will not use the Object.create implementation if it exists as this would cause a testing requirement to test with and without the implementations
* @param obj Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
*/
CoreUtils.objKeys = function (obj) {
var hasOwnProperty = Object[prototype].hasOwnProperty;
var hasDontEnumBug = !({ toString: null }).propertyIsEnumerable('toString');
var type = typeof obj;
if (type !== 'function' && (type !== 'object' || obj === null)) {
throw new TypeError('objKeys called on non-object');
}
var result = [];
for (var prop in obj) {
if (hasOwnProperty.call(obj, prop)) {
result.push(prop);
}
}
if (hasDontEnumBug) {
var dontEnums = [
'toString',
'toLocaleString',
'valueOf',
'hasOwnProperty',
'isPrototypeOf',
'propertyIsEnumerable',
'constructor'
];
var dontEnumsLength = dontEnums.length;
for (var lp = 0; lp < dontEnumsLength; lp++) {
if (hasOwnProperty.call(obj, dontEnums[lp])) {
result.push(dontEnums[lp]);
}
}
}
return result;
};
/**
* Try to define get/set object property accessors for the target object/prototype, this will provide compatibility with
* existing API definition when run within an ES5+ container that supports accessors but still enable the code to be loaded
* and executed in an ES3 container, providing basic IE8 compatibility.
* @param target The object on which to define the property.
* @param prop The name of the property to be defined or modified.
* @param getProp The getter function to wire against the getter.
* @param setProp The setter function to wire against the setter.
* @returns True if it was able to create the accessors otherwise false
*/
CoreUtils.objDefineAccessors = function (target, prop, getProp, setProp) {
var defineProp = Object["defineProperty"];
if (defineProp) {
try {
var descriptor = {
enumerable: true,
configurable: true
};
if (getProp) {
descriptor.get = getProp;
}
if (setProp) {
descriptor.set = setProp;
}
defineProp(target, prop, descriptor);
return true;
}
catch (e) {
// IE8 Defines a defineProperty on Object but it's only supported for DOM elements so it will throw
// We will just ignore this here.
}
}
return false;
};
return CoreUtils;

@@ -107,3 +310,3 @@ }());

ChannelController.prototype.processTelemetry = function (item) {
this.channelQueue.forEach(function (queues) {
CoreUtils.arrForEach(this.channelQueue, function (queues) {
// pass on to first item in queue

@@ -115,9 +318,5 @@ if (queues.length > 0) {

};
Object.defineProperty(ChannelController.prototype, "ChannelControls", {
get: function () {
return this.channelQueue;
},
enumerable: true,
configurable: true
});
ChannelController.prototype.getChannelControls = function () {
return this.channelQueue;
};
ChannelController.prototype.initialize = function (config, core, extensions) {

@@ -131,3 +330,3 @@ var _this = this;

var invalidChannelIdentifier_1;
config.channels.forEach(function (queue) {
CoreUtils.arrForEach(config.channels, function (queue) {
if (queue && queue.length > 0) {

@@ -141,3 +340,3 @@ queue = queue.sort(function (a, b) {

// Initialize each plugin
queue.forEach(function (queueItem) {
CoreUtils.arrForEach(queue, function (queueItem) {
if (queueItem.priority < ChannelControllerPriority) {

@@ -172,6 +371,14 @@ invalidChannelIdentifier_1 = queueItem.identifier;

// Initialize each plugin
arr.forEach(function (queueItem) { return queueItem.initialize(config, core, extensions); });
CoreUtils.arrForEach(arr, function (queueItem) { return queueItem.initialize(config, core, extensions); });
this.channelQueue.push(arr);
}
};
/**
* Static constructor, attempt to create accessors
*/
// tslint:disable-next-line
ChannelController._staticInit = (function () {
// Dynamically create get/set property accessors
CoreUtils.objDefineAccessors(ChannelController.prototype, "ChannelControls", ChannelController.prototype.getChannelControls);
})();
return ChannelController;

@@ -199,3 +406,3 @@ }());

if (!this._notificationManager) {
this._notificationManager = Object.create({
this._notificationManager = CoreUtils.objCreate({
addNotificationListener: function (listener) { },

@@ -215,3 +422,3 @@ removeNotificationListener: function (listener) { },

if (!this.logger) {
this.logger = Object.create({
this.logger = CoreUtils.objCreate({
throwInternal: function (severity, msgId, msg, properties, isUserAct) {

@@ -227,3 +434,3 @@ if (isUserAct === void 0) { isUserAct = false; }

// Initial validation
this._extensions.forEach(function (extension) {
CoreUtils.arrForEach(this._extensions, function (extension) {
var isValid = true;

@@ -259,3 +466,3 @@ if (CoreUtils.isNullOrUndefined(extension) || CoreUtils.isNullOrUndefined(extension.initialize)) {

var priority = {};
this._extensions.forEach(function (ext) {
CoreUtils.arrForEach(this._extensions, function (ext) {
var t = ext;

@@ -290,3 +497,3 @@ if (t && t.priority) {

// initialize remaining regular plugins
this._extensions.forEach(function (ext) {
CoreUtils.arrForEach(this._extensions, function (ext) {
var e = ext;

@@ -308,3 +515,3 @@ if (e && e.priority < _this._channelController.priority) {

BaseCore.prototype.getTransmissionControls = function () {
return this._channelController.ChannelControls;
return this._channelController.getChannelControls();
};

@@ -318,3 +525,3 @@ BaseCore.prototype.track = function (telemetryItem) {

// add default timestamp if not passed in
telemetryItem.time = new Date().toISOString();
telemetryItem.time = CoreUtils.toISOString(new Date());
}

@@ -360,6 +567,6 @@ if (CoreUtils.isNullOrUndefined(telemetryItem.ver)) {

NotificationManager.prototype.removeNotificationListener = function (listener) {
var index = this.listeners.indexOf(listener);
var index = CoreUtils.arrIndexOf(this.listeners, listener);
while (index > -1) {
this.listeners.splice(index, 1);
index = this.listeners.indexOf(listener);
index = CoreUtils.arrIndexOf(this.listeners, listener);
}

@@ -729,7 +936,7 @@ };

var queue = _this.logger ? _this.logger.queue : [];
queue.forEach(function (logMessage) {
CoreUtils.arrForEach(queue, function (logMessage) {
var item = {
name: eventName ? eventName : "InternalMessageId: " + logMessage.messageId,
iKey: _this.config.instrumentationKey,
time: new Date().toISOString(),
time: CoreUtils.toISOString(new Date()),
baseType: _InternalLogMessage.dataType,

@@ -736,0 +943,0 @@ baseData: { message: logMessage.message }

4

browser/applicationinsights-core-js.min.js
/*!
* Application Insights JavaScript SDK - Core, 2.3.0
* Application Insights JavaScript SDK - Core, 2.3.1
* Copyright (c) Microsoft and contributors. All rights reserved.
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e.Microsoft=e.Microsoft||{},e.Microsoft.ApplicationInsights={}))}(this,function(a){"use strict";var t={Unknown:0,NonRetryableStatus:1,InvalidEvent:2,SizeLimitExceeded:3,KillSwitch:4,QueueFull:5},i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)};var g=(e.isNullOrUndefined=function(e){return null==e},e.disableCookies=function(){e._canUseCookies=!1},e.newGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(n,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})},e);function e(){}var n=/[xy]/g,o=(r.prototype.processTelemetry=function(t){this.channelQueue.forEach(function(e){0<e.length&&e[0].processTelemetry(t)})},Object.defineProperty(r.prototype,"ChannelControls",{get:function(){return this.channelQueue},enumerable:!0,configurable:!0}),r.prototype.initialize=function(i,n,o){var r,s=this;i.isCookieUseDisabled&&g.disableCookies(),this.channelQueue=new Array,i.channels&&i.channels.forEach(function(e){if(e&&0<e.length){e=e.sort(function(e,t){return e.priority-t.priority});for(var t=1;t<e.length;t++)e[t-1].setNextPlugin(e[t]);if(e.forEach(function(e){e.priority<500&&(r=e.identifier),e.initialize(i,n,o)}),r)throw Error("Channel has invalid priority"+r);s.channelQueue.push(e)}});for(var e=new Array,t=0;t<o.length;t++){var a=o[t];500<a.priority&&e.push(a)}if(0<e.length){for(e=e.sort(function(e,t){return e.priority-t.priority}),t=1;t<e.length;t++)e[t-1].setNextPlugin(e[t]);e.forEach(function(e){return e.initialize(i,n,o)}),this.channelQueue.push(e)}},r);function r(){this.identifier="ChannelControllerPlugin",this.priority=500}var s=(l.prototype.initialize=function(e,t,i,n){var o=this;if(this._isInitialized)throw Error("Core should not be initialized more than once");if(!e||g.isNullOrUndefined(e.instrumentationKey))throw Error("Please provide instrumentation key");this.config=e,this._notificationManager=n,this._notificationManager||(this._notificationManager=Object.create({addNotificationListener:function(e){},removeNotificationListener:function(e){},eventsSent:function(e){},eventsDiscarded:function(e,t){}})),this.config.extensions=g.isNullOrUndefined(this.config.extensions)?[]:this.config.extensions,this.config.extensionConfig=g.isNullOrUndefined(this.config.extensionConfig)?{}:this.config.extensionConfig,this._notificationManager&&(this.config.extensionConfig.NotificationManager=this._notificationManager),this.logger=i,this.logger||(this.logger=Object.create({throwInternal:function(e,t,i,n,o){void 0===o&&(o=!1)},warnToConsole:function(e){},resetInternalMessageCount:function(){}})),(s=this._extensions).push.apply(s,t.concat(this.config.extensions)),this._extensions.forEach(function(e){var t=!0;if((g.isNullOrUndefined(e)||g.isNullOrUndefined(e.initialize))&&(t=!1),!t)throw Error("Extensions must provide callback to initialize")}),this._extensions.push(this._channelController),this._extensions=this._extensions.sort(function(e,t){var i=e,n=t,o=typeof i.processTelemetry,r=typeof n.processTelemetry;return"function"==o&&"function"==r?i.priority-n.priority:"function"==o&&"function"!=r?1:"function"!=o&&"function"==r?-1:void 0});var r={};this._extensions.forEach(function(e){var t=e;t&&t.priority&&(g.isNullOrUndefined(r[t.priority])?r[t.priority]=t.identifier:o.logger&&o.logger.warnToConsole("Two extensions have same priority"+r[t.priority]+", "+t.identifier))});for(var s,a=-1,l=0;l<this._extensions.length-1;l++){var c=this._extensions[l];if(!c||"function"==typeof c.processTelemetry){if(c.priority===this._channelController.priority){a=l+1;break}this._extensions[l].setNextPlugin(this._extensions[l+1])}}if(this._channelController.initialize(this.config,this,this._extensions),this._extensions.forEach(function(e){e&&e.priority<o._channelController.priority&&e.initialize(o.config,o,o._extensions)}),a<this._extensions.length&&this._extensions.splice(a),0===this.getTransmissionControls().length)throw new Error("No channels available");this._isInitialized=!0},l.prototype.getTransmissionControls=function(){return this._channelController.ChannelControls},l.prototype.track=function(e){e.iKey||(e.iKey=this.config.instrumentationKey),e.time||(e.time=(new Date).toISOString()),g.isNullOrUndefined(e.ver)&&(e.ver="4.0"),0===this._extensions.length&&this._channelController.processTelemetry(e);for(var t=0;t<this._extensions.length;){if(this._extensions[t].processTelemetry){this._extensions[t].processTelemetry(e);break}t++}},l);function l(){this._isInitialized=!1,this._extensions=new Array,this._channelController=new o}var c,f=(u.prototype.addNotificationListener=function(e){this.listeners.push(e)},u.prototype.removeNotificationListener=function(e){for(var t=this.listeners.indexOf(e);-1<t;)this.listeners.splice(t,1),t=this.listeners.indexOf(e)},u.prototype.eventsSent=function(t){for(var i=this,e=function(e){n.listeners[e].eventsSent&&setTimeout(function(){return i.listeners[e].eventsSent(t)},0)},n=this,o=0;o<this.listeners.length;++o)e(o)},u.prototype.eventsDiscarded=function(t,i){for(var n=this,e=function(e){o.listeners[e].eventsDiscarded&&setTimeout(function(){return n.listeners[e].eventsDiscarded(t,i)},0)},o=this,r=0;r<this.listeners.length;++r)e(r)},u);function u(){this.listeners=[]}(c=a.LoggingSeverity||(a.LoggingSeverity={}))[c.CRITICAL=1]="CRITICAL",c[c.WARNING=2]="WARNING";var h={BrowserDoesNotSupportLocalStorage:0,BrowserCannotReadLocalStorage:1,BrowserCannotReadSessionStorage:2,BrowserCannotWriteLocalStorage:3,BrowserCannotWriteSessionStorage:4,BrowserFailedRemovalFromLocalStorage:5,BrowserFailedRemovalFromSessionStorage:6,CannotSendEmptyTelemetry:7,ClientPerformanceMathError:8,ErrorParsingAISessionCookie:9,ErrorPVCalc:10,ExceptionWhileLoggingError:11,FailedAddingTelemetryToBuffer:12,FailedMonitorAjaxAbort:13,FailedMonitorAjaxDur:14,FailedMonitorAjaxOpen:15,FailedMonitorAjaxRSC:16,FailedMonitorAjaxSend:17,FailedMonitorAjaxGetCorrelationHeader:18,FailedToAddHandlerForOnBeforeUnload:19,FailedToSendQueuedTelemetry:20,FailedToReportDataLoss:21,FlushFailed:22,MessageLimitPerPVExceeded:23,MissingRequiredFieldSpecification:24,NavigationTimingNotSupported:25,OnError:26,SessionRenewalDateIsZero:27,SenderNotInitialized:28,StartTrackEventFailed:29,StopTrackEventFailed:30,StartTrackFailed:31,StopTrackFailed:32,TelemetrySampledAndNotSent:33,TrackEventFailed:34,TrackExceptionFailed:35,TrackMetricFailed:36,TrackPVFailed:37,TrackPVFailedCalc:38,TrackTraceFailed:39,TransmissionFailed:40,FailedToSetStorageBuffer:41,FailedToRestoreStorageBuffer:42,InvalidBackendResponse:43,FailedToFixDepricatedValues:44,InvalidDurationValue:45,TelemetryEnvelopeInvalid:46,CreateEnvelopeError:47,CannotSerializeObject:48,CannotSerializeObjectNonSerializable:49,CircularReferenceDetected:50,ClearAuthContextFailed:51,ExceptionTruncated:52,IllegalCharsInName:53,ItemNotInArray:54,MaxAjaxPerPVExceeded:55,MessageTruncated:56,NameTooLong:57,SampleRateOutOfRange:58,SetAuthContextFailed:59,SetAuthContextFailedAccountName:60,StringValueTooLong:61,StartCalledMoreThanOnce:62,StopCalledWithoutStart:63,TelemetryInitializerFailed:64,TrackArgumentsNotSpecified:65,UrlTooLong:66,SessionStorageBufferFull:67,CannotAccessCookie:68,IdTooLong:69,InvalidEvent:70,FailedMonitorAjaxSetRequestHeader:71,SendBrowserInfoOnUserInit:72},d=(p.sanitizeDiagnosticText=function(e){return'"'+e.replace(/\"/g,"")+'"'},p.dataType="MessageData",p.AiNonUserActionablePrefix="AI (Internal): ",p.AiUserActionablePrefix="AI: ",p);function p(e,t,i,n){void 0===i&&(i=!1),this.messageId=e,this.message=(i?p.AiUserActionablePrefix:p.AiNonUserActionablePrefix)+e;var o=(t?" message:"+p.sanitizeDiagnosticText(t):"")+(n?" props:"+p.sanitizeDiagnosticText(JSON.stringify(n)):"");this.message+=o}var y=(x.prototype.throwInternal=function(e,t,i,n,o){void 0===o&&(o=!1);var r=new d(t,i,o,n);if(this.enableDebugExceptions())throw r;if(void 0!==r&&r&&void 0!==r.message){if(o){var s=+r.messageId;(!this._messageLogged[s]||this.consoleLoggingLevel()>=a.LoggingSeverity.WARNING)&&(this.warnToConsole(r.message),this._messageLogged[s]=!0)}else this.consoleLoggingLevel()>=a.LoggingSeverity.WARNING&&this.warnToConsole(r.message);this.logInternalMessage(e,r)}},x.prototype.warnToConsole=function(e){"undefined"!=typeof console&&console&&("function"==typeof console.warn?console.warn(e):"function"==typeof console.log&&console.log(e))},x.prototype.resetInternalMessageCount=function(){this._messageCount=0,this._messageLogged={}},x.prototype.logInternalMessage=function(e,t){if(!this._areInternalMessagesThrottled()){var i=!0,n=this.AIInternalMessagePrefix+t.messageId;if(this._messageLogged[n]?i=!1:this._messageLogged[n]=!0,i&&(e<=this.telemetryLoggingLevel()&&(this.queue.push(t),this._messageCount++),this._messageCount===this.maxInternalMessageLimit())){var o="Internal events throttle limit per PageView reached for this app.",r=new d(h.MessageLimitPerPVExceeded,o,!1);this.queue.push(r),this.warnToConsole(o)}}},x.prototype._areInternalMessagesThrottled=function(){return this._messageCount>=this.maxInternalMessageLimit()},x);function x(e){this.queue=[],this.AIInternalMessagePrefix="AITR_",this._messageCount=0,this._messageLogged={},this.enableDebugExceptions=function(){return!1},this.consoleLoggingLevel=function(){return 0},this.telemetryLoggingLevel=function(){return 1},this.maxInternalMessageLimit=function(){return 25},g.isNullOrUndefined(e)||(g.isNullOrUndefined(e.loggingLevelConsole)||(this.consoleLoggingLevel=function(){return e.loggingLevelConsole}),g.isNullOrUndefined(e.loggingLevelTelemetry)||(this.telemetryLoggingLevel=function(){return e.loggingLevelTelemetry}),g.isNullOrUndefined(e.maxMessageLimit)||(this.maxInternalMessageLimit=function(){return e.maxMessageLimit}),g.isNullOrUndefined(e.enableDebugExceptions)||(this.enableDebugExceptions=function(){return e.enableDebugExceptions}))}var m,v,_,C=(i(m=T,v=_=s),void(m.prototype=null===v?Object.create(v):(I.prototype=v.prototype,new I)),T.prototype.initialize=function(e,t){this._notificationManager=new f,this.logger=new y(e),this.config=e,_.prototype.initialize.call(this,e,t,this.logger,this._notificationManager)},T.prototype.getTransmissionControls=function(){return _.prototype.getTransmissionControls.call(this)},T.prototype.track=function(e){if(null===e)throw this._notifyInvalidEvent(e),Error("Invalid telemetry item");this._validateTelemetryItem(e),_.prototype.track.call(this,e)},T.prototype.addNotificationListener=function(e){this._notificationManager&&this._notificationManager.addNotificationListener(e)},T.prototype.removeNotificationListener=function(e){this._notificationManager&&this._notificationManager.removeNotificationListener(e)},T.prototype.pollInternalLogs=function(i){var n=this,e=this.config.diagnosticLogInterval;return 0<e||(e=1e4),setInterval(function(){var e=n.logger?n.logger.queue:[];e.forEach(function(e){var t={name:i||"InternalMessageId: "+e.messageId,iKey:n.config.instrumentationKey,time:(new Date).toISOString(),baseType:d.dataType,baseData:{message:e.message}};n.track(t)}),e.length=0},e)},T.prototype._validateTelemetryItem=function(e){if(g.isNullOrUndefined(e.name))throw this._notifyInvalidEvent(e),Error("telemetry name required")},T.prototype._notifyInvalidEvent=function(e){this._notificationManager&&this._notificationManager.eventsDiscarded([e],t.InvalidEvent)},T);function I(){this.constructor=m}function T(){return _.call(this)||this}a.MinChannelPriorty=100,a.EventsDiscardedReason=t,a.AppInsightsCore=C,a.BaseCore=s,a.CoreUtils=g,a.NotificationManager=f,a.DiagnosticLogger=y,a._InternalLogMessage=d,a._InternalMessageId=h,Object.defineProperty(a,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e.Microsoft=e.Microsoft||{},e.Microsoft.ApplicationInsights={}))}(this,function(a){"use strict";var t={Unknown:0,NonRetryableStatus:1,InvalidEvent:2,SizeLimitExceeded:3,KillSwitch:4,QueueFull:5},i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};var c="prototype",f=(n.isNullOrUndefined=function(e){return null===e||e===undefined},n.isDate=function(e){return"[object Date]"===Object[c].toString.call(e)},n.disableCookies=function(){n._canUseCookies=!1},n.newGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(e,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})},n.toISOString=function(e){if(n.isDate(e)){var t=function(e){var t=String(e);return 1===t.length&&(t="0"+t),t};return e.getUTCFullYear()+"-"+t(e.getUTCMonth()+1)+"-"+t(e.getUTCDate())+"T"+t(e.getUTCHours())+":"+t(e.getUTCMinutes())+":"+t(e.getUTCSeconds())+"."+String((e.getUTCMilliseconds()/1e3).toFixed(3)).slice(2,5)+"Z"}},n.arrForEach=function(e,t,n){for(var i=e.length,o=0;o<i;++o)o in e&&t.call(n||e,e[o],o,e)},n.arrIndexOf=function(e,t,n){for(var i=e.length,o=n||0,r=Math.max(0<=o?o:i-Math.abs(o),0);r<i;r++)if(r in e&&e[r]===t)return r;return-1},n.arrMap=function(e,t,n){for(var i=e.length,o=n||e,r=new Array(i),s=0;s<i;s++)s in e&&(r[s]=t.call(o,e[s],e));return r},n.arrReduce=function(e,t,n){var i,o=e.length,r=0;if(3<=arguments.length)i=n;else{for(;r<o&&!(r in e);)r++;i=e[r++]}for(;r<o;)r in e&&(i=t(i,e[r],r,e)),r++;return i},n.objCreate=function(e){if(null==e)return{};var t=typeof e;if("object"!=t&&"function"!=t)throw new TypeError("Object prototype may only be an Object: "+e);function n(){}return n[c]=e,new n},n.objKeys=function(e){var t=Object[c].hasOwnProperty,n=!{toString:null}.propertyIsEnumerable("toString"),i=typeof e;if("function"!=i&&("object"!=i||null===e))throw new TypeError("objKeys called on non-object");var o=[];for(var r in e)t.call(e,r)&&o.push(r);if(n)for(var s=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],a=s.length,l=0;l<a;l++)t.call(e,s[l])&&o.push(s[l]);return o},n.objDefineAccessors=function(e,t,n,i){var o=Object.defineProperty;if(o)try{var r={enumerable:!0,configurable:!0};return n&&(r.get=n),i&&(r.set=i),o(e,t,r),!0}catch(s){}return!1},n);function n(){}var e=/[xy]/g,o=(r.prototype.processTelemetry=function(t){f.arrForEach(this.channelQueue,function(e){0<e.length&&e[0].processTelemetry(t)})},r.prototype.getChannelControls=function(){return this.channelQueue},r.prototype.initialize=function(n,i,o){var r,s=this;n.isCookieUseDisabled&&f.disableCookies(),this.channelQueue=new Array,n.channels&&f.arrForEach(n.channels,function(e){if(e&&0<e.length){e=e.sort(function(e,t){return e.priority-t.priority});for(var t=1;t<e.length;t++)e[t-1].setNextPlugin(e[t]);if(f.arrForEach(e,function(e){e.priority<500&&(r=e.identifier),e.initialize(n,i,o)}),r)throw Error("Channel has invalid priority"+r);s.channelQueue.push(e)}});for(var e=new Array,t=0;t<o.length;t++){var a=o[t];500<a.priority&&e.push(a)}if(0<e.length){for(e=e.sort(function(e,t){return e.priority-t.priority}),t=1;t<e.length;t++)e[t-1].setNextPlugin(e[t]);f.arrForEach(e,function(e){return e.initialize(n,i,o)}),this.channelQueue.push(e)}},r._staticInit=void f.objDefineAccessors(r.prototype,"ChannelControls",r.prototype.getChannelControls),r);function r(){this.identifier="ChannelControllerPlugin",this.priority=500}var s=(l.prototype.initialize=function(e,t,n,i){var o=this;if(this._isInitialized)throw Error("Core should not be initialized more than once");if(!e||f.isNullOrUndefined(e.instrumentationKey))throw Error("Please provide instrumentation key");this.config=e,this._notificationManager=i,this._notificationManager||(this._notificationManager=f.objCreate({addNotificationListener:function(e){},removeNotificationListener:function(e){},eventsSent:function(e){},eventsDiscarded:function(e,t){}})),this.config.extensions=f.isNullOrUndefined(this.config.extensions)?[]:this.config.extensions,this.config.extensionConfig=f.isNullOrUndefined(this.config.extensionConfig)?{}:this.config.extensionConfig,this._notificationManager&&(this.config.extensionConfig.NotificationManager=this._notificationManager),this.logger=n,this.logger||(this.logger=f.objCreate({throwInternal:function(e,t,n,i,o){void 0===o&&(o=!1)},warnToConsole:function(e){},resetInternalMessageCount:function(){}})),(s=this._extensions).push.apply(s,t.concat(this.config.extensions)),f.arrForEach(this._extensions,function(e){var t=!0;if((f.isNullOrUndefined(e)||f.isNullOrUndefined(e.initialize))&&(t=!1),!t)throw Error("Extensions must provide callback to initialize")}),this._extensions.push(this._channelController),this._extensions=this._extensions.sort(function(e,t){var n=e,i=t,o=typeof n.processTelemetry,r=typeof i.processTelemetry;return"function"==o&&"function"==r?n.priority-i.priority:"function"==o&&"function"!=r?1:"function"!=o&&"function"==r?-1:void 0});var r={};f.arrForEach(this._extensions,function(e){var t=e;t&&t.priority&&(f.isNullOrUndefined(r[t.priority])?r[t.priority]=t.identifier:o.logger&&o.logger.warnToConsole("Two extensions have same priority"+r[t.priority]+", "+t.identifier))});for(var s,a=-1,l=0;l<this._extensions.length-1;l++){var c=this._extensions[l];if(!c||"function"==typeof c.processTelemetry){if(c.priority===this._channelController.priority){a=l+1;break}this._extensions[l].setNextPlugin(this._extensions[l+1])}}if(this._channelController.initialize(this.config,this,this._extensions),f.arrForEach(this._extensions,function(e){e&&e.priority<o._channelController.priority&&e.initialize(o.config,o,o._extensions)}),a<this._extensions.length&&this._extensions.splice(a),0===this.getTransmissionControls().length)throw new Error("No channels available");this._isInitialized=!0},l.prototype.getTransmissionControls=function(){return this._channelController.getChannelControls()},l.prototype.track=function(e){e.iKey||(e.iKey=this.config.instrumentationKey),e.time||(e.time=f.toISOString(new Date)),f.isNullOrUndefined(e.ver)&&(e.ver="4.0"),0===this._extensions.length&&this._channelController.processTelemetry(e);for(var t=0;t<this._extensions.length;){if(this._extensions[t].processTelemetry){this._extensions[t].processTelemetry(e);break}t++}},l);function l(){this._isInitialized=!1,this._extensions=new Array,this._channelController=new o}var u,g=(h.prototype.addNotificationListener=function(e){this.listeners.push(e)},h.prototype.removeNotificationListener=function(e){for(var t=f.arrIndexOf(this.listeners,e);-1<t;)this.listeners.splice(t,1),t=f.arrIndexOf(this.listeners,e)},h.prototype.eventsSent=function(t){for(var n=this,e=function(e){i.listeners[e].eventsSent&&setTimeout(function(){return n.listeners[e].eventsSent(t)},0)},i=this,o=0;o<this.listeners.length;++o)e(o)},h.prototype.eventsDiscarded=function(t,n){for(var i=this,e=function(e){o.listeners[e].eventsDiscarded&&setTimeout(function(){return i.listeners[e].eventsDiscarded(t,n)},0)},o=this,r=0;r<this.listeners.length;++r)e(r)},h);function h(){this.listeners=[]}(u=a.LoggingSeverity||(a.LoggingSeverity={}))[u.CRITICAL=1]="CRITICAL",u[u.WARNING=2]="WARNING";var d={BrowserDoesNotSupportLocalStorage:0,BrowserCannotReadLocalStorage:1,BrowserCannotReadSessionStorage:2,BrowserCannotWriteLocalStorage:3,BrowserCannotWriteSessionStorage:4,BrowserFailedRemovalFromLocalStorage:5,BrowserFailedRemovalFromSessionStorage:6,CannotSendEmptyTelemetry:7,ClientPerformanceMathError:8,ErrorParsingAISessionCookie:9,ErrorPVCalc:10,ExceptionWhileLoggingError:11,FailedAddingTelemetryToBuffer:12,FailedMonitorAjaxAbort:13,FailedMonitorAjaxDur:14,FailedMonitorAjaxOpen:15,FailedMonitorAjaxRSC:16,FailedMonitorAjaxSend:17,FailedMonitorAjaxGetCorrelationHeader:18,FailedToAddHandlerForOnBeforeUnload:19,FailedToSendQueuedTelemetry:20,FailedToReportDataLoss:21,FlushFailed:22,MessageLimitPerPVExceeded:23,MissingRequiredFieldSpecification:24,NavigationTimingNotSupported:25,OnError:26,SessionRenewalDateIsZero:27,SenderNotInitialized:28,StartTrackEventFailed:29,StopTrackEventFailed:30,StartTrackFailed:31,StopTrackFailed:32,TelemetrySampledAndNotSent:33,TrackEventFailed:34,TrackExceptionFailed:35,TrackMetricFailed:36,TrackPVFailed:37,TrackPVFailedCalc:38,TrackTraceFailed:39,TransmissionFailed:40,FailedToSetStorageBuffer:41,FailedToRestoreStorageBuffer:42,InvalidBackendResponse:43,FailedToFixDepricatedValues:44,InvalidDurationValue:45,TelemetryEnvelopeInvalid:46,CreateEnvelopeError:47,CannotSerializeObject:48,CannotSerializeObjectNonSerializable:49,CircularReferenceDetected:50,ClearAuthContextFailed:51,ExceptionTruncated:52,IllegalCharsInName:53,ItemNotInArray:54,MaxAjaxPerPVExceeded:55,MessageTruncated:56,NameTooLong:57,SampleRateOutOfRange:58,SetAuthContextFailed:59,SetAuthContextFailedAccountName:60,StringValueTooLong:61,StartCalledMoreThanOnce:62,StopCalledWithoutStart:63,TelemetryInitializerFailed:64,TrackArgumentsNotSpecified:65,UrlTooLong:66,SessionStorageBufferFull:67,CannotAccessCookie:68,IdTooLong:69,InvalidEvent:70,FailedMonitorAjaxSetRequestHeader:71,SendBrowserInfoOnUserInit:72},p=(y.sanitizeDiagnosticText=function(e){return'"'+e.replace(/\"/g,"")+'"'},y.dataType="MessageData",y.AiNonUserActionablePrefix="AI (Internal): ",y.AiUserActionablePrefix="AI: ",y);function y(e,t,n,i){void 0===n&&(n=!1),this.messageId=e,this.message=(n?y.AiUserActionablePrefix:y.AiNonUserActionablePrefix)+e;var o=(t?" message:"+y.sanitizeDiagnosticText(t):"")+(i?" props:"+y.sanitizeDiagnosticText(JSON.stringify(i)):"");this.message+=o}var v=(x.prototype.throwInternal=function(e,t,n,i,o){void 0===o&&(o=!1);var r=new p(t,n,o,i);if(this.enableDebugExceptions())throw r;if(void 0!==r&&r&&"undefined"!=typeof r.message){if(o){var s=+r.messageId;(!this._messageLogged[s]||this.consoleLoggingLevel()>=a.LoggingSeverity.WARNING)&&(this.warnToConsole(r.message),this._messageLogged[s]=!0)}else this.consoleLoggingLevel()>=a.LoggingSeverity.WARNING&&this.warnToConsole(r.message);this.logInternalMessage(e,r)}},x.prototype.warnToConsole=function(e){"undefined"!=typeof console&&console&&("function"==typeof console.warn?console.warn(e):"function"==typeof console.log&&console.log(e))},x.prototype.resetInternalMessageCount=function(){this._messageCount=0,this._messageLogged={}},x.prototype.logInternalMessage=function(e,t){if(!this._areInternalMessagesThrottled()){var n=!0,i=this.AIInternalMessagePrefix+t.messageId;if(this._messageLogged[i]?n=!1:this._messageLogged[i]=!0,n&&(e<=this.telemetryLoggingLevel()&&(this.queue.push(t),this._messageCount++),this._messageCount===this.maxInternalMessageLimit())){var o="Internal events throttle limit per PageView reached for this app.",r=new p(d.MessageLimitPerPVExceeded,o,!1);this.queue.push(r),this.warnToConsole(o)}}},x.prototype._areInternalMessagesThrottled=function(){return this._messageCount>=this.maxInternalMessageLimit()},x);function x(e){this.queue=[],this.AIInternalMessagePrefix="AITR_",this._messageCount=0,this._messageLogged={},this.enableDebugExceptions=function(){return!1},this.consoleLoggingLevel=function(){return 0},this.telemetryLoggingLevel=function(){return 1},this.maxInternalMessageLimit=function(){return 25},f.isNullOrUndefined(e)||(f.isNullOrUndefined(e.loggingLevelConsole)||(this.consoleLoggingLevel=function(){return e.loggingLevelConsole}),f.isNullOrUndefined(e.loggingLevelTelemetry)||(this.telemetryLoggingLevel=function(){return e.loggingLevelTelemetry}),f.isNullOrUndefined(e.maxMessageLimit)||(this.maxInternalMessageLimit=function(){return e.maxMessageLimit}),f.isNullOrUndefined(e.enableDebugExceptions)||(this.enableDebugExceptions=function(){return e.enableDebugExceptions}))}var m,C=(function I(e,t){function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(T,m=s),T.prototype.initialize=function(e,t){this._notificationManager=new g,this.logger=new v(e),this.config=e,m.prototype.initialize.call(this,e,t,this.logger,this._notificationManager)},T.prototype.getTransmissionControls=function(){return m.prototype.getTransmissionControls.call(this)},T.prototype.track=function(e){if(null===e)throw this._notifyInvalidEvent(e),Error("Invalid telemetry item");this._validateTelemetryItem(e),m.prototype.track.call(this,e)},T.prototype.addNotificationListener=function(e){this._notificationManager&&this._notificationManager.addNotificationListener(e)},T.prototype.removeNotificationListener=function(e){this._notificationManager&&this._notificationManager.removeNotificationListener(e)},T.prototype.pollInternalLogs=function(n){var i=this,e=this.config.diagnosticLogInterval;return 0<e||(e=1e4),setInterval(function(){var e=i.logger?i.logger.queue:[];f.arrForEach(e,function(e){var t={name:n||"InternalMessageId: "+e.messageId,iKey:i.config.instrumentationKey,time:f.toISOString(new Date),baseType:p.dataType,baseData:{message:e.message}};i.track(t)}),e.length=0},e)},T.prototype._validateTelemetryItem=function(e){if(f.isNullOrUndefined(e.name))throw this._notifyInvalidEvent(e),Error("telemetry name required")},T.prototype._notifyInvalidEvent=function(e){this._notificationManager&&this._notificationManager.eventsDiscarded([e],t.InvalidEvent)},T);function T(){return m.call(this)||this}a.MinChannelPriorty=100,a.EventsDiscardedReason=t,a.AppInsightsCore=C,a.BaseCore=s,a.CoreUtils=f,a.NotificationManager=g,a.DiagnosticLogger=v,a._InternalLogMessage=p,a._InternalMessageId=d,Object.defineProperty(a,"__esModule",{value:!0})});
//# sourceMappingURL=applicationinsights-core-js.min.js.map

@@ -30,4 +30,4 @@ // Copyright (c) Microsoft Corporation. All rights reserved.

*/
QueueFull: 5,
QueueFull: 5
};
//# sourceMappingURL=EventsDiscardedReason.js.map

@@ -63,7 +63,7 @@ import * as tslib_1 from "tslib";

var queue = _this.logger ? _this.logger.queue : [];
queue.forEach(function (logMessage) {
CoreUtils.arrForEach(queue, function (logMessage) {
var item = {
name: eventName ? eventName : "InternalMessageId: " + logMessage.messageId,
iKey: _this.config.instrumentationKey,
time: new Date().toISOString(),
time: CoreUtils.toISOString(new Date()),
baseType: _InternalLogMessage.dataType,

@@ -70,0 +70,0 @@ baseData: { message: logMessage.message }

@@ -23,3 +23,3 @@ import { CoreUtils } from "./CoreUtils";

if (!this._notificationManager) {
this._notificationManager = Object.create({
this._notificationManager = CoreUtils.objCreate({
addNotificationListener: function (listener) { },

@@ -39,3 +39,3 @@ removeNotificationListener: function (listener) { },

if (!this.logger) {
this.logger = Object.create({
this.logger = CoreUtils.objCreate({
throwInternal: function (severity, msgId, msg, properties, isUserAct) {

@@ -51,3 +51,3 @@ if (isUserAct === void 0) { isUserAct = false; }

// Initial validation
this._extensions.forEach(function (extension) {
CoreUtils.arrForEach(this._extensions, function (extension) {
var isValid = true;

@@ -83,3 +83,3 @@ if (CoreUtils.isNullOrUndefined(extension) || CoreUtils.isNullOrUndefined(extension.initialize)) {

var priority = {};
this._extensions.forEach(function (ext) {
CoreUtils.arrForEach(this._extensions, function (ext) {
var t = ext;

@@ -114,3 +114,3 @@ if (t && t.priority) {

// initialize remaining regular plugins
this._extensions.forEach(function (ext) {
CoreUtils.arrForEach(this._extensions, function (ext) {
var e = ext;

@@ -132,3 +132,3 @@ if (e && e.priority < _this._channelController.priority) {

BaseCore.prototype.getTransmissionControls = function () {
return this._channelController.ChannelControls;
return this._channelController.getChannelControls();
};

@@ -142,3 +142,3 @@ BaseCore.prototype.track = function (telemetryItem) {

// add default timestamp if not passed in
telemetryItem.time = new Date().toISOString();
telemetryItem.time = CoreUtils.toISOString(new Date());
}

@@ -145,0 +145,0 @@ if (CoreUtils.isNullOrUndefined(telemetryItem.ver)) {

@@ -11,3 +11,3 @@ import { CoreUtils } from "./CoreUtils";

ChannelController.prototype.processTelemetry = function (item) {
this.channelQueue.forEach(function (queues) {
CoreUtils.arrForEach(this.channelQueue, function (queues) {
// pass on to first item in queue

@@ -19,9 +19,5 @@ if (queues.length > 0) {

};
Object.defineProperty(ChannelController.prototype, "ChannelControls", {
get: function () {
return this.channelQueue;
},
enumerable: true,
configurable: true
});
ChannelController.prototype.getChannelControls = function () {
return this.channelQueue;
};
ChannelController.prototype.initialize = function (config, core, extensions) {

@@ -35,3 +31,3 @@ var _this = this;

var invalidChannelIdentifier_1;
config.channels.forEach(function (queue) {
CoreUtils.arrForEach(config.channels, function (queue) {
if (queue && queue.length > 0) {

@@ -45,3 +41,3 @@ queue = queue.sort(function (a, b) {

// Initialize each plugin
queue.forEach(function (queueItem) {
CoreUtils.arrForEach(queue, function (queueItem) {
if (queueItem.priority < ChannelControllerPriority) {

@@ -76,6 +72,14 @@ invalidChannelIdentifier_1 = queueItem.identifier;

// Initialize each plugin
arr.forEach(function (queueItem) { return queueItem.initialize(config, core, extensions); });
CoreUtils.arrForEach(arr, function (queueItem) { return queueItem.initialize(config, core, extensions); });
this.channelQueue.push(arr);
}
};
/**
* Static constructor, attempt to create accessors
*/
// tslint:disable-next-line
ChannelController._staticInit = (function () {
// Dynamically create get/set property accessors
CoreUtils.objDefineAccessors(ChannelController.prototype, "ChannelControls", ChannelController.prototype.getChannelControls);
})();
return ChannelController;

@@ -82,0 +86,0 @@ }());

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
"use strict";
// Added to help with minfication
var prototype = "prototype";
var CoreUtils = /** @class */ (function () {

@@ -11,2 +13,8 @@ function CoreUtils() {

/**
* Check if an object is of type Date
*/
CoreUtils.isDate = function (obj) {
return Object[prototype].toString.call(obj) === "[object Date]";
};
/**
* Creates a new GUID.

@@ -24,2 +32,198 @@ * @return {string} A GUID.

};
/**
* Convert a date to I.S.O. format in IE8
*/
CoreUtils.toISOString = function (date) {
if (CoreUtils.isDate(date)) {
var pad = function (num) {
var r = String(num);
if (r.length === 1) {
r = "0" + r;
}
return r;
};
return date.getUTCFullYear()
+ "-" + pad(date.getUTCMonth() + 1)
+ "-" + pad(date.getUTCDate())
+ "T" + pad(date.getUTCHours())
+ ":" + pad(date.getUTCMinutes())
+ ":" + pad(date.getUTCSeconds())
+ "." + String((date.getUTCMilliseconds() / 1000).toFixed(3)).slice(2, 5)
+ "Z";
}
};
/**
* Performs the specified action for each element in an array. This helper exists to avoid adding a polyfil for older browsers
* that do not define Array.prototype.xxxx (eg. ES3 only, IE8) just in case any page checks for presence/absence of the prototype
* implementation. Note: For consistency this will not use the Array.prototype.xxxx implementation if it exists as this would
* cause a testing requirement to test with and without the implementations
* @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.
* @param thisArg [Optional] An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
*/
CoreUtils.arrForEach = function (arr, callbackfn, thisArg) {
var len = arr.length;
for (var idx = 0; idx < len; ++idx) {
if (idx in arr) {
callbackfn.call(thisArg || arr, arr[idx], idx, arr);
}
}
};
/**
* Returns the index of the first occurrence of a value in an array. This helper exists to avoid adding a polyfil for older browsers
* that do not define Array.prototype.xxxx (eg. ES3 only, IE8) just in case any page checks for presence/absence of the prototype
* implementation. Note: For consistency this will not use the Array.prototype.xxxx implementation if it exists as this would
* cause a testing requirement to test with and without the implementations
* @param searchElement The value to locate in the array.
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.
*/
CoreUtils.arrIndexOf = function (arr, searchElement, fromIndex) {
var len = arr.length;
var from = fromIndex || 0;
for (var lp = Math.max(from >= 0 ? from : len - Math.abs(from), 0); lp < len; lp++) {
if (lp in arr && arr[lp] === searchElement) {
return lp;
}
}
return -1;
};
/**
* Calls a defined callback function on each element of an array, and returns an array that contains the results. This helper exists
* to avoid adding a polyfil for older browsers that do not define Array.prototype.xxxx (eg. ES3 only, IE8) just in case any page
* checks for presence/absence of the prototype implementation. Note: For consistency this will not use the Array.prototype.xxxx
* implementation if it exists as this would cause a testing requirement to test with and without the implementations
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
*/
CoreUtils.arrMap = function (arr, callbackfn, thisArg) {
var len = arr.length;
var _this = thisArg || arr;
var results = new Array(len);
for (var lp = 0; lp < len; lp++) {
if (lp in arr) {
results[lp] = callbackfn.call(_this, arr[lp], arr);
}
}
return results;
};
/**
* Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is
* provided as an argument in the next call to the callback function. This helper exists to avoid adding a polyfil for older browsers that do not define
* Array.prototype.xxxx (eg. ES3 only, IE8) just in case any page checks for presence/absence of the prototype implementation. Note: For consistency
* this will not use the Array.prototype.xxxx implementation if it exists as this would cause a testing requirement to test with and without the implementations
* @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.
* @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
*/
CoreUtils.arrReduce = function (arr, callbackfn, initialValue) {
var len = arr.length;
var lp = 0;
var value;
// Specifically checking the number of passed arguments as the value could be anything
if (arguments.length >= 3) {
value = arguments[2];
}
else {
while (lp < len && !(lp in arr)) {
lp++;
}
value = arr[lp++];
}
while (lp < len) {
if (lp in arr) {
value = callbackfn(value, arr[lp], lp, arr);
}
lp++;
}
return value;
};
/**
* Creates an object that has the specified prototype, and that optionally contains specified properties. This helper exists to avoid adding a polyfil
* for older browsers that do not define Object.create (eg. ES3 only, IE8) just in case any page checks for presence/absence of the prototype implementation.
* Note: For consistency this will not use the Object.create implementation if it exists as this would cause a testing requirement to test with and without the implementations
* @param obj Object to use as a prototype. May be null
*/
CoreUtils.objCreate = function (obj) {
if (obj == null) {
return {};
}
var type = typeof obj;
if (type !== 'object' && type !== 'function') {
throw new TypeError('Object prototype may only be an Object: ' + obj);
}
function tmpFunc() { }
;
tmpFunc[prototype] = obj;
return new tmpFunc();
};
/**
* Returns the names of the enumerable string properties and methods of an object. This helper exists to avoid adding a polyfil for older browsers
* that do not define Object.create (eg. ES3 only, IE8) just in case any page checks for presence/absence of the prototype implementation.
* Note: For consistency this will not use the Object.create implementation if it exists as this would cause a testing requirement to test with and without the implementations
* @param obj Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
*/
CoreUtils.objKeys = function (obj) {
var hasOwnProperty = Object[prototype].hasOwnProperty;
var hasDontEnumBug = !({ toString: null }).propertyIsEnumerable('toString');
var type = typeof obj;
if (type !== 'function' && (type !== 'object' || obj === null)) {
throw new TypeError('objKeys called on non-object');
}
var result = [];
for (var prop in obj) {
if (hasOwnProperty.call(obj, prop)) {
result.push(prop);
}
}
if (hasDontEnumBug) {
var dontEnums = [
'toString',
'toLocaleString',
'valueOf',
'hasOwnProperty',
'isPrototypeOf',
'propertyIsEnumerable',
'constructor'
];
var dontEnumsLength = dontEnums.length;
for (var lp = 0; lp < dontEnumsLength; lp++) {
if (hasOwnProperty.call(obj, dontEnums[lp])) {
result.push(dontEnums[lp]);
}
}
}
return result;
};
/**
* Try to define get/set object property accessors for the target object/prototype, this will provide compatibility with
* existing API definition when run within an ES5+ container that supports accessors but still enable the code to be loaded
* and executed in an ES3 container, providing basic IE8 compatibility.
* @param target The object on which to define the property.
* @param prop The name of the property to be defined or modified.
* @param getProp The getter function to wire against the getter.
* @param setProp The setter function to wire against the setter.
* @returns True if it was able to create the accessors otherwise false
*/
CoreUtils.objDefineAccessors = function (target, prop, getProp, setProp) {
var defineProp = Object["defineProperty"];
if (defineProp) {
try {
var descriptor = {
enumerable: true,
configurable: true
};
if (getProp) {
descriptor.get = getProp;
}
if (setProp) {
descriptor.set = setProp;
}
defineProp(target, prop, descriptor);
return true;
}
catch (e) {
// IE8 Defines a defineProperty on Object but it's only supported for DOM elements so it will throw
// We will just ignore this here.
}
}
return false;
};
return CoreUtils;

@@ -26,0 +230,0 @@ }());

@@ -0,1 +1,2 @@

import { CoreUtils } from "./CoreUtils";
/**

@@ -20,6 +21,6 @@ * Class to manage sending notifications to all the listeners.

NotificationManager.prototype.removeNotificationListener = function (listener) {
var index = this.listeners.indexOf(listener);
var index = CoreUtils.arrIndexOf(this.listeners, listener);
while (index > -1) {
this.listeners.splice(index, 1);
index = this.listeners.indexOf(listener);
index = CoreUtils.arrIndexOf(this.listeners, listener);
}

@@ -26,0 +27,0 @@ };

/*!
* Application Insights JavaScript SDK - Core, 2.3.0
* Application Insights JavaScript SDK - Core, 2.3.1
* Copyright (c) Microsoft and contributors. All rights reserved.

@@ -40,3 +40,3 @@ */

*/
QueueFull: 5,
QueueFull: 5
};

@@ -73,2 +73,4 @@

// Added to help with minfication
var prototype = "prototype";
var CoreUtils = /** @class */ (function () {

@@ -81,2 +83,8 @@ function CoreUtils() {

/**
* Check if an object is of type Date
*/
CoreUtils.isDate = function (obj) {
return Object[prototype].toString.call(obj) === "[object Date]";
};
/**
* Creates a new GUID.

@@ -94,2 +102,197 @@ * @return {string} A GUID.

};
/**
* Convert a date to I.S.O. format in IE8
*/
CoreUtils.toISOString = function (date) {
if (CoreUtils.isDate(date)) {
var pad = function (num) {
var r = String(num);
if (r.length === 1) {
r = "0" + r;
}
return r;
};
return date.getUTCFullYear()
+ "-" + pad(date.getUTCMonth() + 1)
+ "-" + pad(date.getUTCDate())
+ "T" + pad(date.getUTCHours())
+ ":" + pad(date.getUTCMinutes())
+ ":" + pad(date.getUTCSeconds())
+ "." + String((date.getUTCMilliseconds() / 1000).toFixed(3)).slice(2, 5)
+ "Z";
}
};
/**
* Performs the specified action for each element in an array. This helper exists to avoid adding a polyfil for older browsers
* that do not define Array.prototype.xxxx (eg. ES3 only, IE8) just in case any page checks for presence/absence of the prototype
* implementation. Note: For consistency this will not use the Array.prototype.xxxx implementation if it exists as this would
* cause a testing requirement to test with and without the implementations
* @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.
* @param thisArg [Optional] An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
*/
CoreUtils.arrForEach = function (arr, callbackfn, thisArg) {
var len = arr.length;
for (var idx = 0; idx < len; ++idx) {
if (idx in arr) {
callbackfn.call(thisArg || arr, arr[idx], idx, arr);
}
}
};
/**
* Returns the index of the first occurrence of a value in an array. This helper exists to avoid adding a polyfil for older browsers
* that do not define Array.prototype.xxxx (eg. ES3 only, IE8) just in case any page checks for presence/absence of the prototype
* implementation. Note: For consistency this will not use the Array.prototype.xxxx implementation if it exists as this would
* cause a testing requirement to test with and without the implementations
* @param searchElement The value to locate in the array.
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.
*/
CoreUtils.arrIndexOf = function (arr, searchElement, fromIndex) {
var len = arr.length;
var from = fromIndex || 0;
for (var lp = Math.max(from >= 0 ? from : len - Math.abs(from), 0); lp < len; lp++) {
if (lp in arr && arr[lp] === searchElement) {
return lp;
}
}
return -1;
};
/**
* Calls a defined callback function on each element of an array, and returns an array that contains the results. This helper exists
* to avoid adding a polyfil for older browsers that do not define Array.prototype.xxxx (eg. ES3 only, IE8) just in case any page
* checks for presence/absence of the prototype implementation. Note: For consistency this will not use the Array.prototype.xxxx
* implementation if it exists as this would cause a testing requirement to test with and without the implementations
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
*/
CoreUtils.arrMap = function (arr, callbackfn, thisArg) {
var len = arr.length;
var _this = thisArg || arr;
var results = new Array(len);
for (var lp = 0; lp < len; lp++) {
if (lp in arr) {
results[lp] = callbackfn.call(_this, arr[lp], arr);
}
}
return results;
};
/**
* Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is
* provided as an argument in the next call to the callback function. This helper exists to avoid adding a polyfil for older browsers that do not define
* Array.prototype.xxxx (eg. ES3 only, IE8) just in case any page checks for presence/absence of the prototype implementation. Note: For consistency
* this will not use the Array.prototype.xxxx implementation if it exists as this would cause a testing requirement to test with and without the implementations
* @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.
* @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
*/
CoreUtils.arrReduce = function (arr, callbackfn, initialValue) {
var len = arr.length;
var lp = 0;
var value;
// Specifically checking the number of passed arguments as the value could be anything
if (arguments.length >= 3) {
value = arguments[2];
}
else {
while (lp < len && !(lp in arr)) {
lp++;
}
value = arr[lp++];
}
while (lp < len) {
if (lp in arr) {
value = callbackfn(value, arr[lp], lp, arr);
}
lp++;
}
return value;
};
/**
* Creates an object that has the specified prototype, and that optionally contains specified properties. This helper exists to avoid adding a polyfil
* for older browsers that do not define Object.create (eg. ES3 only, IE8) just in case any page checks for presence/absence of the prototype implementation.
* Note: For consistency this will not use the Object.create implementation if it exists as this would cause a testing requirement to test with and without the implementations
* @param obj Object to use as a prototype. May be null
*/
CoreUtils.objCreate = function (obj) {
if (obj == null) {
return {};
}
var type = typeof obj;
if (type !== 'object' && type !== 'function') {
throw new TypeError('Object prototype may only be an Object: ' + obj);
}
function tmpFunc() { }
tmpFunc[prototype] = obj;
return new tmpFunc();
};
/**
* Returns the names of the enumerable string properties and methods of an object. This helper exists to avoid adding a polyfil for older browsers
* that do not define Object.create (eg. ES3 only, IE8) just in case any page checks for presence/absence of the prototype implementation.
* Note: For consistency this will not use the Object.create implementation if it exists as this would cause a testing requirement to test with and without the implementations
* @param obj Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
*/
CoreUtils.objKeys = function (obj) {
var hasOwnProperty = Object[prototype].hasOwnProperty;
var hasDontEnumBug = !({ toString: null }).propertyIsEnumerable('toString');
var type = typeof obj;
if (type !== 'function' && (type !== 'object' || obj === null)) {
throw new TypeError('objKeys called on non-object');
}
var result = [];
for (var prop in obj) {
if (hasOwnProperty.call(obj, prop)) {
result.push(prop);
}
}
if (hasDontEnumBug) {
var dontEnums = [
'toString',
'toLocaleString',
'valueOf',
'hasOwnProperty',
'isPrototypeOf',
'propertyIsEnumerable',
'constructor'
];
var dontEnumsLength = dontEnums.length;
for (var lp = 0; lp < dontEnumsLength; lp++) {
if (hasOwnProperty.call(obj, dontEnums[lp])) {
result.push(dontEnums[lp]);
}
}
}
return result;
};
/**
* Try to define get/set object property accessors for the target object/prototype, this will provide compatibility with
* existing API definition when run within an ES5+ container that supports accessors but still enable the code to be loaded
* and executed in an ES3 container, providing basic IE8 compatibility.
* @param target The object on which to define the property.
* @param prop The name of the property to be defined or modified.
* @param getProp The getter function to wire against the getter.
* @param setProp The setter function to wire against the setter.
* @returns True if it was able to create the accessors otherwise false
*/
CoreUtils.objDefineAccessors = function (target, prop, getProp, setProp) {
var defineProp = Object["defineProperty"];
if (defineProp) {
try {
var descriptor = {
enumerable: true,
configurable: true
};
if (getProp) {
descriptor.get = getProp;
}
if (setProp) {
descriptor.set = setProp;
}
defineProp(target, prop, descriptor);
return true;
}
catch (e) {
// IE8 Defines a defineProperty on Object but it's only supported for DOM elements so it will throw
// We will just ignore this here.
}
}
return false;
};
return CoreUtils;

@@ -107,3 +310,3 @@ }());

ChannelController.prototype.processTelemetry = function (item) {
this.channelQueue.forEach(function (queues) {
CoreUtils.arrForEach(this.channelQueue, function (queues) {
// pass on to first item in queue

@@ -115,9 +318,5 @@ if (queues.length > 0) {

};
Object.defineProperty(ChannelController.prototype, "ChannelControls", {
get: function () {
return this.channelQueue;
},
enumerable: true,
configurable: true
});
ChannelController.prototype.getChannelControls = function () {
return this.channelQueue;
};
ChannelController.prototype.initialize = function (config, core, extensions) {

@@ -131,3 +330,3 @@ var _this = this;

var invalidChannelIdentifier_1;
config.channels.forEach(function (queue) {
CoreUtils.arrForEach(config.channels, function (queue) {
if (queue && queue.length > 0) {

@@ -141,3 +340,3 @@ queue = queue.sort(function (a, b) {

// Initialize each plugin
queue.forEach(function (queueItem) {
CoreUtils.arrForEach(queue, function (queueItem) {
if (queueItem.priority < ChannelControllerPriority) {

@@ -172,6 +371,14 @@ invalidChannelIdentifier_1 = queueItem.identifier;

// Initialize each plugin
arr.forEach(function (queueItem) { return queueItem.initialize(config, core, extensions); });
CoreUtils.arrForEach(arr, function (queueItem) { return queueItem.initialize(config, core, extensions); });
this.channelQueue.push(arr);
}
};
/**
* Static constructor, attempt to create accessors
*/
// tslint:disable-next-line
ChannelController._staticInit = (function () {
// Dynamically create get/set property accessors
CoreUtils.objDefineAccessors(ChannelController.prototype, "ChannelControls", ChannelController.prototype.getChannelControls);
})();
return ChannelController;

@@ -199,3 +406,3 @@ }());

if (!this._notificationManager) {
this._notificationManager = Object.create({
this._notificationManager = CoreUtils.objCreate({
addNotificationListener: function (listener) { },

@@ -215,3 +422,3 @@ removeNotificationListener: function (listener) { },

if (!this.logger) {
this.logger = Object.create({
this.logger = CoreUtils.objCreate({
throwInternal: function (severity, msgId, msg, properties, isUserAct) {

@@ -227,3 +434,3 @@ if (isUserAct === void 0) { isUserAct = false; }

// Initial validation
this._extensions.forEach(function (extension) {
CoreUtils.arrForEach(this._extensions, function (extension) {
var isValid = true;

@@ -259,3 +466,3 @@ if (CoreUtils.isNullOrUndefined(extension) || CoreUtils.isNullOrUndefined(extension.initialize)) {

var priority = {};
this._extensions.forEach(function (ext) {
CoreUtils.arrForEach(this._extensions, function (ext) {
var t = ext;

@@ -290,3 +497,3 @@ if (t && t.priority) {

// initialize remaining regular plugins
this._extensions.forEach(function (ext) {
CoreUtils.arrForEach(this._extensions, function (ext) {
var e = ext;

@@ -308,3 +515,3 @@ if (e && e.priority < _this._channelController.priority) {

BaseCore.prototype.getTransmissionControls = function () {
return this._channelController.ChannelControls;
return this._channelController.getChannelControls();
};

@@ -318,3 +525,3 @@ BaseCore.prototype.track = function (telemetryItem) {

// add default timestamp if not passed in
telemetryItem.time = new Date().toISOString();
telemetryItem.time = CoreUtils.toISOString(new Date());
}

@@ -360,6 +567,6 @@ if (CoreUtils.isNullOrUndefined(telemetryItem.ver)) {

NotificationManager.prototype.removeNotificationListener = function (listener) {
var index = this.listeners.indexOf(listener);
var index = CoreUtils.arrIndexOf(this.listeners, listener);
while (index > -1) {
this.listeners.splice(index, 1);
index = this.listeners.indexOf(listener);
index = CoreUtils.arrIndexOf(this.listeners, listener);
}

@@ -729,7 +936,7 @@ };

var queue = _this.logger ? _this.logger.queue : [];
queue.forEach(function (logMessage) {
CoreUtils.arrForEach(queue, function (logMessage) {
var item = {
name: eventName ? eventName : "InternalMessageId: " + logMessage.messageId,
iKey: _this.config.instrumentationKey,
time: new Date().toISOString(),
time: CoreUtils.toISOString(new Date()),
baseType: _InternalLogMessage.dataType,

@@ -736,0 +943,0 @@ baseData: { message: logMessage.message }

/*!
* Application Insights JavaScript SDK - Core, 2.3.0
* Application Insights JavaScript SDK - Core, 2.3.1
* Copyright (c) Microsoft and contributors. All rights reserved.
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e.Microsoft=e.Microsoft||{},e.Microsoft.ApplicationInsights={}))}(this,function(a){"use strict";var t={Unknown:0,NonRetryableStatus:1,InvalidEvent:2,SizeLimitExceeded:3,KillSwitch:4,QueueFull:5},i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)};var g=(e.isNullOrUndefined=function(e){return null==e},e.disableCookies=function(){e._canUseCookies=!1},e.newGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(n,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})},e);function e(){}var n=/[xy]/g,o=(r.prototype.processTelemetry=function(t){this.channelQueue.forEach(function(e){0<e.length&&e[0].processTelemetry(t)})},Object.defineProperty(r.prototype,"ChannelControls",{get:function(){return this.channelQueue},enumerable:!0,configurable:!0}),r.prototype.initialize=function(i,n,o){var r,s=this;i.isCookieUseDisabled&&g.disableCookies(),this.channelQueue=new Array,i.channels&&i.channels.forEach(function(e){if(e&&0<e.length){e=e.sort(function(e,t){return e.priority-t.priority});for(var t=1;t<e.length;t++)e[t-1].setNextPlugin(e[t]);if(e.forEach(function(e){e.priority<500&&(r=e.identifier),e.initialize(i,n,o)}),r)throw Error("Channel has invalid priority"+r);s.channelQueue.push(e)}});for(var e=new Array,t=0;t<o.length;t++){var a=o[t];500<a.priority&&e.push(a)}if(0<e.length){for(e=e.sort(function(e,t){return e.priority-t.priority}),t=1;t<e.length;t++)e[t-1].setNextPlugin(e[t]);e.forEach(function(e){return e.initialize(i,n,o)}),this.channelQueue.push(e)}},r);function r(){this.identifier="ChannelControllerPlugin",this.priority=500}var s=(l.prototype.initialize=function(e,t,i,n){var o=this;if(this._isInitialized)throw Error("Core should not be initialized more than once");if(!e||g.isNullOrUndefined(e.instrumentationKey))throw Error("Please provide instrumentation key");this.config=e,this._notificationManager=n,this._notificationManager||(this._notificationManager=Object.create({addNotificationListener:function(e){},removeNotificationListener:function(e){},eventsSent:function(e){},eventsDiscarded:function(e,t){}})),this.config.extensions=g.isNullOrUndefined(this.config.extensions)?[]:this.config.extensions,this.config.extensionConfig=g.isNullOrUndefined(this.config.extensionConfig)?{}:this.config.extensionConfig,this._notificationManager&&(this.config.extensionConfig.NotificationManager=this._notificationManager),this.logger=i,this.logger||(this.logger=Object.create({throwInternal:function(e,t,i,n,o){void 0===o&&(o=!1)},warnToConsole:function(e){},resetInternalMessageCount:function(){}})),(s=this._extensions).push.apply(s,t.concat(this.config.extensions)),this._extensions.forEach(function(e){var t=!0;if((g.isNullOrUndefined(e)||g.isNullOrUndefined(e.initialize))&&(t=!1),!t)throw Error("Extensions must provide callback to initialize")}),this._extensions.push(this._channelController),this._extensions=this._extensions.sort(function(e,t){var i=e,n=t,o=typeof i.processTelemetry,r=typeof n.processTelemetry;return"function"==o&&"function"==r?i.priority-n.priority:"function"==o&&"function"!=r?1:"function"!=o&&"function"==r?-1:void 0});var r={};this._extensions.forEach(function(e){var t=e;t&&t.priority&&(g.isNullOrUndefined(r[t.priority])?r[t.priority]=t.identifier:o.logger&&o.logger.warnToConsole("Two extensions have same priority"+r[t.priority]+", "+t.identifier))});for(var s,a=-1,l=0;l<this._extensions.length-1;l++){var c=this._extensions[l];if(!c||"function"==typeof c.processTelemetry){if(c.priority===this._channelController.priority){a=l+1;break}this._extensions[l].setNextPlugin(this._extensions[l+1])}}if(this._channelController.initialize(this.config,this,this._extensions),this._extensions.forEach(function(e){e&&e.priority<o._channelController.priority&&e.initialize(o.config,o,o._extensions)}),a<this._extensions.length&&this._extensions.splice(a),0===this.getTransmissionControls().length)throw new Error("No channels available");this._isInitialized=!0},l.prototype.getTransmissionControls=function(){return this._channelController.ChannelControls},l.prototype.track=function(e){e.iKey||(e.iKey=this.config.instrumentationKey),e.time||(e.time=(new Date).toISOString()),g.isNullOrUndefined(e.ver)&&(e.ver="4.0"),0===this._extensions.length&&this._channelController.processTelemetry(e);for(var t=0;t<this._extensions.length;){if(this._extensions[t].processTelemetry){this._extensions[t].processTelemetry(e);break}t++}},l);function l(){this._isInitialized=!1,this._extensions=new Array,this._channelController=new o}var c,f=(u.prototype.addNotificationListener=function(e){this.listeners.push(e)},u.prototype.removeNotificationListener=function(e){for(var t=this.listeners.indexOf(e);-1<t;)this.listeners.splice(t,1),t=this.listeners.indexOf(e)},u.prototype.eventsSent=function(t){for(var i=this,e=function(e){n.listeners[e].eventsSent&&setTimeout(function(){return i.listeners[e].eventsSent(t)},0)},n=this,o=0;o<this.listeners.length;++o)e(o)},u.prototype.eventsDiscarded=function(t,i){for(var n=this,e=function(e){o.listeners[e].eventsDiscarded&&setTimeout(function(){return n.listeners[e].eventsDiscarded(t,i)},0)},o=this,r=0;r<this.listeners.length;++r)e(r)},u);function u(){this.listeners=[]}(c=a.LoggingSeverity||(a.LoggingSeverity={}))[c.CRITICAL=1]="CRITICAL",c[c.WARNING=2]="WARNING";var h={BrowserDoesNotSupportLocalStorage:0,BrowserCannotReadLocalStorage:1,BrowserCannotReadSessionStorage:2,BrowserCannotWriteLocalStorage:3,BrowserCannotWriteSessionStorage:4,BrowserFailedRemovalFromLocalStorage:5,BrowserFailedRemovalFromSessionStorage:6,CannotSendEmptyTelemetry:7,ClientPerformanceMathError:8,ErrorParsingAISessionCookie:9,ErrorPVCalc:10,ExceptionWhileLoggingError:11,FailedAddingTelemetryToBuffer:12,FailedMonitorAjaxAbort:13,FailedMonitorAjaxDur:14,FailedMonitorAjaxOpen:15,FailedMonitorAjaxRSC:16,FailedMonitorAjaxSend:17,FailedMonitorAjaxGetCorrelationHeader:18,FailedToAddHandlerForOnBeforeUnload:19,FailedToSendQueuedTelemetry:20,FailedToReportDataLoss:21,FlushFailed:22,MessageLimitPerPVExceeded:23,MissingRequiredFieldSpecification:24,NavigationTimingNotSupported:25,OnError:26,SessionRenewalDateIsZero:27,SenderNotInitialized:28,StartTrackEventFailed:29,StopTrackEventFailed:30,StartTrackFailed:31,StopTrackFailed:32,TelemetrySampledAndNotSent:33,TrackEventFailed:34,TrackExceptionFailed:35,TrackMetricFailed:36,TrackPVFailed:37,TrackPVFailedCalc:38,TrackTraceFailed:39,TransmissionFailed:40,FailedToSetStorageBuffer:41,FailedToRestoreStorageBuffer:42,InvalidBackendResponse:43,FailedToFixDepricatedValues:44,InvalidDurationValue:45,TelemetryEnvelopeInvalid:46,CreateEnvelopeError:47,CannotSerializeObject:48,CannotSerializeObjectNonSerializable:49,CircularReferenceDetected:50,ClearAuthContextFailed:51,ExceptionTruncated:52,IllegalCharsInName:53,ItemNotInArray:54,MaxAjaxPerPVExceeded:55,MessageTruncated:56,NameTooLong:57,SampleRateOutOfRange:58,SetAuthContextFailed:59,SetAuthContextFailedAccountName:60,StringValueTooLong:61,StartCalledMoreThanOnce:62,StopCalledWithoutStart:63,TelemetryInitializerFailed:64,TrackArgumentsNotSpecified:65,UrlTooLong:66,SessionStorageBufferFull:67,CannotAccessCookie:68,IdTooLong:69,InvalidEvent:70,FailedMonitorAjaxSetRequestHeader:71,SendBrowserInfoOnUserInit:72},d=(p.sanitizeDiagnosticText=function(e){return'"'+e.replace(/\"/g,"")+'"'},p.dataType="MessageData",p.AiNonUserActionablePrefix="AI (Internal): ",p.AiUserActionablePrefix="AI: ",p);function p(e,t,i,n){void 0===i&&(i=!1),this.messageId=e,this.message=(i?p.AiUserActionablePrefix:p.AiNonUserActionablePrefix)+e;var o=(t?" message:"+p.sanitizeDiagnosticText(t):"")+(n?" props:"+p.sanitizeDiagnosticText(JSON.stringify(n)):"");this.message+=o}var y=(x.prototype.throwInternal=function(e,t,i,n,o){void 0===o&&(o=!1);var r=new d(t,i,o,n);if(this.enableDebugExceptions())throw r;if(void 0!==r&&r&&void 0!==r.message){if(o){var s=+r.messageId;(!this._messageLogged[s]||this.consoleLoggingLevel()>=a.LoggingSeverity.WARNING)&&(this.warnToConsole(r.message),this._messageLogged[s]=!0)}else this.consoleLoggingLevel()>=a.LoggingSeverity.WARNING&&this.warnToConsole(r.message);this.logInternalMessage(e,r)}},x.prototype.warnToConsole=function(e){"undefined"!=typeof console&&console&&("function"==typeof console.warn?console.warn(e):"function"==typeof console.log&&console.log(e))},x.prototype.resetInternalMessageCount=function(){this._messageCount=0,this._messageLogged={}},x.prototype.logInternalMessage=function(e,t){if(!this._areInternalMessagesThrottled()){var i=!0,n=this.AIInternalMessagePrefix+t.messageId;if(this._messageLogged[n]?i=!1:this._messageLogged[n]=!0,i&&(e<=this.telemetryLoggingLevel()&&(this.queue.push(t),this._messageCount++),this._messageCount===this.maxInternalMessageLimit())){var o="Internal events throttle limit per PageView reached for this app.",r=new d(h.MessageLimitPerPVExceeded,o,!1);this.queue.push(r),this.warnToConsole(o)}}},x.prototype._areInternalMessagesThrottled=function(){return this._messageCount>=this.maxInternalMessageLimit()},x);function x(e){this.queue=[],this.AIInternalMessagePrefix="AITR_",this._messageCount=0,this._messageLogged={},this.enableDebugExceptions=function(){return!1},this.consoleLoggingLevel=function(){return 0},this.telemetryLoggingLevel=function(){return 1},this.maxInternalMessageLimit=function(){return 25},g.isNullOrUndefined(e)||(g.isNullOrUndefined(e.loggingLevelConsole)||(this.consoleLoggingLevel=function(){return e.loggingLevelConsole}),g.isNullOrUndefined(e.loggingLevelTelemetry)||(this.telemetryLoggingLevel=function(){return e.loggingLevelTelemetry}),g.isNullOrUndefined(e.maxMessageLimit)||(this.maxInternalMessageLimit=function(){return e.maxMessageLimit}),g.isNullOrUndefined(e.enableDebugExceptions)||(this.enableDebugExceptions=function(){return e.enableDebugExceptions}))}var m,v,_,C=(i(m=T,v=_=s),void(m.prototype=null===v?Object.create(v):(I.prototype=v.prototype,new I)),T.prototype.initialize=function(e,t){this._notificationManager=new f,this.logger=new y(e),this.config=e,_.prototype.initialize.call(this,e,t,this.logger,this._notificationManager)},T.prototype.getTransmissionControls=function(){return _.prototype.getTransmissionControls.call(this)},T.prototype.track=function(e){if(null===e)throw this._notifyInvalidEvent(e),Error("Invalid telemetry item");this._validateTelemetryItem(e),_.prototype.track.call(this,e)},T.prototype.addNotificationListener=function(e){this._notificationManager&&this._notificationManager.addNotificationListener(e)},T.prototype.removeNotificationListener=function(e){this._notificationManager&&this._notificationManager.removeNotificationListener(e)},T.prototype.pollInternalLogs=function(i){var n=this,e=this.config.diagnosticLogInterval;return 0<e||(e=1e4),setInterval(function(){var e=n.logger?n.logger.queue:[];e.forEach(function(e){var t={name:i||"InternalMessageId: "+e.messageId,iKey:n.config.instrumentationKey,time:(new Date).toISOString(),baseType:d.dataType,baseData:{message:e.message}};n.track(t)}),e.length=0},e)},T.prototype._validateTelemetryItem=function(e){if(g.isNullOrUndefined(e.name))throw this._notifyInvalidEvent(e),Error("telemetry name required")},T.prototype._notifyInvalidEvent=function(e){this._notificationManager&&this._notificationManager.eventsDiscarded([e],t.InvalidEvent)},T);function I(){this.constructor=m}function T(){return _.call(this)||this}a.MinChannelPriorty=100,a.EventsDiscardedReason=t,a.AppInsightsCore=C,a.BaseCore=s,a.CoreUtils=g,a.NotificationManager=f,a.DiagnosticLogger=y,a._InternalLogMessage=d,a._InternalMessageId=h,Object.defineProperty(a,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e.Microsoft=e.Microsoft||{},e.Microsoft.ApplicationInsights={}))}(this,function(a){"use strict";var t={Unknown:0,NonRetryableStatus:1,InvalidEvent:2,SizeLimitExceeded:3,KillSwitch:4,QueueFull:5},i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};var c="prototype",f=(n.isNullOrUndefined=function(e){return null===e||e===undefined},n.isDate=function(e){return"[object Date]"===Object[c].toString.call(e)},n.disableCookies=function(){n._canUseCookies=!1},n.newGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(e,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})},n.toISOString=function(e){if(n.isDate(e)){var t=function(e){var t=String(e);return 1===t.length&&(t="0"+t),t};return e.getUTCFullYear()+"-"+t(e.getUTCMonth()+1)+"-"+t(e.getUTCDate())+"T"+t(e.getUTCHours())+":"+t(e.getUTCMinutes())+":"+t(e.getUTCSeconds())+"."+String((e.getUTCMilliseconds()/1e3).toFixed(3)).slice(2,5)+"Z"}},n.arrForEach=function(e,t,n){for(var i=e.length,o=0;o<i;++o)o in e&&t.call(n||e,e[o],o,e)},n.arrIndexOf=function(e,t,n){for(var i=e.length,o=n||0,r=Math.max(0<=o?o:i-Math.abs(o),0);r<i;r++)if(r in e&&e[r]===t)return r;return-1},n.arrMap=function(e,t,n){for(var i=e.length,o=n||e,r=new Array(i),s=0;s<i;s++)s in e&&(r[s]=t.call(o,e[s],e));return r},n.arrReduce=function(e,t,n){var i,o=e.length,r=0;if(3<=arguments.length)i=n;else{for(;r<o&&!(r in e);)r++;i=e[r++]}for(;r<o;)r in e&&(i=t(i,e[r],r,e)),r++;return i},n.objCreate=function(e){if(null==e)return{};var t=typeof e;if("object"!=t&&"function"!=t)throw new TypeError("Object prototype may only be an Object: "+e);function n(){}return n[c]=e,new n},n.objKeys=function(e){var t=Object[c].hasOwnProperty,n=!{toString:null}.propertyIsEnumerable("toString"),i=typeof e;if("function"!=i&&("object"!=i||null===e))throw new TypeError("objKeys called on non-object");var o=[];for(var r in e)t.call(e,r)&&o.push(r);if(n)for(var s=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],a=s.length,l=0;l<a;l++)t.call(e,s[l])&&o.push(s[l]);return o},n.objDefineAccessors=function(e,t,n,i){var o=Object.defineProperty;if(o)try{var r={enumerable:!0,configurable:!0};return n&&(r.get=n),i&&(r.set=i),o(e,t,r),!0}catch(s){}return!1},n);function n(){}var e=/[xy]/g,o=(r.prototype.processTelemetry=function(t){f.arrForEach(this.channelQueue,function(e){0<e.length&&e[0].processTelemetry(t)})},r.prototype.getChannelControls=function(){return this.channelQueue},r.prototype.initialize=function(n,i,o){var r,s=this;n.isCookieUseDisabled&&f.disableCookies(),this.channelQueue=new Array,n.channels&&f.arrForEach(n.channels,function(e){if(e&&0<e.length){e=e.sort(function(e,t){return e.priority-t.priority});for(var t=1;t<e.length;t++)e[t-1].setNextPlugin(e[t]);if(f.arrForEach(e,function(e){e.priority<500&&(r=e.identifier),e.initialize(n,i,o)}),r)throw Error("Channel has invalid priority"+r);s.channelQueue.push(e)}});for(var e=new Array,t=0;t<o.length;t++){var a=o[t];500<a.priority&&e.push(a)}if(0<e.length){for(e=e.sort(function(e,t){return e.priority-t.priority}),t=1;t<e.length;t++)e[t-1].setNextPlugin(e[t]);f.arrForEach(e,function(e){return e.initialize(n,i,o)}),this.channelQueue.push(e)}},r._staticInit=void f.objDefineAccessors(r.prototype,"ChannelControls",r.prototype.getChannelControls),r);function r(){this.identifier="ChannelControllerPlugin",this.priority=500}var s=(l.prototype.initialize=function(e,t,n,i){var o=this;if(this._isInitialized)throw Error("Core should not be initialized more than once");if(!e||f.isNullOrUndefined(e.instrumentationKey))throw Error("Please provide instrumentation key");this.config=e,this._notificationManager=i,this._notificationManager||(this._notificationManager=f.objCreate({addNotificationListener:function(e){},removeNotificationListener:function(e){},eventsSent:function(e){},eventsDiscarded:function(e,t){}})),this.config.extensions=f.isNullOrUndefined(this.config.extensions)?[]:this.config.extensions,this.config.extensionConfig=f.isNullOrUndefined(this.config.extensionConfig)?{}:this.config.extensionConfig,this._notificationManager&&(this.config.extensionConfig.NotificationManager=this._notificationManager),this.logger=n,this.logger||(this.logger=f.objCreate({throwInternal:function(e,t,n,i,o){void 0===o&&(o=!1)},warnToConsole:function(e){},resetInternalMessageCount:function(){}})),(s=this._extensions).push.apply(s,t.concat(this.config.extensions)),f.arrForEach(this._extensions,function(e){var t=!0;if((f.isNullOrUndefined(e)||f.isNullOrUndefined(e.initialize))&&(t=!1),!t)throw Error("Extensions must provide callback to initialize")}),this._extensions.push(this._channelController),this._extensions=this._extensions.sort(function(e,t){var n=e,i=t,o=typeof n.processTelemetry,r=typeof i.processTelemetry;return"function"==o&&"function"==r?n.priority-i.priority:"function"==o&&"function"!=r?1:"function"!=o&&"function"==r?-1:void 0});var r={};f.arrForEach(this._extensions,function(e){var t=e;t&&t.priority&&(f.isNullOrUndefined(r[t.priority])?r[t.priority]=t.identifier:o.logger&&o.logger.warnToConsole("Two extensions have same priority"+r[t.priority]+", "+t.identifier))});for(var s,a=-1,l=0;l<this._extensions.length-1;l++){var c=this._extensions[l];if(!c||"function"==typeof c.processTelemetry){if(c.priority===this._channelController.priority){a=l+1;break}this._extensions[l].setNextPlugin(this._extensions[l+1])}}if(this._channelController.initialize(this.config,this,this._extensions),f.arrForEach(this._extensions,function(e){e&&e.priority<o._channelController.priority&&e.initialize(o.config,o,o._extensions)}),a<this._extensions.length&&this._extensions.splice(a),0===this.getTransmissionControls().length)throw new Error("No channels available");this._isInitialized=!0},l.prototype.getTransmissionControls=function(){return this._channelController.getChannelControls()},l.prototype.track=function(e){e.iKey||(e.iKey=this.config.instrumentationKey),e.time||(e.time=f.toISOString(new Date)),f.isNullOrUndefined(e.ver)&&(e.ver="4.0"),0===this._extensions.length&&this._channelController.processTelemetry(e);for(var t=0;t<this._extensions.length;){if(this._extensions[t].processTelemetry){this._extensions[t].processTelemetry(e);break}t++}},l);function l(){this._isInitialized=!1,this._extensions=new Array,this._channelController=new o}var u,g=(h.prototype.addNotificationListener=function(e){this.listeners.push(e)},h.prototype.removeNotificationListener=function(e){for(var t=f.arrIndexOf(this.listeners,e);-1<t;)this.listeners.splice(t,1),t=f.arrIndexOf(this.listeners,e)},h.prototype.eventsSent=function(t){for(var n=this,e=function(e){i.listeners[e].eventsSent&&setTimeout(function(){return n.listeners[e].eventsSent(t)},0)},i=this,o=0;o<this.listeners.length;++o)e(o)},h.prototype.eventsDiscarded=function(t,n){for(var i=this,e=function(e){o.listeners[e].eventsDiscarded&&setTimeout(function(){return i.listeners[e].eventsDiscarded(t,n)},0)},o=this,r=0;r<this.listeners.length;++r)e(r)},h);function h(){this.listeners=[]}(u=a.LoggingSeverity||(a.LoggingSeverity={}))[u.CRITICAL=1]="CRITICAL",u[u.WARNING=2]="WARNING";var d={BrowserDoesNotSupportLocalStorage:0,BrowserCannotReadLocalStorage:1,BrowserCannotReadSessionStorage:2,BrowserCannotWriteLocalStorage:3,BrowserCannotWriteSessionStorage:4,BrowserFailedRemovalFromLocalStorage:5,BrowserFailedRemovalFromSessionStorage:6,CannotSendEmptyTelemetry:7,ClientPerformanceMathError:8,ErrorParsingAISessionCookie:9,ErrorPVCalc:10,ExceptionWhileLoggingError:11,FailedAddingTelemetryToBuffer:12,FailedMonitorAjaxAbort:13,FailedMonitorAjaxDur:14,FailedMonitorAjaxOpen:15,FailedMonitorAjaxRSC:16,FailedMonitorAjaxSend:17,FailedMonitorAjaxGetCorrelationHeader:18,FailedToAddHandlerForOnBeforeUnload:19,FailedToSendQueuedTelemetry:20,FailedToReportDataLoss:21,FlushFailed:22,MessageLimitPerPVExceeded:23,MissingRequiredFieldSpecification:24,NavigationTimingNotSupported:25,OnError:26,SessionRenewalDateIsZero:27,SenderNotInitialized:28,StartTrackEventFailed:29,StopTrackEventFailed:30,StartTrackFailed:31,StopTrackFailed:32,TelemetrySampledAndNotSent:33,TrackEventFailed:34,TrackExceptionFailed:35,TrackMetricFailed:36,TrackPVFailed:37,TrackPVFailedCalc:38,TrackTraceFailed:39,TransmissionFailed:40,FailedToSetStorageBuffer:41,FailedToRestoreStorageBuffer:42,InvalidBackendResponse:43,FailedToFixDepricatedValues:44,InvalidDurationValue:45,TelemetryEnvelopeInvalid:46,CreateEnvelopeError:47,CannotSerializeObject:48,CannotSerializeObjectNonSerializable:49,CircularReferenceDetected:50,ClearAuthContextFailed:51,ExceptionTruncated:52,IllegalCharsInName:53,ItemNotInArray:54,MaxAjaxPerPVExceeded:55,MessageTruncated:56,NameTooLong:57,SampleRateOutOfRange:58,SetAuthContextFailed:59,SetAuthContextFailedAccountName:60,StringValueTooLong:61,StartCalledMoreThanOnce:62,StopCalledWithoutStart:63,TelemetryInitializerFailed:64,TrackArgumentsNotSpecified:65,UrlTooLong:66,SessionStorageBufferFull:67,CannotAccessCookie:68,IdTooLong:69,InvalidEvent:70,FailedMonitorAjaxSetRequestHeader:71,SendBrowserInfoOnUserInit:72},p=(y.sanitizeDiagnosticText=function(e){return'"'+e.replace(/\"/g,"")+'"'},y.dataType="MessageData",y.AiNonUserActionablePrefix="AI (Internal): ",y.AiUserActionablePrefix="AI: ",y);function y(e,t,n,i){void 0===n&&(n=!1),this.messageId=e,this.message=(n?y.AiUserActionablePrefix:y.AiNonUserActionablePrefix)+e;var o=(t?" message:"+y.sanitizeDiagnosticText(t):"")+(i?" props:"+y.sanitizeDiagnosticText(JSON.stringify(i)):"");this.message+=o}var v=(x.prototype.throwInternal=function(e,t,n,i,o){void 0===o&&(o=!1);var r=new p(t,n,o,i);if(this.enableDebugExceptions())throw r;if(void 0!==r&&r&&"undefined"!=typeof r.message){if(o){var s=+r.messageId;(!this._messageLogged[s]||this.consoleLoggingLevel()>=a.LoggingSeverity.WARNING)&&(this.warnToConsole(r.message),this._messageLogged[s]=!0)}else this.consoleLoggingLevel()>=a.LoggingSeverity.WARNING&&this.warnToConsole(r.message);this.logInternalMessage(e,r)}},x.prototype.warnToConsole=function(e){"undefined"!=typeof console&&console&&("function"==typeof console.warn?console.warn(e):"function"==typeof console.log&&console.log(e))},x.prototype.resetInternalMessageCount=function(){this._messageCount=0,this._messageLogged={}},x.prototype.logInternalMessage=function(e,t){if(!this._areInternalMessagesThrottled()){var n=!0,i=this.AIInternalMessagePrefix+t.messageId;if(this._messageLogged[i]?n=!1:this._messageLogged[i]=!0,n&&(e<=this.telemetryLoggingLevel()&&(this.queue.push(t),this._messageCount++),this._messageCount===this.maxInternalMessageLimit())){var o="Internal events throttle limit per PageView reached for this app.",r=new p(d.MessageLimitPerPVExceeded,o,!1);this.queue.push(r),this.warnToConsole(o)}}},x.prototype._areInternalMessagesThrottled=function(){return this._messageCount>=this.maxInternalMessageLimit()},x);function x(e){this.queue=[],this.AIInternalMessagePrefix="AITR_",this._messageCount=0,this._messageLogged={},this.enableDebugExceptions=function(){return!1},this.consoleLoggingLevel=function(){return 0},this.telemetryLoggingLevel=function(){return 1},this.maxInternalMessageLimit=function(){return 25},f.isNullOrUndefined(e)||(f.isNullOrUndefined(e.loggingLevelConsole)||(this.consoleLoggingLevel=function(){return e.loggingLevelConsole}),f.isNullOrUndefined(e.loggingLevelTelemetry)||(this.telemetryLoggingLevel=function(){return e.loggingLevelTelemetry}),f.isNullOrUndefined(e.maxMessageLimit)||(this.maxInternalMessageLimit=function(){return e.maxMessageLimit}),f.isNullOrUndefined(e.enableDebugExceptions)||(this.enableDebugExceptions=function(){return e.enableDebugExceptions}))}var m,C=(function I(e,t){function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(T,m=s),T.prototype.initialize=function(e,t){this._notificationManager=new g,this.logger=new v(e),this.config=e,m.prototype.initialize.call(this,e,t,this.logger,this._notificationManager)},T.prototype.getTransmissionControls=function(){return m.prototype.getTransmissionControls.call(this)},T.prototype.track=function(e){if(null===e)throw this._notifyInvalidEvent(e),Error("Invalid telemetry item");this._validateTelemetryItem(e),m.prototype.track.call(this,e)},T.prototype.addNotificationListener=function(e){this._notificationManager&&this._notificationManager.addNotificationListener(e)},T.prototype.removeNotificationListener=function(e){this._notificationManager&&this._notificationManager.removeNotificationListener(e)},T.prototype.pollInternalLogs=function(n){var i=this,e=this.config.diagnosticLogInterval;return 0<e||(e=1e4),setInterval(function(){var e=i.logger?i.logger.queue:[];f.arrForEach(e,function(e){var t={name:n||"InternalMessageId: "+e.messageId,iKey:i.config.instrumentationKey,time:f.toISOString(new Date),baseType:p.dataType,baseData:{message:e.message}};i.track(t)}),e.length=0},e)},T.prototype._validateTelemetryItem=function(e){if(f.isNullOrUndefined(e.name))throw this._notifyInvalidEvent(e),Error("telemetry name required")},T.prototype._notifyInvalidEvent=function(e){this._notificationManager&&this._notificationManager.eventsDiscarded([e],t.InvalidEvent)},T);function T(){return m.call(this)||this}a.MinChannelPriorty=100,a.EventsDiscardedReason=t,a.AppInsightsCore=C,a.BaseCore=s,a.CoreUtils=f,a.NotificationManager=g,a.DiagnosticLogger=v,a._InternalLogMessage=p,a._InternalMessageId=d,Object.defineProperty(a,"__esModule",{value:!0})});
//# sourceMappingURL=applicationinsights-core-js.min.js.map
{
"name": "@microsoft/applicationinsights-core-js",
"author": "Microsoft Corporation",
"version": "2.3.0",
"version": "2.3.1",
"description": "Microsoft Application Insights Core Javascript SDK",

@@ -6,0 +6,0 @@ "keywords": [

@@ -88,7 +88,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved.

queue.forEach((logMessage: _InternalLogMessage) => {
CoreUtils.arrForEach(queue, (logMessage: _InternalLogMessage) => {
const item: ITelemetryItem = {
name: eventName ? eventName : "InternalMessageId: " + logMessage.messageId,
iKey: this.config.instrumentationKey,
time: new Date().toISOString(),
time: CoreUtils.toISOString(new Date()),
baseType: _InternalLogMessage.dataType,

@@ -95,0 +95,0 @@ baseData: { message: logMessage.message }

@@ -48,3 +48,3 @@ // Copyright (c) Microsoft Corporation. All rights reserved.

if (!this._notificationManager) {
this._notificationManager = Object.create({
this._notificationManager = CoreUtils.objCreate({
addNotificationListener: (listener) => {},

@@ -67,3 +67,3 @@ removeNotificationListener: (listener) => {},

if (!this.logger) {
this.logger = Object.create({
this.logger = CoreUtils.objCreate({
throwInternal: (severity, msgId, msg: string, properties?: Object, isUserAct = false) => {},

@@ -79,3 +79,3 @@ warnToConsole: (message: string) => {},

// Initial validation
this._extensions.forEach((extension: ITelemetryPlugin) => {
CoreUtils.arrForEach(this._extensions, (extension: ITelemetryPlugin) => {
let isValid = true;

@@ -116,3 +116,3 @@ if (CoreUtils.isNullOrUndefined(extension) || CoreUtils.isNullOrUndefined(extension.initialize)) {

const priority = {};
this._extensions.forEach(ext => {
CoreUtils.arrForEach(this._extensions, ext => {
const t = (ext as ITelemetryPlugin);

@@ -151,3 +151,3 @@ if (t && t.priority) {

// initialize remaining regular plugins
this._extensions.forEach(ext => {
CoreUtils.arrForEach(this._extensions, ext => {
const e = ext as ITelemetryPlugin;

@@ -171,3 +171,3 @@ if (e && e.priority < this._channelController.priority) {

getTransmissionControls(): IChannelControls[][] {
return this._channelController.ChannelControls;
return this._channelController.getChannelControls();
}

@@ -182,3 +182,3 @@

// add default timestamp if not passed in
telemetryItem.time = new Date().toISOString();
telemetryItem.time = CoreUtils.toISOString(new Date());
}

@@ -185,0 +185,0 @@ if (CoreUtils.isNullOrUndefined(telemetryItem.ver)) {

@@ -27,3 +27,3 @@ // Copyright (c) Microsoft Corporation. All rights reserved.

public processTelemetry(item: ITelemetryItem) {
this.channelQueue.forEach(queues => {
CoreUtils.arrForEach(this.channelQueue, queues => {
// pass on to first item in queue

@@ -36,3 +36,3 @@ if (queues.length > 0) {

public get ChannelControls(): IChannelControls[][] {
public getChannelControls(): IChannelControls[][] {
return this.channelQueue;

@@ -49,3 +49,3 @@ }

let invalidChannelIdentifier;
config.channels.forEach(queue => {
CoreUtils.arrForEach(config.channels, queue => {

@@ -62,3 +62,3 @@ if (queue && queue.length > 0) {

// Initialize each plugin
queue.forEach(queueItem => {
CoreUtils.arrForEach(queue, queueItem => {
if (queueItem.priority < ChannelControllerPriority) {

@@ -98,3 +98,3 @@ invalidChannelIdentifier = queueItem.identifier;

// Initialize each plugin
arr.forEach(queueItem => queueItem.initialize(config, core, extensions));
CoreUtils.arrForEach(arr, queueItem => queueItem.initialize(config, core, extensions));

@@ -104,3 +104,12 @@ this.channelQueue.push(arr);

}
/**
* Static constructor, attempt to create accessors
*/
// tslint:disable-next-line
private static _staticInit = (() => {
// Dynamically create get/set property accessors
CoreUtils.objDefineAccessors(ChannelController.prototype, "ChannelControls", ChannelController.prototype.getChannelControls);
})();
}

@@ -5,2 +5,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved.

// Added to help with minfication
let prototype = "prototype";
export class CoreUtils {

@@ -13,7 +16,13 @@ public static _canUseCookies: boolean;

/**
* Check if an object is of type Date
*/
public static isDate(obj: any): boolean {
return Object[prototype].toString.call(obj) === "[object Date]";
}
/**
* Creates a new GUID.
* @return {string} A GUID.
*/
/**
* Creates a new GUID.
* @return {string} A GUID.
*/

@@ -31,6 +40,225 @@ public static disableCookies() {

/**
* Convert a date to I.S.O. format in IE8
*/
public static toISOString(date: Date) {
if (CoreUtils.isDate(date)) {
const pad = (num: number) => {
let r = String(num);
if (r.length === 1) {
r = "0" + r;
}
return r;
}
return date.getUTCFullYear()
+ "-" + pad(date.getUTCMonth() + 1)
+ "-" + pad(date.getUTCDate())
+ "T" + pad(date.getUTCHours())
+ ":" + pad(date.getUTCMinutes())
+ ":" + pad(date.getUTCSeconds())
+ "." + String((date.getUTCMilliseconds() / 1000).toFixed(3)).slice(2, 5)
+ "Z";
}
}
/**
* Performs the specified action for each element in an array. This helper exists to avoid adding a polyfil for older browsers
* that do not define Array.prototype.xxxx (eg. ES3 only, IE8) just in case any page checks for presence/absence of the prototype
* implementation. Note: For consistency this will not use the Array.prototype.xxxx implementation if it exists as this would
* cause a testing requirement to test with and without the implementations
* @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.
* @param thisArg [Optional] An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
*/
public static arrForEach<T>(arr: T[], callbackfn: (value: T, index?: number, array?: T[]) => void, thisArg?: any):void {
let len = arr.length;
for (let idx = 0; idx < len; ++idx) {
if (idx in arr) {
callbackfn.call(thisArg || arr, arr[idx], idx, arr);
}
}
}
/**
* Returns the index of the first occurrence of a value in an array. This helper exists to avoid adding a polyfil for older browsers
* that do not define Array.prototype.xxxx (eg. ES3 only, IE8) just in case any page checks for presence/absence of the prototype
* implementation. Note: For consistency this will not use the Array.prototype.xxxx implementation if it exists as this would
* cause a testing requirement to test with and without the implementations
* @param searchElement The value to locate in the array.
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.
*/
public static arrIndexOf<T>(arr: T[], searchElement: T, fromIndex?: number): number {
let len = arr.length;
let from = fromIndex || 0;
for (let lp = Math.max(from >= 0 ? from : len - Math.abs(from), 0); lp < len; lp++) {
if (lp in arr && arr[lp] === searchElement) {
return lp;
}
}
return -1;
}
/**
* Calls a defined callback function on each element of an array, and returns an array that contains the results. This helper exists
* to avoid adding a polyfil for older browsers that do not define Array.prototype.xxxx (eg. ES3 only, IE8) just in case any page
* checks for presence/absence of the prototype implementation. Note: For consistency this will not use the Array.prototype.xxxx
* implementation if it exists as this would cause a testing requirement to test with and without the implementations
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
*/
public static arrMap<T,R>(arr: T[], callbackfn: (value: T, index?: number, array?: T[]) => R, thisArg?: any): R[] {
let len = arr.length;
let _this = thisArg || arr;
let results = new Array(len);
for (let lp = 0; lp < len; lp++) {
if (lp in arr) {
results[lp] = callbackfn.call(_this, arr[lp], arr);
}
}
return results;
}
/**
* Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is
* provided as an argument in the next call to the callback function. This helper exists to avoid adding a polyfil for older browsers that do not define
* Array.prototype.xxxx (eg. ES3 only, IE8) just in case any page checks for presence/absence of the prototype implementation. Note: For consistency
* this will not use the Array.prototype.xxxx implementation if it exists as this would cause a testing requirement to test with and without the implementations
* @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.
* @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
*/
public static arrReduce<T,R>(arr: T[], callbackfn: (previousValue: T|R, currentValue?: T, currentIndex?: number, array?: T[]) => R, initialValue?: R): R {
let len = arr.length;
let lp = 0;
let value;
// Specifically checking the number of passed arguments as the value could be anything
if (arguments.length >= 3) {
value = arguments[2];
} else {
while (lp < len && !(lp in arr)) {
lp++;
}
value = arr[lp++];
}
while (lp < len) {
if (lp in arr) {
value = callbackfn(value, arr[lp], lp, arr);
}
lp++;
}
return value;
}
/**
* Creates an object that has the specified prototype, and that optionally contains specified properties. This helper exists to avoid adding a polyfil
* for older browsers that do not define Object.create (eg. ES3 only, IE8) just in case any page checks for presence/absence of the prototype implementation.
* Note: For consistency this will not use the Object.create implementation if it exists as this would cause a testing requirement to test with and without the implementations
* @param obj Object to use as a prototype. May be null
*/
public static objCreate(obj:object):any {
if (obj == null) {
return {};
}
let type = typeof obj;
if (type !== 'object' && type !== 'function') {
throw new TypeError('Object prototype may only be an Object: ' + obj)
}
function tmpFunc() {};
tmpFunc[prototype] = obj;
return new tmpFunc();
}
/**
* Returns the names of the enumerable string properties and methods of an object. This helper exists to avoid adding a polyfil for older browsers
* that do not define Object.create (eg. ES3 only, IE8) just in case any page checks for presence/absence of the prototype implementation.
* Note: For consistency this will not use the Object.create implementation if it exists as this would cause a testing requirement to test with and without the implementations
* @param obj Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
*/
public static objKeys(obj: {}): string[] {
var hasOwnProperty = Object[prototype].hasOwnProperty;
var hasDontEnumBug = !({ toString: null }).propertyIsEnumerable('toString');
let type = typeof obj;
if (type !== 'function' && (type !== 'object' || obj === null)) {
throw new TypeError('objKeys called on non-object');
}
let result:string[] = [];
for (let prop in obj) {
if (hasOwnProperty.call(obj, prop)) {
result.push(prop);
}
}
if (hasDontEnumBug) {
let dontEnums = [
'toString',
'toLocaleString',
'valueOf',
'hasOwnProperty',
'isPrototypeOf',
'propertyIsEnumerable',
'constructor'
];
let dontEnumsLength = dontEnums.length;
for (let lp = 0; lp < dontEnumsLength; lp++) {
if (hasOwnProperty.call(obj, dontEnums[lp])) {
result.push(dontEnums[lp]);
}
}
}
return result;
}
/**
* Try to define get/set object property accessors for the target object/prototype, this will provide compatibility with
* existing API definition when run within an ES5+ container that supports accessors but still enable the code to be loaded
* and executed in an ES3 container, providing basic IE8 compatibility.
* @param target The object on which to define the property.
* @param prop The name of the property to be defined or modified.
* @param getProp The getter function to wire against the getter.
* @param setProp The setter function to wire against the setter.
* @returns True if it was able to create the accessors otherwise false
*/
public static objDefineAccessors<T>(target:any, prop:string, getProp?:() => T, setProp?: (v:T) => void) : boolean
{
let defineProp = Object["defineProperty"];
if (defineProp) {
try {
let descriptor:PropertyDescriptor = {
enumerable: true,
configurable: true
}
if (getProp) {
descriptor.get = getProp;
}
if (setProp) {
descriptor.set = setProp;
}
defineProp(target, prop, descriptor);
return true;
} catch (e) {
// IE8 Defines a defineProperty on Object but it's only supported for DOM elements so it will throw
// We will just ignore this here.
}
}
return false;
}
}
const GuidRegex = /[xy]/g;

@@ -6,2 +6,3 @@ // Copyright (c) Microsoft Corporation. All rights reserved.

import { INotificationManager } from './../JavaScriptSDK.Interfaces/INotificationManager';
import { CoreUtils } from "./CoreUtils";

@@ -27,6 +28,6 @@ /**

removeNotificationListener(listener: INotificationListener): void {
let index: number = this.listeners.indexOf(listener);
let index: number = CoreUtils.arrIndexOf(this.listeners, listener);
while (index > -1) {
this.listeners.splice(index, 1);
index = this.listeners.indexOf(listener);
index = CoreUtils.arrIndexOf(this.listeners, listener);
}

@@ -33,0 +34,0 @@ }

@@ -8,3 +8,3 @@ {

"moduleResolution": "node",
"target": "es5",
"target": "es3",
"forceConsistentCasingInFileNames": true,

@@ -11,0 +11,0 @@ "importHelpers": true,

@@ -12,4 +12,8 @@ import { IAppInsightsCore } from "../JavaScriptSDK.Interfaces/IAppInsightsCore";

processTelemetry(item: ITelemetryItem): void;
readonly ChannelControls: IChannelControls[][];
getChannelControls(): IChannelControls[][];
initialize(config: IConfiguration, core: IAppInsightsCore, extensions: IPlugin[]): void;
/**
* Static constructor, attempt to create accessors
*/
private static _staticInit;
}

@@ -5,2 +5,6 @@ export declare class CoreUtils {

/**
* Check if an object is of type Date
*/
static isDate(obj: any): boolean;
/**
* Creates a new GUID.

@@ -11,2 +15,67 @@ * @return {string} A GUID.

static newGuid(): string;
/**
* Convert a date to I.S.O. format in IE8
*/
static toISOString(date: Date): string;
/**
* Performs the specified action for each element in an array. This helper exists to avoid adding a polyfil for older browsers
* that do not define Array.prototype.xxxx (eg. ES3 only, IE8) just in case any page checks for presence/absence of the prototype
* implementation. Note: For consistency this will not use the Array.prototype.xxxx implementation if it exists as this would
* cause a testing requirement to test with and without the implementations
* @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.
* @param thisArg [Optional] An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
*/
static arrForEach<T>(arr: T[], callbackfn: (value: T, index?: number, array?: T[]) => void, thisArg?: any): void;
/**
* Returns the index of the first occurrence of a value in an array. This helper exists to avoid adding a polyfil for older browsers
* that do not define Array.prototype.xxxx (eg. ES3 only, IE8) just in case any page checks for presence/absence of the prototype
* implementation. Note: For consistency this will not use the Array.prototype.xxxx implementation if it exists as this would
* cause a testing requirement to test with and without the implementations
* @param searchElement The value to locate in the array.
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.
*/
static arrIndexOf<T>(arr: T[], searchElement: T, fromIndex?: number): number;
/**
* Calls a defined callback function on each element of an array, and returns an array that contains the results. This helper exists
* to avoid adding a polyfil for older browsers that do not define Array.prototype.xxxx (eg. ES3 only, IE8) just in case any page
* checks for presence/absence of the prototype implementation. Note: For consistency this will not use the Array.prototype.xxxx
* implementation if it exists as this would cause a testing requirement to test with and without the implementations
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
*/
static arrMap<T, R>(arr: T[], callbackfn: (value: T, index?: number, array?: T[]) => R, thisArg?: any): R[];
/**
* Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is
* provided as an argument in the next call to the callback function. This helper exists to avoid adding a polyfil for older browsers that do not define
* Array.prototype.xxxx (eg. ES3 only, IE8) just in case any page checks for presence/absence of the prototype implementation. Note: For consistency
* this will not use the Array.prototype.xxxx implementation if it exists as this would cause a testing requirement to test with and without the implementations
* @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.
* @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
*/
static arrReduce<T, R>(arr: T[], callbackfn: (previousValue: T | R, currentValue?: T, currentIndex?: number, array?: T[]) => R, initialValue?: R): R;
/**
* Creates an object that has the specified prototype, and that optionally contains specified properties. This helper exists to avoid adding a polyfil
* for older browsers that do not define Object.create (eg. ES3 only, IE8) just in case any page checks for presence/absence of the prototype implementation.
* Note: For consistency this will not use the Object.create implementation if it exists as this would cause a testing requirement to test with and without the implementations
* @param obj Object to use as a prototype. May be null
*/
static objCreate(obj: object): any;
/**
* Returns the names of the enumerable string properties and methods of an object. This helper exists to avoid adding a polyfil for older browsers
* that do not define Object.create (eg. ES3 only, IE8) just in case any page checks for presence/absence of the prototype implementation.
* Note: For consistency this will not use the Object.create implementation if it exists as this would cause a testing requirement to test with and without the implementations
* @param obj Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
*/
static objKeys(obj: {}): string[];
/**
* Try to define get/set object property accessors for the target object/prototype, this will provide compatibility with
* existing API definition when run within an ES5+ container that supports accessors but still enable the code to be loaded
* and executed in an ES3 container, providing basic IE8 compatibility.
* @param target The object on which to define the property.
* @param prop The name of the property to be defined or modified.
* @param getProp The getter function to wire against the getter.
* @param setProp The setter function to wire against the setter.
* @returns True if it was able to create the accessors otherwise false
*/
static objDefineAccessors<T>(target: any, prop: string, getProp?: () => T, setProp?: (v: T) => void): boolean;
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc