From c9be85001d272da392e0c84964d36175734d496f Mon Sep 17 00:00:00 2001 From: Nev Wylie Date: Tue, 21 Apr 2020 13:45:55 -0700 Subject: [PATCH] Update snippet to support reporting script load failures - New Snippet Setup pollutes the global namespace (window) #974 --- AISKU/snippet/snippet.js | 394 +++++++++++++----- AISKU/snippet/snippet.min.js | 13 +- AISKU/src/Init.ts | 4 +- README.md | 22 +- common/config/rush/npm-shrinkwrap.json | 63 ++- gruntfile.js | 11 + .../src/JavaScriptSDK.Enums/LoggingEnums.ts | 3 +- 7 files changed, 365 insertions(+), 145 deletions(-) diff --git a/AISKU/snippet/snippet.js b/AISKU/snippet/snippet.js index 4e36d0a32..84c159912 100644 --- a/AISKU/snippet/snippet.js +++ b/AISKU/snippet/snippet.js @@ -1,106 +1,304 @@ -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 - - // 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); - }); - }; - } +(function (win, doc, snipConfig) { + var locn = win.location; + var helpLink = "https://aka.ms/"; + 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 method = ["Event", "PageView", "Exception", "Trace", "DependencyData", "Metric", "PageViewPerformance"]; - while (method.length) { - createLazyMethod("track" + method.pop()); + 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: [], + snipVer: 3.0, // 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 + }; + 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]; + } + } + } - 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 - }); + // 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 handled; - }; - aiConfig.autoExceptionInstrumented = true; - } + 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 App Insights Sdk script (See stack for details)"; + var evts = []; + evts.push(_createException(iKey, message, targetSrc)); + evts.push(_createInternal(iKey, message, targetSrc)); + + _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.snipVer || appInsights.version); - return appInsights; -})({ - instrumentationKey: "INSTRUMENTATION_KEY" - }); + return { + time: _getTime(), + iKey: iKey, + name: "Microsoft.ApplicationInsights." + iKey.replace(/-/g, strEmpty) + "." + theType, + sampleRate: 100, + tags: tags, + data: { + baseData: { + ver: 2 + } + } + }; + } -// global instance must be set in this order to mitigate issues in ie8 and lower -window[aiName] = aisdk; + function _createInternal(iKey, message, targetSrc) { + 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 = {}; -// if somebody calls the snippet twice, don't report page view again -if (aisdk.queue && aisdk.queue.length === 0) { - aisdk.trackPageView({}); -} + return envelope; + } + + function _createException(iKey, message, targetSrc) { + var envelope = _createEnvelope(iKey, "Exception"); + var data = envelope.data; + data.baseType = "ExceptionData"; + data.baseData.exceptions = [{ + typeName: "ScriptLoadFailed", + 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_"), + 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; + + 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 + }; + + // 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, { + 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) + cfg: { // Application Insights Configuration + instrumentationKey: "INSTRUMENTATION_KEY" + } +}); diff --git a/AISKU/snippet/snippet.min.js b/AISKU/snippet/snippet.min.js index f58470148..1eedfefbb 100644 --- a/AISKU/snippet/snippet.min.js +++ b/AISKU/snippet/snippet.min.js @@ -1,5 +1,8 @@ -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(v,T,y){var S=v.location,k="script",C="instrumentationKey",D="ingestionendpoint",E="disableExceptionTracking",I="ai.device.",b="toLowerCase",N="POST",e="appInsightsSDK",t=y.name||"appInsights";(y.name||v[e])&&(v[e]=t);var n=v[t]||function(u){var d=!1,g=!1,f={initialize:!0,queue:[],snipVer:3,version:2,config:u};function m(e,t){var n={},a="Browser";return n[I+"id"]=a[b](),n[I+"type"]=a,n["ai.operation.name"]=S&&S.pathname||"_unknown_",n["ai.internal.sdkVersion"]="javascript:snippet_"+(f.snipVer||f.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 n,h=u.url||y.src;if(h){function a(e){var t,n,a,i,r,o,s,c,p,l;d=!0,f.queue=[],g||(g=!0,t=h,o=function(){var e={},t=u.connectionString;if(t)for(var n=t.split(";"),a=0;a\nHost: "+(S&&S.pathname||"_unknown_"),parsedStack:[]}],i)),l.push(function(e,t,n){var a=m(s,"Message"),i=a.data;i.baseType="MessageData";var r=i.baseData;return r.message='AI (Internal): 99 message:"'+("SDK LOAD Failure: Failed to load App Insights Sdk script (See stack for details) ("+n+")").replace(/\"/g,"")+'"',r.properties={},a}(0,0,t)),function(e,t){if(JSON){var n=v.fetch;if(n&&!y.useXhr)n(t,{method:N,body:JSON.stringify(e),mode:"cors"});else if(XMLHttpRequest){var a=new XMLHttpRequest;a.open(N,t),a.setRequestHeader("Content-type","application/json"),a.send(JSON.stringify(e))}}}(l,p))}function i(e,t){g||setTimeout(function(){!t&&f.core||a()},500)}var e=((n=T.createElement(k)).src=h,n.onload=i,n.onerror=a,n.onreadystatechange=function(e,t){"loaded"!==n.readyState&&"complete"!==n.readyState||i(0,t)},n);y.ld<0?T.getElementsByTagName("head")[0].appendChild(e):setTimeout(function(){T.getElementsByTagName(k)[0].parentNode.appendChild(e)},y.ld||0)}try{f.cookie=T.cookie}catch(l){}function t(e){for(;e.length;){var t=e.pop();f[t]=function(){var e=arguments;d||f.queue.push(function(){f[t].apply(f,e)})}}}var r="track",o="TrackPage",s="TrackEvent";t([r+"Event",r+"PageView",r+"Exception",r+"Trace",r+"DependencyData",r+"Metric",r+"PageViewPerformance","start"+o,"stop"+o,"start"+s,"stop"+s,"addTelemetryInitializer","setAuthenticatedUserContext","clearAuthenticatedUserContext","flush"]),f.SeverityLevel={Verbose:0,Information:1,Warning:2,Error:3,Critical:4};var c=(u.extensionConfig||{}).ApplicationInsightsAnalytics||{};if(!0!==u[E]&&!0!==c[E]){method="onerror",t(["_"+method]);var p=v[method];v[method]=function(e,t,n,a,i){var r=p&&p(e,t,n,a,i);return!0!==r&&f["_"+method]({message:e,url:t,lineNumber:n,columnNumber:a,error:i}),r},u.autoExceptionInstrumented=!0}return f}(y.cfg);(v[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 +//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) +cfg: { // Application Insights Configuration + instrumentationKey: "INSTRUMENTATION_KEY" +}}); \ No newline at end of file diff --git a/AISKU/src/Init.ts b/AISKU/src/Init.ts index d3b2ab4e4..2f292adb4 100644 --- a/AISKU/src/Init.ts +++ b/AISKU/src/Init.ts @@ -34,8 +34,8 @@ try { const snippet: Snippet = _window[aiName] || ({ version: 2.0 } as any); // overwrite snippet with full appInsights - // for 2.0 initialize only if required - if ((snippet.version === 2.0 && (_window[aiName] as any).initialize) || snippet.version === undefined ) { + // 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 ) { ApplicationInsightsContainer.getAppInsights(snippet, snippet.version); } } diff --git a/README.md b/README.md index 69e603017..6e4c97e12 100644 --- a/README.md +++ b/README.md @@ -59,14 +59,26 @@ 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. + - 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 d9cc7d3f7..d306e2498 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 3b5ad611c..125834676 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/AppInsightsCore/src/JavaScriptSDK.Enums/LoggingEnums.ts b/shared/AppInsightsCore/src/JavaScriptSDK.Enums/LoggingEnums.ts index 1b6ff8260..ed60c8375 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;