From 5cb9e44cfd8eef63099c5ecd5b11d8cb9fb81697 Mon Sep 17 00:00:00 2001 From: Nev <54870357+MSNev@users.noreply.github.com> Date: Fri, 1 May 2020 09:47:19 -0700 Subject: [PATCH] Update snippet to support reporting script load failures (#1258) - New Snippet Setup pollutes the global namespace (window) #974 --- AISKU/snippet/snippet.js | 409 +++++++++++++----- AISKU/snippet/snippet.min.js | 14 +- AISKU/src/Init.ts | 4 +- AISKU/src/Initialization.ts | 26 +- README.md | 24 +- common/config/rush/npm-shrinkwrap.json | 63 ++- gruntfile.js | 11 + .../src/Interfaces/IConfig.ts | 3 +- .../src/JavaScriptSDK.Enums/LoggingEnums.ts | 3 +- 9 files changed, 397 insertions(+), 160 deletions(-) diff --git a/AISKU/snippet/snippet.js b/AISKU/snippet/snippet.js index 4e36d0a3..9de4ee5a 100644 --- a/AISKU/snippet/snippet.js +++ b/AISKU/snippet/snippet.js @@ -1,106 +1,315 @@ -var sdkInstance = "appInsightsSDK"; -window[sdkInstance] = "appInsights"; -var aiName = window[sdkInstance]; // provide non default instance name through key appInsightsSDK -var aisdk = window[aiName] || (function (aiConfig) { - var appInsights = { - config: aiConfig - }; - appInsights.initialize = true; // initialize sdk on download +(function (win, doc, snipConfig) { + var locn = win.location; + var helpLink = "https://go.microsoft.com/fwlink/?linkid=2128109"; + var scriptText = "script"; + var strInstrumentationKey = "instrumentationKey"; + var strIngestionendpoint = "ingestionendpoint"; + var strDisableExceptionTracking = "disableExceptionTracking"; + 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 localDocument = document, localWindow = window, scriptText = "script"; - setTimeout(function () { - var scriptElement = localDocument.createElement(scriptText); - scriptElement.src = aiConfig.url || "https://az416426.vo.msecnd.net/scripts/b/ai.2.min.js"; - localDocument.getElementsByTagName(scriptText)[0].parentNode.appendChild(scriptElement); - }); - - // capture initial cookie - try { - appInsights.cookie = localDocument.cookie; - } catch (e) { } - - appInsights.queue = []; - appInsights.version = 2.0; - - 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); - }); + var strPostMethod = "POST"; + var sdkInstanceName = "appInsightsSDK"; // required for Initialization to find the current instance + var aiName = snipConfig.name || "appInsights"; // provide non default instance name through snipConfig name value + if (snipConfig.name || win[sdkInstanceName]) { + // Only set if supplied or another name is defined to avoid polluting the global namespace + win[sdkInstanceName] = aiName; + } + var aisdk = win[aiName] || (function (aiConfig) { + var loadFailed = false; + var handled = false; + var appInsights = { + initialize: true, // initialize sdk on download + queue: [], + sv: "3", // Track the actual snippet version for reporting. + version: 2.0, // initialization version, if this is not 2.0 the previous scripts fail to initialize + config: aiConfig }; - } - - var method = ["Event", "PageView", "Exception", "Trace", "DependencyData", "Metric", "PageViewPerformance"]; - while (method.length) { - createLazyMethod("track" + method.pop()); - } - - var track = "Track"; - var trackPage = track + "Page"; - createLazyMethod("start" + trackPage); - 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 - }); + function _parseConnectionString() { + var fields = {}; + var connectionString = aiConfig.connectionString; + if (connectionString) { + var kvPairs = connectionString.split(";"); + for (var lp = 0; lp < kvPairs.length; lp++) { + var kvParts = kvPairs[lp].split("="); + + if (kvParts.length === 2) { // only save fields with valid formats + fields[kvParts[0][strToLowerCase]()] = kvParts[1]; + } + } } - 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({}); } - - return appInsights; -})({ - instrumentationKey: "INSTRUMENTATION_KEY" - }); - -// global instance must be set in this order to mitigate issues in ie8 and lower -window[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, { + 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 + //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 + cfg: { // Application Insights Configuration + instrumentationKey: "INSTRUMENTATION_KEY" + } +}); diff --git a/AISKU/snippet/snippet.min.js b/AISKU/snippet/snippet.min.js index f5847014..e7cf624a 100644 --- a/AISKU/snippet/snippet.min.js +++ b/AISKU/snippet/snippet.min.js @@ -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}( -{ - instrumentationKey:"INSTRUMENTATION_KEY" -} -);(window[aiName]=aisdk).queue&&0===aisdk.queue.length&&aisdk.trackPageView({}); +!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= 2 or not defined + if ((snippet.version >= 2.0 && (_window[aiName] as any).initialize) || snippet.version === undefined ) { ApplicationInsightsContainer.getAppInsights(snippet, snippet.version); } } diff --git a/AISKU/src/Initialization.ts b/AISKU/src/Initialization.ts index 41e518b5..ea878492 100644 --- a/AISKU/src/Initialization.ts +++ b/AISKU/src/Initialization.ts @@ -433,6 +433,9 @@ export class Initialization implements IApplicationInsights { (function () { let sdkSrc = null; let isModule = false; + let cdns: string[] = [ + "://az416426.vo.msecnd.net/" + ]; try { // 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(); if (url) { let src = ""; - if (url.indexOf("://az416426.vo.msecnd.net/") !== -1) { - src = "cdn1"; - if (url.indexOf("/scripts/") === -1) { - if (url.indexOf("/next/") !== -1) { - src += "-next"; - } else if (url.indexOf("/beta/") !== -1) { - src += "-beta"; + for (let idx = 0; idx < cdns.length; idx++) { + if (url.indexof(cdns[idx]) !== -1) { + src = "cdn" + (idx + 1); + if (url.indexOf("/scripts/") === -1) { + if (url.indexOf("/next/") !== -1) { + src += "-next"; + } else if (url.indexOf("/beta/") !== -1) { + src += "-beta"; + } } - } - } - if (src) { - _internalSdkSrc = src + (isModule ? ".mod" : ""); + _internalSdkSrc = src + (isModule ? ".mod" : ""); + break; + } } } } catch (e) { diff --git a/README.md b/README.md index 69e60301..7a340120 100644 --- a/README.md +++ b/README.md @@ -59,14 +59,28 @@ If your app does not use NPM, you can directly instrument your webpages with App ```html ``` +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 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. diff --git a/common/config/rush/npm-shrinkwrap.json b/common/config/rush/npm-shrinkwrap.json index d9cc7d3f..d306e249 100644 --- a/common/config/rush/npm-shrinkwrap.json +++ b/common/config/rush/npm-shrinkwrap.json @@ -25,14 +25,14 @@ } }, "@babel/generator": { - "version": "7.9.4", + "version": "7.9.5", "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": { - "version": "7.8.3", - "from": "@babel/helper-function-name@^7.8.3", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.8.3.tgz" + "version": "7.9.5", + "from": "@babel/helper-function-name@^7.9.5", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.9.5.tgz" }, "@babel/helper-get-function-arity": { "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" }, "@babel/helper-validator-identifier": { - "version": "7.9.0", + "version": "7.9.5", "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": { "version": "7.9.2", @@ -132,9 +132,9 @@ "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.8.6.tgz" }, "@babel/traverse": { - "version": "7.9.0", + "version": "7.9.5", "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": { "debug": { "version": "4.1.1", @@ -149,9 +149,9 @@ } }, "@babel/types": { - "version": "7.9.0", + "version": "7.9.5", "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": { "version": "1.0.4", @@ -648,9 +648,9 @@ "resolved": "https://registry.npmjs.org/airbnb-prop-types/-/airbnb-prop-types-2.15.0.tgz" }, "ajv": { - "version": "6.12.0", + "version": "6.12.2", "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": { "version": "3.2.0", @@ -3257,9 +3257,9 @@ "resolved": "https://registry.npmjs.org/ncp/-/ncp-0.5.1.tgz" }, "nearley": { - "version": "2.19.1", + "version": "2.19.2", "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": { "commander": { "version": "2.20.3", @@ -3358,9 +3358,9 @@ "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.7.0.tgz" }, "object-is": { - "version": "1.0.2", + "version": "1.1.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": { "version": "1.1.1", @@ -3842,9 +3842,9 @@ "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz" }, "resolve": { - "version": "1.15.1", + "version": "1.16.1", "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": { "version": "2.0.0", @@ -3970,15 +3970,10 @@ "from": "commander@~2.20.3", "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": { - "version": "3.8.1", + "version": "3.9.1", "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" }, "source-map-support": { - "version": "0.5.16", + "version": "0.5.17", "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": { "source-map": { "version": "0.6.1", @@ -4270,9 +4265,9 @@ "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.0.tgz" }, "spdx-exceptions": { - "version": "2.2.0", + "version": "2.3.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": { "version": "3.0.0", @@ -4371,9 +4366,9 @@ "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.1.tgz" }, "string.prototype.trimend": { - "version": "1.0.0", + "version": "1.0.1", "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": { "version": "2.1.2", @@ -4386,9 +4381,9 @@ "resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.2.tgz" }, "string.prototype.trimstart": { - "version": "1.0.0", + "version": "1.0.1", "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": { "version": "3.0.1", diff --git a/gruntfile.js b/gruntfile.js index 3b5ad611..12583467 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -228,6 +228,17 @@ module.exports = function (grunt) { snippetvNext: { files: { 'AISKU/snippet/snippet.min.js': ['AISKU/snippet/snippet.js'] + }, + options: { + sourceMap: false, + ie8: true, + compress: { + passes:3, + unsafe: true, + }, + output: { + webkit:true + } } } }, diff --git a/shared/AppInsightsCommon/src/Interfaces/IConfig.ts b/shared/AppInsightsCommon/src/Interfaces/IConfig.ts index 706d1221..43dc12f3 100644 --- a/shared/AppInsightsCommon/src/Interfaces/IConfig.ts +++ b/shared/AppInsightsCommon/src/Interfaces/IConfig.ts @@ -215,10 +215,9 @@ export interface IConfig { /** * @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} * @memberof IConfig - * @defaultValue "https://az416426.vo.msecnd.net/scripts/beta/ai.1.js" */ url?: string; diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Enums/LoggingEnums.ts b/shared/AppInsightsCore/src/JavaScriptSDK.Enums/LoggingEnums.ts index 1b6ff826..ed60c837 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK.Enums/LoggingEnums.ts +++ b/shared/AppInsightsCore/src/JavaScriptSDK.Enums/LoggingEnums.ts @@ -92,6 +92,7 @@ export const _InternalMessageId = { InvalidEvent: 70, FailedMonitorAjaxSetRequestHeader: 71, SendBrowserInfoOnUserInit: 72, - PluginException: 73 + PluginException: 73, + SnippetScriptLoadFailure: 99 }; export type _InternalMessageId = number | typeof _InternalMessageId;