From c2639025ffcf455b813d6a26af785440d9aa8ee8 Mon Sep 17 00:00:00 2001 From: Nev Wylie <54870357+MSNev@users.noreply.github.com> Date: Tue, 20 Jun 2023 14:58:03 -0700 Subject: [PATCH 01/20] Rework web sniipet project for building snippet.ts --- gruntfile.js | 17 +- .../build/applicationinsights-web-snippet.ts | 13 - .../build/web-snippet-cs.ts | 1 - .../build/web-snippet.ts | 1 - .../package.json | 2 +- .../src/applicationinsights-web-snippet.ts | 4 +- .../src/snippet.xts | 331 ++++++++++++++++++ .../src/web-snippet-cs.ts | 1 - .../src/web-snippet.ts | 1 - .../tsconfig.json | 7 +- 10 files changed, 348 insertions(+), 30 deletions(-) delete mode 100644 tools/applicationinsights-web-snippet/build/applicationinsights-web-snippet.ts delete mode 100644 tools/applicationinsights-web-snippet/build/web-snippet-cs.ts delete mode 100644 tools/applicationinsights-web-snippet/build/web-snippet.ts create mode 100644 tools/applicationinsights-web-snippet/src/snippet.xts delete mode 100644 tools/applicationinsights-web-snippet/src/web-snippet-cs.ts delete mode 100644 tools/applicationinsights-web-snippet/src/web-snippet.ts diff --git a/gruntfile.js b/gruntfile.js index 24493d77e..59b85ef87 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -28,23 +28,28 @@ module.exports = function (grunt) { } function generateNewSnippet(connString) { + // Before: create a rollup task to minify dest-es5/snippet.js -> build/es5/snippet.min.js + // Change this to web-snipet build/es5/snippet.min.js + var prefix = "IKey"; var snippetBuffer = grunt.file.read("./AISKU/snippet/snippet.min.js"); if (connString) { snippetBuffer = snippetBuffer.replace(/^\s*instrumentationKey:\s*\".*\"/gm, " connectionString: \"YOUR_CONNECTION_STRING\""); snippetBuffer = snippetBuffer.replace(/^\s*connectionString:\s*\".*\"/gm, " connectionString: \"YOUR_CONNECTION_STRING\""); + prefix = "ConnString" } else { snippetBuffer = snippetBuffer.replace(/^\s*instrumentationKey:\s*\".*\"/gm, " connectionString: \"InstrumentationKey=INSTRUMENTATION_KEY\""); snippetBuffer = snippetBuffer.replace(/^\s*connectionString:\s*\".*\"/gm, " connectionString: \"InstrumentationKey=INSTRUMENTATION_KEY\""); } var snippetStr = _encodeStr(snippetBuffer.toString()); - var expectedStr = "##replaceSnippet##"; - var srcPath = "./tools/applicationinsights-web-snippet/src"; + var expectedStr = `##replace${prefix}Snippet##`; + var srcPath = "./tools/applicationinsights-web-snippet/dist-es5"; return { files: [{ expand: true, cwd: srcPath, - dest: "./tools/applicationinsights-web-snippet/build", - src: `web-snippet${connString ? "-cs" : ""}.ts` + dest: "./tools/applicationinsights-web-snippet/dist-es5", + src: "applicationinsights-web-snippet.js" + //src: `web-snippet${connString ? "-cs" : ""}.js` }], options: { replacements: [{ @@ -512,7 +517,7 @@ module.exports = function (grunt) { path: "./tools/applicationinsights-web-snippet", cfg: { src: [ - "./tools/applicationinsights-web-snippet/build/*.ts" + "./tools/applicationinsights-web-snippet/src/**/*.ts" ] } }, @@ -674,7 +679,7 @@ module.exports = function (grunt) { copy: { "web-snippet": { files: [ - { src: "./tools/applicationinsights-web-snippet/src/applicationinsights-web-snippet.ts", dest: `./tools/applicationinsights-web-snippet/build/applicationinsights-web-snippet.ts` }, + { src: "./tools/applicationinsights-web-snippet/build/output/applicationinsights-web-snippet.js", dest: `./tools/applicationinsights-web-snippet/dist-es5/applicationinsights-web-snippet.js` }, ] }, config: { diff --git a/tools/applicationinsights-web-snippet/build/applicationinsights-web-snippet.ts b/tools/applicationinsights-web-snippet/build/applicationinsights-web-snippet.ts deleted file mode 100644 index 5c4fd7ba3..000000000 --- a/tools/applicationinsights-web-snippet/build/applicationinsights-web-snippet.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { webSnippet } from "./web-snippet"; -import { webSnippetCs } from "./web-snippet-cs" - -function webSnippetVersion() { - let parse = /sv:\"([^\"]+)\"/.exec(webSnippet); - if (parse) { - return parse[1]; - } - - return ""; -} - -export { webSnippet, webSnippetCs, webSnippetVersion } \ No newline at end of file diff --git a/tools/applicationinsights-web-snippet/build/web-snippet-cs.ts b/tools/applicationinsights-web-snippet/build/web-snippet-cs.ts deleted file mode 100644 index cbeff7c6d..000000000 --- a/tools/applicationinsights-web-snippet/build/web-snippet-cs.ts +++ /dev/null @@ -1 +0,0 @@ -export const webSnippetCs = "!function(v,y,T){var S=v.location,k=\"script\",D=\"instrumentationKey\",C=\"ingestionendpoint\",I=\"disableExceptionTracking\",E=\"ai.device.\",b=\"toLowerCase\",w=(D[b](),\"crossOrigin\"),N=\"POST\",e=\"appInsightsSDK\",t=T.name||\"appInsights\",n=((T.name||v[e])&&(v[e]=t),v[t]||function(l){var u=!1,d=!1,g={initialize:!0,queue:[],sv:\"6\",version:2,config:l};function m(e,t){var n={},a=\"Browser\";return n[E+\"id\"]=a[b](),n[E+\"type\"]=a,n[\"ai.operation.name\"]=S&&S.pathname||\"_unknown_\",n[\"ai.internal.sdkVersion\"]=\"javascript:snippet_\"+(g.sv||g.version),{time:(a=new Date).getUTCFullYear()+\"-\"+i(1+a.getUTCMonth())+\"-\"+i(a.getUTCDate())+\"T\"+i(a.getUTCHours())+\":\"+i(a.getUTCMinutes())+\":\"+i(a.getUTCSeconds())+\".\"+(a.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}}};function i(e){e=\"\"+e;return 1===e.length?\"0\"+e:e}}var e,n,f=l.url||T.src;function a(e){var t,n,a,i,o,s,r,c,p;u=!0,g.queue=[],d||(d=!0,i=f,r=(c=function(){var e,t={},n=l.connectionString;if(n)for(var a=n.split(\";\"),i=0;i { + loadFailed = true; + appInsights.queue = []; // Clear the queue + if (!handled) { + handled = true; + _reportFailure(targetSrc); + } + } + + const _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); + } + } + + const _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) { + // do Nothing + } + + function _createMethods(methods) { + while (methods.length) { + (function (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; + 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); + }); + } + }; + })(methods.pop()); + } + } + + 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)) { + var 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, + evt: win.event + }); + } + + 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; + + function _onInit() { + if (snipConfig.onInit) { + snipConfig.onInit(aiSdk); + } + } + + // if somebody calls the snippet twice, don't report page view again + if (aiSdk.queue && aiSdk.queue.length === 0) { + aiSdk.queue.push(_onInit); + aiSdk.trackPageView({}); + } else { + // Already loaded so just call the onInit + _onInit(); + } +})(window, document, { + src: "https://js.monitor.azure.com/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 + // onInit: null, // Once the application insights instance has loaded and initialized this callback function will be called with 1 argument -- the sdk instance (DO NOT ADD anything to the sdk.queue -- As they won't get called) + cfg: { // Application Insights Configuration + connectionString: "YOUR_CONNECTION_STRING" + } +}); diff --git a/tools/applicationinsights-web-snippet/src/web-snippet-cs.ts b/tools/applicationinsights-web-snippet/src/web-snippet-cs.ts deleted file mode 100644 index fe78d79a1..000000000 --- a/tools/applicationinsights-web-snippet/src/web-snippet-cs.ts +++ /dev/null @@ -1 +0,0 @@ -export const webSnippetCs = "##replaceSnippet##"; diff --git a/tools/applicationinsights-web-snippet/src/web-snippet.ts b/tools/applicationinsights-web-snippet/src/web-snippet.ts deleted file mode 100644 index 844dacb50..000000000 --- a/tools/applicationinsights-web-snippet/src/web-snippet.ts +++ /dev/null @@ -1 +0,0 @@ -export const webSnippet = "##replaceSnippet##"; diff --git a/tools/applicationinsights-web-snippet/tsconfig.json b/tools/applicationinsights-web-snippet/tsconfig.json index e12c58f70..de75888f7 100644 --- a/tools/applicationinsights-web-snippet/tsconfig.json +++ b/tools/applicationinsights-web-snippet/tsconfig.json @@ -13,13 +13,12 @@ "skipLibCheck": true, "forceConsistentCasingInFileNames": true, "declaration": true, - "declarationDir": "./types", - "outDir": "./dist-es5", - "rootDir": "./build", + "declarationDir": "build/types", + "outDir": "build/output", + "rootDir": "./src", "removeComments": false }, "include": [ - "./build/*.ts" ], "exclude": [ "node_modules" From 7852fa7e8592aa1dd0cce4663a274591ff629077 Mon Sep 17 00:00:00 2001 From: siyuniu-ms Date: Tue, 20 Jun 2023 17:46:29 -0700 Subject: [PATCH 02/20] compile correct --- common/config/rush/npm-shrinkwrap.json | 532 +++++++++--------- .../src/Interfaces/IConfig.ts | 1 - .../package.json | 1 + .../src/{snippet.xts => snippet.ts} | 150 ++--- .../src/type.ts | 63 +++ 5 files changed, 407 insertions(+), 340 deletions(-) rename tools/applicationinsights-web-snippet/src/{snippet.xts => snippet.ts} (74%) create mode 100644 tools/applicationinsights-web-snippet/src/type.ts diff --git a/common/config/rush/npm-shrinkwrap.json b/common/config/rush/npm-shrinkwrap.json index a34371eee..1b11cb369 100644 --- a/common/config/rush/npm-shrinkwrap.json +++ b/common/config/rush/npm-shrinkwrap.json @@ -90,19 +90,19 @@ } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.19.1", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz", - "integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.5.tgz", + "integrity": "sha512-aJXu+6lErq8ltp+JhkJUfk1MTGyuA4v7f3pA+BJ5HLfNC6nAQ0Cpi9uOquUj8Hehg0aUiHzWQbOVJGao6ztBAQ==", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/highlight": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz", - "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.5.tgz", + "integrity": "sha512-BSKlD1hgnedS5XRnGOljZawtag7H1yPfQp0tdNJCHoH6AZ+Pcm9VvkrK59/Yy593Ypg0zMxH2BxD1VPYUQ7UIw==", "dependencies": { - "@babel/helper-validator-identifier": "^7.18.6", + "@babel/helper-validator-identifier": "^7.22.5", "chalk": "^2.0.0", "js-tokens": "^4.0.0" }, @@ -222,18 +222,18 @@ } }, "node_modules/@eslint/js": { - "version": "8.41.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.41.0.tgz", - "integrity": "sha512-LxcyMGxwmTh2lY9FwHPGWOHmYFCZvbrFCBZL4FzSSsxsRPuhrYUg/49/0KDfW8tnIEaEHtfmn6+NPN+1DqaNmA==", + "version": "8.43.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.43.0.tgz", + "integrity": "sha512-s2UHCoiXfxMvmfzqoN+vrQ84ahUSYde9qNO1MdxmoEhyHWsfmwOpFlwYV+ePJEVc7gFnATGUi376WowX1N7tFg==", "peer": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, "node_modules/@humanwhocodes/config-array": { - "version": "0.11.8", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", - "integrity": "sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g==", + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.10.tgz", + "integrity": "sha512-KVVjQmNUepDVGXNuoRRdmmEjruj0KfiGSbS8LVc12LMsWDQzRXJ0qdhN8L8uUigKpfEHRhlaQFY0ib1tnUbNeQ==", "peer": true, "dependencies": { "@humanwhocodes/object-schema": "^1.2.1", @@ -269,16 +269,16 @@ "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==" }, "node_modules/@microsoft/api-extractor": { - "version": "7.35.0", - "resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.35.0.tgz", - "integrity": "sha512-yBGfPJeEtzk8sg2hE2/vOPRvnJBvstbWNGeyGV1jIEUSgytzQ0QPgPEkOsP2n7nBfnyRXmZaBa2vJPGOzVWy+g==", + "version": "7.36.0", + "resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.36.0.tgz", + "integrity": "sha512-P+kYgJFDXIr+UNzhRMhlpM/dderi6ab4lxn35vdhfAIMPtGCSXIJxrrtpTOQmQW8CZtmoZX06LYoUsKCc1zjow==", "dependencies": { - "@microsoft/api-extractor-model": "7.27.0", + "@microsoft/api-extractor-model": "7.27.3", "@microsoft/tsdoc": "0.14.2", "@microsoft/tsdoc-config": "~0.16.1", - "@rushstack/node-core-library": "3.59.1", - "@rushstack/rig-package": "0.3.19", - "@rushstack/ts-command-line": "4.13.3", + "@rushstack/node-core-library": "3.59.4", + "@rushstack/rig-package": "0.4.0", + "@rushstack/ts-command-line": "4.15.1", "colors": "~1.2.1", "lodash": "~4.17.15", "resolve": "~1.22.1", @@ -291,13 +291,13 @@ } }, "node_modules/@microsoft/api-extractor-model": { - "version": "7.27.0", - "resolved": "https://registry.npmjs.org/@microsoft/api-extractor-model/-/api-extractor-model-7.27.0.tgz", - "integrity": "sha512-wHqIMiwSARmiuVLn/zmVpiRncq6hvBfC5GF+sjrN3w4FqVkqFYk7DetvfRNdy/3URdqqmYGrhJlcU9HpLnHOPg==", + "version": "7.27.3", + "resolved": "https://registry.npmjs.org/@microsoft/api-extractor-model/-/api-extractor-model-7.27.3.tgz", + "integrity": "sha512-fSFvw7otYHduOkyshjTbapKKgwF8bgquVHvgF8VgeKtMYvqXkoaj7W6VcM7PNY7E2bbblhUgC4XNdqZLD4SJGw==", "dependencies": { "@microsoft/tsdoc": "0.14.2", "@microsoft/tsdoc-config": "~0.16.1", - "@rushstack/node-core-library": "3.59.1" + "@rushstack/node-core-library": "3.59.4" } }, "node_modules/@microsoft/api-extractor/node_modules/typescript": { @@ -385,20 +385,20 @@ } }, "node_modules/@nevware21/ts-async": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/@nevware21/ts-async/-/ts-async-0.2.4.tgz", - "integrity": "sha512-MjzaXcVPNzJIr0x0QzxaVn7j6N0fVjOKELISLrnihFCkoRjXx3fl/7KB1yGk6wqJ/wXRMAw4IHLOi0Ml7ovdyA==", + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/@nevware21/ts-async/-/ts-async-0.2.6.tgz", + "integrity": "sha512-NCUqEZSbsy7LVtKlUScd/eTst6djkWauLlzoIPVKCOxalEBdO8lrgNRIm4Xy68JNudNN5faqa2WA12X8m0BVhA==", "dependencies": { - "@nevware21/ts-utils": ">= 0.9.5 < 2.x" + "@nevware21/ts-utils": ">= 0.9.7 < 2.x" }, "peerDependencies": { "typescript": ">=1" } }, "node_modules/@nevware21/ts-utils": { - "version": "0.9.5", - "resolved": "https://registry.npmjs.org/@nevware21/ts-utils/-/ts-utils-0.9.5.tgz", - "integrity": "sha512-hCUM1/HKLcHKWeTjX/ervVOp6eim+XEdFI3U7NUU+yec7XPQTxe4sDujPY5unlTQ2CHpxTewRo7mIyaRdMFlUw==", + "version": "0.9.8", + "resolved": "https://registry.npmjs.org/@nevware21/ts-utils/-/ts-utils-0.9.8.tgz", + "integrity": "sha512-kZ8s8hcn9jPVX/M7kSsBYrOGlHjqLahmxrG7QeKTk5paeVwfgKdvVCjj5Acb4UGb/ukU1G34U1Z3eb7bbVanyA==", "peerDependencies": { "typescript": ">=1" } @@ -471,9 +471,9 @@ } }, "node_modules/@rollup/plugin-node-resolve": { - "version": "15.0.2", - "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.0.2.tgz", - "integrity": "sha512-Y35fRGUjC3FaurG722uhUuG8YHOJRJQbI6/CkbRkdPotSpDj9NtIN85z1zrcyDcCQIW4qp5mgG72U+gJ0TAFEg==", + "version": "15.1.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.1.0.tgz", + "integrity": "sha512-xeZHCgsiZ9pzYVgAo9580eCGqwh/XCEUM9q6iQfGNocjgkufHAqC3exA+45URvhiYV8sBF9RlBai650eNs7AsA==", "dependencies": { "@rollup/pluginutils": "^5.0.1", "@types/resolve": "1.20.2", @@ -1077,7 +1077,7 @@ "node_modules/@rush-temp/applicationinsights-web-snippet": { "version": "0.0.0", "resolved": "file:projects/applicationinsights-web-snippet.tgz", - "integrity": "sha512-2s12tbK20KMtuADM+qypCGGuKqpYvDnnRBeQlcRrkZyi83swryRqcA55hg2SVOJA0nn1EBQs/EtzMwsd0ss0iA==", + "integrity": "sha512-FpoD7gC1D0hizSjHJheYUnhf4okQAS+JNMEXrht2z1chtBeRfoGuS0uhHe3ZppMH294sWWOXNjMkQsZ3KmMV7g==", "dependencies": { "@nevware21/grunt-eslint-ts": "^0.2.2", "@nevware21/grunt-ts-plugin": "^0.4.3", @@ -1096,9 +1096,9 @@ } }, "node_modules/@rushstack/node-core-library": { - "version": "3.59.1", - "resolved": "https://registry.npmjs.org/@rushstack/node-core-library/-/node-core-library-3.59.1.tgz", - "integrity": "sha512-iy/xaEhXGpX+DY1ZzAtNA+QPw+9+TJh773Im+JxG4R1fu00/vWq470UOEj6upxlUxmp0JxhnmNRxzfptHrn/Uw==", + "version": "3.59.4", + "resolved": "https://registry.npmjs.org/@rushstack/node-core-library/-/node-core-library-3.59.4.tgz", + "integrity": "sha512-YAKJDC6Mz/KA1D7bvB88WaRX3knt/ZuLzkRu5G9QADGSjLtvTWzCNCytRF2PCSaaHOZaZsWul4F1KQdgFgUDqA==", "dependencies": { "colors": "~1.2.1", "fs-extra": "~7.0.1", @@ -1118,18 +1118,18 @@ } }, "node_modules/@rushstack/rig-package": { - "version": "0.3.19", - "resolved": "https://registry.npmjs.org/@rushstack/rig-package/-/rig-package-0.3.19.tgz", - "integrity": "sha512-2d0/Gn+qjOYneZbiHjn4SjyDwq9I0WagV37z0F1V71G+yONgH7wlt3K/UoNiDkhA8gTHYPRo2jz3CvttybwSag==", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@rushstack/rig-package/-/rig-package-0.4.0.tgz", + "integrity": "sha512-FnM1TQLJYwSiurP6aYSnansprK5l8WUK8VG38CmAaZs29ZeL1msjK0AP1VS4ejD33G0kE/2cpsPsS9jDenBMxw==", "dependencies": { "resolve": "~1.22.1", "strip-json-comments": "~3.1.1" } }, "node_modules/@rushstack/ts-command-line": { - "version": "4.13.3", - "resolved": "https://registry.npmjs.org/@rushstack/ts-command-line/-/ts-command-line-4.13.3.tgz", - "integrity": "sha512-6aQIv/o1EgsC/+SpgUyRmzg2QIAL6sudEzw3sWzJKwWuQTc5XRsyZpyldfE7WAmIqMXDao9QG35/NYORjHm5Zw==", + "version": "4.15.1", + "resolved": "https://registry.npmjs.org/@rushstack/ts-command-line/-/ts-command-line-4.15.1.tgz", + "integrity": "sha512-EL4jxZe5fhb1uVL/P/wQO+Z8Rc8FMiWJ1G7VgnPDvdIt5GVjRfK7vwzder1CZQiX3x0PY6uxENYLNGTFd1InRQ==", "dependencies": { "@types/argparse": "1.0.38", "argparse": "~1.0.9", @@ -1257,9 +1257,9 @@ } }, "node_modules/@types/har-format": { - "version": "1.2.10", - "resolved": "https://registry.npmjs.org/@types/har-format/-/har-format-1.2.10.tgz", - "integrity": "sha512-o0J30wqycjF5miWDKYKKzzOU1ZTLuA42HZ4HE7/zqTOc/jTLdQ5NhYWvsRQo45Nfi1KHoRdNhteSI4BAxTF1Pg==" + "version": "1.2.11", + "resolved": "https://registry.npmjs.org/@types/har-format/-/har-format-1.2.11.tgz", + "integrity": "sha512-T232/TneofqK30AD1LRrrf8KnjLvzrjWDp7eWST5KoiSzrBfRsLrWDPk4STQPW4NZG6v2MltnduBVmakbZOBIQ==" }, "node_modules/@types/http-cache-semantics": { "version": "4.0.1", @@ -1267,9 +1267,9 @@ "integrity": "sha512-SZs7ekbP8CN0txVG2xVRH6EgKmEm31BOxA07vkFaETzZz1xh+cbt8BcI0slpymvwhx5dlFnQG2rTlPVQn+iRPQ==" }, "node_modules/@types/json-schema": { - "version": "7.0.11", - "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", - "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", + "version": "7.0.12", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.12.tgz", + "integrity": "sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==", "peer": true }, "node_modules/@types/keyv": { @@ -1281,9 +1281,9 @@ } }, "node_modules/@types/lodash": { - "version": "4.14.194", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.194.tgz", - "integrity": "sha512-r22s9tAS7imvBt2lyHC9B8AGwWnXaYb1tY09oyLkXDs4vArpYJzw09nj8MLx5VfciBPGIb+ZwG0ssYnEPJxn/g==" + "version": "4.14.195", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.195.tgz", + "integrity": "sha512-Hwx9EUgdwf2GLarOjQp5ZH8ZmblzcbTBC2wtQWNKARBSxM9ezRIAUpeDTgoQRAFB0+8CNWXVA9+MaSOzOF3nPg==" }, "node_modules/@types/minimatch": { "version": "5.1.2", @@ -1306,14 +1306,14 @@ "integrity": "sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==" }, "node_modules/@types/qunit": { - "version": "2.19.5", - "resolved": "https://registry.npmjs.org/@types/qunit/-/qunit-2.19.5.tgz", - "integrity": "sha512-NvyN1m6nKlRpAXETsTdqzEfW6C+5xbIqrXxQbnm8PmfxM7Ixi73KPoHgXCLJZHw8fd9pvCm3gVeX3nBYRuZLYQ==" + "version": "2.19.6", + "resolved": "https://registry.npmjs.org/@types/qunit/-/qunit-2.19.6.tgz", + "integrity": "sha512-bz9STa6EHurtpSfn5cNiScBladlw43bM+7luQA985Kd9YlF4dZaLmKt3c5/oSyN1AWAl50YBpqTq0BxCP64nGg==" }, "node_modules/@types/react": { - "version": "16.14.41", - "resolved": "https://registry.npmjs.org/@types/react/-/react-16.14.41.tgz", - "integrity": "sha512-h+joCKF2r5rdECoM1U8WCEIHBp5/0TSR5Nyq8gtnnYY1n2WqGuj3indYqTjMb2/b5g2rfxJV6u4jUFq95lbT6Q==", + "version": "16.14.43", + "resolved": "https://registry.npmjs.org/@types/react/-/react-16.14.43.tgz", + "integrity": "sha512-7zdjv7jvoLLQg1tTvpQsm+hyNUMT2mPlNV1+d0I8fbGhkJl82spopMyBlu4wb1dviZAxpGdk5eHu/muacknnfw==", "dependencies": { "@types/prop-types": "*", "@types/scheduler": "*", @@ -1367,15 +1367,15 @@ } }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "5.59.7", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.59.7.tgz", - "integrity": "sha512-BL+jYxUFIbuYwy+4fF86k5vdT9lT0CNJ6HtwrIvGh0PhH8s0yy5rjaKH2fDCrz5ITHy07WCzVGNvAmjJh4IJFA==", + "version": "5.60.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.60.0.tgz", + "integrity": "sha512-78B+anHLF1TI8Jn/cD0Q00TBYdMgjdOn980JfAVa9yw5sop8nyTfVOQAv6LWywkOGLclDBtv5z3oxN4w7jxyNg==", "peer": true, "dependencies": { "@eslint-community/regexpp": "^4.4.0", - "@typescript-eslint/scope-manager": "5.59.7", - "@typescript-eslint/type-utils": "5.59.7", - "@typescript-eslint/utils": "5.59.7", + "@typescript-eslint/scope-manager": "5.60.0", + "@typescript-eslint/type-utils": "5.60.0", + "@typescript-eslint/utils": "5.60.0", "debug": "^4.3.4", "grapheme-splitter": "^1.0.4", "ignore": "^5.2.0", @@ -1401,14 +1401,14 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "5.59.7", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.59.7.tgz", - "integrity": "sha512-VhpsIEuq/8i5SF+mPg9jSdIwgMBBp0z9XqjiEay+81PYLJuroN+ET1hM5IhkiYMJd9MkTz8iJLt7aaGAgzWUbQ==", + "version": "5.60.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.60.0.tgz", + "integrity": "sha512-jBONcBsDJ9UoTWrARkRRCgDz6wUggmH5RpQVlt7BimSwaTkTjwypGzKORXbR4/2Hqjk9hgwlon2rVQAjWNpkyQ==", "peer": true, "dependencies": { - "@typescript-eslint/scope-manager": "5.59.7", - "@typescript-eslint/types": "5.59.7", - "@typescript-eslint/typescript-estree": "5.59.7", + "@typescript-eslint/scope-manager": "5.60.0", + "@typescript-eslint/types": "5.60.0", + "@typescript-eslint/typescript-estree": "5.60.0", "debug": "^4.3.4" }, "engines": { @@ -1428,13 +1428,13 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "5.59.7", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.59.7.tgz", - "integrity": "sha512-FL6hkYWK9zBGdxT2wWEd2W8ocXMu3K94i3gvMrjXpx+koFYdYV7KprKfirpgY34vTGzEPPuKoERpP8kD5h7vZQ==", + "version": "5.60.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.60.0.tgz", + "integrity": "sha512-hakuzcxPwXi2ihf9WQu1BbRj1e/Pd8ZZwVTG9kfbxAMZstKz8/9OoexIwnmLzShtsdap5U/CoQGRCWlSuPbYxQ==", "peer": true, "dependencies": { - "@typescript-eslint/types": "5.59.7", - "@typescript-eslint/visitor-keys": "5.59.7" + "@typescript-eslint/types": "5.60.0", + "@typescript-eslint/visitor-keys": "5.60.0" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -1445,13 +1445,13 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "5.59.7", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.59.7.tgz", - "integrity": "sha512-ozuz/GILuYG7osdY5O5yg0QxXUAEoI4Go3Do5xeu+ERH9PorHBPSdvD3Tjp2NN2bNLh1NJQSsQu2TPu/Ly+HaQ==", + "version": "5.60.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.60.0.tgz", + "integrity": "sha512-X7NsRQddORMYRFH7FWo6sA9Y/zbJ8s1x1RIAtnlj6YprbToTiQnM6vxcMu7iYhdunmoC0rUWlca13D5DVHkK2g==", "peer": true, "dependencies": { - "@typescript-eslint/typescript-estree": "5.59.7", - "@typescript-eslint/utils": "5.59.7", + "@typescript-eslint/typescript-estree": "5.60.0", + "@typescript-eslint/utils": "5.60.0", "debug": "^4.3.4", "tsutils": "^3.21.0" }, @@ -1472,9 +1472,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "5.59.7", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.59.7.tgz", - "integrity": "sha512-UnVS2MRRg6p7xOSATscWkKjlf/NDKuqo5TdbWck6rIRZbmKpVNTLALzNvcjIfHBE7736kZOFc/4Z3VcZwuOM/A==", + "version": "5.60.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.60.0.tgz", + "integrity": "sha512-ascOuoCpNZBccFVNJRSC6rPq4EmJ2NkuoKnd6LDNyAQmdDnziAtxbCGWCbefG1CNzmDvd05zO36AmB7H8RzKPA==", "peer": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -1485,13 +1485,13 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "5.59.7", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.59.7.tgz", - "integrity": "sha512-4A1NtZ1I3wMN2UGDkU9HMBL+TIQfbrh4uS0WDMMpf3xMRursDbqEf1ahh6vAAe3mObt8k3ZATnezwG4pdtWuUQ==", + "version": "5.60.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.60.0.tgz", + "integrity": "sha512-R43thAuwarC99SnvrBmh26tc7F6sPa2B3evkXp/8q954kYL6Ro56AwASYWtEEi+4j09GbiNAHqYwNNZuNlARGQ==", "peer": true, "dependencies": { - "@typescript-eslint/types": "5.59.7", - "@typescript-eslint/visitor-keys": "5.59.7", + "@typescript-eslint/types": "5.60.0", + "@typescript-eslint/visitor-keys": "5.60.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -1512,17 +1512,17 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "5.59.7", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.59.7.tgz", - "integrity": "sha512-yCX9WpdQKaLufz5luG4aJbOpdXf/fjwGMcLFXZVPUz3QqLirG5QcwwnIHNf8cjLjxK4qtzTO8udUtMQSAToQnQ==", + "version": "5.60.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.60.0.tgz", + "integrity": "sha512-ba51uMqDtfLQ5+xHtwlO84vkdjrqNzOnqrnwbMHMRY8Tqeme8C2Q8Fc7LajfGR+e3/4LoYiWXUM6BpIIbHJ4hQ==", "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@types/json-schema": "^7.0.9", "@types/semver": "^7.3.12", - "@typescript-eslint/scope-manager": "5.59.7", - "@typescript-eslint/types": "5.59.7", - "@typescript-eslint/typescript-estree": "5.59.7", + "@typescript-eslint/scope-manager": "5.60.0", + "@typescript-eslint/types": "5.60.0", + "@typescript-eslint/typescript-estree": "5.60.0", "eslint-scope": "^5.1.1", "semver": "^7.3.7" }, @@ -1538,12 +1538,12 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "5.59.7", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.59.7.tgz", - "integrity": "sha512-tyN+X2jvMslUszIiYbF0ZleP+RqQsFVpGrKI6e0Eet1w8WmhsAtmzaqm8oM8WJQ1ysLwhnsK/4hYHJjOgJVfQQ==", + "version": "5.60.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.60.0.tgz", + "integrity": "sha512-wm9Uz71SbCyhUKgcaPRauBdTegUyY/ZWl8gLwD/i/ybJqscrrdVSFImpvUz16BLPChIeKBK5Fa9s6KDQjsjyWw==", "peer": true, "dependencies": { - "@typescript-eslint/types": "5.59.7", + "@typescript-eslint/types": "5.60.0", "eslint-visitor-keys": "^3.3.0" }, "engines": { @@ -1560,9 +1560,9 @@ "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" }, "node_modules/acorn": { - "version": "8.8.2", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", - "integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==", + "version": "8.9.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.9.0.tgz", + "integrity": "sha512-jaVNAFBHNLXspO543WnNNPZFRtavh3skAkITqD0/2aeMkKZTN+254PyhwxFYrk3vQ1xfY+2wbesJMs/JC8/PwQ==", "peer": true, "bin": { "acorn": "bin/acorn" @@ -1835,9 +1835,9 @@ } }, "node_modules/browserslist": { - "version": "4.21.5", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.5.tgz", - "integrity": "sha512-tUkiguQGW7S3IhB7N+c2MV/HZPSCPAAiYBZXLsBhFB/PCy6ZKKsZrmBayHV9fdGV/ARIfJ14NkxKzRDjvp7L6w==", + "version": "4.21.9", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.9.tgz", + "integrity": "sha512-M0MFoZzbUrRU4KNfCrDLnvyE7gub+peetoTid3TBIqtunaDJyXlwhakT+/VkvSXcfIzFfK/nkCs4nmyTmxdNSg==", "funding": [ { "type": "opencollective", @@ -1846,13 +1846,17 @@ { "type": "tidelift", "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" } ], "dependencies": { - "caniuse-lite": "^1.0.30001449", - "electron-to-chromium": "^1.4.284", - "node-releases": "^2.0.8", - "update-browserslist-db": "^1.0.10" + "caniuse-lite": "^1.0.30001503", + "electron-to-chromium": "^1.4.431", + "node-releases": "^2.0.12", + "update-browserslist-db": "^1.0.11" }, "bin": { "browserslist": "cli.js" @@ -1917,9 +1921,9 @@ } }, "node_modules/cacheable-request": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-7.0.2.tgz", - "integrity": "sha512-pouW8/FmiPQbuGpkXQ9BAPv/Mo5xDGANgSNXzTzJ8DrKGuXOssM4wIQRjfanNRh3Yu5cfYPvcorqbhg2KIJtew==", + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-7.0.4.tgz", + "integrity": "sha512-v+p6ongsrp0yTGbJXjgxPow2+DL93DASP4kXCDKb8/bwRtt9OEF3whggkkDkGNzgcWy2XaF4a8nZglC7uElscg==", "dependencies": { "clone-response": "^1.0.2", "get-stream": "^5.1.0", @@ -1950,9 +1954,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001489", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001489.tgz", - "integrity": "sha512-x1mgZEXK8jHIfAxm+xgdpHpk50IN3z3q3zP261/WS+uvePxW8izXuCu6AHz0lkuYTlATDehiZ/tNyYBdSQsOUQ==", + "version": "1.0.30001505", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001505.tgz", + "integrity": "sha512-jaAOR5zVtxHfL0NjZyflVTtXm3D3J9P15zSJ7HmQF8dSKGA6tqzQq+0ZI3xkjyQj46I4/M0K2GbMpcAFOcbr3A==", "funding": [ { "type": "opencollective", @@ -2335,9 +2339,9 @@ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "node_modules/electron-to-chromium": { - "version": "1.4.403", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.403.tgz", - "integrity": "sha512-evCMqXJWmbQHdlh307peXNguqVIMmcLGrQwXiR+Qc98js8jPDeT9rse1+EF2YRjWgueuzj1r4WWLAe4/U+xjMg==" + "version": "1.4.435", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.435.tgz", + "integrity": "sha512-B0CBWVFhvoQCW/XtjRzgrmqcgVWg6RXOEM/dK59+wFV93BFGR6AeNKc4OyhM+T3IhJaOOG8o/V+33Y2mwJWtzw==" }, "node_modules/encodeurl": { "version": "1.0.2", @@ -2389,16 +2393,16 @@ } }, "node_modules/eslint": { - "version": "8.41.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.41.0.tgz", - "integrity": "sha512-WQDQpzGBOP5IrXPo4Hc0814r4/v2rrIsB0rhT7jtunIalgg6gYXWhRMOejVO8yH21T/FGaxjmFjBMNqcIlmH1Q==", + "version": "8.43.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.43.0.tgz", + "integrity": "sha512-aaCpf2JqqKesMFGgmRPessmVKjcGXqdlAYLLC3THM8t5nBRZRQ+st5WM/hoJXkdioEXLLbXgclUpM0TXo5HX5Q==", "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.4.0", "@eslint/eslintrc": "^2.0.3", - "@eslint/js": "8.41.0", - "@humanwhocodes/config-array": "^0.11.8", + "@eslint/js": "8.43.0", + "@humanwhocodes/config-array": "^0.11.10", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", "ajv": "^6.10.0", @@ -4199,9 +4203,9 @@ } }, "node_modules/node-releases": { - "version": "2.0.11", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.11.tgz", - "integrity": "sha512-+M0PwXeU80kRohZ3aT4J/OnR+l9/KD2nVLNNoRgFtnf+umQVFdGBAO2N8+nCnEi0xlh/Wk3zOGC+vNNx+uM79Q==" + "version": "2.0.12", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.12.tgz", + "integrity": "sha512-QzsYKWhXTWx8h1kIvqfnC++o0pEmpRQA/aenALsL2F4pqNVr7YzcdMlDij5WBnwftRbJCNJL/O7zdKaxKPHqgQ==" }, "node_modules/node-watch": { "version": "0.7.3", @@ -5032,9 +5036,9 @@ } }, "node_modules/rollup": { - "version": "3.23.0", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.23.0.tgz", - "integrity": "sha512-h31UlwEi7FHihLe1zbk+3Q7z1k/84rb9BSwmBSr/XjOCEaBJ2YyedQDuM0t/kfOS0IxM+vk1/zI9XxYj9V+NJQ==", + "version": "3.25.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.25.1.tgz", + "integrity": "sha512-tywOR+rwIt5m2ZAWSe5AIJcTat8vGlnPFAv15ycCrw33t6iFsXZ6mzHVFh2psSjxQPmI+xgzMZZizUAukBI4aQ==", "bin": { "rollup": "dist/bin/rollup" }, @@ -5555,9 +5559,9 @@ "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" }, "node_modules/tslib": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.2.tgz", - "integrity": "sha512-5svOrSA2w3iGFDs1HibEVBGbDrAY82bFQ3HZ3ixB+88nsbsWQoKqDRb5UBYAUPEzbBn6dAp5gRNXglySbx1MlA==" + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.3.tgz", + "integrity": "sha512-mSxlJJwl3BMEQCUNnxXBU9jP4JBktcEGhURcPR6VQVlnP0FdDEsIaz0C35dXNGLyRfrATNofF0F5p2KPxQgB+w==" }, "node_modules/tsutils": { "version": "3.21.0", @@ -5933,16 +5937,16 @@ } }, "@babel/helper-validator-identifier": { - "version": "7.19.1", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz", - "integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==" + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.5.tgz", + "integrity": "sha512-aJXu+6lErq8ltp+JhkJUfk1MTGyuA4v7f3pA+BJ5HLfNC6nAQ0Cpi9uOquUj8Hehg0aUiHzWQbOVJGao6ztBAQ==" }, "@babel/highlight": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz", - "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.5.tgz", + "integrity": "sha512-BSKlD1hgnedS5XRnGOljZawtag7H1yPfQp0tdNJCHoH6AZ+Pcm9VvkrK59/Yy593Ypg0zMxH2BxD1VPYUQ7UIw==", "requires": { - "@babel/helper-validator-identifier": "^7.18.6", + "@babel/helper-validator-identifier": "^7.22.5", "chalk": "^2.0.0", "js-tokens": "^4.0.0" }, @@ -6031,15 +6035,15 @@ } }, "@eslint/js": { - "version": "8.41.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.41.0.tgz", - "integrity": "sha512-LxcyMGxwmTh2lY9FwHPGWOHmYFCZvbrFCBZL4FzSSsxsRPuhrYUg/49/0KDfW8tnIEaEHtfmn6+NPN+1DqaNmA==", + "version": "8.43.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.43.0.tgz", + "integrity": "sha512-s2UHCoiXfxMvmfzqoN+vrQ84ahUSYde9qNO1MdxmoEhyHWsfmwOpFlwYV+ePJEVc7gFnATGUi376WowX1N7tFg==", "peer": true }, "@humanwhocodes/config-array": { - "version": "0.11.8", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", - "integrity": "sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g==", + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.10.tgz", + "integrity": "sha512-KVVjQmNUepDVGXNuoRRdmmEjruj0KfiGSbS8LVc12LMsWDQzRXJ0qdhN8L8uUigKpfEHRhlaQFY0ib1tnUbNeQ==", "peer": true, "requires": { "@humanwhocodes/object-schema": "^1.2.1", @@ -6065,16 +6069,16 @@ "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==" }, "@microsoft/api-extractor": { - "version": "7.35.0", - "resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.35.0.tgz", - "integrity": "sha512-yBGfPJeEtzk8sg2hE2/vOPRvnJBvstbWNGeyGV1jIEUSgytzQ0QPgPEkOsP2n7nBfnyRXmZaBa2vJPGOzVWy+g==", + "version": "7.36.0", + "resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.36.0.tgz", + "integrity": "sha512-P+kYgJFDXIr+UNzhRMhlpM/dderi6ab4lxn35vdhfAIMPtGCSXIJxrrtpTOQmQW8CZtmoZX06LYoUsKCc1zjow==", "requires": { - "@microsoft/api-extractor-model": "7.27.0", + "@microsoft/api-extractor-model": "7.27.3", "@microsoft/tsdoc": "0.14.2", "@microsoft/tsdoc-config": "~0.16.1", - "@rushstack/node-core-library": "3.59.1", - "@rushstack/rig-package": "0.3.19", - "@rushstack/ts-command-line": "4.13.3", + "@rushstack/node-core-library": "3.59.4", + "@rushstack/rig-package": "0.4.0", + "@rushstack/ts-command-line": "4.15.1", "colors": "~1.2.1", "lodash": "~4.17.15", "resolve": "~1.22.1", @@ -6091,13 +6095,13 @@ } }, "@microsoft/api-extractor-model": { - "version": "7.27.0", - "resolved": "https://registry.npmjs.org/@microsoft/api-extractor-model/-/api-extractor-model-7.27.0.tgz", - "integrity": "sha512-wHqIMiwSARmiuVLn/zmVpiRncq6hvBfC5GF+sjrN3w4FqVkqFYk7DetvfRNdy/3URdqqmYGrhJlcU9HpLnHOPg==", + "version": "7.27.3", + "resolved": "https://registry.npmjs.org/@microsoft/api-extractor-model/-/api-extractor-model-7.27.3.tgz", + "integrity": "sha512-fSFvw7otYHduOkyshjTbapKKgwF8bgquVHvgF8VgeKtMYvqXkoaj7W6VcM7PNY7E2bbblhUgC4XNdqZLD4SJGw==", "requires": { "@microsoft/tsdoc": "0.14.2", "@microsoft/tsdoc-config": "~0.16.1", - "@rushstack/node-core-library": "3.59.1" + "@rushstack/node-core-library": "3.59.4" } }, "@microsoft/applicationinsights-web-snippet": { @@ -6155,17 +6159,17 @@ "requires": {} }, "@nevware21/ts-async": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/@nevware21/ts-async/-/ts-async-0.2.4.tgz", - "integrity": "sha512-MjzaXcVPNzJIr0x0QzxaVn7j6N0fVjOKELISLrnihFCkoRjXx3fl/7KB1yGk6wqJ/wXRMAw4IHLOi0Ml7ovdyA==", + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/@nevware21/ts-async/-/ts-async-0.2.6.tgz", + "integrity": "sha512-NCUqEZSbsy7LVtKlUScd/eTst6djkWauLlzoIPVKCOxalEBdO8lrgNRIm4Xy68JNudNN5faqa2WA12X8m0BVhA==", "requires": { - "@nevware21/ts-utils": ">= 0.9.5 < 2.x" + "@nevware21/ts-utils": ">= 0.9.7 < 2.x" } }, "@nevware21/ts-utils": { - "version": "0.9.5", - "resolved": "https://registry.npmjs.org/@nevware21/ts-utils/-/ts-utils-0.9.5.tgz", - "integrity": "sha512-hCUM1/HKLcHKWeTjX/ervVOp6eim+XEdFI3U7NUU+yec7XPQTxe4sDujPY5unlTQ2CHpxTewRo7mIyaRdMFlUw==", + "version": "0.9.8", + "resolved": "https://registry.npmjs.org/@nevware21/ts-utils/-/ts-utils-0.9.8.tgz", + "integrity": "sha512-kZ8s8hcn9jPVX/M7kSsBYrOGlHjqLahmxrG7QeKTk5paeVwfgKdvVCjj5Acb4UGb/ukU1G34U1Z3eb7bbVanyA==", "requires": {} }, "@nodelib/fs.scandir": { @@ -6215,9 +6219,9 @@ } }, "@rollup/plugin-node-resolve": { - "version": "15.0.2", - "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.0.2.tgz", - "integrity": "sha512-Y35fRGUjC3FaurG722uhUuG8YHOJRJQbI6/CkbRkdPotSpDj9NtIN85z1zrcyDcCQIW4qp5mgG72U+gJ0TAFEg==", + "version": "15.1.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.1.0.tgz", + "integrity": "sha512-xeZHCgsiZ9pzYVgAo9580eCGqwh/XCEUM9q6iQfGNocjgkufHAqC3exA+45URvhiYV8sBF9RlBai650eNs7AsA==", "requires": { "@rollup/pluginutils": "^5.0.1", "@types/resolve": "1.20.2", @@ -6763,7 +6767,7 @@ }, "@rush-temp/applicationinsights-web-snippet": { "version": "file:projects\\applicationinsights-web-snippet.tgz", - "integrity": "sha512-2s12tbK20KMtuADM+qypCGGuKqpYvDnnRBeQlcRrkZyi83swryRqcA55hg2SVOJA0nn1EBQs/EtzMwsd0ss0iA==", + "integrity": "sha512-FpoD7gC1D0hizSjHJheYUnhf4okQAS+JNMEXrht2z1chtBeRfoGuS0uhHe3ZppMH294sWWOXNjMkQsZ3KmMV7g==", "requires": { "@nevware21/grunt-eslint-ts": "^0.2.2", "@nevware21/grunt-ts-plugin": "^0.4.3", @@ -6782,9 +6786,9 @@ } }, "@rushstack/node-core-library": { - "version": "3.59.1", - "resolved": "https://registry.npmjs.org/@rushstack/node-core-library/-/node-core-library-3.59.1.tgz", - "integrity": "sha512-iy/xaEhXGpX+DY1ZzAtNA+QPw+9+TJh773Im+JxG4R1fu00/vWq470UOEj6upxlUxmp0JxhnmNRxzfptHrn/Uw==", + "version": "3.59.4", + "resolved": "https://registry.npmjs.org/@rushstack/node-core-library/-/node-core-library-3.59.4.tgz", + "integrity": "sha512-YAKJDC6Mz/KA1D7bvB88WaRX3knt/ZuLzkRu5G9QADGSjLtvTWzCNCytRF2PCSaaHOZaZsWul4F1KQdgFgUDqA==", "requires": { "colors": "~1.2.1", "fs-extra": "~7.0.1", @@ -6796,18 +6800,18 @@ } }, "@rushstack/rig-package": { - "version": "0.3.19", - "resolved": "https://registry.npmjs.org/@rushstack/rig-package/-/rig-package-0.3.19.tgz", - "integrity": "sha512-2d0/Gn+qjOYneZbiHjn4SjyDwq9I0WagV37z0F1V71G+yONgH7wlt3K/UoNiDkhA8gTHYPRo2jz3CvttybwSag==", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@rushstack/rig-package/-/rig-package-0.4.0.tgz", + "integrity": "sha512-FnM1TQLJYwSiurP6aYSnansprK5l8WUK8VG38CmAaZs29ZeL1msjK0AP1VS4ejD33G0kE/2cpsPsS9jDenBMxw==", "requires": { "resolve": "~1.22.1", "strip-json-comments": "~3.1.1" } }, "@rushstack/ts-command-line": { - "version": "4.13.3", - "resolved": "https://registry.npmjs.org/@rushstack/ts-command-line/-/ts-command-line-4.13.3.tgz", - "integrity": "sha512-6aQIv/o1EgsC/+SpgUyRmzg2QIAL6sudEzw3sWzJKwWuQTc5XRsyZpyldfE7WAmIqMXDao9QG35/NYORjHm5Zw==", + "version": "4.15.1", + "resolved": "https://registry.npmjs.org/@rushstack/ts-command-line/-/ts-command-line-4.15.1.tgz", + "integrity": "sha512-EL4jxZe5fhb1uVL/P/wQO+Z8Rc8FMiWJ1G7VgnPDvdIt5GVjRfK7vwzder1CZQiX3x0PY6uxENYLNGTFd1InRQ==", "requires": { "@types/argparse": "1.0.38", "argparse": "~1.0.9", @@ -6926,9 +6930,9 @@ } }, "@types/har-format": { - "version": "1.2.10", - "resolved": "https://registry.npmjs.org/@types/har-format/-/har-format-1.2.10.tgz", - "integrity": "sha512-o0J30wqycjF5miWDKYKKzzOU1ZTLuA42HZ4HE7/zqTOc/jTLdQ5NhYWvsRQo45Nfi1KHoRdNhteSI4BAxTF1Pg==" + "version": "1.2.11", + "resolved": "https://registry.npmjs.org/@types/har-format/-/har-format-1.2.11.tgz", + "integrity": "sha512-T232/TneofqK30AD1LRrrf8KnjLvzrjWDp7eWST5KoiSzrBfRsLrWDPk4STQPW4NZG6v2MltnduBVmakbZOBIQ==" }, "@types/http-cache-semantics": { "version": "4.0.1", @@ -6936,9 +6940,9 @@ "integrity": "sha512-SZs7ekbP8CN0txVG2xVRH6EgKmEm31BOxA07vkFaETzZz1xh+cbt8BcI0slpymvwhx5dlFnQG2rTlPVQn+iRPQ==" }, "@types/json-schema": { - "version": "7.0.11", - "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", - "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", + "version": "7.0.12", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.12.tgz", + "integrity": "sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==", "peer": true }, "@types/keyv": { @@ -6950,9 +6954,9 @@ } }, "@types/lodash": { - "version": "4.14.194", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.194.tgz", - "integrity": "sha512-r22s9tAS7imvBt2lyHC9B8AGwWnXaYb1tY09oyLkXDs4vArpYJzw09nj8MLx5VfciBPGIb+ZwG0ssYnEPJxn/g==" + "version": "4.14.195", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.195.tgz", + "integrity": "sha512-Hwx9EUgdwf2GLarOjQp5ZH8ZmblzcbTBC2wtQWNKARBSxM9ezRIAUpeDTgoQRAFB0+8CNWXVA9+MaSOzOF3nPg==" }, "@types/minimatch": { "version": "5.1.2", @@ -6975,14 +6979,14 @@ "integrity": "sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==" }, "@types/qunit": { - "version": "2.19.5", - "resolved": "https://registry.npmjs.org/@types/qunit/-/qunit-2.19.5.tgz", - "integrity": "sha512-NvyN1m6nKlRpAXETsTdqzEfW6C+5xbIqrXxQbnm8PmfxM7Ixi73KPoHgXCLJZHw8fd9pvCm3gVeX3nBYRuZLYQ==" + "version": "2.19.6", + "resolved": "https://registry.npmjs.org/@types/qunit/-/qunit-2.19.6.tgz", + "integrity": "sha512-bz9STa6EHurtpSfn5cNiScBladlw43bM+7luQA985Kd9YlF4dZaLmKt3c5/oSyN1AWAl50YBpqTq0BxCP64nGg==" }, "@types/react": { - "version": "16.14.41", - "resolved": "https://registry.npmjs.org/@types/react/-/react-16.14.41.tgz", - "integrity": "sha512-h+joCKF2r5rdECoM1U8WCEIHBp5/0TSR5Nyq8gtnnYY1n2WqGuj3indYqTjMb2/b5g2rfxJV6u4jUFq95lbT6Q==", + "version": "16.14.43", + "resolved": "https://registry.npmjs.org/@types/react/-/react-16.14.43.tgz", + "integrity": "sha512-7zdjv7jvoLLQg1tTvpQsm+hyNUMT2mPlNV1+d0I8fbGhkJl82spopMyBlu4wb1dviZAxpGdk5eHu/muacknnfw==", "requires": { "@types/prop-types": "*", "@types/scheduler": "*", @@ -7036,15 +7040,15 @@ } }, "@typescript-eslint/eslint-plugin": { - "version": "5.59.7", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.59.7.tgz", - "integrity": "sha512-BL+jYxUFIbuYwy+4fF86k5vdT9lT0CNJ6HtwrIvGh0PhH8s0yy5rjaKH2fDCrz5ITHy07WCzVGNvAmjJh4IJFA==", + "version": "5.60.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.60.0.tgz", + "integrity": "sha512-78B+anHLF1TI8Jn/cD0Q00TBYdMgjdOn980JfAVa9yw5sop8nyTfVOQAv6LWywkOGLclDBtv5z3oxN4w7jxyNg==", "peer": true, "requires": { "@eslint-community/regexpp": "^4.4.0", - "@typescript-eslint/scope-manager": "5.59.7", - "@typescript-eslint/type-utils": "5.59.7", - "@typescript-eslint/utils": "5.59.7", + "@typescript-eslint/scope-manager": "5.60.0", + "@typescript-eslint/type-utils": "5.60.0", + "@typescript-eslint/utils": "5.60.0", "debug": "^4.3.4", "grapheme-splitter": "^1.0.4", "ignore": "^5.2.0", @@ -7054,53 +7058,53 @@ } }, "@typescript-eslint/parser": { - "version": "5.59.7", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.59.7.tgz", - "integrity": "sha512-VhpsIEuq/8i5SF+mPg9jSdIwgMBBp0z9XqjiEay+81PYLJuroN+ET1hM5IhkiYMJd9MkTz8iJLt7aaGAgzWUbQ==", + "version": "5.60.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.60.0.tgz", + "integrity": "sha512-jBONcBsDJ9UoTWrARkRRCgDz6wUggmH5RpQVlt7BimSwaTkTjwypGzKORXbR4/2Hqjk9hgwlon2rVQAjWNpkyQ==", "peer": true, "requires": { - "@typescript-eslint/scope-manager": "5.59.7", - "@typescript-eslint/types": "5.59.7", - "@typescript-eslint/typescript-estree": "5.59.7", + "@typescript-eslint/scope-manager": "5.60.0", + "@typescript-eslint/types": "5.60.0", + "@typescript-eslint/typescript-estree": "5.60.0", "debug": "^4.3.4" } }, "@typescript-eslint/scope-manager": { - "version": "5.59.7", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.59.7.tgz", - "integrity": "sha512-FL6hkYWK9zBGdxT2wWEd2W8ocXMu3K94i3gvMrjXpx+koFYdYV7KprKfirpgY34vTGzEPPuKoERpP8kD5h7vZQ==", + "version": "5.60.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.60.0.tgz", + "integrity": "sha512-hakuzcxPwXi2ihf9WQu1BbRj1e/Pd8ZZwVTG9kfbxAMZstKz8/9OoexIwnmLzShtsdap5U/CoQGRCWlSuPbYxQ==", "peer": true, "requires": { - "@typescript-eslint/types": "5.59.7", - "@typescript-eslint/visitor-keys": "5.59.7" + "@typescript-eslint/types": "5.60.0", + "@typescript-eslint/visitor-keys": "5.60.0" } }, "@typescript-eslint/type-utils": { - "version": "5.59.7", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.59.7.tgz", - "integrity": "sha512-ozuz/GILuYG7osdY5O5yg0QxXUAEoI4Go3Do5xeu+ERH9PorHBPSdvD3Tjp2NN2bNLh1NJQSsQu2TPu/Ly+HaQ==", + "version": "5.60.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.60.0.tgz", + "integrity": "sha512-X7NsRQddORMYRFH7FWo6sA9Y/zbJ8s1x1RIAtnlj6YprbToTiQnM6vxcMu7iYhdunmoC0rUWlca13D5DVHkK2g==", "peer": true, "requires": { - "@typescript-eslint/typescript-estree": "5.59.7", - "@typescript-eslint/utils": "5.59.7", + "@typescript-eslint/typescript-estree": "5.60.0", + "@typescript-eslint/utils": "5.60.0", "debug": "^4.3.4", "tsutils": "^3.21.0" } }, "@typescript-eslint/types": { - "version": "5.59.7", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.59.7.tgz", - "integrity": "sha512-UnVS2MRRg6p7xOSATscWkKjlf/NDKuqo5TdbWck6rIRZbmKpVNTLALzNvcjIfHBE7736kZOFc/4Z3VcZwuOM/A==", + "version": "5.60.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.60.0.tgz", + "integrity": "sha512-ascOuoCpNZBccFVNJRSC6rPq4EmJ2NkuoKnd6LDNyAQmdDnziAtxbCGWCbefG1CNzmDvd05zO36AmB7H8RzKPA==", "peer": true }, "@typescript-eslint/typescript-estree": { - "version": "5.59.7", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.59.7.tgz", - "integrity": "sha512-4A1NtZ1I3wMN2UGDkU9HMBL+TIQfbrh4uS0WDMMpf3xMRursDbqEf1ahh6vAAe3mObt8k3ZATnezwG4pdtWuUQ==", + "version": "5.60.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.60.0.tgz", + "integrity": "sha512-R43thAuwarC99SnvrBmh26tc7F6sPa2B3evkXp/8q954kYL6Ro56AwASYWtEEi+4j09GbiNAHqYwNNZuNlARGQ==", "peer": true, "requires": { - "@typescript-eslint/types": "5.59.7", - "@typescript-eslint/visitor-keys": "5.59.7", + "@typescript-eslint/types": "5.60.0", + "@typescript-eslint/visitor-keys": "5.60.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -7109,28 +7113,28 @@ } }, "@typescript-eslint/utils": { - "version": "5.59.7", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.59.7.tgz", - "integrity": "sha512-yCX9WpdQKaLufz5luG4aJbOpdXf/fjwGMcLFXZVPUz3QqLirG5QcwwnIHNf8cjLjxK4qtzTO8udUtMQSAToQnQ==", + "version": "5.60.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.60.0.tgz", + "integrity": "sha512-ba51uMqDtfLQ5+xHtwlO84vkdjrqNzOnqrnwbMHMRY8Tqeme8C2Q8Fc7LajfGR+e3/4LoYiWXUM6BpIIbHJ4hQ==", "peer": true, "requires": { "@eslint-community/eslint-utils": "^4.2.0", "@types/json-schema": "^7.0.9", "@types/semver": "^7.3.12", - "@typescript-eslint/scope-manager": "5.59.7", - "@typescript-eslint/types": "5.59.7", - "@typescript-eslint/typescript-estree": "5.59.7", + "@typescript-eslint/scope-manager": "5.60.0", + "@typescript-eslint/types": "5.60.0", + "@typescript-eslint/typescript-estree": "5.60.0", "eslint-scope": "^5.1.1", "semver": "^7.3.7" } }, "@typescript-eslint/visitor-keys": { - "version": "5.59.7", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.59.7.tgz", - "integrity": "sha512-tyN+X2jvMslUszIiYbF0ZleP+RqQsFVpGrKI6e0Eet1w8WmhsAtmzaqm8oM8WJQ1ysLwhnsK/4hYHJjOgJVfQQ==", + "version": "5.60.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.60.0.tgz", + "integrity": "sha512-wm9Uz71SbCyhUKgcaPRauBdTegUyY/ZWl8gLwD/i/ybJqscrrdVSFImpvUz16BLPChIeKBK5Fa9s6KDQjsjyWw==", "peer": true, "requires": { - "@typescript-eslint/types": "5.59.7", + "@typescript-eslint/types": "5.60.0", "eslint-visitor-keys": "^3.3.0" } }, @@ -7140,9 +7144,9 @@ "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" }, "acorn": { - "version": "8.8.2", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", - "integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==", + "version": "8.9.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.9.0.tgz", + "integrity": "sha512-jaVNAFBHNLXspO543WnNNPZFRtavh3skAkITqD0/2aeMkKZTN+254PyhwxFYrk3vQ1xfY+2wbesJMs/JC8/PwQ==", "peer": true }, "acorn-jsx": { @@ -7346,14 +7350,14 @@ } }, "browserslist": { - "version": "4.21.5", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.5.tgz", - "integrity": "sha512-tUkiguQGW7S3IhB7N+c2MV/HZPSCPAAiYBZXLsBhFB/PCy6ZKKsZrmBayHV9fdGV/ARIfJ14NkxKzRDjvp7L6w==", + "version": "4.21.9", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.9.tgz", + "integrity": "sha512-M0MFoZzbUrRU4KNfCrDLnvyE7gub+peetoTid3TBIqtunaDJyXlwhakT+/VkvSXcfIzFfK/nkCs4nmyTmxdNSg==", "requires": { - "caniuse-lite": "^1.0.30001449", - "electron-to-chromium": "^1.4.284", - "node-releases": "^2.0.8", - "update-browserslist-db": "^1.0.10" + "caniuse-lite": "^1.0.30001503", + "electron-to-chromium": "^1.4.431", + "node-releases": "^2.0.12", + "update-browserslist-db": "^1.0.11" } }, "buffer": { @@ -7386,9 +7390,9 @@ "integrity": "sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA==" }, "cacheable-request": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-7.0.2.tgz", - "integrity": "sha512-pouW8/FmiPQbuGpkXQ9BAPv/Mo5xDGANgSNXzTzJ8DrKGuXOssM4wIQRjfanNRh3Yu5cfYPvcorqbhg2KIJtew==", + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-7.0.4.tgz", + "integrity": "sha512-v+p6ongsrp0yTGbJXjgxPow2+DL93DASP4kXCDKb8/bwRtt9OEF3whggkkDkGNzgcWy2XaF4a8nZglC7uElscg==", "requires": { "clone-response": "^1.0.2", "get-stream": "^5.1.0", @@ -7410,9 +7414,9 @@ "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==" }, "caniuse-lite": { - "version": "1.0.30001489", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001489.tgz", - "integrity": "sha512-x1mgZEXK8jHIfAxm+xgdpHpk50IN3z3q3zP261/WS+uvePxW8izXuCu6AHz0lkuYTlATDehiZ/tNyYBdSQsOUQ==" + "version": "1.0.30001505", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001505.tgz", + "integrity": "sha512-jaAOR5zVtxHfL0NjZyflVTtXm3D3J9P15zSJ7HmQF8dSKGA6tqzQq+0ZI3xkjyQj46I4/M0K2GbMpcAFOcbr3A==" }, "chalk": { "version": "4.1.2", @@ -7692,9 +7696,9 @@ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "electron-to-chromium": { - "version": "1.4.403", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.403.tgz", - "integrity": "sha512-evCMqXJWmbQHdlh307peXNguqVIMmcLGrQwXiR+Qc98js8jPDeT9rse1+EF2YRjWgueuzj1r4WWLAe4/U+xjMg==" + "version": "1.4.435", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.435.tgz", + "integrity": "sha512-B0CBWVFhvoQCW/XtjRzgrmqcgVWg6RXOEM/dK59+wFV93BFGR6AeNKc4OyhM+T3IhJaOOG8o/V+33Y2mwJWtzw==" }, "encodeurl": { "version": "1.0.2", @@ -7734,16 +7738,16 @@ "peer": true }, "eslint": { - "version": "8.41.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.41.0.tgz", - "integrity": "sha512-WQDQpzGBOP5IrXPo4Hc0814r4/v2rrIsB0rhT7jtunIalgg6gYXWhRMOejVO8yH21T/FGaxjmFjBMNqcIlmH1Q==", + "version": "8.43.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.43.0.tgz", + "integrity": "sha512-aaCpf2JqqKesMFGgmRPessmVKjcGXqdlAYLLC3THM8t5nBRZRQ+st5WM/hoJXkdioEXLLbXgclUpM0TXo5HX5Q==", "peer": true, "requires": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.4.0", "@eslint/eslintrc": "^2.0.3", - "@eslint/js": "8.41.0", - "@humanwhocodes/config-array": "^0.11.8", + "@eslint/js": "8.43.0", + "@humanwhocodes/config-array": "^0.11.10", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", "ajv": "^6.10.0", @@ -9140,9 +9144,9 @@ } }, "node-releases": { - "version": "2.0.11", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.11.tgz", - "integrity": "sha512-+M0PwXeU80kRohZ3aT4J/OnR+l9/KD2nVLNNoRgFtnf+umQVFdGBAO2N8+nCnEi0xlh/Wk3zOGC+vNNx+uM79Q==" + "version": "2.0.12", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.12.tgz", + "integrity": "sha512-QzsYKWhXTWx8h1kIvqfnC++o0pEmpRQA/aenALsL2F4pqNVr7YzcdMlDij5WBnwftRbJCNJL/O7zdKaxKPHqgQ==" }, "node-watch": { "version": "0.7.3", @@ -9735,9 +9739,9 @@ } }, "rollup": { - "version": "3.23.0", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.23.0.tgz", - "integrity": "sha512-h31UlwEi7FHihLe1zbk+3Q7z1k/84rb9BSwmBSr/XjOCEaBJ2YyedQDuM0t/kfOS0IxM+vk1/zI9XxYj9V+NJQ==", + "version": "3.25.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.25.1.tgz", + "integrity": "sha512-tywOR+rwIt5m2ZAWSe5AIJcTat8vGlnPFAv15ycCrw33t6iFsXZ6mzHVFh2psSjxQPmI+xgzMZZizUAukBI4aQ==", "requires": { "fsevents": "~2.3.2" } @@ -10136,9 +10140,9 @@ "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" }, "tslib": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.2.tgz", - "integrity": "sha512-5svOrSA2w3iGFDs1HibEVBGbDrAY82bFQ3HZ3ixB+88nsbsWQoKqDRb5UBYAUPEzbBn6dAp5gRNXglySbx1MlA==" + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.3.tgz", + "integrity": "sha512-mSxlJJwl3BMEQCUNnxXBU9jP4JBktcEGhURcPR6VQVlnP0FdDEsIaz0C35dXNGLyRfrATNofF0F5p2KPxQgB+w==" }, "tsutils": { "version": "3.21.0", diff --git a/shared/AppInsightsCommon/src/Interfaces/IConfig.ts b/shared/AppInsightsCommon/src/Interfaces/IConfig.ts index f030c7ca6..588330533 100644 --- a/shared/AppInsightsCommon/src/Interfaces/IConfig.ts +++ b/shared/AppInsightsCommon/src/Interfaces/IConfig.ts @@ -1,6 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { IConfiguration, ICustomProperties, isNullOrUndefined } from "@microsoft/applicationinsights-core-js"; import { DistributedTracingModes } from "../Enums"; import { IRequestContext } from "./IRequestContext"; import { IStorageBuffer } from "./IStorageBuffer"; diff --git a/tools/applicationinsights-web-snippet/package.json b/tools/applicationinsights-web-snippet/package.json index f0492cd15..69c163cda 100644 --- a/tools/applicationinsights-web-snippet/package.json +++ b/tools/applicationinsights-web-snippet/package.json @@ -25,6 +25,7 @@ "devDependencies": { "@types/qunit": "^2.19.3", "@microsoft/ai-test-framework": "0.0.1", + "@microsoft/applicationinsights-common": "3.0.2", "@microsoft/applicationinsights-rollup-plugin-uglify3-js": "1.0.0", "@microsoft/applicationinsights-rollup-es5": "1.0.2", "typescript": "^4.9.3", diff --git a/tools/applicationinsights-web-snippet/src/snippet.xts b/tools/applicationinsights-web-snippet/src/snippet.ts similarity index 74% rename from tools/applicationinsights-web-snippet/src/snippet.xts rename to tools/applicationinsights-web-snippet/src/snippet.ts index b331ecfe3..e65b71358 100644 --- a/tools/applicationinsights-web-snippet/src/snippet.xts +++ b/tools/applicationinsights-web-snippet/src/snippet.ts @@ -1,30 +1,32 @@ -(function (win: Window, doc: Docuemnt, snipConfig: ISnippetConfig) { - let 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 strConStringIKey = strInstrumentationKey[strToLowerCase](); - var strEmpty = ""; - var strUndefined = "undefined"; - var strCrossOrigin = "crossOrigin"; +import { AIConfig, AppInsights, Envelope, Fields, ISnippetConfig, ScriptElement } from "./type"; - 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 +(function (win: Window, doc: Document, snipConfig: ISnippetConfig) { + let locn: Location = win.location; + let helpLink = "https://go.microsoft.com/fwlink/?linkid=2128109"; + let scriptText = "script"; + let strInstrumentationKey = "instrumentationKey"; + let strIngestionendpoint = "ingestionendpoint"; + let strDisableExceptionTracking = "disableExceptionTracking"; + let strAiDevice = "ai.device."; + let strAiOperationName = "ai.operation.name"; + let strAiSdkVersion = "ai.internal.sdkVersion"; + let strToLowerCase = "toLowerCase"; + let strConStringIKey = strInstrumentationKey[strToLowerCase](); + let strEmpty = ""; + let strUndefined = "undefined"; + let strCrossOrigin = "crossOrigin"; + + let strPostMethod = "POST"; + let sdkInstanceName = "appInsightsSDK"; // required for Initialization to find the current instance + let 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 = { + let aiSdk = win[aiName] || (function (aiConfig: AIConfig) { + let loadFailed = false; + let handled = false; + let appInsights:AppInsights= { initialize: true, // initialize sdk on download queue: [], sv: "6", // Track the actual snippet version for reporting. @@ -32,12 +34,12 @@ config: aiConfig }; function _parseConnectionString() { - var fields = {}; - var connectionString = aiConfig.connectionString; + let fields:Fields = {}; + let connectionString = aiConfig.connectionString; if (connectionString) { - var kvPairs = connectionString.split(";"); - for (var lp = 0; lp < kvPairs.length; lp++) { - var kvParts = kvPairs[lp].split("="); + let kvPairs = connectionString.split(";"); + for (let lp = 0; lp < kvPairs.length; lp++) { + let kvParts = kvPairs[lp].split("="); if (kvParts.length === 2) { // only save fields with valid formats fields[kvParts[0][strToLowerCase]()] = kvParts[1]; @@ -48,23 +50,23 @@ // apply the default endpoints if (!fields[strIngestionendpoint]) { // use endpoint suffix where overrides are not provided - var endpointSuffix = fields.endpointsuffix; + let endpointSuffix = fields.endpointsuffix; // Only fetch the location if a suffix was supplied - var fLocation = endpointSuffix ? fields.location : null; + let fLocation = endpointSuffix ? fields.location : null; fields[strIngestionendpoint] = "https://" + (fLocation ? fLocation + "." : strEmpty) + "dc." + (endpointSuffix || "services.visualstudio.com"); } return fields; } - function _sendEvents(evts, endpointUrl) { + function _sendEvents(evts:Envelope[], endpointUrl?:any) { if (JSON) { - var sender = win.fetch; + let 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(); + let xhr = new XMLHttpRequest(); xhr.open(strPostMethod, endpointUrl); xhr.setRequestHeader("Content-type", "application/json"); xhr.send(JSON.stringify(evts)); @@ -72,14 +74,14 @@ } } - function _reportFailure(targetSrc) { - var conString = _parseConnectionString(); - var iKey = conString[strConStringIKey] || aiConfig[strInstrumentationKey] || strEmpty; - var ingest = conString[strIngestionendpoint]; - var endpointUrl = ingest ? ingest + "/v2/track" : aiConfig.endpointUrl; // only add /v2/track when from connectionstring + function _reportFailure(targetSrc:string) { + let conString = _parseConnectionString(); + let iKey = conString[strConStringIKey] || aiConfig[strInstrumentationKey] || strEmpty; + let ingest = conString[strIngestionendpoint]; + let endpointUrl = ingest ? ingest + "/v2/track" : aiConfig.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 = []; + let message = "SDK LOAD Failure: Failed to load Application Insights SDK script (See stack for details)"; + let evts:Envelope[] = []; evts.push(_createException(iKey, message, targetSrc, endpointUrl)); evts.push(_createInternal(iKey, message, targetSrc, endpointUrl)); @@ -88,9 +90,9 @@ // 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; + let date = new Date(); + function pad(num: Number) { + let r = strEmpty + num; if (r.length === 1) { r = "0" + r; } @@ -108,9 +110,9 @@ + "Z"; } - function _createEnvelope(iKey, theType) { - var tags = {}; - var type = "Browser"; + function _createEnvelope(iKey:string, theType:string) { + let tags = {}; + let type = "Browser"; tags[strAiDevice + "id"] = type[strToLowerCase](); tags[strAiDevice + "type"] = type; tags[strAiOperationName] = locn && locn.pathname || "_unknown_"; @@ -130,22 +132,23 @@ }; } - function _createInternal(iKey, message, targetSrc, endpointUrl) { - var envelope = _createEnvelope(iKey, "Message"); - var data = envelope.data; + function _createInternal(iKey:string, message:string, targetSrc:string, endpointUrl:any) { + let envelope : Envelope = _createEnvelope(iKey, "Message"); + let data = envelope.data; data.baseType = "MessageData"; - var baseData = data.baseData; + let 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; + function _createException(iKey:string, message:string, targetSrc:string, endpointUrl:any) { + let envelope : Envelope = _createEnvelope(iKey, "Exception"); + let data = envelope.data; data.baseType = "ExceptionData"; data.baseData.exceptions = [{ typeName: "SDKLoadFailed", @@ -159,7 +162,7 @@ } // Assigning these to local variables allows them to be minified to save space: - var targetSrc = aiConfig.url || snipConfig.src; + let targetSrc = aiConfig.url || snipConfig.src; if (targetSrc) { const _handleError = (evt?: any) => { loadFailed = true; @@ -170,7 +173,7 @@ } } - const _handleLoad = (evt, isAbort) => { + const _handleLoad = (evt?: any, isAbort?:any) => { if (!handled) { // IE10, Opera calls loaded before the script is processed. // so delaying to give the script a chance to be processed @@ -183,20 +186,17 @@ } const _createScript = () => { - var scriptElement = doc.createElement(scriptText); + let scriptElement : ScriptElement = doc.createElement(scriptText); scriptElement.src = targetSrc; - // Allocate Cross origin only if defined and available - var crossOrigin = snipConfig[strCrossOrigin]; + let 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) { + scriptElement.onreadystatechange = function (evt?:any, isAbort?:any) { if (scriptElement.readyState === "loaded" || scriptElement.readyState === "complete") { _handleLoad(evt, isAbort); } @@ -205,10 +205,10 @@ return scriptElement; } - var theScript = _createScript(); - if (snipConfig.ld < 0) { + let theScript = _createScript(); + if (snipConfig.ld && snipConfig.ld < 0) { // if user wants to append tag to document head, blocking page load - var headNode = doc.getElementsByTagName("head")[0]; + let headNode = doc.getElementsByTagName("head")[0]; headNode.appendChild(theScript); } else { setTimeout(function () { @@ -222,16 +222,16 @@ try { appInsights.cookie = doc.cookie; } catch (e) { - // do Nothing + // eslint-disable-next-line no-empty } - function _createMethods(methods) { + function _createMethods(methods:any[]) { while (methods.length) { (function (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; + let 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 () { @@ -244,9 +244,9 @@ } } - var track = "track"; - var trackPage = "TrackPage"; - var trackEvent = "TrackEvent"; + let track = "track"; + let trackPage = "TrackPage"; + let trackEvent = "TrackEvent"; _createMethods([track + "Event", track + "PageView", track + "Exception", @@ -275,13 +275,13 @@ // 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 ||{}); + let analyticsCfg = ((aiConfig.extensionConfig || {}).ApplicationInsightsAnalytics ||{}); if (!(aiConfig[strDisableExceptionTracking] === true || analyticsCfg[strDisableExceptionTracking] === true)) { - var method = "onerror"; + let 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); + let originalOnError = win[method]; + win[method] = function(message:string, url:string, lineNumber:Number, columnNumber:Number, error?:any) { + let handled = originalOnError && originalOnError(message, url, lineNumber, columnNumber, error); if (handled !== true) { appInsights["_" + method]({ message: message, diff --git a/tools/applicationinsights-web-snippet/src/type.ts b/tools/applicationinsights-web-snippet/src/type.ts new file mode 100644 index 000000000..057cd6928 --- /dev/null +++ b/tools/applicationinsights-web-snippet/src/type.ts @@ -0,0 +1,63 @@ + +import { IConfig } from "@microsoft/applicationinsights-common"; +export interface ISnippetConfig { + src: string; + name?: string; + ld?: number; + useXhr?: boolean; + crossOrigin?: string; + onInit?: any; + cfg: { + connectionString: any; + }; +} +export interface AIConfig extends IConfig{ + connectionString?: any; + instrumentationKey?: any; + endpointUrl?: string; + url?: string; + extensionConfig?: any; +} + +export interface Fields { + strIngestionendpoint?: any; + endpointsuffix?: any; + location?: any; + // Add other properties as needed + } + +export interface Envelope{ + time?: any; + iKey?: string; + name?: string; + sampleRate?: number; + tags?: any; + data: { + baseData: { + ver?: number; + exceptions?: any[]; + message?: string; + properties?: any; + }, + baseType?: any, + + } + } + +export interface ScriptElement extends HTMLElement{ + src?: any; + onload: any; + onreadystatechange?: any; + readyState?: any; + } + +export interface AppInsights{ + initialize: boolean; + queue: any[]; + sv: string; + version: number; + config: AIConfig; + cookie?: any; + core?: any; + + } \ No newline at end of file From a743f19a8876b79bff042233aea7d2acef5d2a41 Mon Sep 17 00:00:00 2001 From: siyuniu-ms Date: Tue, 20 Jun 2023 17:51:24 -0700 Subject: [PATCH 03/20] Create copy-generated.js --- .../src/copy-generated.js | 301 ++++++++++++++++++ 1 file changed, 301 insertions(+) create mode 100644 tools/applicationinsights-web-snippet/src/copy-generated.js diff --git a/tools/applicationinsights-web-snippet/src/copy-generated.js b/tools/applicationinsights-web-snippet/src/copy-generated.js new file mode 100644 index 000000000..9d0542060 --- /dev/null +++ b/tools/applicationinsights-web-snippet/src/copy-generated.js @@ -0,0 +1,301 @@ +(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 strConStringIKey = strInstrumentationKey[strToLowerCase](); + var strEmpty = ""; + var strUndefined = "undefined"; + var strCrossOrigin = "crossOrigin"; + 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, + queue: [], + sv: "6", + version: 2.0, + 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]; + } + } + } + // 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[strConStringIKey] || aiConfig[strInstrumentationKey] || strEmpty; + var ingest = conString[strIngestionendpoint]; + var endpointUrl = ingest ? ingest + "/v2/track" : aiConfig.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, "-"), + 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) { + var _handleError_1 = function (evt) { + loadFailed = true; + appInsights.queue = []; // Clear the queue + if (!handled) { + handled = true; + _reportFailure(targetSrc); + } + }; + var _handleLoad_1 = function (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_1(); + } + }, 500); + } + }; + var _createScript = function () { + 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_1; + scriptElement.onerror = _handleError_1; + // Some browsers support onload while others onreadystatechange and others both + scriptElement.onreadystatechange = function (evt, isAbort) { + if (scriptElement.readyState === "loaded" || scriptElement.readyState === "complete") { + _handleLoad_1(evt, isAbort); + } + }; + return scriptElement; + }; + var theScript_1 = _createScript(); + if (snipConfig.ld && snipConfig.ld < 0) { + // if user wants to append tag to document head, blocking page load + var headNode = doc.getElementsByTagName("head")[0]; + headNode.appendChild(theScript_1); + } + 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_1); + }, snipConfig.ld || 0); + } + } + // capture initial cookie + try { + appInsights.cookie = doc.cookie; + } + catch (e) { + // eslint-disable-next-line no-empty + } + function _createMethods(methods) { + while (methods.length) { + (function (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; + 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); + }); + } + }; + })(methods.pop()); + } + } + 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)) { + var method_1 = "onerror"; + _createMethods(["_" + method_1]); + var originalOnError_1 = win[method_1]; + win[method_1] = function (message, url, lineNumber, columnNumber, error) { + var handled = originalOnError_1 && originalOnError_1(message, url, lineNumber, columnNumber, error); + if (handled !== true) { + appInsights["_" + method_1]({ + message: message, + url: url, + lineNumber: lineNumber, + columnNumber: columnNumber, + error: error, + evt: win.event + }); + } + 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; + function _onInit() { + if (snipConfig.onInit) { + snipConfig.onInit(aiSdk); + } + } + // if somebody calls the snippet twice, don't report page view again + if (aiSdk.queue && aiSdk.queue.length === 0) { + aiSdk.queue.push(_onInit); + aiSdk.trackPageView({}); + } + else { + // Already loaded so just call the onInit + _onInit(); + } +})(window, document, { + src: "https://js.monitor.azure.com/scripts/b/ai.2.min.js", + // 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", + // onInit: null, // Once the application insights instance has loaded and initialized this callback function will be called with 1 argument -- the sdk instance (DO NOT ADD anything to the sdk.queue -- As they won't get called) + cfg: { + connectionString: "YOUR_CONNECTION_STRING" + } +}); +export {}; From 03fcd7ea3debd752273d9bf80dcf44dec901c7c5 Mon Sep 17 00:00:00 2001 From: siyuniu-ms Date: Tue, 20 Jun 2023 23:55:24 -0700 Subject: [PATCH 04/20] runnable --- common/config/rush/npm-shrinkwrap.json | 18 +++-- gruntfile.js | 10 ++- .../src/Interfaces/IConfig.ts | 1 + .../package.json | 9 ++- .../rollup.config.js | 74 +++++++++++++++++-- 5 files changed, 92 insertions(+), 20 deletions(-) diff --git a/common/config/rush/npm-shrinkwrap.json b/common/config/rush/npm-shrinkwrap.json index 1b11cb369..d2b834e9f 100644 --- a/common/config/rush/npm-shrinkwrap.json +++ b/common/config/rush/npm-shrinkwrap.json @@ -1077,8 +1077,9 @@ "node_modules/@rush-temp/applicationinsights-web-snippet": { "version": "0.0.0", "resolved": "file:projects/applicationinsights-web-snippet.tgz", - "integrity": "sha512-FpoD7gC1D0hizSjHJheYUnhf4okQAS+JNMEXrht2z1chtBeRfoGuS0uhHe3ZppMH294sWWOXNjMkQsZ3KmMV7g==", + "integrity": "sha512-aLq6Kb8Slqa2VOiv7atFDIMDaJO0IogxW4BVYOx6vbP3isAST2LwAnpyfsiTRpYdKIkmnn9Xx95ReilYF2rPKA==", "dependencies": { + "@microsoft/dynamicproto-js": "^2.0.2", "@nevware21/grunt-eslint-ts": "^0.2.2", "@nevware21/grunt-ts-plugin": "^0.4.3", "@rollup/plugin-commonjs": "^24.0.0", @@ -1954,9 +1955,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001505", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001505.tgz", - "integrity": "sha512-jaAOR5zVtxHfL0NjZyflVTtXm3D3J9P15zSJ7HmQF8dSKGA6tqzQq+0ZI3xkjyQj46I4/M0K2GbMpcAFOcbr3A==", + "version": "1.0.30001506", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001506.tgz", + "integrity": "sha512-6XNEcpygZMCKaufIcgpQNZNf00GEqc7VQON+9Rd0K1bMYo8xhMZRAo5zpbnbMNizi4YNgIDAFrdykWsvY3H4Hw==", "funding": [ { "type": "opencollective", @@ -6767,8 +6768,9 @@ }, "@rush-temp/applicationinsights-web-snippet": { "version": "file:projects\\applicationinsights-web-snippet.tgz", - "integrity": "sha512-FpoD7gC1D0hizSjHJheYUnhf4okQAS+JNMEXrht2z1chtBeRfoGuS0uhHe3ZppMH294sWWOXNjMkQsZ3KmMV7g==", + "integrity": "sha512-aLq6Kb8Slqa2VOiv7atFDIMDaJO0IogxW4BVYOx6vbP3isAST2LwAnpyfsiTRpYdKIkmnn9Xx95ReilYF2rPKA==", "requires": { + "@microsoft/dynamicproto-js": "^2.0.2", "@nevware21/grunt-eslint-ts": "^0.2.2", "@nevware21/grunt-ts-plugin": "^0.4.3", "@rollup/plugin-commonjs": "^24.0.0", @@ -7414,9 +7416,9 @@ "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==" }, "caniuse-lite": { - "version": "1.0.30001505", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001505.tgz", - "integrity": "sha512-jaAOR5zVtxHfL0NjZyflVTtXm3D3J9P15zSJ7HmQF8dSKGA6tqzQq+0ZI3xkjyQj46I4/M0K2GbMpcAFOcbr3A==" + "version": "1.0.30001506", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001506.tgz", + "integrity": "sha512-6XNEcpygZMCKaufIcgpQNZNf00GEqc7VQON+9Rd0K1bMYo8xhMZRAo5zpbnbMNizi4YNgIDAFrdykWsvY3H4Hw==" }, "chalk": { "version": "4.1.2", diff --git a/gruntfile.js b/gruntfile.js index 59b85ef87..b8c3b6027 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -28,10 +28,10 @@ module.exports = function (grunt) { } function generateNewSnippet(connString) { - // Before: create a rollup task to minify dest-es5/snippet.js -> build/es5/snippet.min.js + // TODO: Before: create a rollup task to minify dest-es5/snippet.js -> build/es5/snippet.min.js // Change this to web-snipet build/es5/snippet.min.js var prefix = "IKey"; - var snippetBuffer = grunt.file.read("./AISKU/snippet/snippet.min.js"); + var snippetBuffer = grunt.file.read("./tools/applicationinsights-web-snippet/build/output/snippet.min.js"); if (connString) { snippetBuffer = snippetBuffer.replace(/^\s*instrumentationKey:\s*\".*\"/gm, " connectionString: \"YOUR_CONNECTION_STRING\""); snippetBuffer = snippetBuffer.replace(/^\s*connectionString:\s*\".*\"/gm, " connectionString: \"YOUR_CONNECTION_STRING\""); @@ -674,12 +674,14 @@ module.exports = function (grunt) { }, 'string-replace': { 'generate-snippet-ikey': generateNewSnippet(false), - 'generate-snippet-connString': generateNewSnippet(true) + 'generate-snippet-connString': generateNewSnippet(true), + 'generate-min': minTasks("applicationinsights-web-snippet"), }, copy: { "web-snippet": { files: [ { src: "./tools/applicationinsights-web-snippet/build/output/applicationinsights-web-snippet.js", dest: `./tools/applicationinsights-web-snippet/dist-es5/applicationinsights-web-snippet.js` }, + { src: "./tools/applicationinsights-web-snippet/build/output/snippet.js", dest: `./tools/applicationinsights-web-snippet/dist-es5/snippet.js` }, ] }, config: { @@ -789,6 +791,8 @@ module.exports = function (grunt) { grunt.registerTask("chromedebugextension-restore", restoreTasks("chrome-debug-extension")); grunt.registerTask("websnippetReplace", ["copy:web-snippet", "string-replace:generate-snippet-ikey", "string-replace:generate-snippet-connString"]); + grunt.registerTask("snippet-min", minTasks("applicationinsights-web-snippet")); + grunt.registerTask("snippet-restore", minTasks("applicationinsights-web-snippet")); grunt.registerTask("websnippet", tsBuildActions("applicationinsights-web-snippet")); grunt.registerTask("websnippettests", tsTestActions("applicationinsights-web-snippet")); diff --git a/shared/AppInsightsCommon/src/Interfaces/IConfig.ts b/shared/AppInsightsCommon/src/Interfaces/IConfig.ts index 588330533..f030c7ca6 100644 --- a/shared/AppInsightsCommon/src/Interfaces/IConfig.ts +++ b/shared/AppInsightsCommon/src/Interfaces/IConfig.ts @@ -1,5 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +import { IConfiguration, ICustomProperties, isNullOrUndefined } from "@microsoft/applicationinsights-core-js"; import { DistributedTracingModes } from "../Enums"; import { IRequestContext } from "./IRequestContext"; import { IStorageBuffer } from "./IStorageBuffer"; diff --git a/tools/applicationinsights-web-snippet/package.json b/tools/applicationinsights-web-snippet/package.json index 69c163cda..3e695a690 100644 --- a/tools/applicationinsights-web-snippet/package.json +++ b/tools/applicationinsights-web-snippet/package.json @@ -18,8 +18,9 @@ "rebuild": "npm run build", "test": "grunt websnippettests", "lint": "tslint -p tsconfig.json", - "npm-pack": "npm pack" - + "npm-pack": "npm pack", + "ai-min": "grunt snippet-min", + "ai-restore": "grunt snippet-restore" }, "license": "MIT", "devDependencies": { @@ -42,5 +43,7 @@ "@nevware21/grunt-ts-plugin": "^0.4.3", "@nevware21/grunt-eslint-ts": "^0.2.2" }, - "dependencies": {} + "dependencies": { + "@microsoft/dynamicproto-js": "^2.0.2" + } } diff --git a/tools/applicationinsights-web-snippet/rollup.config.js b/tools/applicationinsights-web-snippet/rollup.config.js index e70ffe642..c3b432259 100644 --- a/tools/applicationinsights-web-snippet/rollup.config.js +++ b/tools/applicationinsights-web-snippet/rollup.config.js @@ -1,9 +1,13 @@ import replace from "@rollup/plugin-replace"; import commonjs from '@rollup/plugin-commonjs'; - - +import { createConfig } from "../../rollup.base.config"; +import { updateDistEsmFiles } from "../updateDistEsm/updateDistEsm"; const version = require("./package.json").version; const inputName = "./dist-es5/applicationinsights-web-snippet"; +const snippetInputName = "./dist-es5/snippet"; +const snippetOutputName = "snippet"; +const snippetOutputPath = "../../build/output/snippet"; + const outputName = "applicationinsights-web-snippet"; const distPath = "./dist/es5/"; const banner = [ @@ -13,6 +17,8 @@ const banner = [ " */" ].join("\n"); + + const nodeUmdRollupConfigFactory = () => { const nodeRollupConfig = { input: `${inputName}.js`, @@ -46,6 +52,39 @@ const nodeUmdRollupConfigFactory = () => { return nodeRollupConfig; }; +const snippetNodeUmdRollupConfigFactory = () => { + const nodeRollupConfig = { + input: `${snippetInputName}.js`, + output: { + file: `${distPath}/${snippetOutputName}.js`, + banner: banner, + format: "umd", + name: "Microsoft.ApplicationInsights-Web-Snippet", + extend: true, + freeze: false, + sourcemap: false, + externalLiveBindings: false, + globals:[ 'UglifyJs' ] + }, + plugins: [ + replace({ + preventAssignment: true, + delimiters: ["", ""], + values: { + "// Copyright (c) Microsoft Corporation. All rights reserved.": "", + "// Licensed under the MIT License.": "" + } + }), + commonjs({ + include: 'node_modules/**', + transformMixedEsModules: true + }) + ] + }; + + return nodeRollupConfig; +}; + const moduleRollupConfigFactory = (format) => { const moduleRollupConfig = { input: `${inputName}.js`, @@ -79,8 +118,31 @@ const moduleRollupConfigFactory = (format) => { return moduleRollupConfig; }; +const replaceValues = { + "// Copyright (c) Microsoft Corporation. All rights reserved.": "", + "// Licensed under the MIT License.": "" +}; +updateDistEsmFiles(replaceValues, banner, true, true, "dist-es5"); + +var tasks = []; +tasks = createConfig(banner, + { + namespace: "Microsoft.ApplicationInsights", + version: version, + node: { + entryPoint: snippetOutputName, + outputName: snippetOutputPath + }, + browser: { + entryPoint: snippetOutputName, + outputName: snippetOutputPath + }, + }, + [ "applicationinsights-web-snippet" ] +) + +tasks.push(nodeUmdRollupConfigFactory()); +tasks.push(moduleRollupConfigFactory('esm')); +tasks.push(snippetNodeUmdRollupConfigFactory()); -export default [ - nodeUmdRollupConfigFactory(), - moduleRollupConfigFactory('esm'), -]; +export default tasks; From 805e14bba04b7720501645a264159a0b12a4ef89 Mon Sep 17 00:00:00 2001 From: siyuniu-ms Date: Tue, 20 Jun 2023 23:56:18 -0700 Subject: [PATCH 05/20] Create copy-min.js --- tools/applicationinsights-web-snippet/src/copy-min.js | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 tools/applicationinsights-web-snippet/src/copy-min.js diff --git a/tools/applicationinsights-web-snippet/src/copy-min.js b/tools/applicationinsights-web-snippet/src/copy-min.js new file mode 100644 index 000000000..f0c59b974 --- /dev/null +++ b/tools/applicationinsights-web-snippet/src/copy-min.js @@ -0,0 +1,6 @@ +/*! + * Application Insights JavaScript SDK - Web Snippet, 1.1.0 + * Copyright (c) Microsoft and contributors. All rights reserved. + */ +var e=function(){"use strict";function e(){C.onInit&&C.onInit(i)}var v,y,T,t,n,i,S=window,k=document,C={src:"https://js.monitor.azure.com/scripts/b/ai.2.min.js",crossOrigin:"anonymous",cfg:{connectionString:"YOUR_CONNECTION_STRING"}},D=S.location,I="script",E="ingestionendpoint",N="disableExceptionTracking",b="ai.device.";"instrumentationKey"[v="toLowerCase"](),y="crossOrigin",T="POST",t="appInsightsSDK",n=C.name||"appInsights",(C.name||S[t])&&(S[t]=n),i=S[n]||function(u){var l=!1,d=!1,g={initialize:!0,queue:[],sv:"6",version:2,config:u};function f(e,t){var n={},i="Browser";return n[b+"id"]=i[v](),n[b+"type"]=i,n["ai.operation.name"]=D&&D.pathname||"_unknown_",n["ai.internal.sdkVersion"]="javascript:snippet_"+(g.sv||g.version),{time:(i=new Date).getUTCFullYear()+"-"+a(1+i.getUTCMonth())+"-"+a(i.getUTCDate())+"T"+a(i.getUTCHours())+":"+a(i.getUTCMinutes())+":"+a(i.getUTCSeconds())+"."+(i.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}}};function a(e){e=""+e;return 1===e.length?"0"+e:e}}var n,i,e,a,m=u.url||C.src;m&&(n=function(e){var t,n,i,a,o,s,r,c,p;l=!0,g.queue=[],d||(d=!0,a=m,r=(c=function(){var e,t={},n=u.connectionString;if(n)for(var i=n.split(";"),a=0;a Date: Wed, 21 Jun 2023 16:02:03 -0700 Subject: [PATCH 06/20] min could work if path is resolved --- common/config/rush/npm-shrinkwrap.json | 12 +-- gruntfile.js | 23 +++--- .../package.json | 8 +- .../rollup.config.js | 74 ++----------------- .../rollupSnippet.config.js | 74 +++++++++++++++++++ 5 files changed, 106 insertions(+), 85 deletions(-) create mode 100644 tools/applicationinsights-web-snippet/rollupSnippet.config.js diff --git a/common/config/rush/npm-shrinkwrap.json b/common/config/rush/npm-shrinkwrap.json index d2b834e9f..d734144de 100644 --- a/common/config/rush/npm-shrinkwrap.json +++ b/common/config/rush/npm-shrinkwrap.json @@ -2340,9 +2340,9 @@ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "node_modules/electron-to-chromium": { - "version": "1.4.435", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.435.tgz", - "integrity": "sha512-B0CBWVFhvoQCW/XtjRzgrmqcgVWg6RXOEM/dK59+wFV93BFGR6AeNKc4OyhM+T3IhJaOOG8o/V+33Y2mwJWtzw==" + "version": "1.4.436", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.436.tgz", + "integrity": "sha512-aktOxo8fnrMC8vOIBMVS3PXbT1nrPQ+SouUuN7Y0a+Rw3pOMrvIV92Ybnax7x4tugA+ZpYA5fOHTby7ama8OQQ==" }, "node_modules/encodeurl": { "version": "1.0.2", @@ -7698,9 +7698,9 @@ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "electron-to-chromium": { - "version": "1.4.435", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.435.tgz", - "integrity": "sha512-B0CBWVFhvoQCW/XtjRzgrmqcgVWg6RXOEM/dK59+wFV93BFGR6AeNKc4OyhM+T3IhJaOOG8o/V+33Y2mwJWtzw==" + "version": "1.4.436", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.436.tgz", + "integrity": "sha512-aktOxo8fnrMC8vOIBMVS3PXbT1nrPQ+SouUuN7Y0a+Rw3pOMrvIV92Ybnax7x4tugA+ZpYA5fOHTby7ama8OQQ==" }, "encodeurl": { "version": "1.0.2", diff --git a/gruntfile.js b/gruntfile.js index b8c3b6027..aa029a342 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -31,6 +31,7 @@ module.exports = function (grunt) { // TODO: Before: create a rollup task to minify dest-es5/snippet.js -> build/es5/snippet.min.js // Change this to web-snipet build/es5/snippet.min.js var prefix = "IKey"; + console.log("generateNewSnippet debug here ----- debug here --------- "); var snippetBuffer = grunt.file.read("./tools/applicationinsights-web-snippet/build/output/snippet.min.js"); if (connString) { snippetBuffer = snippetBuffer.replace(/^\s*instrumentationKey:\s*\".*\"/gm, " connectionString: \"YOUR_CONNECTION_STRING\""); @@ -49,7 +50,6 @@ module.exports = function (grunt) { cwd: srcPath, dest: "./tools/applicationinsights-web-snippet/dist-es5", src: "applicationinsights-web-snippet.js" - //src: `web-snippet${connString ? "-cs" : ""}.js` }], options: { replacements: [{ @@ -534,10 +534,10 @@ module.exports = function (grunt) { })); function tsBuildActions(name, addTests, replaceName) { + grunt.log.writeln(`Running build actions for "${name}"`); var actions = [ "eslint-ts:" + name + "-lint-fix" ]; - var aiMinifyConfig = theBuildConfig["ai-minify"] || {}; var gruntTsConfig = theBuildConfig["ts"]; var replaceConfig = theBuildConfig["string-replace"] || {}; @@ -674,16 +674,19 @@ module.exports = function (grunt) { }, 'string-replace': { 'generate-snippet-ikey': generateNewSnippet(false), - 'generate-snippet-connString': generateNewSnippet(true), - 'generate-min': minTasks("applicationinsights-web-snippet"), + 'generate-snippet-connString': generateNewSnippet(true) }, copy: { - "web-snippet": { + "snippet": { files: [ - { src: "./tools/applicationinsights-web-snippet/build/output/applicationinsights-web-snippet.js", dest: `./tools/applicationinsights-web-snippet/dist-es5/applicationinsights-web-snippet.js` }, { src: "./tools/applicationinsights-web-snippet/build/output/snippet.js", dest: `./tools/applicationinsights-web-snippet/dist-es5/snippet.js` }, ] }, + "web-snippet": { + files: [ + { src: "./tools/applicationinsights-web-snippet/build/output/applicationinsights-web-snippet.js", dest: `./tools/applicationinsights-web-snippet/dist-es5/applicationinsights-web-snippet.js` }, + ] + }, config: { files: [ { src: "./tools/config/config.json", dest: `./tools/config/browser/ai.config${configVer}.cfg.json` }, @@ -790,10 +793,12 @@ module.exports = function (grunt) { grunt.registerTask("chromedebugextension-min", minTasks("chrome-debug-extension")); grunt.registerTask("chromedebugextension-restore", restoreTasks("chrome-debug-extension")); - grunt.registerTask("websnippetReplace", ["copy:web-snippet", "string-replace:generate-snippet-ikey", "string-replace:generate-snippet-connString"]); - grunt.registerTask("snippet-min", minTasks("applicationinsights-web-snippet")); - grunt.registerTask("snippet-restore", minTasks("applicationinsights-web-snippet")); grunt.registerTask("websnippet", tsBuildActions("applicationinsights-web-snippet")); + grunt.registerTask("snippetCopy", ["copy:snippet"]); + grunt.registerTask("snippet-min", minTasks("applicationinsights-web-snippet")); + grunt.registerTask("websnippetReplace", ["copy:web-snippet", "string-replace:generate-snippet-ikey", "string-replace:generate-snippet-connString"]); + + grunt.registerTask("snippet-restore", restoreTasks("applicationinsights-web-snippet")); grunt.registerTask("websnippettests", tsTestActions("applicationinsights-web-snippet")); grunt.registerTask("clickanalytics", tsBuildActions("clickanalytics")); diff --git a/tools/applicationinsights-web-snippet/package.json b/tools/applicationinsights-web-snippet/package.json index 3e695a690..0b4741a17 100644 --- a/tools/applicationinsights-web-snippet/package.json +++ b/tools/applicationinsights-web-snippet/package.json @@ -11,9 +11,13 @@ "url": "https://github.com/microsoft/ApplicationInsights-JS/tree/main/extensions/applicationinsights-web-snippet" }, "scripts": { - "build": "npm run build:esm && npm run replace && npm run build:browser", - "replace": "grunt websnippetReplace", + "build": "npm run build:esm && npm run snippet-generate && npm run replace && npm run build:browser", "build:esm": "grunt websnippet", + "snippet-generate": "npm run snippetCopy && npm run build:snippet && npm run snippetMin", + "snippetCopy": "grunt snippetCopy", + "build:snippet": "rollup -c rollupSnippet.config.js --bundleConfigAsCjs", + "snippetMin": "grunt snippet-min", + "replace": "grunt websnippetReplace", "build:browser": "rollup -c rollup.config.js --bundleConfigAsCjs", "rebuild": "npm run build", "test": "grunt websnippettests", diff --git a/tools/applicationinsights-web-snippet/rollup.config.js b/tools/applicationinsights-web-snippet/rollup.config.js index c3b432259..e70ffe642 100644 --- a/tools/applicationinsights-web-snippet/rollup.config.js +++ b/tools/applicationinsights-web-snippet/rollup.config.js @@ -1,13 +1,9 @@ import replace from "@rollup/plugin-replace"; import commonjs from '@rollup/plugin-commonjs'; -import { createConfig } from "../../rollup.base.config"; -import { updateDistEsmFiles } from "../updateDistEsm/updateDistEsm"; + + const version = require("./package.json").version; const inputName = "./dist-es5/applicationinsights-web-snippet"; -const snippetInputName = "./dist-es5/snippet"; -const snippetOutputName = "snippet"; -const snippetOutputPath = "../../build/output/snippet"; - const outputName = "applicationinsights-web-snippet"; const distPath = "./dist/es5/"; const banner = [ @@ -17,8 +13,6 @@ const banner = [ " */" ].join("\n"); - - const nodeUmdRollupConfigFactory = () => { const nodeRollupConfig = { input: `${inputName}.js`, @@ -52,39 +46,6 @@ const nodeUmdRollupConfigFactory = () => { return nodeRollupConfig; }; -const snippetNodeUmdRollupConfigFactory = () => { - const nodeRollupConfig = { - input: `${snippetInputName}.js`, - output: { - file: `${distPath}/${snippetOutputName}.js`, - banner: banner, - format: "umd", - name: "Microsoft.ApplicationInsights-Web-Snippet", - extend: true, - freeze: false, - sourcemap: false, - externalLiveBindings: false, - globals:[ 'UglifyJs' ] - }, - plugins: [ - replace({ - preventAssignment: true, - delimiters: ["", ""], - values: { - "// Copyright (c) Microsoft Corporation. All rights reserved.": "", - "// Licensed under the MIT License.": "" - } - }), - commonjs({ - include: 'node_modules/**', - transformMixedEsModules: true - }) - ] - }; - - return nodeRollupConfig; -}; - const moduleRollupConfigFactory = (format) => { const moduleRollupConfig = { input: `${inputName}.js`, @@ -118,31 +79,8 @@ const moduleRollupConfigFactory = (format) => { return moduleRollupConfig; }; -const replaceValues = { - "// Copyright (c) Microsoft Corporation. All rights reserved.": "", - "// Licensed under the MIT License.": "" -}; -updateDistEsmFiles(replaceValues, banner, true, true, "dist-es5"); - -var tasks = []; -tasks = createConfig(banner, - { - namespace: "Microsoft.ApplicationInsights", - version: version, - node: { - entryPoint: snippetOutputName, - outputName: snippetOutputPath - }, - browser: { - entryPoint: snippetOutputName, - outputName: snippetOutputPath - }, - }, - [ "applicationinsights-web-snippet" ] -) - -tasks.push(nodeUmdRollupConfigFactory()); -tasks.push(moduleRollupConfigFactory('esm')); -tasks.push(snippetNodeUmdRollupConfigFactory()); -export default tasks; +export default [ + nodeUmdRollupConfigFactory(), + moduleRollupConfigFactory('esm'), +]; diff --git a/tools/applicationinsights-web-snippet/rollupSnippet.config.js b/tools/applicationinsights-web-snippet/rollupSnippet.config.js new file mode 100644 index 000000000..672cefde2 --- /dev/null +++ b/tools/applicationinsights-web-snippet/rollupSnippet.config.js @@ -0,0 +1,74 @@ +import replace from "@rollup/plugin-replace"; +import commonjs from '@rollup/plugin-commonjs'; +import { createConfig } from "../../rollup.base.config"; +import { updateDistEsmFiles } from "../updateDistEsm/updateDistEsm"; +const version = require("./package.json").version; +const snippetInputName = "./dist-es5/snippet"; +const snippetOutputName = "snippet"; +const snippetOutputPath = "../../build/output/snippet"; +const distPath = "./dist/es5/"; +const banner = [ + "/*!", + ` * Application Insights JavaScript SDK - Web Snippet, ${version}`, + " * Copyright (c) Microsoft and contributors. All rights reserved.", + " */" +].join("\n"); + +const snippetNodeUmdRollupConfigFactory = () => { + const nodeRollupConfig = { + input: `${snippetInputName}.js`, + output: { + file: `${distPath}/${snippetOutputName}.js`, + banner: banner, + format: "cjs", + name: "Microsoft.ApplicationInsights-Web-Snippet", + extend: true, + freeze: false, + sourcemap: false, + externalLiveBindings: false, + globals:[ 'UglifyJs' ] + }, + plugins: [ + replace({ + preventAssignment: true, + delimiters: ["", ""], + values: { + "// Copyright (c) Microsoft Corporation. All rights reserved.": "", + "// Licensed under the MIT License.": "" + } + }), + commonjs({ + include: 'node_modules/**', + transformMixedEsModules: true + }) + ] + }; + + return nodeRollupConfig; +}; + + +const replaceValues = { + "// Copyright (c) Microsoft Corporation. All rights reserved.": "", + "// Licensed under the MIT License.": "" +}; +updateDistEsmFiles(replaceValues, banner, true, true, "dist-es5"); + +let tasks = createConfig(banner, + { + namespace: "Microsoft.ApplicationInsights", + version: version, + node: { + entryPoint: snippetOutputName, + outputName: snippetOutputPath + }, + browser: { + entryPoint: snippetOutputName, + outputName: snippetOutputPath + }, + }, + [ "applicationinsights-web-snippet" ] +) + +tasks.unshift(snippetNodeUmdRollupConfigFactory()); +export default tasks; \ No newline at end of file From 16658a9eb829474ef80741d9eb6c486c9df9da89 Mon Sep 17 00:00:00 2001 From: siyuniu-ms Date: Wed, 21 Jun 2023 17:55:49 -0700 Subject: [PATCH 07/20] runnable --- common/config/rush/npm-shrinkwrap.json | 4 +- gruntfile.js | 38 +++++++++---------- .../package.json | 2 +- .../src/copy-min.js | 6 --- .../src/type.ts | 11 ++---- tools/grunt-tasks/stringReplace.js | 8 ++-- 6 files changed, 30 insertions(+), 39 deletions(-) delete mode 100644 tools/applicationinsights-web-snippet/src/copy-min.js diff --git a/common/config/rush/npm-shrinkwrap.json b/common/config/rush/npm-shrinkwrap.json index d734144de..dff9ca0c4 100644 --- a/common/config/rush/npm-shrinkwrap.json +++ b/common/config/rush/npm-shrinkwrap.json @@ -1077,7 +1077,7 @@ "node_modules/@rush-temp/applicationinsights-web-snippet": { "version": "0.0.0", "resolved": "file:projects/applicationinsights-web-snippet.tgz", - "integrity": "sha512-aLq6Kb8Slqa2VOiv7atFDIMDaJO0IogxW4BVYOx6vbP3isAST2LwAnpyfsiTRpYdKIkmnn9Xx95ReilYF2rPKA==", + "integrity": "sha512-TyiHI78+6sx8a16XpJK5qKIc7VBA7YWSL3YxBPkr2aW6mc+9xMt+C6cftgASzP6LI77RtOZB5JGbKBYsV6dwRw==", "dependencies": { "@microsoft/dynamicproto-js": "^2.0.2", "@nevware21/grunt-eslint-ts": "^0.2.2", @@ -6768,7 +6768,7 @@ }, "@rush-temp/applicationinsights-web-snippet": { "version": "file:projects\\applicationinsights-web-snippet.tgz", - "integrity": "sha512-aLq6Kb8Slqa2VOiv7atFDIMDaJO0IogxW4BVYOx6vbP3isAST2LwAnpyfsiTRpYdKIkmnn9Xx95ReilYF2rPKA==", + "integrity": "sha512-TyiHI78+6sx8a16XpJK5qKIc7VBA7YWSL3YxBPkr2aW6mc+9xMt+C6cftgASzP6LI77RtOZB5JGbKBYsV6dwRw==", "requires": { "@microsoft/dynamicproto-js": "^2.0.2", "@nevware21/grunt-eslint-ts": "^0.2.2", diff --git a/gruntfile.js b/gruntfile.js index aa029a342..38b9b355c 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -28,21 +28,6 @@ module.exports = function (grunt) { } function generateNewSnippet(connString) { - // TODO: Before: create a rollup task to minify dest-es5/snippet.js -> build/es5/snippet.min.js - // Change this to web-snipet build/es5/snippet.min.js - var prefix = "IKey"; - console.log("generateNewSnippet debug here ----- debug here --------- "); - var snippetBuffer = grunt.file.read("./tools/applicationinsights-web-snippet/build/output/snippet.min.js"); - if (connString) { - snippetBuffer = snippetBuffer.replace(/^\s*instrumentationKey:\s*\".*\"/gm, " connectionString: \"YOUR_CONNECTION_STRING\""); - snippetBuffer = snippetBuffer.replace(/^\s*connectionString:\s*\".*\"/gm, " connectionString: \"YOUR_CONNECTION_STRING\""); - prefix = "ConnString" - } else { - snippetBuffer = snippetBuffer.replace(/^\s*instrumentationKey:\s*\".*\"/gm, " connectionString: \"InstrumentationKey=INSTRUMENTATION_KEY\""); - snippetBuffer = snippetBuffer.replace(/^\s*connectionString:\s*\".*\"/gm, " connectionString: \"InstrumentationKey=INSTRUMENTATION_KEY\""); - } - var snippetStr = _encodeStr(snippetBuffer.toString()); - var expectedStr = `##replace${prefix}Snippet##`; var srcPath = "./tools/applicationinsights-web-snippet/dist-es5"; return { files: [{ @@ -52,10 +37,24 @@ module.exports = function (grunt) { src: "applicationinsights-web-snippet.js" }], options: { - replacements: [{ - pattern: expectedStr, - replacement: snippetStr - }] + replacements: function() { + var prefix = "IKey"; + var snippetBuffer = grunt.file.read("./tools/applicationinsights-web-snippet/build/output/snippet.min.js"); + if (connString) { + snippetBuffer = snippetBuffer.replace(/^\s*instrumentationKey:\s*\".*\"/gm, " connectionString: \"YOUR_CONNECTION_STRING\""); + snippetBuffer = snippetBuffer.replace(/^\s*connectionString:\s*\".*\"/gm, " connectionString: \"YOUR_CONNECTION_STRING\""); + prefix = "ConnString"; + } else { + snippetBuffer = snippetBuffer.replace(/^\s*instrumentationKey:\s*\".*\"/gm, " connectionString: \"InstrumentationKey=INSTRUMENTATION_KEY\""); + snippetBuffer = snippetBuffer.replace(/^\s*connectionString:\s*\".*\"/gm, " connectionString: \"InstrumentationKey=INSTRUMENTATION_KEY\""); + } + var snippetStr = _encodeStr(snippetBuffer.toString()); + var expectedStr = `##replace${prefix}Snippet##`; + return [{ + pattern: expectedStr, + replacement: snippetStr + }] + } } }; } @@ -534,7 +533,6 @@ module.exports = function (grunt) { })); function tsBuildActions(name, addTests, replaceName) { - grunt.log.writeln(`Running build actions for "${name}"`); var actions = [ "eslint-ts:" + name + "-lint-fix" ]; diff --git a/tools/applicationinsights-web-snippet/package.json b/tools/applicationinsights-web-snippet/package.json index 0b4741a17..21a3cda99 100644 --- a/tools/applicationinsights-web-snippet/package.json +++ b/tools/applicationinsights-web-snippet/package.json @@ -30,7 +30,7 @@ "devDependencies": { "@types/qunit": "^2.19.3", "@microsoft/ai-test-framework": "0.0.1", - "@microsoft/applicationinsights-common": "3.0.2", + "@microsoft/applicationinsights-web": "3.0.2", "@microsoft/applicationinsights-rollup-plugin-uglify3-js": "1.0.0", "@microsoft/applicationinsights-rollup-es5": "1.0.2", "typescript": "^4.9.3", diff --git a/tools/applicationinsights-web-snippet/src/copy-min.js b/tools/applicationinsights-web-snippet/src/copy-min.js deleted file mode 100644 index f0c59b974..000000000 --- a/tools/applicationinsights-web-snippet/src/copy-min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! - * Application Insights JavaScript SDK - Web Snippet, 1.1.0 - * Copyright (c) Microsoft and contributors. All rights reserved. - */ -var e=function(){"use strict";function e(){C.onInit&&C.onInit(i)}var v,y,T,t,n,i,S=window,k=document,C={src:"https://js.monitor.azure.com/scripts/b/ai.2.min.js",crossOrigin:"anonymous",cfg:{connectionString:"YOUR_CONNECTION_STRING"}},D=S.location,I="script",E="ingestionendpoint",N="disableExceptionTracking",b="ai.device.";"instrumentationKey"[v="toLowerCase"](),y="crossOrigin",T="POST",t="appInsightsSDK",n=C.name||"appInsights",(C.name||S[t])&&(S[t]=n),i=S[n]||function(u){var l=!1,d=!1,g={initialize:!0,queue:[],sv:"6",version:2,config:u};function f(e,t){var n={},i="Browser";return n[b+"id"]=i[v](),n[b+"type"]=i,n["ai.operation.name"]=D&&D.pathname||"_unknown_",n["ai.internal.sdkVersion"]="javascript:snippet_"+(g.sv||g.version),{time:(i=new Date).getUTCFullYear()+"-"+a(1+i.getUTCMonth())+"-"+a(i.getUTCDate())+"T"+a(i.getUTCHours())+":"+a(i.getUTCMinutes())+":"+a(i.getUTCSeconds())+"."+(i.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}}};function a(e){e=""+e;return 1===e.length?"0"+e:e}}var n,i,e,a,m=u.url||C.src;m&&(n=function(e){var t,n,i,a,o,s,r,c,p;l=!0,g.queue=[],d||(d=!0,a=m,r=(c=function(){var e,t={},n=u.connectionString;if(n)for(var i=n.split(";"),a=0;a Date: Wed, 21 Jun 2023 18:52:44 -0700 Subject: [PATCH 08/20] rewrite replace --- gruntfile.js | 11 ++-- .../rollupSnippet.config.js | 53 +------------------ 2 files changed, 9 insertions(+), 55 deletions(-) diff --git a/gruntfile.js b/gruntfile.js index 38b9b355c..47ec61a93 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -41,15 +41,18 @@ module.exports = function (grunt) { var prefix = "IKey"; var snippetBuffer = grunt.file.read("./tools/applicationinsights-web-snippet/build/output/snippet.min.js"); if (connString) { - snippetBuffer = snippetBuffer.replace(/^\s*instrumentationKey:\s*\".*\"/gm, " connectionString: \"YOUR_CONNECTION_STRING\""); - snippetBuffer = snippetBuffer.replace(/^\s*connectionString:\s*\".*\"/gm, " connectionString: \"YOUR_CONNECTION_STRING\""); + snippetBuffer = snippetBuffer.replace(/connectionString:\s*".*?"/gms, " connectionString: \"YOUR_CONNECTION_STRING\""); + snippetBuffer = snippetBuffer.replace(/connectionString:\s*".*?"/gms, " connectionString: \"YOUR_CONNECTION_STRING\""); prefix = "ConnString"; } else { - snippetBuffer = snippetBuffer.replace(/^\s*instrumentationKey:\s*\".*\"/gm, " connectionString: \"InstrumentationKey=INSTRUMENTATION_KEY\""); - snippetBuffer = snippetBuffer.replace(/^\s*connectionString:\s*\".*\"/gm, " connectionString: \"InstrumentationKey=INSTRUMENTATION_KEY\""); + snippetBuffer = snippetBuffer.replace(/connectionString:\s*".*?"/gms, " connectionString: \"InstrumentationKey=INSTRUMENTATION_KEY\""); + snippetBuffer = snippetBuffer.replace(/connectionString:\s*".*?"/gms, " connectionString: \"InstrumentationKey=INSTRUMENTATION_KEY\""); + let snippetBuffer2 = "cfg:{connectionString:\"YOUR_CONNECTION_STRING\""; + console.log("what is it doing", snippetBuffer2.replace(/^\s*connectionString:\s*\".*\"/gm, " connectionString: \"InstrumentationKey=INSTRUMENTATION_KEY\"")); } var snippetStr = _encodeStr(snippetBuffer.toString()); var expectedStr = `##replace${prefix}Snippet##`; + console.log("change expectedStr to " + expectedStr); return [{ pattern: expectedStr, replacement: snippetStr diff --git a/tools/applicationinsights-web-snippet/rollupSnippet.config.js b/tools/applicationinsights-web-snippet/rollupSnippet.config.js index 672cefde2..b3d1817b2 100644 --- a/tools/applicationinsights-web-snippet/rollupSnippet.config.js +++ b/tools/applicationinsights-web-snippet/rollupSnippet.config.js @@ -3,58 +3,11 @@ import commonjs from '@rollup/plugin-commonjs'; import { createConfig } from "../../rollup.base.config"; import { updateDistEsmFiles } from "../updateDistEsm/updateDistEsm"; const version = require("./package.json").version; -const snippetInputName = "./dist-es5/snippet"; + const snippetOutputName = "snippet"; const snippetOutputPath = "../../build/output/snippet"; -const distPath = "./dist/es5/"; -const banner = [ - "/*!", - ` * Application Insights JavaScript SDK - Web Snippet, ${version}`, - " * Copyright (c) Microsoft and contributors. All rights reserved.", - " */" -].join("\n"); - -const snippetNodeUmdRollupConfigFactory = () => { - const nodeRollupConfig = { - input: `${snippetInputName}.js`, - output: { - file: `${distPath}/${snippetOutputName}.js`, - banner: banner, - format: "cjs", - name: "Microsoft.ApplicationInsights-Web-Snippet", - extend: true, - freeze: false, - sourcemap: false, - externalLiveBindings: false, - globals:[ 'UglifyJs' ] - }, - plugins: [ - replace({ - preventAssignment: true, - delimiters: ["", ""], - values: { - "// Copyright (c) Microsoft Corporation. All rights reserved.": "", - "// Licensed under the MIT License.": "" - } - }), - commonjs({ - include: 'node_modules/**', - transformMixedEsModules: true - }) - ] - }; - - return nodeRollupConfig; -}; - - -const replaceValues = { - "// Copyright (c) Microsoft Corporation. All rights reserved.": "", - "// Licensed under the MIT License.": "" -}; -updateDistEsmFiles(replaceValues, banner, true, true, "dist-es5"); -let tasks = createConfig(banner, +export default createConfig("", { namespace: "Microsoft.ApplicationInsights", version: version, @@ -70,5 +23,3 @@ let tasks = createConfig(banner, [ "applicationinsights-web-snippet" ] ) -tasks.unshift(snippetNodeUmdRollupConfigFactory()); -export default tasks; \ No newline at end of file From 9a508f197c461ca36fcd2b98136fd8ef253f72d6 Mon Sep 17 00:00:00 2001 From: siyuniu-ms Date: Wed, 21 Jun 2023 18:57:32 -0700 Subject: [PATCH 09/20] bot --- gruntfile.js | 2 +- tools/applicationinsights-web-snippet/rollupSnippet.config.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gruntfile.js b/gruntfile.js index 47ec61a93..1a85934e2 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -55,7 +55,7 @@ module.exports = function (grunt) { console.log("change expectedStr to " + expectedStr); return [{ pattern: expectedStr, - replacement: snippetStr + replacement: snippetStr, }] } } diff --git a/tools/applicationinsights-web-snippet/rollupSnippet.config.js b/tools/applicationinsights-web-snippet/rollupSnippet.config.js index b3d1817b2..f799c27b9 100644 --- a/tools/applicationinsights-web-snippet/rollupSnippet.config.js +++ b/tools/applicationinsights-web-snippet/rollupSnippet.config.js @@ -20,6 +20,6 @@ export default createConfig("", outputName: snippetOutputPath }, }, - [ "applicationinsights-web-snippet" ] + [ "applicationinsights-web-snippet" ], ) From d676a6eb28b3d85230f538bca8fdc7336779ea36 Mon Sep 17 00:00:00 2001 From: siyuniu-ms Date: Wed, 21 Jun 2023 18:58:15 -0700 Subject: [PATCH 10/20] Update rollupSnippet.config.js --- tools/applicationinsights-web-snippet/rollupSnippet.config.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/tools/applicationinsights-web-snippet/rollupSnippet.config.js b/tools/applicationinsights-web-snippet/rollupSnippet.config.js index f799c27b9..bee0621c9 100644 --- a/tools/applicationinsights-web-snippet/rollupSnippet.config.js +++ b/tools/applicationinsights-web-snippet/rollupSnippet.config.js @@ -1,7 +1,4 @@ -import replace from "@rollup/plugin-replace"; -import commonjs from '@rollup/plugin-commonjs'; import { createConfig } from "../../rollup.base.config"; -import { updateDistEsmFiles } from "../updateDistEsm/updateDistEsm"; const version = require("./package.json").version; const snippetOutputName = "snippet"; From 5b5c45cb8b3ca8f2260d0ef27d7bb7141e4c8259 Mon Sep 17 00:00:00 2001 From: siyuniu-ms Date: Wed, 21 Jun 2023 19:00:35 -0700 Subject: [PATCH 11/20] Update gruntfile.js --- gruntfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gruntfile.js b/gruntfile.js index 1a85934e2..2ba0e6c30 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -56,7 +56,7 @@ module.exports = function (grunt) { return [{ pattern: expectedStr, replacement: snippetStr, - }] + }]; } } }; From 3915cba4c7c0945f7484f20aff9c1f0706727efb Mon Sep 17 00:00:00 2001 From: siyuniu-ms Date: Wed, 21 Jun 2023 19:01:18 -0700 Subject: [PATCH 12/20] Update rollupSnippet.config.js --- tools/applicationinsights-web-snippet/rollupSnippet.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/applicationinsights-web-snippet/rollupSnippet.config.js b/tools/applicationinsights-web-snippet/rollupSnippet.config.js index bee0621c9..1d103b503 100644 --- a/tools/applicationinsights-web-snippet/rollupSnippet.config.js +++ b/tools/applicationinsights-web-snippet/rollupSnippet.config.js @@ -17,6 +17,6 @@ export default createConfig("", outputName: snippetOutputPath }, }, - [ "applicationinsights-web-snippet" ], + [ "applicationinsights-web-snippet" ]; ) From d629d21b6819f4c08519a098ccb85e24e2c6787a Mon Sep 17 00:00:00 2001 From: siyuniu-ms Date: Wed, 21 Jun 2023 19:02:51 -0700 Subject: [PATCH 13/20] Update rollupSnippet.config.js --- tools/applicationinsights-web-snippet/rollupSnippet.config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/applicationinsights-web-snippet/rollupSnippet.config.js b/tools/applicationinsights-web-snippet/rollupSnippet.config.js index 1d103b503..954d86c1e 100644 --- a/tools/applicationinsights-web-snippet/rollupSnippet.config.js +++ b/tools/applicationinsights-web-snippet/rollupSnippet.config.js @@ -17,6 +17,6 @@ export default createConfig("", outputName: snippetOutputPath }, }, - [ "applicationinsights-web-snippet" ]; -) + [ "applicationinsights-web-snippet" ] +); From a111fba1d0851fd9abe0d4fde3cb37685b2fa7e7 Mon Sep 17 00:00:00 2001 From: siyuniu-ms Date: Wed, 21 Jun 2023 19:04:40 -0700 Subject: [PATCH 14/20] Update gruntfile.js --- gruntfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gruntfile.js b/gruntfile.js index 2ba0e6c30..64a390c31 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -55,7 +55,7 @@ module.exports = function (grunt) { console.log("change expectedStr to " + expectedStr); return [{ pattern: expectedStr, - replacement: snippetStr, + replacement: snippetStr }]; } } From 700abba5ee905c416b4353597fcf81b0db6c6f45 Mon Sep 17 00:00:00 2001 From: siyuniu-ms Date: Wed, 21 Jun 2023 19:23:50 -0700 Subject: [PATCH 15/20] Update AppInsightsCoreSize.Tests.ts --- .../Tests/Unit/src/AppInsightsCoreSize.Tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared/AppInsightsCore/Tests/Unit/src/AppInsightsCoreSize.Tests.ts b/shared/AppInsightsCore/Tests/Unit/src/AppInsightsCoreSize.Tests.ts index b8771f6b1..6bfe637d1 100644 --- a/shared/AppInsightsCore/Tests/Unit/src/AppInsightsCoreSize.Tests.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/AppInsightsCoreSize.Tests.ts @@ -2,8 +2,8 @@ import { Assert, AITestClass } from "@microsoft/ai-test-framework"; import * as pako from "pako"; export class AppInsightsCoreSizeCheck extends AITestClass { - private readonly MAX_RAW_SIZE = 55; - private readonly MAX_BUNDLE_SIZE = 55; + private readonly MAX_RAW_SIZE = 56; + private readonly MAX_BUNDLE_SIZE = 56; private readonly MAX_RAW_DEFLATE_SIZE = 24; private readonly MAX_BUNDLE_DEFLATE_SIZE = 24; private readonly rawFilePath = "../dist/es5/applicationinsights-core-js.min.js"; From 63ab1953bb20421c00f5085796289b512b1cb2f5 Mon Sep 17 00:00:00 2001 From: siyuniu-ms Date: Thu, 22 Jun 2023 17:21:27 -0700 Subject: [PATCH 16/20] update type --- common/config/rush/npm-shrinkwrap.json | 16 +- .../Tests/Unit/src/SnippetTests.ts | 2 +- .../package.json | 1 + .../src/copy-generated.js | 301 ------------------ .../src/snippet.ts | 29 +- .../src/type.ts | 44 +-- 6 files changed, 31 insertions(+), 362 deletions(-) delete mode 100644 tools/applicationinsights-web-snippet/src/copy-generated.js diff --git a/common/config/rush/npm-shrinkwrap.json b/common/config/rush/npm-shrinkwrap.json index dff9ca0c4..8384b9c86 100644 --- a/common/config/rush/npm-shrinkwrap.json +++ b/common/config/rush/npm-shrinkwrap.json @@ -1077,7 +1077,7 @@ "node_modules/@rush-temp/applicationinsights-web-snippet": { "version": "0.0.0", "resolved": "file:projects/applicationinsights-web-snippet.tgz", - "integrity": "sha512-TyiHI78+6sx8a16XpJK5qKIc7VBA7YWSL3YxBPkr2aW6mc+9xMt+C6cftgASzP6LI77RtOZB5JGbKBYsV6dwRw==", + "integrity": "sha512-3mjnTSu0le0mj2mI5NQkFWC5jd+lAL6D4d3Hgs+a5KMq/yLpIPUo/zq/qfSMDxulx+Ie6RAluEmfjWB48ycoiw==", "dependencies": { "@microsoft/dynamicproto-js": "^2.0.2", "@nevware21/grunt-eslint-ts": "^0.2.2", @@ -2340,9 +2340,9 @@ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "node_modules/electron-to-chromium": { - "version": "1.4.436", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.436.tgz", - "integrity": "sha512-aktOxo8fnrMC8vOIBMVS3PXbT1nrPQ+SouUuN7Y0a+Rw3pOMrvIV92Ybnax7x4tugA+ZpYA5fOHTby7ama8OQQ==" + "version": "1.4.438", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.438.tgz", + "integrity": "sha512-x94U0FhphEsHsOloCvlsujHCvoir0ZQ73ZAs/QN4PLx98uNvyEU79F75rq1db75Bx/atvuh7KPeuxelh+xfYJw==" }, "node_modules/encodeurl": { "version": "1.0.2", @@ -6768,7 +6768,7 @@ }, "@rush-temp/applicationinsights-web-snippet": { "version": "file:projects\\applicationinsights-web-snippet.tgz", - "integrity": "sha512-TyiHI78+6sx8a16XpJK5qKIc7VBA7YWSL3YxBPkr2aW6mc+9xMt+C6cftgASzP6LI77RtOZB5JGbKBYsV6dwRw==", + "integrity": "sha512-3mjnTSu0le0mj2mI5NQkFWC5jd+lAL6D4d3Hgs+a5KMq/yLpIPUo/zq/qfSMDxulx+Ie6RAluEmfjWB48ycoiw==", "requires": { "@microsoft/dynamicproto-js": "^2.0.2", "@nevware21/grunt-eslint-ts": "^0.2.2", @@ -7698,9 +7698,9 @@ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "electron-to-chromium": { - "version": "1.4.436", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.436.tgz", - "integrity": "sha512-aktOxo8fnrMC8vOIBMVS3PXbT1nrPQ+SouUuN7Y0a+Rw3pOMrvIV92Ybnax7x4tugA+ZpYA5fOHTby7ama8OQQ==" + "version": "1.4.438", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.438.tgz", + "integrity": "sha512-x94U0FhphEsHsOloCvlsujHCvoir0ZQ73ZAs/QN4PLx98uNvyEU79F75rq1db75Bx/atvuh7KPeuxelh+xfYJw==" }, "encodeurl": { "version": "1.0.2", diff --git a/tools/applicationinsights-web-snippet/Tests/Unit/src/SnippetTests.ts b/tools/applicationinsights-web-snippet/Tests/Unit/src/SnippetTests.ts index f64c1aa9f..fd819be9e 100644 --- a/tools/applicationinsights-web-snippet/Tests/Unit/src/SnippetTests.ts +++ b/tools/applicationinsights-web-snippet/Tests/Unit/src/SnippetTests.ts @@ -1,5 +1,5 @@ import { AITestClass } from "@microsoft/ai-test-framework"; -import { webSnippetVersion, webSnippet, webSnippetCs } from "../../../build/applicationinsights-web-snippet"; +import { webSnippetVersion, webSnippet, webSnippetCs } from "../../../dist-es5/applicationinsights-web-snippet"; export class SnippetTests extends AITestClass { diff --git a/tools/applicationinsights-web-snippet/package.json b/tools/applicationinsights-web-snippet/package.json index 21a3cda99..5235c7d1f 100644 --- a/tools/applicationinsights-web-snippet/package.json +++ b/tools/applicationinsights-web-snippet/package.json @@ -33,6 +33,7 @@ "@microsoft/applicationinsights-web": "3.0.2", "@microsoft/applicationinsights-rollup-plugin-uglify3-js": "1.0.0", "@microsoft/applicationinsights-rollup-es5": "1.0.2", + "@microsoft/applicationinsights-common": "3.0.2", "typescript": "^4.9.3", "tslib": "^2.0.0", "magic-string": "^0.25.7", diff --git a/tools/applicationinsights-web-snippet/src/copy-generated.js b/tools/applicationinsights-web-snippet/src/copy-generated.js deleted file mode 100644 index 9d0542060..000000000 --- a/tools/applicationinsights-web-snippet/src/copy-generated.js +++ /dev/null @@ -1,301 +0,0 @@ -(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 strConStringIKey = strInstrumentationKey[strToLowerCase](); - var strEmpty = ""; - var strUndefined = "undefined"; - var strCrossOrigin = "crossOrigin"; - 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, - queue: [], - sv: "6", - version: 2.0, - 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]; - } - } - } - // 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[strConStringIKey] || aiConfig[strInstrumentationKey] || strEmpty; - var ingest = conString[strIngestionendpoint]; - var endpointUrl = ingest ? ingest + "/v2/track" : aiConfig.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, "-"), - 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) { - var _handleError_1 = function (evt) { - loadFailed = true; - appInsights.queue = []; // Clear the queue - if (!handled) { - handled = true; - _reportFailure(targetSrc); - } - }; - var _handleLoad_1 = function (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_1(); - } - }, 500); - } - }; - var _createScript = function () { - 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_1; - scriptElement.onerror = _handleError_1; - // Some browsers support onload while others onreadystatechange and others both - scriptElement.onreadystatechange = function (evt, isAbort) { - if (scriptElement.readyState === "loaded" || scriptElement.readyState === "complete") { - _handleLoad_1(evt, isAbort); - } - }; - return scriptElement; - }; - var theScript_1 = _createScript(); - if (snipConfig.ld && snipConfig.ld < 0) { - // if user wants to append tag to document head, blocking page load - var headNode = doc.getElementsByTagName("head")[0]; - headNode.appendChild(theScript_1); - } - 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_1); - }, snipConfig.ld || 0); - } - } - // capture initial cookie - try { - appInsights.cookie = doc.cookie; - } - catch (e) { - // eslint-disable-next-line no-empty - } - function _createMethods(methods) { - while (methods.length) { - (function (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; - 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); - }); - } - }; - })(methods.pop()); - } - } - 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)) { - var method_1 = "onerror"; - _createMethods(["_" + method_1]); - var originalOnError_1 = win[method_1]; - win[method_1] = function (message, url, lineNumber, columnNumber, error) { - var handled = originalOnError_1 && originalOnError_1(message, url, lineNumber, columnNumber, error); - if (handled !== true) { - appInsights["_" + method_1]({ - message: message, - url: url, - lineNumber: lineNumber, - columnNumber: columnNumber, - error: error, - evt: win.event - }); - } - 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; - function _onInit() { - if (snipConfig.onInit) { - snipConfig.onInit(aiSdk); - } - } - // if somebody calls the snippet twice, don't report page view again - if (aiSdk.queue && aiSdk.queue.length === 0) { - aiSdk.queue.push(_onInit); - aiSdk.trackPageView({}); - } - else { - // Already loaded so just call the onInit - _onInit(); - } -})(window, document, { - src: "https://js.monitor.azure.com/scripts/b/ai.2.min.js", - // 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", - // onInit: null, // Once the application insights instance has loaded and initialized this callback function will be called with 1 argument -- the sdk instance (DO NOT ADD anything to the sdk.queue -- As they won't get called) - cfg: { - connectionString: "YOUR_CONNECTION_STRING" - } -}); -export {}; diff --git a/tools/applicationinsights-web-snippet/src/snippet.ts b/tools/applicationinsights-web-snippet/src/snippet.ts index e65b71358..f00833468 100644 --- a/tools/applicationinsights-web-snippet/src/snippet.ts +++ b/tools/applicationinsights-web-snippet/src/snippet.ts @@ -1,4 +1,6 @@ -import { AIConfig, AppInsights, Envelope, Fields, ISnippetConfig, ScriptElement } from "./type"; +import { AppInsights, Fields, ISnippetConfig } from "./type"; +import { IConfiguration, Snippet } from "@microsoft/applicationinsights-web"; +import { IEnvelope } from "@microsoft/applicationinsights-common"; (function (win: Window, doc: Document, snipConfig: ISnippetConfig) { let locn: Location = win.location; @@ -23,7 +25,7 @@ import { AIConfig, AppInsights, Envelope, Fields, ISnippetConfig, ScriptElement // Only set if supplied or another name is defined to avoid polluting the global namespace win[sdkInstanceName] = aiName; } - let aiSdk = win[aiName] || (function (aiConfig: AIConfig) { + let aiSdk = win[aiName] || (function (aiConfig: IConfiguration) { let loadFailed = false; let handled = false; let appInsights:AppInsights= { @@ -59,7 +61,7 @@ import { AIConfig, AppInsights, Envelope, Fields, ISnippetConfig, ScriptElement return fields; } - function _sendEvents(evts:Envelope[], endpointUrl?:any) { + function _sendEvents(evts:IEnvelope[], endpointUrl?:any) { if (JSON) { let sender = win.fetch; if (sender && !snipConfig.useXhr) { @@ -81,7 +83,7 @@ import { AIConfig, AppInsights, Envelope, Fields, ISnippetConfig, ScriptElement let endpointUrl = ingest ? ingest + "/v2/track" : aiConfig.endpointUrl; // only add /v2/track when from connectionstring let message = "SDK LOAD Failure: Failed to load Application Insights SDK script (See stack for details)"; - let evts:Envelope[] = []; + let evts:IEnvelope[] = []; evts.push(_createException(iKey, message, targetSrc, endpointUrl)); evts.push(_createInternal(iKey, message, targetSrc, endpointUrl)); @@ -128,12 +130,15 @@ import { AIConfig, AppInsights, Envelope, Fields, ISnippetConfig, ScriptElement baseData: { ver: 2 } - } + }, + ver: "4.0", + seq: 1, + aiDataContract: undefined }; } function _createInternal(iKey:string, message:string, targetSrc:string, endpointUrl:any) { - let envelope : Envelope = _createEnvelope(iKey, "Message"); + let envelope : IEnvelope = _createEnvelope(iKey, "Message"); let data = envelope.data; data.baseType = "MessageData"; let baseData = data.baseData; @@ -147,7 +152,7 @@ import { AIConfig, AppInsights, Envelope, Fields, ISnippetConfig, ScriptElement } function _createException(iKey:string, message:string, targetSrc:string, endpointUrl:any) { - let envelope : Envelope = _createEnvelope(iKey, "Exception"); + let envelope : IEnvelope = _createEnvelope(iKey, "Exception"); let data = envelope.data; data.baseType = "ExceptionData"; data.baseData.exceptions = [{ @@ -162,7 +167,7 @@ import { AIConfig, AppInsights, Envelope, Fields, ISnippetConfig, ScriptElement } // Assigning these to local variables allows them to be minified to save space: - let targetSrc = aiConfig.url || snipConfig.src; + let targetSrc = (aiConfig as any)["url"] || snipConfig.src if (targetSrc) { const _handleError = (evt?: any) => { loadFailed = true; @@ -186,8 +191,8 @@ import { AIConfig, AppInsights, Envelope, Fields, ISnippetConfig, ScriptElement } const _createScript = () => { - let scriptElement : ScriptElement = doc.createElement(scriptText); - scriptElement.src = targetSrc; + let scriptElement : HTMLElement = doc.createElement(scriptText); + (scriptElement as any)["src"] = targetSrc; // Allocate Cross origin only if defined and available let crossOrigin = snipConfig[strCrossOrigin]; if ((crossOrigin || crossOrigin === "") && scriptElement[strCrossOrigin] != strUndefined) { @@ -196,8 +201,8 @@ import { AIConfig, AppInsights, Envelope, Fields, ISnippetConfig, ScriptElement scriptElement.onload = _handleLoad; scriptElement.onerror = _handleError; // Some browsers support onload while others onreadystatechange and others both - scriptElement.onreadystatechange = function (evt?:any, isAbort?:any) { - if (scriptElement.readyState === "loaded" || scriptElement.readyState === "complete") { + (scriptElement as any)["onreadystatechange"] = function (evt?:any, isAbort?:any) { + if ((scriptElement as any)["readyState"] === "loaded" || (scriptElement as any)["readyState"] === "complete") { _handleLoad(evt, isAbort); } }; diff --git a/tools/applicationinsights-web-snippet/src/type.ts b/tools/applicationinsights-web-snippet/src/type.ts index 0956b423f..009967ca5 100644 --- a/tools/applicationinsights-web-snippet/src/type.ts +++ b/tools/applicationinsights-web-snippet/src/type.ts @@ -1,4 +1,5 @@ -import { IConfiguration } from "@microsoft/applicationinsights-web"; +import { IConfiguration, Snippet } from "@microsoft/applicationinsights-web"; + export interface ISnippetConfig { src: string; name?: string; @@ -6,14 +7,7 @@ export interface ISnippetConfig { useXhr?: boolean; crossOrigin?: string; onInit?: any; - cfg: { - connectionString: any; - }; -} - -export interface AIConfig extends IConfiguration { - autoExceptionInstrumented?: boolean; - url?: string; + cfg: IConfiguration; } export interface Fields { @@ -23,38 +17,8 @@ export interface Fields { // Add other properties as needed } -export interface Envelope{ - time?: any; - iKey?: string; - name?: string; - sampleRate?: number; - tags?: any; - data: { - baseData: { - ver?: number; - exceptions?: any[]; - message?: string; - properties?: any; - }, - baseType?: any, - - } - } - -export interface ScriptElement extends HTMLElement{ - src?: any; - onload: any; - onreadystatechange?: any; - readyState?: any; - } - -export interface AppInsights{ +export interface AppInsights extends Snippet{ initialize: boolean; - queue: any[]; - sv: string; - version: number; - config: AIConfig; cookie?: any; core?: any; - } \ No newline at end of file From b203a1e80c52945588f6cb04bdaddd11a31cbbef Mon Sep 17 00:00:00 2001 From: siyuniu-ms Date: Thu, 22 Jun 2023 17:39:36 -0700 Subject: [PATCH 17/20] reduce type.ts --- tools/applicationinsights-web-snippet/src/snippet.ts | 12 +++++++----- tools/applicationinsights-web-snippet/src/type.ts | 8 +------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/tools/applicationinsights-web-snippet/src/snippet.ts b/tools/applicationinsights-web-snippet/src/snippet.ts index f00833468..d88bfa37c 100644 --- a/tools/applicationinsights-web-snippet/src/snippet.ts +++ b/tools/applicationinsights-web-snippet/src/snippet.ts @@ -1,4 +1,4 @@ -import { AppInsights, Fields, ISnippetConfig } from "./type"; +import { Fields, ISnippetConfig } from "./type"; import { IConfiguration, Snippet } from "@microsoft/applicationinsights-web"; import { IEnvelope } from "@microsoft/applicationinsights-common"; @@ -28,7 +28,7 @@ import { IEnvelope } from "@microsoft/applicationinsights-common"; let aiSdk = win[aiName] || (function (aiConfig: IConfiguration) { let loadFailed = false; let handled = false; - let appInsights:AppInsights= { + let appInsights: (Snippet & {initialize:boolean, cookie?:any, core?:any})= { initialize: true, // initialize sdk on download queue: [], sv: "6", // Track the actual snippet version for reporting. @@ -120,7 +120,7 @@ import { IEnvelope } from "@microsoft/applicationinsights-common"; tags[strAiOperationName] = locn && locn.pathname || "_unknown_"; tags[strAiSdkVersion] = "javascript:snippet_" + (appInsights.sv || appInsights.version); - return { + let envelope:IEnvelope = { time: _getTime(), iKey: iKey, name: "Microsoft.ApplicationInsights." + iKey.replace(/-/g, strEmpty) + "." + theType, @@ -131,10 +131,12 @@ import { IEnvelope } from "@microsoft/applicationinsights-common"; ver: 2 } }, - ver: "4.0", - seq: 1, + ver: 4.0, + seq: "1", aiDataContract: undefined }; + + return envelope; } function _createInternal(iKey:string, message:string, targetSrc:string, endpointUrl:any) { diff --git a/tools/applicationinsights-web-snippet/src/type.ts b/tools/applicationinsights-web-snippet/src/type.ts index 009967ca5..72f478df9 100644 --- a/tools/applicationinsights-web-snippet/src/type.ts +++ b/tools/applicationinsights-web-snippet/src/type.ts @@ -1,4 +1,4 @@ -import { IConfiguration, Snippet } from "@microsoft/applicationinsights-web"; +import { IConfiguration } from "@microsoft/applicationinsights-web"; export interface ISnippetConfig { src: string; @@ -16,9 +16,3 @@ export interface Fields { location?: any; // Add other properties as needed } - -export interface AppInsights extends Snippet{ - initialize: boolean; - cookie?: any; - core?: any; - } \ No newline at end of file From af4b357f1948e4f297a282b0cafa30a869722d02 Mon Sep 17 00:00:00 2001 From: siyuniu-ms Date: Thu, 22 Jun 2023 18:32:42 -0700 Subject: [PATCH 18/20] change import way --- tools/applicationinsights-web-snippet/package.json | 4 ++-- tools/applicationinsights-web-snippet/src/snippet.ts | 4 ++-- tools/applicationinsights-web-snippet/src/type.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/applicationinsights-web-snippet/package.json b/tools/applicationinsights-web-snippet/package.json index 5235c7d1f..0b7b52b6e 100644 --- a/tools/applicationinsights-web-snippet/package.json +++ b/tools/applicationinsights-web-snippet/package.json @@ -33,7 +33,6 @@ "@microsoft/applicationinsights-web": "3.0.2", "@microsoft/applicationinsights-rollup-plugin-uglify3-js": "1.0.0", "@microsoft/applicationinsights-rollup-es5": "1.0.2", - "@microsoft/applicationinsights-common": "3.0.2", "typescript": "^4.9.3", "tslib": "^2.0.0", "magic-string": "^0.25.7", @@ -49,6 +48,7 @@ "@nevware21/grunt-eslint-ts": "^0.2.2" }, "dependencies": { - "@microsoft/dynamicproto-js": "^2.0.2" + "@microsoft/dynamicproto-js": "^2.0.2", + "@microsoft/applicationinsights-common": "3.0.2" } } diff --git a/tools/applicationinsights-web-snippet/src/snippet.ts b/tools/applicationinsights-web-snippet/src/snippet.ts index d88bfa37c..fe518d0e7 100644 --- a/tools/applicationinsights-web-snippet/src/snippet.ts +++ b/tools/applicationinsights-web-snippet/src/snippet.ts @@ -1,6 +1,6 @@ import { Fields, ISnippetConfig } from "./type"; -import { IConfiguration, Snippet } from "@microsoft/applicationinsights-web"; import { IEnvelope } from "@microsoft/applicationinsights-common"; +import { IConfiguration, Snippet } from "@microsoft/applicationinsights-web"; (function (win: Window, doc: Document, snipConfig: ISnippetConfig) { let locn: Location = win.location; @@ -302,7 +302,7 @@ import { IEnvelope } from "@microsoft/applicationinsights-common"; return handled; }; - aiConfig.autoExceptionInstrumented = true; + aiConfig["autoExceptionInstrumented"] = true; } return appInsights; diff --git a/tools/applicationinsights-web-snippet/src/type.ts b/tools/applicationinsights-web-snippet/src/type.ts index 72f478df9..dc99c7a43 100644 --- a/tools/applicationinsights-web-snippet/src/type.ts +++ b/tools/applicationinsights-web-snippet/src/type.ts @@ -15,4 +15,4 @@ export interface Fields { endpointsuffix?: any; location?: any; // Add other properties as needed - } +} From f80d451a5d0d7f97fcc6aa2f98bd92aca28d068f Mon Sep 17 00:00:00 2001 From: siyuniu-ms Date: Thu, 22 Jun 2023 20:27:33 -0700 Subject: [PATCH 19/20] test config change --- tools/applicationinsights-web-snippet/Tests/tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/applicationinsights-web-snippet/Tests/tsconfig.json b/tools/applicationinsights-web-snippet/Tests/tsconfig.json index 5fd1d6fcf..6ebd8bb66 100644 --- a/tools/applicationinsights-web-snippet/Tests/tsconfig.json +++ b/tools/applicationinsights-web-snippet/Tests/tsconfig.json @@ -10,7 +10,8 @@ "declaration": true, "importHelpers": false, "noEmitHelpers": false, - "skipLibCheck": true + "skipLibCheck": true, + "allowJs": true, }, "files": [], "exclude": [ From 4b203e80ae3cfc2550857e1084594761ddf18197 Mon Sep 17 00:00:00 2001 From: siyuniu-ms Date: Fri, 23 Jun 2023 14:22:01 -0700 Subject: [PATCH 20/20] change version --- .../Tests/Unit/src/SnippetTests.ts | 2 +- tools/applicationinsights-web-snippet/src/snippet.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/applicationinsights-web-snippet/Tests/Unit/src/SnippetTests.ts b/tools/applicationinsights-web-snippet/Tests/Unit/src/SnippetTests.ts index fd819be9e..05269f834 100644 --- a/tools/applicationinsights-web-snippet/Tests/Unit/src/SnippetTests.ts +++ b/tools/applicationinsights-web-snippet/Tests/Unit/src/SnippetTests.ts @@ -12,7 +12,7 @@ export class SnippetTests extends AITestClass { this.testCase({ name: "Check snippet version", test: () => { - QUnit.assert.equal("6", webSnippetVersion()); + QUnit.assert.equal("7", webSnippetVersion()); } }); diff --git a/tools/applicationinsights-web-snippet/src/snippet.ts b/tools/applicationinsights-web-snippet/src/snippet.ts index fe518d0e7..bbe1a8976 100644 --- a/tools/applicationinsights-web-snippet/src/snippet.ts +++ b/tools/applicationinsights-web-snippet/src/snippet.ts @@ -31,7 +31,7 @@ import { IConfiguration, Snippet } from "@microsoft/applicationinsights-web"; let appInsights: (Snippet & {initialize:boolean, cookie?:any, core?:any})= { initialize: true, // initialize sdk on download queue: [], - sv: "6", // Track the actual snippet version for reporting. + sv: "7", // 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 };