Update snippet to support reporting script load failures (#1258)
- New Snippet Setup pollutes the global namespace (window) #974
This commit is contained in:
Родитель
88cf8edccf
Коммит
5cb9e44cfd
|
@ -1,106 +1,315 @@
|
||||||
var sdkInstance = "appInsightsSDK";
|
(function (win, doc, snipConfig) {
|
||||||
window[sdkInstance] = "appInsights";
|
var locn = win.location;
|
||||||
var aiName = window[sdkInstance]; // provide non default instance name through key appInsightsSDK
|
var helpLink = "https://go.microsoft.com/fwlink/?linkid=2128109";
|
||||||
var aisdk = window[aiName] || (function (aiConfig) {
|
var scriptText = "script";
|
||||||
var appInsights = {
|
var strInstrumentationKey = "instrumentationKey";
|
||||||
config: aiConfig
|
var strIngestionendpoint = "ingestionendpoint";
|
||||||
};
|
var strDisableExceptionTracking = "disableExceptionTracking";
|
||||||
appInsights.initialize = true; // initialize sdk on download
|
var strAiDevice = "ai.device.";
|
||||||
|
var strAiOperationName = "ai.operation.name";
|
||||||
|
var strAiSdkVersion = "ai.internal.sdkVersion";
|
||||||
|
var strToLowerCase = "toLowerCase";
|
||||||
|
var strEmpty = "";
|
||||||
|
var strUndefined = "undefined";
|
||||||
|
var strCrossOrigin = "crossOrigin";
|
||||||
|
|
||||||
// Assigning these to local variables allows them to be minified to save space:
|
var strPostMethod = "POST";
|
||||||
var localDocument = document, localWindow = window, scriptText = "script";
|
var sdkInstanceName = "appInsightsSDK"; // required for Initialization to find the current instance
|
||||||
setTimeout(function () {
|
var aiName = snipConfig.name || "appInsights"; // provide non default instance name through snipConfig name value
|
||||||
var scriptElement = localDocument.createElement(scriptText);
|
if (snipConfig.name || win[sdkInstanceName]) {
|
||||||
scriptElement.src = aiConfig.url || "https://az416426.vo.msecnd.net/scripts/b/ai.2.min.js";
|
// Only set if supplied or another name is defined to avoid polluting the global namespace
|
||||||
localDocument.getElementsByTagName(scriptText)[0].parentNode.appendChild(scriptElement);
|
win[sdkInstanceName] = aiName;
|
||||||
});
|
}
|
||||||
|
var aisdk = win[aiName] || (function (aiConfig) {
|
||||||
// capture initial cookie
|
var loadFailed = false;
|
||||||
try {
|
var handled = false;
|
||||||
appInsights.cookie = localDocument.cookie;
|
var appInsights = {
|
||||||
} catch (e) { }
|
initialize: true, // initialize sdk on download
|
||||||
|
queue: [],
|
||||||
appInsights.queue = [];
|
sv: "3", // Track the actual snippet version for reporting.
|
||||||
appInsights.version = 2.0;
|
version: 2.0, // initialization version, if this is not 2.0 the previous scripts fail to initialize
|
||||||
|
config: aiConfig
|
||||||
function createLazyMethod(name) {
|
|
||||||
// Define a temporary method that queues-up a the real method call
|
|
||||||
appInsights[name] = function () {
|
|
||||||
// Capture the original arguments passed to the method
|
|
||||||
var originalArguments = arguments;
|
|
||||||
// Queue-up a call to the real method
|
|
||||||
appInsights.queue.push(function () {
|
|
||||||
// Invoke the real method with the captured original arguments
|
|
||||||
appInsights[name].apply(appInsights, originalArguments);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
}
|
function _parseConnectionString() {
|
||||||
|
var fields = {};
|
||||||
var method = ["Event", "PageView", "Exception", "Trace", "DependencyData", "Metric", "PageViewPerformance"];
|
var connectionString = aiConfig.connectionString;
|
||||||
while (method.length) {
|
if (connectionString) {
|
||||||
createLazyMethod("track" + method.pop());
|
var kvPairs = connectionString.split(";");
|
||||||
}
|
for (var lp = 0; lp < kvPairs.length; lp++) {
|
||||||
|
var kvParts = kvPairs[lp].split("=");
|
||||||
var track = "Track";
|
|
||||||
var trackPage = track + "Page";
|
if (kvParts.length === 2) { // only save fields with valid formats
|
||||||
createLazyMethod("start" + trackPage);
|
fields[kvParts[0][strToLowerCase]()] = kvParts[1];
|
||||||
createLazyMethod("stop" + trackPage);
|
}
|
||||||
|
}
|
||||||
var trackEvent = track + "Event";
|
|
||||||
createLazyMethod("start" + trackEvent);
|
|
||||||
createLazyMethod("stop" + trackEvent);
|
|
||||||
|
|
||||||
createLazyMethod("addTelemetryInitializer");
|
|
||||||
createLazyMethod("setAuthenticatedUserContext");
|
|
||||||
createLazyMethod("clearAuthenticatedUserContext");
|
|
||||||
createLazyMethod("flush");
|
|
||||||
|
|
||||||
// expose SeverityLevel enum
|
|
||||||
appInsights['SeverityLevel'] = {
|
|
||||||
Verbose : 0,
|
|
||||||
Information : 1,
|
|
||||||
Warning : 2,
|
|
||||||
Error : 3,
|
|
||||||
Critical : 4,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Collect global errors
|
|
||||||
// Note: ApplicationInsightsAnalytics is the extension string identifier for
|
|
||||||
// AppAnalytics. It is defined in ApplicationInsights.ts:ApplicationInsights.identifer
|
|
||||||
if (!(aiConfig.disableExceptionTracking === true ||
|
|
||||||
(aiConfig.extensionConfig &&
|
|
||||||
aiConfig.extensionConfig.ApplicationInsightsAnalytics &&
|
|
||||||
aiConfig.extensionConfig.ApplicationInsightsAnalytics.disableExceptionTracking === true))) {
|
|
||||||
|
|
||||||
method = "onerror";
|
|
||||||
createLazyMethod("_" + method);
|
|
||||||
var originalOnError = localWindow[method];
|
|
||||||
localWindow[method] = function(message, url, lineNumber, columnNumber, error) {
|
|
||||||
var handled = originalOnError && originalOnError(message, url, lineNumber, columnNumber, error);
|
|
||||||
if (handled !== true) {
|
|
||||||
appInsights["_" + method]({
|
|
||||||
message: message,
|
|
||||||
url: url,
|
|
||||||
lineNumber: lineNumber,
|
|
||||||
columnNumber: columnNumber,
|
|
||||||
error: error
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return handled;
|
// apply the default endpoints
|
||||||
|
if (!fields[strIngestionendpoint]) {
|
||||||
|
// use endpoint suffix where overrides are not provided
|
||||||
|
var endpointSuffix = fields.endpointsuffix;
|
||||||
|
// Only fetch the location if a suffix was supplied
|
||||||
|
var fLocation = endpointSuffix ? fields.location : null;
|
||||||
|
fields[strIngestionendpoint] = "https://" + (fLocation ? fLocation + "." : strEmpty) + "dc." + (endpointSuffix || "services.visualstudio.com");
|
||||||
|
}
|
||||||
|
|
||||||
|
return fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
function _sendEvents(evts, endpointUrl) {
|
||||||
|
if (JSON) {
|
||||||
|
var sender = win.fetch;
|
||||||
|
if (sender && !snipConfig.useXhr) {
|
||||||
|
sender(endpointUrl, { method:strPostMethod, body: JSON.stringify(evts), mode:"cors"});
|
||||||
|
} else if (XMLHttpRequest) {
|
||||||
|
// IE doesn't support fetch and private clouds may only be using IE
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
xhr.open(strPostMethod, endpointUrl);
|
||||||
|
xhr.setRequestHeader("Content-type", "application/json");
|
||||||
|
xhr.send(JSON.stringify(evts));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function _reportFailure(targetSrc) {
|
||||||
|
var conString = _parseConnectionString();
|
||||||
|
var iKey = conString[strInstrumentationKey] || aiConfig[strInstrumentationKey] || strEmpty;
|
||||||
|
var ingest = conString[strIngestionendpoint];
|
||||||
|
var endpointUrl = ingest ? ingest + "/v2/track" : config.endpointUrl; // only add /v2/track when from connectionstring
|
||||||
|
|
||||||
|
var message = "SDK LOAD Failure: Failed to load Application Insights SDK script (See stack for details)";
|
||||||
|
var evts = [];
|
||||||
|
evts.push(_createException(iKey, message, targetSrc, endpointUrl));
|
||||||
|
evts.push(_createInternal(iKey, message, targetSrc, endpointUrl));
|
||||||
|
|
||||||
|
_sendEvents(evts, endpointUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gets the time as an ISO date format, using a function as IE7/8 doesn't support toISOString
|
||||||
|
function _getTime() {
|
||||||
|
var date = new Date();
|
||||||
|
function pad(num) {
|
||||||
|
var r = strEmpty + 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";
|
||||||
|
}
|
||||||
|
|
||||||
|
function _createEnvelope(iKey, theType) {
|
||||||
|
var tags = {};
|
||||||
|
var type = "Browser";
|
||||||
|
tags[strAiDevice + "id"] = type[strToLowerCase]();
|
||||||
|
tags[strAiDevice + "type"] = type;
|
||||||
|
tags[strAiOperationName] = locn && locn.pathname || "_unknown_";
|
||||||
|
tags[strAiSdkVersion] = "javascript:snippet_" + (appInsights.sv || appInsights.version);
|
||||||
|
|
||||||
|
return {
|
||||||
|
time: _getTime(),
|
||||||
|
iKey: iKey,
|
||||||
|
name: "Microsoft.ApplicationInsights." + iKey.replace(/-/g, strEmpty) + "." + theType,
|
||||||
|
sampleRate: 100,
|
||||||
|
tags: tags,
|
||||||
|
data: {
|
||||||
|
baseData: {
|
||||||
|
ver: 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function _createInternal(iKey, message, targetSrc, endpointUrl) {
|
||||||
|
var envelope = _createEnvelope(iKey, "Message");
|
||||||
|
var data = envelope.data;
|
||||||
|
data.baseType = "MessageData";
|
||||||
|
var baseData = data.baseData;
|
||||||
|
baseData.message = "AI (Internal): 99 message:\"" + (message + " (" + targetSrc + ")").replace(/\"/g, strEmpty) + "\"";
|
||||||
|
baseData.properties = {
|
||||||
|
endpoint: endpointUrl
|
||||||
|
};
|
||||||
|
|
||||||
|
return envelope;
|
||||||
|
}
|
||||||
|
|
||||||
|
function _createException(iKey, message, targetSrc, endpointUrl) {
|
||||||
|
var envelope = _createEnvelope(iKey, "Exception");
|
||||||
|
var data = envelope.data;
|
||||||
|
data.baseType = "ExceptionData";
|
||||||
|
data.baseData.exceptions = [{
|
||||||
|
typeName: "SDKLoadFailed",
|
||||||
|
message: message.replace(/\./g, "-"), // Replacing '.' characters as it causes the portal to hide the start of the message in the summary
|
||||||
|
hasFullStack: false,
|
||||||
|
stack: message + "\nSnippet failed to load [" + targetSrc + "] -- Telemetry is disabled\nHelp Link: " + helpLink + "\nHost: " + (locn && locn.pathname || "_unknown_") + "\nEndpoint: " + endpointUrl,
|
||||||
|
parsedStack: []
|
||||||
|
}];
|
||||||
|
|
||||||
|
return envelope;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assigning these to local variables allows them to be minified to save space:
|
||||||
|
var targetSrc = aiConfig.url || snipConfig.src;
|
||||||
|
if (targetSrc) {
|
||||||
|
function _handleError(evt) {
|
||||||
|
loadFailed = true;
|
||||||
|
appInsights.queue = []; // Clear the queue
|
||||||
|
if (!handled) {
|
||||||
|
handled = true;
|
||||||
|
_reportFailure(targetSrc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function _handleLoad(evt, isAbort) {
|
||||||
|
if (!handled) {
|
||||||
|
// IE10, Opera calls loaded before the script is processed.
|
||||||
|
// so delaying to give the script a chance to be processed
|
||||||
|
setTimeout(function() {
|
||||||
|
if (isAbort || !appInsights.core) {
|
||||||
|
_handleError();
|
||||||
|
}
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function _createScript() {
|
||||||
|
var scriptElement = doc.createElement(scriptText);
|
||||||
|
scriptElement.src = targetSrc;
|
||||||
|
|
||||||
|
// Allocate Cross origin only if defined and available
|
||||||
|
var crossOrigin = snipConfig[strCrossOrigin];
|
||||||
|
if ((crossOrigin || crossOrigin === "") && scriptElement[strCrossOrigin] != strUndefined) {
|
||||||
|
scriptElement[strCrossOrigin] = crossOrigin;
|
||||||
|
}
|
||||||
|
|
||||||
|
scriptElement.onload = _handleLoad;
|
||||||
|
scriptElement.onerror = _handleError;
|
||||||
|
|
||||||
|
// Some browsers support onload while others onreadystatechange and others both
|
||||||
|
scriptElement.onreadystatechange = function (evt, isAbort) {
|
||||||
|
if (scriptElement.readyState === "loaded" || scriptElement.readyState === "complete") {
|
||||||
|
_handleLoad(evt, isAbort);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return scriptElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
var theScript = _createScript();
|
||||||
|
if (snipConfig.ld < 0) {
|
||||||
|
// if user wants to append tag to document head, blocking page load
|
||||||
|
var headNode = doc.getElementsByTagName("head")[0];
|
||||||
|
headNode.appendChild(theScript);
|
||||||
|
} else {
|
||||||
|
setTimeout(function () {
|
||||||
|
// Attempts to place the script tag in the same location as the first script on the page
|
||||||
|
doc.getElementsByTagName(scriptText)[0].parentNode.appendChild(theScript);
|
||||||
|
}, snipConfig.ld || 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// capture initial cookie
|
||||||
|
try {
|
||||||
|
appInsights.cookie = doc.cookie;
|
||||||
|
} catch (e) { }
|
||||||
|
|
||||||
|
function _createMethods(methods) {
|
||||||
|
while (methods.length) {
|
||||||
|
var name = methods.pop();
|
||||||
|
// Define a temporary method that queues-up a the real method call
|
||||||
|
appInsights[name] = function () {
|
||||||
|
// Capture the original arguments passed to the method
|
||||||
|
var originalArguments = arguments;
|
||||||
|
if (!loadFailed) { // If we have detected that the main script failed to load then stop queuing events that will never be processed
|
||||||
|
// Queue-up a call to the real method
|
||||||
|
appInsights.queue.push(function () {
|
||||||
|
// Invoke the real method with the captured original arguments
|
||||||
|
appInsights[name].apply(appInsights, originalArguments);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var track = "track";
|
||||||
|
var trackPage = "TrackPage";
|
||||||
|
var trackEvent = "TrackEvent";
|
||||||
|
_createMethods([track + "Event",
|
||||||
|
track + "PageView",
|
||||||
|
track + "Exception",
|
||||||
|
track + "Trace",
|
||||||
|
track + "DependencyData",
|
||||||
|
track + "Metric",
|
||||||
|
track + "PageViewPerformance",
|
||||||
|
"start" + trackPage,
|
||||||
|
"stop" + trackPage,
|
||||||
|
"start" + trackEvent,
|
||||||
|
"stop" + trackEvent,
|
||||||
|
"addTelemetryInitializer",
|
||||||
|
"setAuthenticatedUserContext",
|
||||||
|
"clearAuthenticatedUserContext",
|
||||||
|
"flush"]);
|
||||||
|
|
||||||
|
// expose SeverityLevel enum
|
||||||
|
appInsights['SeverityLevel'] = {
|
||||||
|
Verbose : 0,
|
||||||
|
Information : 1,
|
||||||
|
Warning : 2,
|
||||||
|
Error : 3,
|
||||||
|
Critical : 4
|
||||||
};
|
};
|
||||||
aiConfig.autoExceptionInstrumented = true;
|
|
||||||
|
// Collect global errors
|
||||||
|
// Note: ApplicationInsightsAnalytics is the extension string identifier for
|
||||||
|
// AppAnalytics. It is defined in ApplicationInsights.ts:ApplicationInsights.identifer
|
||||||
|
var analyticsCfg = ((aiConfig.extensionConfig || {}).ApplicationInsightsAnalytics ||{});
|
||||||
|
if (!(aiConfig[strDisableExceptionTracking] === true || analyticsCfg[strDisableExceptionTracking] === true)) {
|
||||||
|
method = "onerror";
|
||||||
|
_createMethods(["_" + method]);
|
||||||
|
var originalOnError = win[method];
|
||||||
|
win[method] = function(message, url, lineNumber, columnNumber, error) {
|
||||||
|
var handled = originalOnError && originalOnError(message, url, lineNumber, columnNumber, error);
|
||||||
|
if (handled !== true) {
|
||||||
|
appInsights["_" + method]({
|
||||||
|
message: message,
|
||||||
|
url: url,
|
||||||
|
lineNumber: lineNumber,
|
||||||
|
columnNumber: columnNumber,
|
||||||
|
error: error
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return handled;
|
||||||
|
};
|
||||||
|
aiConfig.autoExceptionInstrumented = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return appInsights;
|
||||||
|
})(snipConfig.cfg);
|
||||||
|
|
||||||
|
// global instance must be set in this order to mitigate issues in ie8 and lower
|
||||||
|
win[aiName] = aisdk;
|
||||||
|
|
||||||
|
// if somebody calls the snippet twice, don't report page view again
|
||||||
|
if (aisdk.queue && aisdk.queue.length === 0) {
|
||||||
|
aisdk.trackPageView({});
|
||||||
}
|
}
|
||||||
|
})(window, document, {
|
||||||
return appInsights;
|
src: "https://az416426.vo.msecnd.net/scripts/b/ai.2.min.js", // The SDK URL Source
|
||||||
})({
|
//name: "appInsights", // Global SDK Instance name defaults to "appInsights" when not supplied
|
||||||
instrumentationKey: "INSTRUMENTATION_KEY"
|
//ld: 0, // Defines the load delay (in ms) before attempting to load the sdk. -1 = block page load and add to head. (default) = 0ms load after timeout,
|
||||||
});
|
//useXhr: 1, // Use XHR instead of fetch to report failures (if available),
|
||||||
|
//crossOrigin: "anonymous", // When supplied this will add the provided value as the cross origin attribute on the script tag
|
||||||
// global instance must be set in this order to mitigate issues in ie8 and lower
|
cfg: { // Application Insights Configuration
|
||||||
window[aiName] = aisdk;
|
instrumentationKey: "INSTRUMENTATION_KEY"
|
||||||
|
}
|
||||||
// if somebody calls the snippet twice, don't report page view again
|
});
|
||||||
if (aisdk.queue && aisdk.queue.length === 0) {
|
|
||||||
aisdk.trackPageView({});
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
var sdkInstance="appInsightsSDK";window[sdkInstance]="appInsights";var aiName=window[sdkInstance],aisdk=window[aiName]||function(n){var o={config:n,initialize:!0},t=document,e=window,i="script";setTimeout(function(){var e=t.createElement(i);e.src=n.url||"https://az416426.vo.msecnd.net/scripts/b/ai.2.min.js",t.getElementsByTagName(i)[0].parentNode.appendChild(e)});try{o.cookie=t.cookie}catch(e){}function a(n){o[n]=function(){var e=arguments;o.queue.push(function(){o[n].apply(o,e)})}}o.queue=[],o.version=2;for(var s=["Event","PageView","Exception","Trace","DependencyData","Metric","PageViewPerformance"];s.length;)a("track"+s.pop());var r="Track",c=r+"Page";a("start"+c),a("stop"+c);var u=r+"Event";if(a("start"+u),a("stop"+u),a("addTelemetryInitializer"),a("setAuthenticatedUserContext"),a("clearAuthenticatedUserContext"),a("flush"),o.SeverityLevel={Verbose:0,Information:1,Warning:2,Error:3,Critical:4},!(!0===n.disableExceptionTracking||n.extensionConfig&&n.extensionConfig.ApplicationInsightsAnalytics&&!0===n.extensionConfig.ApplicationInsightsAnalytics.disableExceptionTracking)){a("_"+(s="onerror"));var p=e[s];e[s]=function(e,n,t,i,a){var r=p&&p(e,n,t,i,a);return!0!==r&&o["_"+s]({message:e,url:n,lineNumber:t,columnNumber:i,error:a}),r},n.autoExceptionInstrumented=!0}return o}(
|
!function(T,l,y){var S=T.location,u="script",k="instrumentationKey",D="ingestionendpoint",C="disableExceptionTracking",E="ai.device.",I="toLowerCase",b="crossOrigin",w="POST",e="appInsightsSDK",t=y.name||"appInsights";(y.name||T[e])&&(T[e]=t);var n=T[t]||function(d){var g=!1,f=!1,m={initialize:!0,queue:[],sv:"3",version:2,config:d};function v(e,t){var n={},a="Browser";return n[E+"id"]=a[I](),n[E+"type"]=a,n["ai.operation.name"]=S&&S.pathname||"_unknown_",n["ai.internal.sdkVersion"]="javascript:snippet_"+(m.sv||m.version),{time:function(){var e=new Date;function t(e){var t=""+e;return 1===t.length&&(t="0"+t),t}return e.getUTCFullYear()+"-"+t(1+e.getUTCMonth())+"-"+t(e.getUTCDate())+"T"+t(e.getUTCHours())+":"+t(e.getUTCMinutes())+":"+t(e.getUTCSeconds())+"."+((e.getUTCMilliseconds()/1e3).toFixed(3)+"").slice(2,5)+"Z"}(),iKey:e,name:"Microsoft.ApplicationInsights."+e.replace(/-/g,"")+"."+t,sampleRate:100,tags:n,data:{baseData:{ver:2}}}}var h=d.url||y.src;if(h){function a(e){var t,n,a,i,r,o,s,c,p,l,u;g=!0,m.queue=[],f||(f=!0,t=h,s=function(){var e={},t=d.connectionString;if(t)for(var n=t.split(";"),a=0;a<n.length;a++){var i=n[a].split("=");2===i.length&&(e[i[0][I]()]=i[1])}if(!e[D]){var r=e.endpointsuffix,o=r?e.location:null;e[D]="https://"+(o?o+".":"")+"dc."+(r||"services.visualstudio.com")}return e}(),c=s[k]||d[k]||"",p=s[D],l=p?p+"/v2/track":config.endpointUrl,(u=[]).push((n="SDK LOAD Failure: Failed to load Application Insights SDK script (See stack for details)",a=t,i=l,(o=(r=v(c,"Exception")).data).baseType="ExceptionData",o.baseData.exceptions=[{typeName:"SDKLoadFailed",message:n.replace(/\./g,"-"),hasFullStack:!1,stack:n+"\nSnippet failed to load ["+a+"] -- Telemetry is disabled\nHelp Link: https://go.microsoft.com/fwlink/?linkid=2128109\nHost: "+(S&&S.pathname||"_unknown_")+"\nEndpoint: "+i,parsedStack:[]}],r)),u.push(function(e,t,n,a){var i=v(c,"Message"),r=i.data;r.baseType="MessageData";var o=r.baseData;return o.message='AI (Internal): 99 message:"'+("SDK LOAD Failure: Failed to load Application Insights SDK script (See stack for details) ("+n+")").replace(/\"/g,"")+'"',o.properties={endpoint:a},i}(0,0,t,l)),function(e,t){if(JSON){var n=T.fetch;if(n&&!y.useXhr)n(t,{method:w,body:JSON.stringify(e),mode:"cors"});else if(XMLHttpRequest){var a=new XMLHttpRequest;a.open(w,t),a.setRequestHeader("Content-type","application/json"),a.send(JSON.stringify(e))}}}(u,l))}function i(e,t){f||setTimeout(function(){!t&&m.core||a()},500)}var e=function(){var n=l.createElement(u);n.src=h;var e=y[b];return!e&&""!==e||"undefined"==n[b]||(n[b]=e),n.onload=i,n.onerror=a,n.onreadystatechange=function(e,t){"loaded"!==n.readyState&&"complete"!==n.readyState||i(0,t)},n}();y.ld<0?l.getElementsByTagName("head")[0].appendChild(e):setTimeout(function(){l.getElementsByTagName(u)[0].parentNode.appendChild(e)},y.ld||0)}try{m.cookie=l.cookie}catch(p){}function t(e){for(;e.length;){var t=e.pop();m[t]=function(){var e=arguments;g||m.queue.push(function(){m[t].apply(m,e)})}}}var n="track",r="TrackPage",o="TrackEvent";t([n+"Event",n+"PageView",n+"Exception",n+"Trace",n+"DependencyData",n+"Metric",n+"PageViewPerformance","start"+r,"stop"+r,"start"+o,"stop"+o,"addTelemetryInitializer","setAuthenticatedUserContext","clearAuthenticatedUserContext","flush"]),m.SeverityLevel={Verbose:0,Information:1,Warning:2,Error:3,Critical:4};var s=(d.extensionConfig||{}).ApplicationInsightsAnalytics||{};if(!0!==d[C]&&!0!==s[C]){method="onerror",t(["_"+method]);var c=T[method];T[method]=function(e,t,n,a,i){var r=c&&c(e,t,n,a,i);return!0!==r&&m["_"+method]({message:e,url:t,lineNumber:n,columnNumber:a,error:i}),r},d.autoExceptionInstrumented=!0}return m}(y.cfg);(T[t]=n).queue&&0===n.queue.length&&n.trackPageView({})}(window,document,{
|
||||||
{
|
src: "https://az416426.vo.msecnd.net/scripts/b/ai.2.min.js", // The SDK URL Source
|
||||||
instrumentationKey:"INSTRUMENTATION_KEY"
|
//name: "appInsights", // Global SDK Instance name defaults to "appInsights" when not supplied
|
||||||
}
|
//ld: 0, // Defines the load delay (in ms) before attempting to load the sdk. -1 = block page load and add to head. (default) = 0ms load after timeout,
|
||||||
);(window[aiName]=aisdk).queue&&0===aisdk.queue.length&&aisdk.trackPageView({});
|
//useXhr: 1, // Use XHR instead of fetch to report failures (if available),
|
||||||
|
//crossOrigin: "anonymous", // When supplied this will add the provided value as the cross origin attribute on the script tag
|
||||||
|
cfg: { // Application Insights Configuration
|
||||||
|
instrumentationKey: "INSTRUMENTATION_KEY"
|
||||||
|
}});
|
|
@ -34,8 +34,8 @@ try {
|
||||||
const snippet: Snippet = _window[aiName] || ({ version: 2.0 } as any);
|
const snippet: Snippet = _window[aiName] || ({ version: 2.0 } as any);
|
||||||
|
|
||||||
// overwrite snippet with full appInsights
|
// overwrite snippet with full appInsights
|
||||||
// for 2.0 initialize only if required
|
// only initiaize if required and detected snippet version is >= 2 or not defined
|
||||||
if ((snippet.version === 2.0 && (_window[aiName] as any).initialize) || snippet.version === undefined ) {
|
if ((snippet.version >= 2.0 && (_window[aiName] as any).initialize) || snippet.version === undefined ) {
|
||||||
ApplicationInsightsContainer.getAppInsights(snippet, snippet.version);
|
ApplicationInsightsContainer.getAppInsights(snippet, snippet.version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -433,6 +433,9 @@ export class Initialization implements IApplicationInsights {
|
||||||
(function () {
|
(function () {
|
||||||
let sdkSrc = null;
|
let sdkSrc = null;
|
||||||
let isModule = false;
|
let isModule = false;
|
||||||
|
let cdns: string[] = [
|
||||||
|
"://az416426.vo.msecnd.net/"
|
||||||
|
];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Try and determine whether the sdk is being loaded from the CDN
|
// Try and determine whether the sdk is being loaded from the CDN
|
||||||
|
@ -455,19 +458,20 @@ export class Initialization implements IApplicationInsights {
|
||||||
let url = sdkSrc.toLowerCase();
|
let url = sdkSrc.toLowerCase();
|
||||||
if (url) {
|
if (url) {
|
||||||
let src = "";
|
let src = "";
|
||||||
if (url.indexOf("://az416426.vo.msecnd.net/") !== -1) {
|
for (let idx = 0; idx < cdns.length; idx++) {
|
||||||
src = "cdn1";
|
if (url.indexof(cdns[idx]) !== -1) {
|
||||||
if (url.indexOf("/scripts/") === -1) {
|
src = "cdn" + (idx + 1);
|
||||||
if (url.indexOf("/next/") !== -1) {
|
if (url.indexOf("/scripts/") === -1) {
|
||||||
src += "-next";
|
if (url.indexOf("/next/") !== -1) {
|
||||||
} else if (url.indexOf("/beta/") !== -1) {
|
src += "-next";
|
||||||
src += "-beta";
|
} else if (url.indexOf("/beta/") !== -1) {
|
||||||
|
src += "-beta";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (src) {
|
_internalSdkSrc = src + (isModule ? ".mod" : "");
|
||||||
_internalSdkSrc = src + (isModule ? ".mod" : "");
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
24
README.md
24
README.md
|
@ -59,14 +59,28 @@ If your app does not use NPM, you can directly instrument your webpages with App
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var sdkInstance="appInsightsSDK";window[sdkInstance]="appInsights";var aiName=window[sdkInstance],aisdk=window[aiName]||function(n){var o={config:n,initialize:!0},t=document,e=window,i="script";setTimeout(function(){var e=t.createElement(i);e.src=n.url||"https://az416426.vo.msecnd.net/scripts/b/ai.2.min.js",t.getElementsByTagName(i)[0].parentNode.appendChild(e)});try{o.cookie=t.cookie}catch(e){}function a(n){o[n]=function(){var e=arguments;o.queue.push(function(){o[n].apply(o,e)})}}o.queue=[],o.version=2;for(var s=["Event","PageView","Exception","Trace","DependencyData","Metric","PageViewPerformance"];s.length;)a("track"+s.pop());var r="Track",c=r+"Page";a("start"+c),a("stop"+c);var u=r+"Event";if(a("start"+u),a("stop"+u),a("addTelemetryInitializer"),a("setAuthenticatedUserContext"),a("clearAuthenticatedUserContext"),a("flush"),o.SeverityLevel={Verbose:0,Information:1,Warning:2,Error:3,Critical:4},!(!0===n.disableExceptionTracking||n.extensionConfig&&n.extensionConfig.ApplicationInsightsAnalytics&&!0===n.extensionConfig.ApplicationInsightsAnalytics.disableExceptionTracking)){a("_"+(s="onerror"));var p=e[s];e[s]=function(e,n,t,i,a){var r=p&&p(e,n,t,i,a);return!0!==r&&o["_"+s]({message:e,url:n,lineNumber:t,columnNumber:i,error:a}),r},n.autoExceptionInstrumented=!0}return o}(
|
!function(T,l,y){var S=T.location,u="script",k="instrumentationKey",D="ingestionendpoint",C="disableExceptionTracking",E="ai.device.",I="toLowerCase",b="crossOrigin",w="POST",e="appInsightsSDK",t=y.name||"appInsights";(y.name||T[e])&&(T[e]=t);var n=T[t]||function(d){var g=!1,f=!1,m={initialize:!0,queue:[],sv:"3",version:2,config:d};function v(e,t){var n={},a="Browser";return n[E+"id"]=a[I](),n[E+"type"]=a,n["ai.operation.name"]=S&&S.pathname||"_unknown_",n["ai.internal.sdkVersion"]="javascript:snippet_"+(m.sv||m.version),{time:function(){var e=new Date;function t(e){var t=""+e;return 1===t.length&&(t="0"+t),t}return e.getUTCFullYear()+"-"+t(1+e.getUTCMonth())+"-"+t(e.getUTCDate())+"T"+t(e.getUTCHours())+":"+t(e.getUTCMinutes())+":"+t(e.getUTCSeconds())+"."+((e.getUTCMilliseconds()/1e3).toFixed(3)+"").slice(2,5)+"Z"}(),iKey:e,name:"Microsoft.ApplicationInsights."+e.replace(/-/g,"")+"."+t,sampleRate:100,tags:n,data:{baseData:{ver:2}}}}var h=d.url||y.src;if(h){function a(e){var t,n,a,i,r,o,s,c,p,l,u;g=!0,m.queue=[],f||(f=!0,t=h,s=function(){var e={},t=d.connectionString;if(t)for(var n=t.split(";"),a=0;a<n.length;a++){var i=n[a].split("=");2===i.length&&(e[i[0][I]()]=i[1])}if(!e[D]){var r=e.endpointsuffix,o=r?e.location:null;e[D]="https://"+(o?o+".":"")+"dc."+(r||"services.visualstudio.com")}return e}(),c=s[k]||d[k]||"",p=s[D],l=p?p+"/v2/track":config.endpointUrl,(u=[]).push((n="SDK LOAD Failure: Failed to load Application Insights SDK script (See stack for details)",a=t,i=l,(o=(r=v(c,"Exception")).data).baseType="ExceptionData",o.baseData.exceptions=[{typeName:"SDKLoadFailed",message:n.replace(/\./g,"-"),hasFullStack:!1,stack:n+"\nSnippet failed to load ["+a+"] -- Telemetry is disabled\nHelp Link: https://go.microsoft.com/fwlink/?linkid=2128109\nHost: "+(S&&S.pathname||"_unknown_")+"\nEndpoint: "+i,parsedStack:[]}],r)),u.push(function(e,t,n,a){var i=v(c,"Message"),r=i.data;r.baseType="MessageData";var o=r.baseData;return o.message='AI (Internal): 99 message:"'+("SDK LOAD Failure: Failed to load Application Insights SDK script (See stack for details) ("+n+")").replace(/\"/g,"")+'"',o.properties={endpoint:a},i}(0,0,t,l)),function(e,t){if(JSON){var n=T.fetch;if(n&&!y.useXhr)n(t,{method:w,body:JSON.stringify(e),mode:"cors"});else if(XMLHttpRequest){var a=new XMLHttpRequest;a.open(w,t),a.setRequestHeader("Content-type","application/json"),a.send(JSON.stringify(e))}}}(u,l))}function i(e,t){f||setTimeout(function(){!t&&m.core||a()},500)}var e=function(){var n=l.createElement(u);n.src=h;var e=y[b];return!e&&""!==e||"undefined"==n[b]||(n[b]=e),n.onload=i,n.onerror=a,n.onreadystatechange=function(e,t){"loaded"!==n.readyState&&"complete"!==n.readyState||i(0,t)},n}();y.ld<0?l.getElementsByTagName("head")[0].appendChild(e):setTimeout(function(){l.getElementsByTagName(u)[0].parentNode.appendChild(e)},y.ld||0)}try{m.cookie=l.cookie}catch(p){}function t(e){for(;e.length;){var t=e.pop();m[t]=function(){var e=arguments;g||m.queue.push(function(){m[t].apply(m,e)})}}}var n="track",r="TrackPage",o="TrackEvent";t([n+"Event",n+"PageView",n+"Exception",n+"Trace",n+"DependencyData",n+"Metric",n+"PageViewPerformance","start"+r,"stop"+r,"start"+o,"stop"+o,"addTelemetryInitializer","setAuthenticatedUserContext","clearAuthenticatedUserContext","flush"]),m.SeverityLevel={Verbose:0,Information:1,Warning:2,Error:3,Critical:4};var s=(d.extensionConfig||{}).ApplicationInsightsAnalytics||{};if(!0!==d[C]&&!0!==s[C]){method="onerror",t(["_"+method]);var c=T[method];T[method]=function(e,t,n,a,i){var r=c&&c(e,t,n,a,i);return!0!==r&&m["_"+method]({message:e,url:t,lineNumber:n,columnNumber:a,error:i}),r},d.autoExceptionInstrumented=!0}return m}(y.cfg);(T[t]=n).queue&&0===n.queue.length&&n.trackPageView({})}(window,document,{
|
||||||
{
|
src: "https://az416426.vo.msecnd.net/scripts/b/ai.2.min.js", // The SDK URL Source
|
||||||
instrumentationKey:"INSTRUMENTATION_KEY"
|
//name: "appInsights", // Global SDK Instance name defaults to "appInsights" when not supplied
|
||||||
}
|
//ld: 0, // Defines the load delay (in ms) before attempting to load the sdk. -1 = block page load and add to head. (default) = 0ms load after timeout,
|
||||||
);(window[aiName]=aisdk).queue&&0===aisdk.queue.length&&aisdk.trackPageView({});
|
//useXhr: 1, // Use XHR instead of fetch to report failures (if available),
|
||||||
|
//crossOrigin: "anonymous", // When supplied this will add the provided value as the cross origin attribute on the script tag
|
||||||
|
cfg: { // Application Insights Configuration
|
||||||
|
instrumentationKey: "INSTRUMENTATION_KEY"
|
||||||
|
}});
|
||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The snippet supports reporting sdk script load failures as exceptions to the portal, this type of error would cause your application/website to either not report any telemetry or in some extreme cases become unstable due to excessive queuing of events which are never sent.
|
||||||
|
|
||||||
|
It also supports some additional snippet specific configuration.
|
||||||
|
- src (string) [required] - The URL of the SDK version to load
|
||||||
|
- name (string) [optional] - The global SDK instance name to use, defaults to appInsights
|
||||||
|
- ld (number in ms) [optional] - Defines the load delay to wait before attempting to load the SDK. Default value is 0ms and any negative value will just add a script tag to the page head and will block the page load event.
|
||||||
|
- useXhr (boolean) [optional] - This setting is specifically for the reporting of SDK load failures. Reporting will first use fetch() if available and then fallback to XHR, setting this value to true just bypasses the fetch check. Use of this value would only be required if you know your app/site is being used in an environment where fetch would fail to send the failure events.
|
||||||
|
- crossOrigin (string) [optional] - By including this setting the script tag used to download the SDK will include the crossOrigin attribute with this string value. When not defined (the default) no crossOrigin attribute is added. Recommended values are not defined (the default); ""; or "anonymous" (For all valid values see https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin)
|
||||||
|
- cfg (object) - This is the Application Insights configuration that is used to initialize your sdk.
|
||||||
|
|
||||||
### Connection String Setup
|
### Connection String Setup
|
||||||
|
|
||||||
For either the NPM or Snippet setup, you can also configure your instance of Application Insights using a Connection String. Simply replace the `instrumentationKey` field with the `connectionString` field.
|
For either the NPM or Snippet setup, you can also configure your instance of Application Insights using a Connection String. Simply replace the `instrumentationKey` field with the `connectionString` field.
|
||||||
|
|
|
@ -25,14 +25,14 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@babel/generator": {
|
"@babel/generator": {
|
||||||
"version": "7.9.4",
|
"version": "7.9.5",
|
||||||
"from": "@babel/generator@^7.9.0",
|
"from": "@babel/generator@^7.9.0",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.9.4.tgz"
|
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.9.5.tgz"
|
||||||
},
|
},
|
||||||
"@babel/helper-function-name": {
|
"@babel/helper-function-name": {
|
||||||
"version": "7.8.3",
|
"version": "7.9.5",
|
||||||
"from": "@babel/helper-function-name@^7.8.3",
|
"from": "@babel/helper-function-name@^7.9.5",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.8.3.tgz"
|
"resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.9.5.tgz"
|
||||||
},
|
},
|
||||||
"@babel/helper-get-function-arity": {
|
"@babel/helper-get-function-arity": {
|
||||||
"version": "7.8.3",
|
"version": "7.8.3",
|
||||||
|
@ -80,9 +80,9 @@
|
||||||
"resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.8.3.tgz"
|
"resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.8.3.tgz"
|
||||||
},
|
},
|
||||||
"@babel/helper-validator-identifier": {
|
"@babel/helper-validator-identifier": {
|
||||||
"version": "7.9.0",
|
"version": "7.9.5",
|
||||||
"from": "@babel/helper-validator-identifier@^7.9.0",
|
"from": "@babel/helper-validator-identifier@^7.9.0",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.9.0.tgz"
|
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.9.5.tgz"
|
||||||
},
|
},
|
||||||
"@babel/helpers": {
|
"@babel/helpers": {
|
||||||
"version": "7.9.2",
|
"version": "7.9.2",
|
||||||
|
@ -132,9 +132,9 @@
|
||||||
"resolved": "https://registry.npmjs.org/@babel/template/-/template-7.8.6.tgz"
|
"resolved": "https://registry.npmjs.org/@babel/template/-/template-7.8.6.tgz"
|
||||||
},
|
},
|
||||||
"@babel/traverse": {
|
"@babel/traverse": {
|
||||||
"version": "7.9.0",
|
"version": "7.9.5",
|
||||||
"from": "@babel/traverse@^7.9.0",
|
"from": "@babel/traverse@^7.9.0",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.9.0.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.9.5.tgz",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"debug": {
|
"debug": {
|
||||||
"version": "4.1.1",
|
"version": "4.1.1",
|
||||||
|
@ -149,9 +149,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@babel/types": {
|
"@babel/types": {
|
||||||
"version": "7.9.0",
|
"version": "7.9.5",
|
||||||
"from": "@babel/types@^7.9.0",
|
"from": "@babel/types@^7.9.0",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.9.0.tgz"
|
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.9.5.tgz"
|
||||||
},
|
},
|
||||||
"@cnakazawa/watch": {
|
"@cnakazawa/watch": {
|
||||||
"version": "1.0.4",
|
"version": "1.0.4",
|
||||||
|
@ -648,9 +648,9 @@
|
||||||
"resolved": "https://registry.npmjs.org/airbnb-prop-types/-/airbnb-prop-types-2.15.0.tgz"
|
"resolved": "https://registry.npmjs.org/airbnb-prop-types/-/airbnb-prop-types-2.15.0.tgz"
|
||||||
},
|
},
|
||||||
"ajv": {
|
"ajv": {
|
||||||
"version": "6.12.0",
|
"version": "6.12.2",
|
||||||
"from": "ajv@^6.5.5",
|
"from": "ajv@^6.5.5",
|
||||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.0.tgz"
|
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.2.tgz"
|
||||||
},
|
},
|
||||||
"ansi-escapes": {
|
"ansi-escapes": {
|
||||||
"version": "3.2.0",
|
"version": "3.2.0",
|
||||||
|
@ -3257,9 +3257,9 @@
|
||||||
"resolved": "https://registry.npmjs.org/ncp/-/ncp-0.5.1.tgz"
|
"resolved": "https://registry.npmjs.org/ncp/-/ncp-0.5.1.tgz"
|
||||||
},
|
},
|
||||||
"nearley": {
|
"nearley": {
|
||||||
"version": "2.19.1",
|
"version": "2.19.2",
|
||||||
"from": "nearley@^2.7.10",
|
"from": "nearley@^2.7.10",
|
||||||
"resolved": "https://registry.npmjs.org/nearley/-/nearley-2.19.1.tgz",
|
"resolved": "https://registry.npmjs.org/nearley/-/nearley-2.19.2.tgz",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"commander": {
|
"commander": {
|
||||||
"version": "2.20.3",
|
"version": "2.20.3",
|
||||||
|
@ -3358,9 +3358,9 @@
|
||||||
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.7.0.tgz"
|
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.7.0.tgz"
|
||||||
},
|
},
|
||||||
"object-is": {
|
"object-is": {
|
||||||
"version": "1.0.2",
|
"version": "1.1.2",
|
||||||
"from": "object-is@^1.0.2",
|
"from": "object-is@^1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/object-is/-/object-is-1.0.2.tgz"
|
"resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.2.tgz"
|
||||||
},
|
},
|
||||||
"object-keys": {
|
"object-keys": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
|
@ -3842,9 +3842,9 @@
|
||||||
"resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz"
|
"resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz"
|
||||||
},
|
},
|
||||||
"resolve": {
|
"resolve": {
|
||||||
"version": "1.15.1",
|
"version": "1.16.1",
|
||||||
"from": "resolve@^1.10.0",
|
"from": "resolve@^1.10.0",
|
||||||
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.15.1.tgz"
|
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.16.1.tgz"
|
||||||
},
|
},
|
||||||
"resolve-cwd": {
|
"resolve-cwd": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
|
@ -3970,15 +3970,10 @@
|
||||||
"from": "commander@~2.20.3",
|
"from": "commander@~2.20.3",
|
||||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz"
|
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz"
|
||||||
},
|
},
|
||||||
"source-map": {
|
|
||||||
"version": "0.6.1",
|
|
||||||
"from": "source-map@>=0.6.1 <0.7.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz"
|
|
||||||
},
|
|
||||||
"uglify-js": {
|
"uglify-js": {
|
||||||
"version": "3.8.1",
|
"version": "3.9.1",
|
||||||
"from": "uglify-js@^3.4.9",
|
"from": "uglify-js@^3.4.9",
|
||||||
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.8.1.tgz"
|
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.9.1.tgz"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -4243,9 +4238,9 @@
|
||||||
"resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.3.tgz"
|
"resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.3.tgz"
|
||||||
},
|
},
|
||||||
"source-map-support": {
|
"source-map-support": {
|
||||||
"version": "0.5.16",
|
"version": "0.5.17",
|
||||||
"from": "source-map-support@^0.5.6",
|
"from": "source-map-support@^0.5.6",
|
||||||
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.16.tgz",
|
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.17.tgz",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"source-map": {
|
"source-map": {
|
||||||
"version": "0.6.1",
|
"version": "0.6.1",
|
||||||
|
@ -4270,9 +4265,9 @@
|
||||||
"resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.0.tgz"
|
"resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.0.tgz"
|
||||||
},
|
},
|
||||||
"spdx-exceptions": {
|
"spdx-exceptions": {
|
||||||
"version": "2.2.0",
|
"version": "2.3.0",
|
||||||
"from": "spdx-exceptions@^2.1.0",
|
"from": "spdx-exceptions@^2.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.2.0.tgz"
|
"resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz"
|
||||||
},
|
},
|
||||||
"spdx-expression-parse": {
|
"spdx-expression-parse": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
|
@ -4371,9 +4366,9 @@
|
||||||
"resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.1.tgz"
|
"resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.1.tgz"
|
||||||
},
|
},
|
||||||
"string.prototype.trimend": {
|
"string.prototype.trimend": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"from": "string.prototype.trimend@^1.0.0",
|
"from": "string.prototype.trimend@^1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.0.tgz"
|
"resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.1.tgz"
|
||||||
},
|
},
|
||||||
"string.prototype.trimleft": {
|
"string.prototype.trimleft": {
|
||||||
"version": "2.1.2",
|
"version": "2.1.2",
|
||||||
|
@ -4386,9 +4381,9 @@
|
||||||
"resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.2.tgz"
|
"resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.2.tgz"
|
||||||
},
|
},
|
||||||
"string.prototype.trimstart": {
|
"string.prototype.trimstart": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"from": "string.prototype.trimstart@^1.0.0",
|
"from": "string.prototype.trimstart@^1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.0.tgz"
|
"resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.1.tgz"
|
||||||
},
|
},
|
||||||
"strip-ansi": {
|
"strip-ansi": {
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
|
|
11
gruntfile.js
11
gruntfile.js
|
@ -228,6 +228,17 @@ module.exports = function (grunt) {
|
||||||
snippetvNext: {
|
snippetvNext: {
|
||||||
files: {
|
files: {
|
||||||
'AISKU/snippet/snippet.min.js': ['AISKU/snippet/snippet.js']
|
'AISKU/snippet/snippet.min.js': ['AISKU/snippet/snippet.js']
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
sourceMap: false,
|
||||||
|
ie8: true,
|
||||||
|
compress: {
|
||||||
|
passes:3,
|
||||||
|
unsafe: true,
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
webkit:true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -215,10 +215,9 @@ export interface IConfig {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Used when initizialing from snippet only.
|
* @deprecated Used when initizialing from snippet only.
|
||||||
* @description The url from where the JS SDK will be downloaded. Default 'https://az416426.vo.msecnd.net/scripts/beta/ai.1.js'
|
* @description The url from where the JS SDK will be downloaded.
|
||||||
* @type {string}
|
* @type {string}
|
||||||
* @memberof IConfig
|
* @memberof IConfig
|
||||||
* @defaultValue "https://az416426.vo.msecnd.net/scripts/beta/ai.1.js"
|
|
||||||
*/
|
*/
|
||||||
url?: string;
|
url?: string;
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,7 @@ export const _InternalMessageId = {
|
||||||
InvalidEvent: 70,
|
InvalidEvent: 70,
|
||||||
FailedMonitorAjaxSetRequestHeader: 71,
|
FailedMonitorAjaxSetRequestHeader: 71,
|
||||||
SendBrowserInfoOnUserInit: 72,
|
SendBrowserInfoOnUserInit: 72,
|
||||||
PluginException: 73
|
PluginException: 73,
|
||||||
|
SnippetScriptLoadFailure: 99
|
||||||
};
|
};
|
||||||
export type _InternalMessageId = number | typeof _InternalMessageId;
|
export type _InternalMessageId = number | typeof _InternalMessageId;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче