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.0.0-beta.0 to 2.0.0-beta.1

64

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

@@ -8,4 +8,4 @@ */

typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = global || self, factory(global.aicore = {}));
}(this, function (exports) { 'use strict';
(factory((global.Microsoft = global.Microsoft || {}, global.Microsoft.ApplicationInsights = {})));
}(this, (function (exports) { 'use strict';

@@ -424,2 +424,3 @@ var MinChannelPriorty = 100;

var isValid_1 = true;
var containsChannels_1 = false;
this.config.extensions.forEach(function (item) {

@@ -429,2 +430,5 @@ if (CoreUtils.isNullOrUndefined(item)) {

}
if (item.priority > ChannelControllerPriority) {
containsChannels_1 = true;
}
});

@@ -434,2 +438,5 @@ if (!isValid_1) {

}
if (containsChannels_1) {
throw Error(validationErrorInExt);
}
}

@@ -646,2 +653,3 @@ // Initial validation complete

if (config.channels) {
var invalidChannelIdentifier_1 = undefined;
config.channels.forEach(function (queue) {

@@ -653,3 +661,11 @@ if (queue && queue.length > 0) {

// Initialize each plugin
queue.forEach(function (queueItem) { return queueItem.initialize(config, core, extensions); });
queue.forEach(function (queueItem) {
if (queueItem.priority < ChannelControllerPriority) {
invalidChannelIdentifier_1 = queueItem.identifier;
}
queueItem.initialize(config, core, extensions);
});
if (invalidChannelIdentifier_1) {
throw Error(ChannelValidationMessage + invalidChannelIdentifier_1);
}
for (var i = 1; i < queue.length; i++) {

@@ -662,23 +678,21 @@ queue[i - 1].setNextPlugin(queue[i]); // setup processing chain

}
else {
var arr = new Array();
for (var i = 0; i < extensions.length; i++) {
var plugin = extensions[i];
if (plugin.priority > ChannelControllerPriority) {
arr.push(plugin);
}
var arr = new Array();
for (var i = 0; i < extensions.length; i++) {
var plugin = extensions[i];
if (plugin.priority > ChannelControllerPriority) {
arr.push(plugin);
}
if (arr.length > 0) {
// sort if not sorted
arr = arr.sort(function (a, b) {
return a.priority - b.priority;
});
// Initialize each plugin
arr.forEach(function (queueItem) { return queueItem.initialize(config, core, extensions); });
// setup next plugin
for (var i = 1; i < arr.length; i++) {
arr[i - 1].setNextPlugin(arr[i]);
}
this.channelQueue.push(arr);
}
if (arr.length > 0) {
// sort if not sorted
arr = arr.sort(function (a, b) {
return a.priority - b.priority;
});
// Initialize each plugin
arr.forEach(function (queueItem) { return queueItem.initialize(config, core, extensions); });
// setup next plugin
for (var i = 1; i < arr.length; i++) {
arr[i - 1].setNextPlugin(arr[i]);
}
this.channelQueue.push(arr);
}

@@ -689,3 +703,5 @@ };

var validationError = "Extensions must provide callback to initialize";
var validationErrorInExt = "Channels must be provided through config.channels only";
var ChannelControllerPriority = 500;
var ChannelValidationMessage = "Channel has invalid priority";

@@ -703,3 +719,3 @@ exports.MinChannelPriorty = MinChannelPriorty;

}));
})));
//# sourceMappingURL=applicationinsights-core-js.js.map
/*!
* Application Insights JavaScript SDK - Core, 2.0.0-beta.0
* Application Insights JavaScript SDK - Core, 2.0.0-beta.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=e||self).aicore={})}(this,function(a){"use strict";var e,t={Unknown:0,NonRetryableStatus:1,InvalidEvent:2,SizeLimitExceeded:3,KillSwitch:4,QueueFull:5},c=function(){function e(){}return e.isNullOrUndefined=function(e){return null==e},e.newGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(i,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})},e}(),i=/[xy]/g,f=function(){function e(){this.listeners=[]}return e.prototype.addNotificationListener=function(e){this.listeners.push(e)},e.prototype.removeNotificationListener=function(e){for(var t=this.listeners.indexOf(e);-1<t;)this.listeners.splice(t,1),t=this.listeners.indexOf(e)},e.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)},e.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)},e}();(e=a.LoggingSeverity||(a.LoggingSeverity={}))[e.CRITICAL=1]="CRITICAL",e[e.WARNING=2]="WARNING";var s={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},l=function(){function r(e,t,i,n){void 0===i&&(i=!1),this.messageId=e,this.message=(i?r.AiUserActionablePrefix:r.AiNonUserActionablePrefix)+e;var o=(t?" message:"+r.sanitizeDiagnosticText(t):"")+(n?" props:"+r.sanitizeDiagnosticText(JSON.stringify(n)):"");this.message+=o}return r.sanitizeDiagnosticText=function(e){return'"'+e.replace(/\"/g,"")+'"'},r.dataType="MessageData",r.AiNonUserActionablePrefix="AI (Internal): ",r.AiUserActionablePrefix="AI: ",r}(),u=function(){function e(e){this.AIInternalMessagePrefix="AITR_",this.enableDebugExceptions=function(){return!1},this.consoleLoggingLevel=function(){return 1},this.telemetryLoggingLevel=function(){return 0},this.maxInternalMessageLimit=function(){return 25},this.queue=[],this._messageCount=0,this._messageLogged={},c.isNullOrUndefined(e)||(c.isNullOrUndefined(e.loggingLevelConsole)||(this.consoleLoggingLevel=function(){return e.loggingLevelConsole}),c.isNullOrUndefined(e.loggingLevelTelemetry)||(this.telemetryLoggingLevel=function(){return e.loggingLevelTelemetry}),c.isNullOrUndefined(e.maxMessageLimit)||(this.maxInternalMessageLimit=function(){return e.maxMessageLimit}),c.isNullOrUndefined(e.enableDebugExceptions)||(this.enableDebugExceptions=function(){return e.enableDebugExceptions}))}return e.prototype.throwInternal=function(e,t,i,n,o){void 0===o&&(o=!1);var r=new l(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)}},e.prototype.warnToConsole=function(e){"undefined"!=typeof console&&console&&("function"==typeof console.warn?console.warn(e):"function"==typeof console.log&&console.log(e))},e.prototype.resetInternalMessageCount=function(){this._messageCount=0,this._messageLogged={}},e.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 l(s.MessageLimitPerPVExceeded,o,!1);this.queue.push(r),this.warnToConsole(o)}}},e.prototype._areInternalMessagesThrottled=function(){return this._messageCount>=this.maxInternalMessageLimit()},e}(),n=function(){function e(){this._isInitialized=!1,this._extensions=new Array,this._channelController=new o}return e.prototype.initialize=function(e,t){var i=this;if(this._isInitialized)throw Error("Core should not be initialized more than once");if(!e||c.isNullOrUndefined(e.instrumentationKey))throw Error("Please provide instrumentation key");if(this.config=e,this._notificationManager=new f,this.config.extensions=c.isNullOrUndefined(this.config.extensions)?[]:this.config.extensions,this.config.extensionConfig=c.isNullOrUndefined(this.config.extensionConfig)?{}:this.config.extensionConfig,this.config.extensionConfig.NotificationManager=this._notificationManager,this.logger=new u(e),t.forEach(function(e){if(c.isNullOrUndefined(e.initialize))throw Error(g)}),0<this.config.extensions.length){var n=!0;if(this.config.extensions.forEach(function(e){c.isNullOrUndefined(e)&&(n=!1)}),!n)throw Error(g)}(r=this._extensions).push.apply(r,[this._channelController].concat(t,this.config.extensions)),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 o={};this._extensions.forEach(function(e){var t=e;t&&t.priority&&(c.isNullOrUndefined(o[t.priority])?o[t.priority]=t.identifier:i.logger.warnToConsole("Two extensions have same priority"+o[t.priority]+", "+t.identifier))});for(var r,s=-1,a=0;a<this._extensions.length-1;a++){var l=this._extensions[a];if(!l||"function"==typeof l.processTelemetry){if(l.priority===d){s=a+1;break}this._extensions[a].setNextPlugin(this._extensions[a+1])}}if(this._channelController.initialize(this.config,this,this._extensions),this._extensions.forEach(function(e){e&&e.priority<d&&e.initialize(i.config,i,i._extensions)}),s<this._extensions.length&&this._extensions.splice(s),0===this.getTransmissionControls().length)throw new Error("No channels available");this._isInitialized=!0},e.prototype.getTransmissionControls=function(){return this._channelController.ChannelControls},e.prototype.track=function(e){if(null===e)throw this._notifiyInvalidEvent(e),Error("Invalid telemetry item");if(e.baseData&&!e.baseType)throw this._notifiyInvalidEvent(e),Error("Provide data.baseType for data.baseData");e.baseType||(e.baseType="EventData"),e.iKey||(e.iKey=this.config.instrumentationKey),e.time||(e.time=(new Date).toISOString()),c.isNullOrUndefined(e.ver)&&(e.ver="4.0"),this._validateTelmetryItem(e),this._updateSdkVersion(e);for(var t=0;t<this._extensions.length;){if(this._extensions[t].processTelemetry){this._extensions[t].processTelemetry(e);break}t++}},e.prototype.addNotificationListener=function(e){this._notificationManager.addNotificationListener(e)},e.prototype.removeNotificationListener=function(e){this._notificationManager.removeNotificationListener(e)},e.prototype.pollInternalLogs=function(){var i=this,e=this.config.diagnosticLogInterval;return 0<e||(e=1e4),setInterval(function(){var e=i.logger.queue;e.forEach(function(e){var t={name:"InternalMessageId: "+e.messageId,iKey:i.config.instrumentationKey,time:(new Date).toISOString(),baseType:l.dataType,baseData:{message:e.message}};i.track(t)}),e.length=0},e)},e.prototype._validateTelmetryItem=function(e){if(c.isNullOrUndefined(e.name))throw this._notifiyInvalidEvent(e),Error("telemetry name required");if(c.isNullOrUndefined(e.time))throw this._notifiyInvalidEvent(e),Error("telemetry timestamp required");if(c.isNullOrUndefined(e.iKey))throw this._notifiyInvalidEvent(e),Error("telemetry instrumentationKey required")},e.prototype._updateSdkVersion=function(e){e.ext||(e.ext={}),e.ext.sdk||(e.ext.sdk={});for(var t="",i=0;i<this._extensions.length;i++){var n=this._extensions[i];if(n.identifier&&n.version){var o=n.identifier+":"+n.version+";";t=t.concat(o)}}""!=t&&(e.ext.sdk.libVer=t)},e.prototype._notifiyInvalidEvent=function(e){this._notificationManager.eventsDiscarded([e],t.InvalidEvent)},e}(),o=function(){function e(){this.identifier="ChannelControllerPlugin",this.priority=d}return e.prototype.processTelemetry=function(t){this.channelQueue.forEach(function(e){0<e.length&&e[0].processTelemetry(t)})},Object.defineProperty(e.prototype,"ChannelControls",{get:function(){return this.channelQueue},enumerable:!0,configurable:!0}),e.prototype.initialize=function(i,n,o){var r=this;if(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})).forEach(function(e){return e.initialize(i,n,o)});for(var t=1;t<e.length;t++)e[t-1].setNextPlugin(e[t]);r.channelQueue.push(e)}});else{for(var e=new Array,t=0;t<o.length;t++){var s=o[t];s.priority>d&&e.push(s)}if(0<e.length){(e=e.sort(function(e,t){return e.priority-t.priority})).forEach(function(e){return e.initialize(i,n,o)});for(t=1;t<e.length;t++)e[t-1].setNextPlugin(e[t]);this.channelQueue.push(e)}}},e}(),g="Extensions must provide callback to initialize",d=500;a.MinChannelPriorty=100,a.EventsDiscardedReason=t,a.AppInsightsCore=n,a.CoreUtils=c,a.NotificationManager=f,a.DiagnosticLogger=u,a._InternalLogMessage=l,a._InternalMessageId=s,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 e,t={Unknown:0,NonRetryableStatus:1,InvalidEvent:2,SizeLimitExceeded:3,KillSwitch:4,QueueFull:5},f=function(){function e(){}return e.isNullOrUndefined=function(e){return null==e},e.newGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(i,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})},e}(),i=/[xy]/g,u=function(){function e(){this.listeners=[]}return e.prototype.addNotificationListener=function(e){this.listeners.push(e)},e.prototype.removeNotificationListener=function(e){for(var t=this.listeners.indexOf(e);-1<t;)this.listeners.splice(t,1),t=this.listeners.indexOf(e)},e.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)},e.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)},e}();(e=a.LoggingSeverity||(a.LoggingSeverity={}))[e.CRITICAL=1]="CRITICAL",e[e.WARNING=2]="WARNING";var s={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},l=function(){function r(e,t,i,n){void 0===i&&(i=!1),this.messageId=e,this.message=(i?r.AiUserActionablePrefix:r.AiNonUserActionablePrefix)+e;var o=(t?" message:"+r.sanitizeDiagnosticText(t):"")+(n?" props:"+r.sanitizeDiagnosticText(JSON.stringify(n)):"");this.message+=o}return r.sanitizeDiagnosticText=function(e){return'"'+e.replace(/\"/g,"")+'"'},r.dataType="MessageData",r.AiNonUserActionablePrefix="AI (Internal): ",r.AiUserActionablePrefix="AI: ",r}(),g=function(){function e(e){this.AIInternalMessagePrefix="AITR_",this.enableDebugExceptions=function(){return!1},this.consoleLoggingLevel=function(){return 1},this.telemetryLoggingLevel=function(){return 0},this.maxInternalMessageLimit=function(){return 25},this.queue=[],this._messageCount=0,this._messageLogged={},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}))}return e.prototype.throwInternal=function(e,t,i,n,o){void 0===o&&(o=!1);var r=new l(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)}},e.prototype.warnToConsole=function(e){"undefined"!=typeof console&&console&&("function"==typeof console.warn?console.warn(e):"function"==typeof console.log&&console.log(e))},e.prototype.resetInternalMessageCount=function(){this._messageCount=0,this._messageLogged={}},e.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 l(s.MessageLimitPerPVExceeded,o,!1);this.queue.push(r),this.warnToConsole(o)}}},e.prototype._areInternalMessagesThrottled=function(){return this._messageCount>=this.maxInternalMessageLimit()},e}(),n=function(){function e(){this._isInitialized=!1,this._extensions=new Array,this._channelController=new o}return e.prototype.initialize=function(e,t){var i=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");if(this.config=e,this._notificationManager=new u,this.config.extensions=f.isNullOrUndefined(this.config.extensions)?[]:this.config.extensions,this.config.extensionConfig=f.isNullOrUndefined(this.config.extensionConfig)?{}:this.config.extensionConfig,this.config.extensionConfig.NotificationManager=this._notificationManager,this.logger=new g(e),t.forEach(function(e){if(f.isNullOrUndefined(e.initialize))throw Error(h)}),0<this.config.extensions.length){var n=!0,o=!1;if(this.config.extensions.forEach(function(e){f.isNullOrUndefined(e)&&(n=!1),e.priority>p&&(o=!0)}),!n)throw Error(h);if(o)throw Error(d)}(s=this._extensions).push.apply(s,[this._channelController].concat(t,this.config.extensions)),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&&(f.isNullOrUndefined(r[t.priority])?r[t.priority]=t.identifier:i.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===p){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<p&&e.initialize(i.config,i,i._extensions)}),a<this._extensions.length&&this._extensions.splice(a),0===this.getTransmissionControls().length)throw new Error("No channels available");this._isInitialized=!0},e.prototype.getTransmissionControls=function(){return this._channelController.ChannelControls},e.prototype.track=function(e){if(null===e)throw this._notifiyInvalidEvent(e),Error("Invalid telemetry item");if(e.baseData&&!e.baseType)throw this._notifiyInvalidEvent(e),Error("Provide data.baseType for data.baseData");e.baseType||(e.baseType="EventData"),e.iKey||(e.iKey=this.config.instrumentationKey),e.time||(e.time=(new Date).toISOString()),f.isNullOrUndefined(e.ver)&&(e.ver="4.0"),this._validateTelmetryItem(e),this._updateSdkVersion(e);for(var t=0;t<this._extensions.length;){if(this._extensions[t].processTelemetry){this._extensions[t].processTelemetry(e);break}t++}},e.prototype.addNotificationListener=function(e){this._notificationManager.addNotificationListener(e)},e.prototype.removeNotificationListener=function(e){this._notificationManager.removeNotificationListener(e)},e.prototype.pollInternalLogs=function(){var i=this,e=this.config.diagnosticLogInterval;return 0<e||(e=1e4),setInterval(function(){var e=i.logger.queue;e.forEach(function(e){var t={name:"InternalMessageId: "+e.messageId,iKey:i.config.instrumentationKey,time:(new Date).toISOString(),baseType:l.dataType,baseData:{message:e.message}};i.track(t)}),e.length=0},e)},e.prototype._validateTelmetryItem=function(e){if(f.isNullOrUndefined(e.name))throw this._notifiyInvalidEvent(e),Error("telemetry name required");if(f.isNullOrUndefined(e.time))throw this._notifiyInvalidEvent(e),Error("telemetry timestamp required");if(f.isNullOrUndefined(e.iKey))throw this._notifiyInvalidEvent(e),Error("telemetry instrumentationKey required")},e.prototype._updateSdkVersion=function(e){e.ext||(e.ext={}),e.ext.sdk||(e.ext.sdk={});for(var t="",i=0;i<this._extensions.length;i++){var n=this._extensions[i];if(n.identifier&&n.version){var o=n.identifier+":"+n.version+";";t=t.concat(o)}}""!=t&&(e.ext.sdk.libVer=t)},e.prototype._notifiyInvalidEvent=function(e){this._notificationManager.eventsDiscarded([e],t.InvalidEvent)},e}(),o=function(){function e(){this.identifier="ChannelControllerPlugin",this.priority=p}return e.prototype.processTelemetry=function(t){this.channelQueue.forEach(function(e){0<e.length&&e[0].processTelemetry(t)})},Object.defineProperty(e.prototype,"ChannelControls",{get:function(){return this.channelQueue},enumerable:!0,configurable:!0}),e.prototype.initialize=function(i,n,o){var r=this;if(this.channelQueue=new Array,i.channels){var s=void 0;i.channels.forEach(function(e){if(e&&0<e.length){if((e=e.sort(function(e,t){return e.priority-t.priority})).forEach(function(e){e.priority<p&&(s=e.identifier),e.initialize(i,n,o)}),s)throw Error(c+s);for(var t=1;t<e.length;t++)e[t-1].setNextPlugin(e[t]);r.channelQueue.push(e)}})}for(var e=new Array,t=0;t<o.length;t++){var a=o[t];a.priority>p&&e.push(a)}if(0<e.length){(e=e.sort(function(e,t){return e.priority-t.priority})).forEach(function(e){return e.initialize(i,n,o)});for(t=1;t<e.length;t++)e[t-1].setNextPlugin(e[t]);this.channelQueue.push(e)}},e}(),h="Extensions must provide callback to initialize",d="Channels must be provided through config.channels only",p=500,c="Channel has invalid priority";a.MinChannelPriorty=100,a.EventsDiscardedReason=t,a.AppInsightsCore=n,a.CoreUtils=f,a.NotificationManager=u,a.DiagnosticLogger=g,a._InternalLogMessage=l,a._InternalMessageId=s,Object.defineProperty(a,"__esModule",{value:!0})});
//# sourceMappingURL=applicationinsights-core-js.min.js.map

@@ -36,2 +36,3 @@ import { EventsDiscardedReason } from "../JavaScriptSDK.Enums/EventsDiscardedReason";

var isValid_1 = true;
var containsChannels_1 = false;
this.config.extensions.forEach(function (item) {

@@ -41,2 +42,5 @@ if (CoreUtils.isNullOrUndefined(item)) {

}
if (item.priority > ChannelControllerPriority) {
containsChannels_1 = true;
}
});

@@ -46,2 +50,5 @@ if (!isValid_1) {

}
if (containsChannels_1) {
throw Error(validationErrorInExt);
}
}

@@ -259,2 +266,3 @@ // Initial validation complete

if (config.channels) {
var invalidChannelIdentifier_1 = undefined;
config.channels.forEach(function (queue) {

@@ -266,3 +274,11 @@ if (queue && queue.length > 0) {

// Initialize each plugin
queue.forEach(function (queueItem) { return queueItem.initialize(config, core, extensions); });
queue.forEach(function (queueItem) {
if (queueItem.priority < ChannelControllerPriority) {
invalidChannelIdentifier_1 = queueItem.identifier;
}
queueItem.initialize(config, core, extensions);
});
if (invalidChannelIdentifier_1) {
throw Error(ChannelValidationMessage + invalidChannelIdentifier_1);
}
for (var i = 1; i < queue.length; i++) {

@@ -275,23 +291,21 @@ queue[i - 1].setNextPlugin(queue[i]); // setup processing chain

}
else {
var arr = new Array();
for (var i = 0; i < extensions.length; i++) {
var plugin = extensions[i];
if (plugin.priority > ChannelControllerPriority) {
arr.push(plugin);
}
var arr = new Array();
for (var i = 0; i < extensions.length; i++) {
var plugin = extensions[i];
if (plugin.priority > ChannelControllerPriority) {
arr.push(plugin);
}
if (arr.length > 0) {
// sort if not sorted
arr = arr.sort(function (a, b) {
return a.priority - b.priority;
});
// Initialize each plugin
arr.forEach(function (queueItem) { return queueItem.initialize(config, core, extensions); });
// setup next plugin
for (var i = 1; i < arr.length; i++) {
arr[i - 1].setNextPlugin(arr[i]);
}
this.channelQueue.push(arr);
}
if (arr.length > 0) {
// sort if not sorted
arr = arr.sort(function (a, b) {
return a.priority - b.priority;
});
// Initialize each plugin
arr.forEach(function (queueItem) { return queueItem.initialize(config, core, extensions); });
// setup next plugin
for (var i = 1; i < arr.length; i++) {
arr[i - 1].setNextPlugin(arr[i]);
}
this.channelQueue.push(arr);
}

@@ -302,4 +316,5 @@ };

var validationError = "Extensions must provide callback to initialize";
var validationErrorInExt = "Channels must be provided through config.channels only";
var ChannelControllerPriority = 500;
var duplicatePriority = "One or more extensions are set at same priority";
var ChannelValidationMessage = "Channel has invalid priority";
//# sourceMappingURL=AppInsightsCore.js.map
/*!
* Application Insights JavaScript SDK - Core, 2.0.0-beta.0
* Application Insights JavaScript SDK - Core, 2.0.0-beta.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=e||self).aicore={})}(this,function(a){"use strict";var e,t={Unknown:0,NonRetryableStatus:1,InvalidEvent:2,SizeLimitExceeded:3,KillSwitch:4,QueueFull:5},c=function(){function e(){}return e.isNullOrUndefined=function(e){return null==e},e.newGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(i,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})},e}(),i=/[xy]/g,f=function(){function e(){this.listeners=[]}return e.prototype.addNotificationListener=function(e){this.listeners.push(e)},e.prototype.removeNotificationListener=function(e){for(var t=this.listeners.indexOf(e);-1<t;)this.listeners.splice(t,1),t=this.listeners.indexOf(e)},e.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)},e.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)},e}();(e=a.LoggingSeverity||(a.LoggingSeverity={}))[e.CRITICAL=1]="CRITICAL",e[e.WARNING=2]="WARNING";var s={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},l=function(){function r(e,t,i,n){void 0===i&&(i=!1),this.messageId=e,this.message=(i?r.AiUserActionablePrefix:r.AiNonUserActionablePrefix)+e;var o=(t?" message:"+r.sanitizeDiagnosticText(t):"")+(n?" props:"+r.sanitizeDiagnosticText(JSON.stringify(n)):"");this.message+=o}return r.sanitizeDiagnosticText=function(e){return'"'+e.replace(/\"/g,"")+'"'},r.dataType="MessageData",r.AiNonUserActionablePrefix="AI (Internal): ",r.AiUserActionablePrefix="AI: ",r}(),u=function(){function e(e){this.AIInternalMessagePrefix="AITR_",this.enableDebugExceptions=function(){return!1},this.consoleLoggingLevel=function(){return 1},this.telemetryLoggingLevel=function(){return 0},this.maxInternalMessageLimit=function(){return 25},this.queue=[],this._messageCount=0,this._messageLogged={},c.isNullOrUndefined(e)||(c.isNullOrUndefined(e.loggingLevelConsole)||(this.consoleLoggingLevel=function(){return e.loggingLevelConsole}),c.isNullOrUndefined(e.loggingLevelTelemetry)||(this.telemetryLoggingLevel=function(){return e.loggingLevelTelemetry}),c.isNullOrUndefined(e.maxMessageLimit)||(this.maxInternalMessageLimit=function(){return e.maxMessageLimit}),c.isNullOrUndefined(e.enableDebugExceptions)||(this.enableDebugExceptions=function(){return e.enableDebugExceptions}))}return e.prototype.throwInternal=function(e,t,i,n,o){void 0===o&&(o=!1);var r=new l(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)}},e.prototype.warnToConsole=function(e){"undefined"!=typeof console&&console&&("function"==typeof console.warn?console.warn(e):"function"==typeof console.log&&console.log(e))},e.prototype.resetInternalMessageCount=function(){this._messageCount=0,this._messageLogged={}},e.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 l(s.MessageLimitPerPVExceeded,o,!1);this.queue.push(r),this.warnToConsole(o)}}},e.prototype._areInternalMessagesThrottled=function(){return this._messageCount>=this.maxInternalMessageLimit()},e}(),n=function(){function e(){this._isInitialized=!1,this._extensions=new Array,this._channelController=new o}return e.prototype.initialize=function(e,t){var i=this;if(this._isInitialized)throw Error("Core should not be initialized more than once");if(!e||c.isNullOrUndefined(e.instrumentationKey))throw Error("Please provide instrumentation key");if(this.config=e,this._notificationManager=new f,this.config.extensions=c.isNullOrUndefined(this.config.extensions)?[]:this.config.extensions,this.config.extensionConfig=c.isNullOrUndefined(this.config.extensionConfig)?{}:this.config.extensionConfig,this.config.extensionConfig.NotificationManager=this._notificationManager,this.logger=new u(e),t.forEach(function(e){if(c.isNullOrUndefined(e.initialize))throw Error(g)}),0<this.config.extensions.length){var n=!0;if(this.config.extensions.forEach(function(e){c.isNullOrUndefined(e)&&(n=!1)}),!n)throw Error(g)}(r=this._extensions).push.apply(r,[this._channelController].concat(t,this.config.extensions)),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 o={};this._extensions.forEach(function(e){var t=e;t&&t.priority&&(c.isNullOrUndefined(o[t.priority])?o[t.priority]=t.identifier:i.logger.warnToConsole("Two extensions have same priority"+o[t.priority]+", "+t.identifier))});for(var r,s=-1,a=0;a<this._extensions.length-1;a++){var l=this._extensions[a];if(!l||"function"==typeof l.processTelemetry){if(l.priority===d){s=a+1;break}this._extensions[a].setNextPlugin(this._extensions[a+1])}}if(this._channelController.initialize(this.config,this,this._extensions),this._extensions.forEach(function(e){e&&e.priority<d&&e.initialize(i.config,i,i._extensions)}),s<this._extensions.length&&this._extensions.splice(s),0===this.getTransmissionControls().length)throw new Error("No channels available");this._isInitialized=!0},e.prototype.getTransmissionControls=function(){return this._channelController.ChannelControls},e.prototype.track=function(e){if(null===e)throw this._notifiyInvalidEvent(e),Error("Invalid telemetry item");if(e.baseData&&!e.baseType)throw this._notifiyInvalidEvent(e),Error("Provide data.baseType for data.baseData");e.baseType||(e.baseType="EventData"),e.iKey||(e.iKey=this.config.instrumentationKey),e.time||(e.time=(new Date).toISOString()),c.isNullOrUndefined(e.ver)&&(e.ver="4.0"),this._validateTelmetryItem(e),this._updateSdkVersion(e);for(var t=0;t<this._extensions.length;){if(this._extensions[t].processTelemetry){this._extensions[t].processTelemetry(e);break}t++}},e.prototype.addNotificationListener=function(e){this._notificationManager.addNotificationListener(e)},e.prototype.removeNotificationListener=function(e){this._notificationManager.removeNotificationListener(e)},e.prototype.pollInternalLogs=function(){var i=this,e=this.config.diagnosticLogInterval;return 0<e||(e=1e4),setInterval(function(){var e=i.logger.queue;e.forEach(function(e){var t={name:"InternalMessageId: "+e.messageId,iKey:i.config.instrumentationKey,time:(new Date).toISOString(),baseType:l.dataType,baseData:{message:e.message}};i.track(t)}),e.length=0},e)},e.prototype._validateTelmetryItem=function(e){if(c.isNullOrUndefined(e.name))throw this._notifiyInvalidEvent(e),Error("telemetry name required");if(c.isNullOrUndefined(e.time))throw this._notifiyInvalidEvent(e),Error("telemetry timestamp required");if(c.isNullOrUndefined(e.iKey))throw this._notifiyInvalidEvent(e),Error("telemetry instrumentationKey required")},e.prototype._updateSdkVersion=function(e){e.ext||(e.ext={}),e.ext.sdk||(e.ext.sdk={});for(var t="",i=0;i<this._extensions.length;i++){var n=this._extensions[i];if(n.identifier&&n.version){var o=n.identifier+":"+n.version+";";t=t.concat(o)}}""!=t&&(e.ext.sdk.libVer=t)},e.prototype._notifiyInvalidEvent=function(e){this._notificationManager.eventsDiscarded([e],t.InvalidEvent)},e}(),o=function(){function e(){this.identifier="ChannelControllerPlugin",this.priority=d}return e.prototype.processTelemetry=function(t){this.channelQueue.forEach(function(e){0<e.length&&e[0].processTelemetry(t)})},Object.defineProperty(e.prototype,"ChannelControls",{get:function(){return this.channelQueue},enumerable:!0,configurable:!0}),e.prototype.initialize=function(i,n,o){var r=this;if(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})).forEach(function(e){return e.initialize(i,n,o)});for(var t=1;t<e.length;t++)e[t-1].setNextPlugin(e[t]);r.channelQueue.push(e)}});else{for(var e=new Array,t=0;t<o.length;t++){var s=o[t];s.priority>d&&e.push(s)}if(0<e.length){(e=e.sort(function(e,t){return e.priority-t.priority})).forEach(function(e){return e.initialize(i,n,o)});for(t=1;t<e.length;t++)e[t-1].setNextPlugin(e[t]);this.channelQueue.push(e)}}},e}(),g="Extensions must provide callback to initialize",d=500;a.MinChannelPriorty=100,a.EventsDiscardedReason=t,a.AppInsightsCore=n,a.CoreUtils=c,a.NotificationManager=f,a.DiagnosticLogger=u,a._InternalLogMessage=l,a._InternalMessageId=s,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 e,t={Unknown:0,NonRetryableStatus:1,InvalidEvent:2,SizeLimitExceeded:3,KillSwitch:4,QueueFull:5},f=function(){function e(){}return e.isNullOrUndefined=function(e){return null==e},e.newGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(i,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})},e}(),i=/[xy]/g,u=function(){function e(){this.listeners=[]}return e.prototype.addNotificationListener=function(e){this.listeners.push(e)},e.prototype.removeNotificationListener=function(e){for(var t=this.listeners.indexOf(e);-1<t;)this.listeners.splice(t,1),t=this.listeners.indexOf(e)},e.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)},e.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)},e}();(e=a.LoggingSeverity||(a.LoggingSeverity={}))[e.CRITICAL=1]="CRITICAL",e[e.WARNING=2]="WARNING";var s={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},l=function(){function r(e,t,i,n){void 0===i&&(i=!1),this.messageId=e,this.message=(i?r.AiUserActionablePrefix:r.AiNonUserActionablePrefix)+e;var o=(t?" message:"+r.sanitizeDiagnosticText(t):"")+(n?" props:"+r.sanitizeDiagnosticText(JSON.stringify(n)):"");this.message+=o}return r.sanitizeDiagnosticText=function(e){return'"'+e.replace(/\"/g,"")+'"'},r.dataType="MessageData",r.AiNonUserActionablePrefix="AI (Internal): ",r.AiUserActionablePrefix="AI: ",r}(),g=function(){function e(e){this.AIInternalMessagePrefix="AITR_",this.enableDebugExceptions=function(){return!1},this.consoleLoggingLevel=function(){return 1},this.telemetryLoggingLevel=function(){return 0},this.maxInternalMessageLimit=function(){return 25},this.queue=[],this._messageCount=0,this._messageLogged={},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}))}return e.prototype.throwInternal=function(e,t,i,n,o){void 0===o&&(o=!1);var r=new l(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)}},e.prototype.warnToConsole=function(e){"undefined"!=typeof console&&console&&("function"==typeof console.warn?console.warn(e):"function"==typeof console.log&&console.log(e))},e.prototype.resetInternalMessageCount=function(){this._messageCount=0,this._messageLogged={}},e.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 l(s.MessageLimitPerPVExceeded,o,!1);this.queue.push(r),this.warnToConsole(o)}}},e.prototype._areInternalMessagesThrottled=function(){return this._messageCount>=this.maxInternalMessageLimit()},e}(),n=function(){function e(){this._isInitialized=!1,this._extensions=new Array,this._channelController=new o}return e.prototype.initialize=function(e,t){var i=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");if(this.config=e,this._notificationManager=new u,this.config.extensions=f.isNullOrUndefined(this.config.extensions)?[]:this.config.extensions,this.config.extensionConfig=f.isNullOrUndefined(this.config.extensionConfig)?{}:this.config.extensionConfig,this.config.extensionConfig.NotificationManager=this._notificationManager,this.logger=new g(e),t.forEach(function(e){if(f.isNullOrUndefined(e.initialize))throw Error(h)}),0<this.config.extensions.length){var n=!0,o=!1;if(this.config.extensions.forEach(function(e){f.isNullOrUndefined(e)&&(n=!1),e.priority>p&&(o=!0)}),!n)throw Error(h);if(o)throw Error(d)}(s=this._extensions).push.apply(s,[this._channelController].concat(t,this.config.extensions)),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&&(f.isNullOrUndefined(r[t.priority])?r[t.priority]=t.identifier:i.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===p){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<p&&e.initialize(i.config,i,i._extensions)}),a<this._extensions.length&&this._extensions.splice(a),0===this.getTransmissionControls().length)throw new Error("No channels available");this._isInitialized=!0},e.prototype.getTransmissionControls=function(){return this._channelController.ChannelControls},e.prototype.track=function(e){if(null===e)throw this._notifiyInvalidEvent(e),Error("Invalid telemetry item");if(e.baseData&&!e.baseType)throw this._notifiyInvalidEvent(e),Error("Provide data.baseType for data.baseData");e.baseType||(e.baseType="EventData"),e.iKey||(e.iKey=this.config.instrumentationKey),e.time||(e.time=(new Date).toISOString()),f.isNullOrUndefined(e.ver)&&(e.ver="4.0"),this._validateTelmetryItem(e),this._updateSdkVersion(e);for(var t=0;t<this._extensions.length;){if(this._extensions[t].processTelemetry){this._extensions[t].processTelemetry(e);break}t++}},e.prototype.addNotificationListener=function(e){this._notificationManager.addNotificationListener(e)},e.prototype.removeNotificationListener=function(e){this._notificationManager.removeNotificationListener(e)},e.prototype.pollInternalLogs=function(){var i=this,e=this.config.diagnosticLogInterval;return 0<e||(e=1e4),setInterval(function(){var e=i.logger.queue;e.forEach(function(e){var t={name:"InternalMessageId: "+e.messageId,iKey:i.config.instrumentationKey,time:(new Date).toISOString(),baseType:l.dataType,baseData:{message:e.message}};i.track(t)}),e.length=0},e)},e.prototype._validateTelmetryItem=function(e){if(f.isNullOrUndefined(e.name))throw this._notifiyInvalidEvent(e),Error("telemetry name required");if(f.isNullOrUndefined(e.time))throw this._notifiyInvalidEvent(e),Error("telemetry timestamp required");if(f.isNullOrUndefined(e.iKey))throw this._notifiyInvalidEvent(e),Error("telemetry instrumentationKey required")},e.prototype._updateSdkVersion=function(e){e.ext||(e.ext={}),e.ext.sdk||(e.ext.sdk={});for(var t="",i=0;i<this._extensions.length;i++){var n=this._extensions[i];if(n.identifier&&n.version){var o=n.identifier+":"+n.version+";";t=t.concat(o)}}""!=t&&(e.ext.sdk.libVer=t)},e.prototype._notifiyInvalidEvent=function(e){this._notificationManager.eventsDiscarded([e],t.InvalidEvent)},e}(),o=function(){function e(){this.identifier="ChannelControllerPlugin",this.priority=p}return e.prototype.processTelemetry=function(t){this.channelQueue.forEach(function(e){0<e.length&&e[0].processTelemetry(t)})},Object.defineProperty(e.prototype,"ChannelControls",{get:function(){return this.channelQueue},enumerable:!0,configurable:!0}),e.prototype.initialize=function(i,n,o){var r=this;if(this.channelQueue=new Array,i.channels){var s=void 0;i.channels.forEach(function(e){if(e&&0<e.length){if((e=e.sort(function(e,t){return e.priority-t.priority})).forEach(function(e){e.priority<p&&(s=e.identifier),e.initialize(i,n,o)}),s)throw Error(c+s);for(var t=1;t<e.length;t++)e[t-1].setNextPlugin(e[t]);r.channelQueue.push(e)}})}for(var e=new Array,t=0;t<o.length;t++){var a=o[t];a.priority>p&&e.push(a)}if(0<e.length){(e=e.sort(function(e,t){return e.priority-t.priority})).forEach(function(e){return e.initialize(i,n,o)});for(t=1;t<e.length;t++)e[t-1].setNextPlugin(e[t]);this.channelQueue.push(e)}},e}(),h="Extensions must provide callback to initialize",d="Channels must be provided through config.channels only",p=500,c="Channel has invalid priority";a.MinChannelPriorty=100,a.EventsDiscardedReason=t,a.AppInsightsCore=n,a.CoreUtils=f,a.NotificationManager=u,a.DiagnosticLogger=g,a._InternalLogMessage=l,a._InternalMessageId=s,Object.defineProperty(a,"__esModule",{value:!0})});
//# sourceMappingURL=applicationinsights-core-js.min.js.map
{
"name": "@microsoft/applicationinsights-core-js",
"author": "Microsoft Corporation",
"version": "2.0.0-beta.0",
"version": "2.0.0-beta.1",
"description": "Microsoft Application Insights Core Javascript SDK",

@@ -40,3 +40,4 @@ "keywords": [

"tslint-microsoft-contrib": "^5.2.1",
"typescript": "2.5.3"
"typescript": "2.5.3",
"rollup": "^0.66.0"
},

@@ -43,0 +44,0 @@ "dependencies": {

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

/**
* Channel queues that is setup by caller in desired order
* Channel queues that is setup by caller in desired order.
* If channels are provided here, core will ignore any channels that are already setup, example if there is a SKU with an initialized channel
*/
channels?: Array<IChannelControls[]>;
}

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

private _extensions: Array<IPlugin>;
public _extensions: Array<IPlugin>;
private _notificationManager: NotificationManager;

@@ -47,3 +47,3 @@ private _isInitialized: boolean = false;

this._notificationManager = new NotificationManager();
this._notificationManager = new NotificationManager();
this.config.extensions = CoreUtils.isNullOrUndefined(this.config.extensions) ? [] : this.config.extensions;

@@ -66,2 +66,3 @@

let isValid = true;
let containsChannels = false;
this.config.extensions.forEach(item =>

@@ -72,2 +73,6 @@ {

}
if (item.priority > ChannelControllerPriority) {
containsChannels = true;
}
});

@@ -78,2 +83,6 @@

}
if (containsChannels) {
throw Error(validationErrorInExt);
}
}

@@ -234,3 +243,3 @@ // Initial validation complete

return setInterval(() => {
return <any>setInterval(() => {
const queue: Array<_InternalLogMessage> = this.logger.queue;

@@ -326,3 +335,5 @@

if (config.channels) {
let invalidChannelIdentifier = undefined;
config.channels.forEach(queue => {
if(queue && queue.length > 0) {

@@ -334,4 +345,13 @@ queue = queue.sort((a,b) => { // sort based on priority within each queue

// Initialize each plugin
queue.forEach(queueItem => queueItem.initialize(config, core, extensions));
queue.forEach(queueItem => {
if (queueItem.priority < ChannelControllerPriority) {
invalidChannelIdentifier = queueItem.identifier;
}
queueItem.initialize(config, core, extensions)
});
if (invalidChannelIdentifier) {
throw Error(ChannelValidationMessage + invalidChannelIdentifier);
}
for (let i = 1; i < queue.length; i++) {

@@ -344,29 +364,29 @@ queue[i - 1].setNextPlugin(queue[i]); // setup processing chain

});
} else {
let arr = new Array<IChannelControls>();
}
let arr = new Array<IChannelControls>();
for (let i = 0; i < extensions.length; i++) {
let plugin = <IChannelControls>extensions[i];
if (plugin.priority > ChannelControllerPriority) {
arr.push(plugin);
}
for (let i = 0; i < extensions.length; i++) {
let plugin = <IChannelControls>extensions[i];
if (plugin.priority > ChannelControllerPriority) {
arr.push(plugin);
}
}
if (arr.length > 0) {
// sort if not sorted
arr = arr.sort((a,b) => {
return a.priority - b.priority;
});
if (arr.length > 0) {
// sort if not sorted
arr = arr.sort((a,b) => {
return a.priority - b.priority;
});
// Initialize each plugin
arr.forEach(queueItem => queueItem.initialize(config, core, extensions));
// Initialize each plugin
arr.forEach(queueItem => queueItem.initialize(config, core, extensions));
// setup next plugin
for (let i = 1; i < arr.length; i++) {
arr[i - 1].setNextPlugin(arr[i]);
}
// setup next plugin
for (let i = 1; i < arr.length; i++) {
arr[i - 1].setNextPlugin(arr[i]);
}
this.channelQueue.push(arr);
}
}
this.channelQueue.push(arr);
}
}

@@ -376,3 +396,4 @@ }

const validationError = "Extensions must provide callback to initialize";
const validationErrorInExt = "Channels must be provided through config.channels only";
const ChannelControllerPriority = 500;
const duplicatePriority = "One or more extensions are set at same priority";
const ChannelValidationMessage = "Channel has invalid priority";

@@ -15,5 +15,5 @@ {

"declarationMap": true,
"declarationDir": "types",
"declarationDir": "vNext/shared/AppInsightsCore/types",
"outDir": "./dist-esm",
"rootDir": "./src",
"rootDir": "vNext/shared/AppInsightsCore/src",
"suppressImplicitAnyIndexErrors": true,

@@ -24,7 +24,7 @@ "allowSyntheticDefaultImports": true

"./src/applicationinsights-core-js.ts",
"./src/JavaScriptSDK/**",
"./src/JavaScriptSDK.Enums/**",
"./src/JavaScriptSDK.Interfaces/**"
"./src/JavaScriptSDK/**/*.ts",
"./src/JavaScriptSDK.Enums/**/*.ts",
"./src/JavaScriptSDK.Interfaces/**/*.ts"
],
"exclude": ["node_modules/"]
}
}

@@ -5,3 +5,3 @@ export { IConfiguration } from "./JavaScriptSDK.Interfaces/IConfiguration";

export { IAppInsightsCore } from "./JavaScriptSDK.Interfaces/IAppInsightsCore";
export { ITelemetryItem } from "./JavaScriptSDK.Interfaces/ITelemetryItem";
export { ITelemetryItem, ICustomProperties } from "./JavaScriptSDK.Interfaces/ITelemetryItem";
export { INotificationListener } from "./JavaScriptSDK.Interfaces/INotificationListener";

@@ -8,0 +8,0 @@ export { IDiagnosticLogger } from "./JavaScriptSDK.Interfaces/IDiagnosticLogger";

@@ -62,5 +62,6 @@ import { ITelemetryPlugin } from "./ITelemetryPlugin";

/**
* Channel queues that is setup by caller in desired order
* Channel queues that is setup by caller in desired order.
* If channels are provided here, core will ignore any channels that are already setup, example if there is a SKU with an initialized channel
*/
channels?: Array<IChannelControls[]>;
}

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

logger: IDiagnosticLogger;
private _extensions;
_extensions: Array<IPlugin>;
private _notificationManager;

@@ -15,0 +15,0 @@ private _isInitialized;

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