ApplicationInsights-JS/gruntfile.js

967 строки
44 KiB
JavaScript
Исходник Обычный вид История

2017-08-04 01:00:44 +03:00
module.exports = function (grunt) {
2023-04-21 19:25:10 +03:00
const versionPlaceholder = '"#version#"';
const aiCoreDefaultNameReplacements = [
];
const aiDefaultNameReplacements = [
];
const aiInternalConstants = [
"./src/InternalConstants.ts"
];
const configVer = getConfigVersion(false);
const configMajorVer = getConfigVersion(true);
function _encodeStr(str) {
return str.replace(/\\/g, '\\\\').
replace(/"/g, '\\"').
replace(/'/g, '\\\'').
replace(/\u0008/g, '\\b').
replace(/\r/g, '\\r').
replace(/\t/g, '\\t').
replace(/\n/g, '\\n').
replace(/\f/g, '\\f');
}
function generateNewSnippet(prefix) {
var srcPath = "./tools/applicationinsights-web-snippet/dist-es5";
return {
files: [{
expand: true,
cwd: srcPath,
dest: "./tools/applicationinsights-web-snippet/dist-es5",
src: "applicationinsights-web-snippet.js"
}],
options: {
replacements: function() {
var snippetBuffer = grunt.file.read("./tools/applicationinsights-web-snippet/build/output/snippet.min.js");
if (prefix === "ConnString") {
snippetBuffer = snippetBuffer.replace(/connectionString:\s*".*?"/gms, " connectionString: \"YOUR_CONNECTION_STRING\"");
} else if (prefix === "IKey") {
snippetBuffer = snippetBuffer.replace(/connectionString:\s*".*?"/gms, " connectionString: \"InstrumentationKey=INSTRUMENTATION_KEY\"");
} else if (prefix === "Origin") {
snippetBuffer = grunt.file.read("./tools/applicationinsights-web-snippet/build/output/originSnippet.min.js");
}
var snippetStr = _encodeStr(snippetBuffer.toString());
var expectedStr = `##replace${prefix}Snippet##`;
return [{
pattern: expectedStr,
replacement: snippetStr
}];
}
}
};
}
function expandMin() {
var srcPath = "./tools/applicationinsights-web-snippet/build/output";
return {
files: [{
expand: true,
cwd: srcPath,
dest: "./tools/applicationinsights-web-snippet/build/output",
src: "snippet.min.js"
}],
options: {
replacements: function() {
var snippetBuffer = grunt.file.read("./tools/applicationinsights-web-snippet/build/output/snippet.min.js");
var snippetConfig = grunt.file.read("./tools/applicationinsights-web-snippet/src/snippet-config.js").trim();
while(snippetConfig.endsWith("\r") || snippetConfig.endsWith("\n")) {
snippetConfig = snippetConfig.substring(0, snippetConfig.length - 1);
}
// We assign a value to SnippetConfig and then forcefully overwrite it into the function input.
if (snippetBuffer.startsWith("!(function")) {
throw "Snippet prefix input is invalid -- replace will fail";
}
var overWriteString = "!(function (cfg){" + snippetBuffer
let orgOverwrite = overWriteString;
overWriteString = overWriteString.replace(/\n\/\/# source.*\n/, "})(" + snippetConfig + ");\n");
if(overWriteString === orgOverwrite) {
throw "Snippet postfix input is invalid -- replace will fail";
}
return [{
pattern: snippetBuffer,
replacement: overWriteString
}];
}
}
};
}
function expandJS() {
var srcPath = "./tools/applicationinsights-web-snippet/build/output";
return {
files: [{
expand: true,
cwd: srcPath,
dest: "./tools/applicationinsights-web-snippet/build/output",
src: "snippet.js"
}],
options: {
replacements: function() {
var snippetBuffer = grunt.file.read("./tools/applicationinsights-web-snippet/build/output/snippet.js");
var snippetConfig = grunt.file.read("./tools/applicationinsights-web-snippet/src/snippet-config.js").trim();
while(snippetConfig.endsWith("\r") || snippetConfig.endsWith("\n")) {
snippetConfig = snippetConfig.substring(0, snippetConfig.length - 1);
}
var overWriteString = snippetBuffer.replace(/\(function \(win, doc\)/, "(function (win, doc, cfg)");
if(overWriteString === snippetBuffer) {
throw "Snippet prefix input is invalid -- replace will fail";
}
let orgOverwrite = overWriteString;
overWriteString = overWriteString.replace(/}\)\(window, document\);/, "})(window, document, " + snippetConfig + ");")
if(overWriteString === orgOverwrite) {
throw "Snippet postfix input is invalid -- replace will fail";
}
return [{
pattern: snippetBuffer,
replacement: overWriteString
}];
}
}
};
}
function getConfigVersion(isMajorVer) {
let version = "";
try {
let config = grunt.file.readJSON("./tools/config/package.json");
let configVer= config["version"];
version = "." + configVer;
if (isMajorVer) {
version = "." + configVer.split(".")[0];
}
} catch (e) {
console.log("stack: '" + e.stack + "', message: '" + e.message + "', name: '" + e.name + "'");
}
return version;
}
function _createRegEx(str) {
// Converts a string into a global regex, escaping any special characters
return new RegExp(str.replace(/([.+?^=!:${}()|\[\]\/\\])/g, '\\$1'), 'g');
}
function setVersionNumber(path, packageVersion) {
var expectedVersion = _createRegEx(versionPlaceholder);
var replaceVersion = "'" + packageVersion + "'";
var srcPath = path + '/src';
// This is the grunt string-replace configuration to replace version placeholder with the actual version number
return {
files: [{
expand: true,
cwd: srcPath,
dest: srcPath,
src: '**/*.ts'
}],
options: {
replacements: [{
pattern: expectedVersion,
replacement: replaceVersion
}]
}
};
}
function restoreVersionPlaceholder(path, packageVersion) {
var expectedVersion1 = _createRegEx("'" + packageVersion + "'");
var expectedVersion2 = _createRegEx('"' + packageVersion + '"');
var srcPath = path + '/src';
// This is the grunt string-replace configuration to replace the actual version number with the version placeholder
return {
files: [{
expand: true,
cwd: srcPath,
dest: srcPath,
src: '**/*.ts'
}],
options: {
replacements: [{
pattern: expectedVersion1,
replacement: versionPlaceholder
},{
pattern: expectedVersion2,
replacement: versionPlaceholder
}]
}
};
}
function deepMerge(target, src) {
try {
var newValue = Object.assign({}, target, src);
if (target && src) {
Object.keys(target).forEach((key) => {
// Any existing src[key] value would have been assigned over the target[key] version
if (src[key] !== undefined) {
if (Array.isArray(newValue[key])) {
target[key].forEach((value) => {
newValue[key].push(value);
});
} else if (typeof newValue[key] === "object") {
// Make sure we merge all properties
newValue[key] = deepMerge(newValue[key], target[key]);
}
}
});
2018-10-03 20:10:44 +03:00
}
return newValue;
} catch (e) {
console.error("stack: '" + e.stack + "', message: '" + e.message + "', name: '" + e.name + "'");
}
}
// const perfTestVersions = ["2.0.0","2.0.1","2.1.0","2.2.0","2.2.1","2.2.2","2.3.0","2.3.1",
// "2.4.1","2.4.3","2.4.4","2.5.2","2.5.3","2.5.4","2.5.5","2.5.6","2.5.7","2.5.8","2.5.9","2.5.10","2.5.11",
// "2.6.0","2.6.1","2.6.2","2.6.3","2.6.4","2.6.5","2.7.0"];
const perfTestVersions=["3.3.0"];
function buildConfig(modules) {
var buildCmds = {
ts: {
options: {
comments: true,
debug: true,
logOutput: true
}
},
"eslint-ts": {
options: {
debug: true
}
},
"ai-minify": {
options: {
debug: true,
//testOnly: true,
}
},
"qunit" : {
all: {
options: {
}
}
},
connect: {
server: {
options: {
port: 9001,
2023-04-21 19:25:10 +03:00
base: '.',
debug: true
}
}
},
"string-replace": {
2017-07-26 20:08:32 +03:00
}
};
for (var key in modules) {
if (modules.hasOwnProperty(key)) {
var modulePath = modules[key].path;
var moduleCfg = modules[key].cfg;
var packageJsonFile = modulePath + '/package.json';
if (grunt.file.exists(packageJsonFile)) {
// Read the actual module version from the package.json
var pkg = grunt.file.readJSON(modulePath + '/package.json');
var addMinifyTasks = modules[key].autoMinify !== false;
if (addMinifyTasks) {
var nameMaps = aiDefaultNameReplacements;
var internalConstants = aiInternalConstants;
if (pkg['name'] === "@microsoft/applicationinsights-core-js") {
nameMaps = aiCoreDefaultNameReplacements;
internalConstants = [ "./src/JavaScriptSDK/InternalConstants.ts" ];
}
var aiMinify = buildCmds["ai-minify"];
aiMinify[key] = {
options: {
projectRoot: modulePath,
src: "./src/**/*.ts",
nameMaps: nameMaps,
internalConstants: internalConstants
}
};
aiMinify[key + "-reverse"] = {
options: {
projectRoot: modulePath,
src: "./src/**/*.ts",
restore: true,
nameMaps: nameMaps,
internalConstants: internalConstants
}
};
}
var addStringReplace = modules[key].stringReplace !== false;
if (addStringReplace) {
var replaceCmds = buildCmds['string-replace'];
// Read the actual module version from the package.json
var packageVersion = pkg['version'];
replaceCmds[key] = setVersionNumber(modulePath, packageVersion);
replaceCmds[key + '-reverse'] = restoreVersionPlaceholder(modulePath, packageVersion);
}
}
if (grunt.file.exists(modulePath + '/src/tsconfig.json')) {
// Use the src tsconfig (if available)
buildCmds.ts[key] = {
'tsconfig': modulePath + "/src/tsconfig.json",
};
} else if (grunt.file.exists(modulePath + '/tsconfig.json')) {
// Otherwise fall back to the root tsconfig (if available)
buildCmds.ts[key] = {
'tsconfig': modulePath + "/tsconfig.json",
};
} else {
throw new Error("TSConfig not found for [" + key + "]");
2017-07-26 20:08:32 +03:00
}
if (moduleCfg) {
buildCmds.ts[key] = Object.assign(buildCmds.ts[key], moduleCfg);
}
// If the tests have their own tsconfig, add that as a new target
var addQunit = false;
var testRoot = "";
if (modules[key].testHttp !== false) {
testRoot = "http://localhost:9001/";
}
var testUrl = testRoot + modulePath + "/test/UnitTests.html";
if (grunt.file.exists(modulePath + '/test/tsconfig.json')) {
addQunit = true;
buildCmds.ts[key + '-tests'] = {
tsconfig: modulePath + "/test/tsconfig.json",
src: [
modulePath + "/test/Unit/src/**/*.ts"
],
out: modulePath + "/test/Unit/dist/" + (modules[key].unitTestName || key + ".tests.js")
};
} else if (grunt.file.exists(modulePath + '/Tests/tsconfig.json')) {
addQunit = true;
testUrl = testRoot + modulePath + "/Tests/UnitTests.html";
buildCmds.ts[key + '-tests'] = {
tsconfig: modulePath + "/Tests/tsconfig.json",
src: [
modulePath + "/Tests/Unit/src/**/*.ts"
],
out: modulePath + "/Tests/Unit/dist/" + (modules[key].unitTestName || key + ".tests.js")
};
}
if (addQunit) {
// Remove any "/./" values from the path
testUrl = testUrl.replace(/\/\.\//g, "/");
buildCmds.qunit[key] = {
options: {
urls: [testUrl],
timeout: 300 * 1000, // 5 min
console: true,
summaryOnly: false,
httpBase: ".",
puppeteer: {
2023-04-21 19:25:10 +03:00
debug: true,
headless: true,
timeout: 30000,
ignoreHTTPErrors: true,
args: [
"--enable-precise-memory-info",
"--expose-internals-for-testing",
"--no-sandbox"
]
}
}
};
}
// If the tests have their own tsconfig, add that as a new target
addQunit = false;
var testUrl = testRoot + modulePath + "/test/PerfTests.html";
if (grunt.file.exists(modulePath + '/test/PerfTests.html')) {
addQunit = true;
buildCmds.ts[key + '-perftest'] = {
tsconfig: modulePath + "/test/tsconfig.json",
src: [
modulePath + "/test/Perf/src/**/*.ts"
],
2023-04-21 19:25:10 +03:00
out: modulePath + "/test/Perf/dist/es5/" + (modules[key].perfTestName || key + ".perf.tests.js")
};
} else if (grunt.file.exists(modulePath + '/Tests/PerfTests.html')) {
addQunit = true;
testUrl = testRoot + modulePath + "/Tests/PerfTests.html";
buildCmds.ts[key + '-perftest'] = {
tsconfig: modulePath + "/Tests/tsconfig.json",
src: [
modulePath + "/Tests/Perf/src/**/*.ts"
],
2023-04-21 19:25:10 +03:00
out: modulePath + "/Tests/Perf/dist/es5/" + (modules[key].perfTestName || key + ".perf.tests.js")
};
}
if (addQunit) {
var testUrls = [ testUrl ];
if (key === "aisku") {
testUrls = perfTestVersions.map((version) => {
return testUrl + `?version=${version}`;
});
}
buildCmds.qunit[key + "-perf"] = {
options: {
2023-04-21 19:25:10 +03:00
urls: testUrls,
timeout: 300 * 1000, // 5 min
console: true,
summaryOnly: false,
puppeteer: {
headless: true,
timeout: 30000,
ignoreHTTPErrors: true,
args: [
'--enable-precise-memory-info',
'--expose-internals-for-testing',
"--no-sandbox"
]
}
}
};
}
let esLintCmd = buildCmds["eslint-ts"];
esLintCmd[key + '-lint'] = {
options: {
tsconfig: modulePath + '/tsconfig.json'
}
};
if (moduleCfg) {
esLintCmd[key + '-lint'] = Object.assign(buildCmds.ts[key], moduleCfg);
2019-03-01 01:28:10 +03:00
}
esLintCmd[key + '-lint-fix'] = deepMerge({ options: { fix: true } }, esLintCmd[key + '-lint']);
}
}
return buildCmds;
}
try {
var theBuildConfig = deepMerge(buildConfig({
// Shared
"core": {
path: "./shared/AppInsightsCore",
unitTestName: "aicoreunit.tests.js",
perfTestName: "aicoreperf.tests.js"
},
"common": {
path: "./shared/AppInsightsCommon",
unitTestName: "aicommon.tests.js"
},
"1dsCore": {
path: "./shared/1ds-core-js",
unitTestName: "core.unittests.js"
},
// SKUs
"aisku": {
path: "./AISKU",
cfg: {
src: [
"AISKU/src/*.ts"
]
},
unitTestName: "aiskuunittests.tests.js",
perfTestName: "aiskuperftests.tests.js"
},
"aiskulite": {
path: "./AISKULight",
cfg: {
src: [
Merge remote-tracking branch 'upstream/beta' into MSNev/MergeBetaToMaster (#1791) * Update version update script to support default "next" release version (major/minor) not just patch (#1756) (#1757) * Merge [master] branch to [beta] and Enable GitHub Actions on [beta] branch (#1762) * Update version update script to support default "next" release version (major/minor) not just patch (#1756) * Additional Performance enhancements to use provided functions rather than internal polyfill's (#1758) * [BUG] 2.7.4-nightly.2202-03 builds have a bug where objKeys() is not returning the keys #1763 (#1764) * Enable GitHub Actions on [beta] branch * Beta Part 1: Part of Mega Dynamic Load/Unload support (#1766) - Refactor TelemetryPluginChain ready to start supporting load/unload - Move TelemetryInitializer to BaseCore - add getPlugin (will be used for remove) - Address Channel flush issue * Merge remote-tracking branch 'upstream/master' into beta (#1772) * Additional Performance enhancements to use provided functions rather than internal polyfill's (#1758) * [BUG] 2.7.4-nightly.2202-03 builds have a bug where objKeys() is not returning the keys #1763 (#1764) * Update version.json (#1767) * [Release] Increase version to 2.7.4 (#1770) - Updates React Plugin to v3.2.4 (with v2.7.4 as dependency) - Updates React Native Plugin to 2.4.4 (with v2.7.4 as dependency) - Updates Chrome Debug Extension to 0.2.4 This release is primarily a performance improvement release where we will now use any built in (or provided polyfill) function over the internal polyfills for - String trim() - String endsWith() - String startsWith() - Additional Date toISOString() - Array isArray() - Array indexOf() - Array map() - Array reduce() - Object freeze() - Object seal() * [Beta] Keep version.json next as minor and resync shrinkwrap - Fix merge issue * Beta Part 2: Part of Mega Dynamic Load/Unload support (#1768) - Add Event Namespace support - Minification of constant values - Add part of the unload functionality (required for unified `teardown()` functionality) * Beta Part 3: Part of Mega Dynamic Load/Unload support (#1780) * Beta Part 3: Part of Mega Dynamic Load/Unload support - Add Core SDK Unload support * Fix telemetry chain for null and undefined * Beta Part 4: Part of Mega Dynamic Load/Unload support (#1781) * Beta Part 4: Part of Mega Dynamic Load/Unload support - Fix function typing issues - Update Analytics Extension to start supporting teardown / unload (more tests required) - Adds namespace option to instrumentation hooks (for debugging teardown issues) - Update AITest Class to log and optionally assert events and hooks that have not been removed - Add Update callback when plugins are added / removed (will be extended for config updates) - Some minor minification improvements * Update comments * Add missing enum definition * Update Sender tests * Beta Part 5: Part of Mega Dynamic Load/Unload support (#1782) - Add Missing Exports - AnalyticsPlugin: Implement teardown and initial test validation - Dependencies Plugin: Implement teardown and initial test validation - Add flush() to IAppInsightsCore * AI Beta: Minor bug fixes and additional debug info (#1787) * Lint fixes: Enable Automatic formatting fixes (#1788) * Beta Part 6: Part of Mega Dynamic Load/Unload support (#1782) (#1789) - Add basic minimal unload / teardown support to all remaining components - Update rollup cleanup dependencies * Beta: Component Governance Updates to address known dependency issues (#1790)
2022-04-01 01:14:29 +03:00
"AISKULight/src/*.ts"
]
},
unitTestName: "aiskuliteunittests.tests.js"
},
// Channels
"aichannel": { path: "./channels/applicationinsights-channel-js" },
"offlinechannel": {
path: "./channels/offline-channel-js"
},
"teechannel": { path: "./channels/tee-channel-js" },
"1dsPost": {
path: "./channels/1ds-post-js",
unitTestName: "post.unittests.js"
},
// Extensions
"appinsights": {
path: "./extensions/applicationinsights-analytics-js",
unitTestName: "appinsights-analytics.tests.js"
},
"clickanalytics": {
path: "./extensions/applicationinsights-clickanalytics-js",
unitTestName: "appinsights-clickanalytics.tests.js"
},
"debugplugin": { path: "./extensions/applicationinsights-debugplugin-js" },
"deps": {
path: "./extensions/applicationinsights-dependencies-js",
unitTestName: "dependencies.tests.js"
},
"perfmarkmeasure": {
path: "./extensions/applicationinsights-perfmarkmeasure-js",
unitTestName: "appinsights-perfmarkmeasure.tests.js"
},
"properties": {
path: "./extensions/applicationinsights-properties-js",
unitTestName: "prop.tests.js"
},
"osplugin": {
path: "./extensions/applicationinsights-osplugin-js",
unitTestName: "applicationinsights-osplugin.tests.js"
},
"cfgsync": {
path: "./extensions/applicationinsights-cfgsync-js",
unitTestName: "cfgsync.tests.js"
},
// Examples
"example-shared-worker": {
autoMinify: false,
path: "./examples/shared-worker",
testHttp: false
},
"example-aisku": {
autoMinify: false,
path: "./examples/AISKU",
testHttp: false
},
"example-dependency": {
autoMinify: false,
path: "./examples/dependency",
testHttp: false
},
"example-cfgsync": {
autoMinify: false,
path: "./examples/cfgSync",
testHttp: false
},
// Tools
"rollupuglify": {
autoMinify: false,
path: "./tools/rollup-plugin-uglify3-js",
cfg: {
src: [
"./tools/rollup-plugin-uglify3-js/src/*.ts",
"!node_modules/**"
],
out: './tools/rollup-plugin-uglify3-js/out/src/uglify3-js.js'
},
testHttp: false
},
"rollupes5": {
autoMinify: false,
path: "./tools/rollup-es5",
unitTestName: "es5rolluptests.js"
},
"shims": {
autoMinify: false,
path: "./tools/shims",
cfg: {
src: [
"./tools/shims/src/*.ts"
]
},
unitTestName: "shimstests.js"
},
"chrome-debug-extension": {
autoMinify: false,
path: "./tools/chrome-debug-extension",
TelemetryViewer: Add Chrome debug extension to master (#1713) * init commit * update rollup * Fixed popup - now runs the React application * Now building the popup and background task seperately so that one doesn't have to export the other to make it build * Updated browser extension code with latest from odsp-web * Update window title of the popup * Readme update * Added custom configuration UI for in-tool authoring of the configuration file * New icon * Name update * Filter text now uses column values from configuration instead of Stream hardcoded field names * Enable some more automatic eslint fixes (#1690) * Update dependencies in package.json * Add ability to zip the extension during build * Update SetVersion script to include the chrome-debug-extension Synchronize manifest.json version with package.json Add CDN publishing scripts Rework package zipping for more flexibility * Bump version to v0.1.1 Fixup Content-Type for publishing to CDN * Add archiver package to devDependencies * Update shrinkwrap for archiver * Update Stream URL * Break circular dependency * Add 'TimeDelta' column type, fix details view to allow for deep paths to be excluded via config * Network data source now handles arrays of events as well * Add default configuration feature * Default configuration updates to flag errors, perf events, add a dynamic value for each event type, and exclude the last tag field in consolidated view * Fix bug where boolean fields would not be displayed * Updated icons for better contrast on the task bar when in dark mode * Add sessionidRegex option * Added jsonFieldNames * Table header no longer scrolls * Update setActiveVersion script to support publishing an unversioned value * Update icons to ensure they are from the set we are allowed to use * Update to version 0.1.2 * Code tidy up and added prettier rule file * Chrome debug extension UI (#1703) * [BUG] Field 'ai.operation.name' on type 'ContextTagKeys' is too long. Expected: 1024 characters" #1692 (#1693) * [BUG] Multiple errors are getting thrown and swallowed during initialization when no instrumentation Key is provided #1691 (#1695) * Governance Updates -- update used dependencies (#1694) * init * working * add css * copy over helper and debugplugin ui * update style * Shrinkwrap update after rush update * Accessibility fixes * Fix accessibility in the configuration page * Fix missing red line between sessions * align styles * Added update instructions to the configuration page, and replaced placeholder link for preset creation instructions * fix build Co-authored-by: Nev <54870357+MSNev@users.noreply.github.com> Co-authored-by: Kevin Brown <kevbrown@microsoft.com> * Merge remote-tracking branch 'origin/master' into ChromeDebugExtension * Fixes - EsLint integration and auto fixes - Add integrity.json generation * Update Chrome Debug extension to use new v.2.7.1 base components * Add files via upload (#1711) * Update README.md in ChromeExtension (#1710) * Update README.md * chrome-extension-readme: Update to relative path * Add files via upload * Fix popup looping (causing dead UI) issue * Update file comments * Add DbgExtensionUtils to AI core with notification support and defaults for AI and OneDs * Performance improvements - Only populate the condensedDetails when required - dont save the condensed details to the "saved" files Functional changes - Add filter match highlighting to the lower window - Add option to include the event content when filtering - Add UI components to enable/disable networking and Sdk event capturing * Enable expand/collapse and address PR comments * Fix CodeScanning issues * Add wildcard support to event table filtering and match highlighting * Added tooltips to new optionsBar UI, removing the need for the "capture" label and explaining the "Content" checkbox, also fixing issue prevent mouse clicks on the new labels from toggling the checkboxes * Readme updates * Change default height to be taller, capitalize SDK * Fixed bug on fresh install when there is no saved filter state which prevented configurations from being loaded * Address Security issues identified by internal component governance services (#1715) * Fix package version differences * Make syntax highlighting in the detail (tree) view case-insensitive * Add Simple Hello World sample * Rename NetworkDataSource and clean up the data source type list * Add defaultNetworkCaptureValue and defaultSDKCaptureValue to IConfiguration * Extract DebugPlugin debug message to a function * Add capturing network requests for sendBeacon() ("ping" requests) * Consolidate the DebugPlugin logging functions Co-authored-by: xiao-lix <lixiao900921@gmail.com> Co-authored-by: Kevin Brown <kevbrown@microsoft.com> Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com> Co-authored-by: KevBrown-MSFT <51932180+KevBrown-MSFT@users.noreply.github.com>
2021-11-19 03:35:41 +03:00
cfg: {
src: [
"./tools/chrome-debug-extension/src/**/*.tsx",
"./tools/chrome-debug-extension/src/**/*.ts",
]
}
},
"applicationinsights-web-snippet": {
autoMinify: false,
path: "./tools/applicationinsights-web-snippet",
cfg: {
src: [
"./tools/applicationinsights-web-snippet/src/**/*.ts"
]
}
},
// Common
"tst-framework": {
autoMinify: false,
path: "./common/Tests/Framework",
cfg: {
src: [
"./common/Tests/Framework/src/*.ts"
]
}
},
}));
function tsBuildActions(name, addTests, replaceName) {
var actions = [
"eslint-ts:" + name + "-lint-fix"
];
var aiMinifyConfig = theBuildConfig["ai-minify"] || {};
var gruntTsConfig = theBuildConfig["ts"];
var replaceConfig = theBuildConfig["string-replace"] || {};
if (replaceName === true || replaceConfig[name]) {
actions.push("string-replace:" + name);
if (aiMinifyConfig[name]) {
// Make sure all translations are reversed first
actions.push("ai-minify:" + name + "-reverse");
// Attempt to compile without any translations (Validates that the original source code is fine before transforming it)
actions.push("ts:" + name);
actions.push("ai-minify:" + name);
}
// Now perform the "real" final compile after minification
actions.push("ts:" + name);
if (addTests && gruntTsConfig[name + "-tests"]) {
actions.push("ts:" + name + "-tests");
}
if (aiMinifyConfig[name + "-reverse"]) {
actions.push("ai-minify:" + name + "-reverse");
}
actions.push("string-replace:" + name + "-reverse");
} else {
if (aiMinifyConfig[name]) {
// Attempt to compile without any translations (Validates that the original source code is fine before transforming it)
actions.push("ts:" + name);
actions.push("ai-minify:" + name);
}
// Now perform the "real" final compile after minification
actions.push("ts:" + name);
if (addTests && gruntTsConfig[name + "-tests"]) {
actions.push("ts:" + name + "-tests");
}
if (aiMinifyConfig[name + "-reverse"]) {
actions.push("ai-minify:" + name + "-reverse");
}
}
actions.push("eslint-ts:" + name + "-lint");
return actions;
2017-07-14 20:56:21 +03:00
}
function tsTestActions(name, minifySrc, compileSrc) {
var gruntTsConfig = theBuildConfig["ts"];
var aiMinifyConfig = theBuildConfig["ai-minify"] || {};
var actions = [
"connect"
];
var replaceConfig = theBuildConfig["string-replace"] || {};
if (replaceConfig[name]) {
actions.push("string-replace:" + name);
}
if (aiMinifyConfig[name]) {
if (minifySrc) {
// Attempt to compile with translations (Validates that the original source code is fine before transforming it)
actions.push("ai-minify:" + name);
} else if (aiMinifyConfig[name + "-reverse"]){
// Attempt to compile without any translations (Validates that the original source code is fine before transforming it)
actions.push("ai-minify:" + name + "-reverse");
}
if (compileSrc && gruntTsConfig[name]) {
actions.push("ts:" + name);
}
}
// If this helper is called then these should always exist
actions.push("ts:" + name + "-tests");
actions.push("qunit:" + name);
if (minifySrc && aiMinifyConfig[name + "-reverse"]) {
actions.push("ai-minify:" + name + "-reverse");
}
if (replaceConfig[name]) {
actions.push("string-replace:" + name + "-reverse");
}
return actions;
}
function minTasks(name) {
var actions = [
];
var aiMinifyConfig = theBuildConfig["ai-minify"] || {};
if (aiMinifyConfig[name]) {
actions.push("ai-minify:" + name);
}
return actions;
}
function restoreTasks(name) {
var actions = [
];
var aiMinifyConfig = theBuildConfig["ai-minify"] || {};
if (aiMinifyConfig[name + "-reverse"]) {
actions.push("ai-minify:" + name + "-reverse");
}
return actions;
}
grunt.initConfig(deepMerge(
theBuildConfig, {
uglify: {
snippetvNext: {
files: {
'AISKU/snippet/snippet.min.js': ['AISKU/snippet/snippet.js']
},
options: {
sourceMap: false,
ie8: false,
compress: {
passes:3,
unsafe: true,
},
output: {
webkit:true
}
}
}
},
'string-replace': {
'generate-expanded-JS': expandJS(),
'generate-expanded-min': expandMin(),
'generate-snippet-ikey': generateNewSnippet("IKey"),
'generate-snippet-connString': generateNewSnippet("ConnString"),
'generate-snippet-origin': generateNewSnippet("Origin")
},
copy: {
"originSnippet": {
files: [
{ src: "./tools/applicationinsights-web-snippet/build/output/snippet.min.js", dest: `./tools/applicationinsights-web-snippet/build/output/originSnippet.min.js` }
]
},
"snippet": {
files: [
{ src: "./tools/applicationinsights-web-snippet/build/output/snippet.js", dest: `./tools/applicationinsights-web-snippet/dist-es5/snippet.js` },
{ src: "./tools/applicationinsights-web-snippet/build/output/snippet.js.map", dest: `./tools/applicationinsights-web-snippet/dist-es5/snippet.js.map` },
{ src: "./tools/applicationinsights-web-snippet/build/output/snippet.min.js", dest: `./tools/applicationinsights-web-snippet/dist-es5/snippet.min.js` },
{ src: "./tools/applicationinsights-web-snippet/build/output/snippet.min.js.map", dest: `./tools/applicationinsights-web-snippet/dist-es5/snippet.min.js.map` }
]
},
"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/es5/ai.config${configVer}.cfg.json` },
{ src: "./tools/config/config.json", dest: `./tools/config/browser/es5/ai.config${configMajorVer}.cfg.json` }
]
}
}
}));
grunt.event.on('qunit.testStart', function (name) {
grunt.log.ok('Running test: ' + name);
});
grunt.loadNpmTasks("@nevware21/grunt-ts-plugin");
grunt.loadNpmTasks("@nevware21/grunt-eslint-ts");
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadTasks('./tools/grunt-tasks');
grunt.registerTask("default", ["ts:rollupuglify", "ts:rollupes5", "ts:rollupes5test", "qunit:rollupes5", "ts:shims", "ts:shimstest", "qunit:shims", "ts:default", "uglify:ai", "uglify:snippet"]);
grunt.registerTask("core", tsBuildActions("core", true));
grunt.registerTask("core-min", minTasks("core"));
grunt.registerTask("core-restore", restoreTasks("core"));
grunt.registerTask("coreunittest", tsTestActions("core"));
grunt.registerTask("core-mintest", tsTestActions("core", true));
grunt.registerTask("coreperftest", ["connect", "ts:core-perftest", "qunit:core-perf"]);
grunt.registerTask("common", tsBuildActions("common"));
grunt.registerTask("common-min", minTasks("common"));
grunt.registerTask("common-restore", restoreTasks("common"));
grunt.registerTask("commontest", tsTestActions("common"));
grunt.registerTask("common-mintest", tsTestActions("common", true));
grunt.registerTask("ai", tsBuildActions("appinsights"));
grunt.registerTask("ai-min", minTasks("appinsights"));
grunt.registerTask("ai-restore", restoreTasks("appinsights"));
grunt.registerTask("aitests", tsTestActions("appinsights"));
grunt.registerTask("ai-mintests", tsTestActions("appinsights", true));
grunt.registerTask("aisku", tsBuildActions("aisku"));
grunt.registerTask("aisku-min", minTasks("aisku"));
grunt.registerTask("aisku-restore", restoreTasks("aisku"));
grunt.registerTask("aiskuunittests", tsTestActions("aisku"));
grunt.registerTask("aisku-mintests", tsTestActions("aisku", true));
grunt.registerTask("aiskuperf", ["connect", "ts:aisku-perftest", "qunit:aisku-perf"]);
grunt.registerTask("aiskulite", tsBuildActions("aiskulite"));
grunt.registerTask("aiskulite-min", minTasks("aiskulite"));
grunt.registerTask("aiskulite-restore", restoreTasks("aiskulite"));
grunt.registerTask("aiskuliteunittests", tsTestActions("aiskulite"));
grunt.registerTask("aiskulite-mintests", tsTestActions("aiskulite", true));
grunt.registerTask("snippetvnext", ["uglify:snippetvNext"]);
grunt.registerTask("test", ["connect", "ts:default", "ts:test", "ts:testSchema", "ts:testE2E", "qunit:all"]);
grunt.registerTask("test1ds", ["coretest", "common", "propertiestests", "depstest", "aitests", "aiskutests"]);
grunt.registerTask("perfmarkmeasure", tsBuildActions("perfmarkmeasure"));
grunt.registerTask("perfmarkmeasure-min", minTasks("perfmarkmeasure"));
grunt.registerTask("perfmarkmeasure-restore", restoreTasks("perfmarkmeasure"));
grunt.registerTask("perfmarkmeasuretests", tsTestActions("perfmarkmeasure"));
grunt.registerTask("perfmarkmeasure-mintests", tsTestActions("perfmarkmeasure", true));
grunt.registerTask("properties", tsBuildActions("properties"));
grunt.registerTask("properties-min", minTasks("properties"));
grunt.registerTask("properties-restore", restoreTasks("properties"));
grunt.registerTask("propertiestests", tsTestActions("properties"));
grunt.registerTask("properties-mintests", tsTestActions("properties", true));
grunt.registerTask("cfgsync", tsBuildActions("cfgsync"));
grunt.registerTask("cfgsync-min", minTasks("cfgsync"));
grunt.registerTask("cfgsync-restore", restoreTasks("cfgsync"));
grunt.registerTask("cfgsynctests", tsTestActions("cfgsync"));
grunt.registerTask("cfgsync-mintests", tsTestActions("cfgsync", true));
grunt.registerTask("deps", tsBuildActions("deps"));
grunt.registerTask("deps-min", minTasks("deps"));
grunt.registerTask("deps-restore", restoreTasks("deps"));
grunt.registerTask("depstest", tsTestActions("deps"));
grunt.registerTask("deps-mintest", tsTestActions("deps", true));
grunt.registerTask("debugplugin", tsBuildActions("debugplugin"));
grunt.registerTask("debugplugin-min", minTasks("debugplugin"));
grunt.registerTask("debugplugin-restore", restoreTasks("debugplugin"));
grunt.registerTask("aichannel", tsBuildActions("aichannel"));
grunt.registerTask("aichannel-min", minTasks("aichannel"));
grunt.registerTask("aichannel-restore", restoreTasks("aichannel"));
grunt.registerTask("aichanneltest", tsTestActions("aichannel"));
grunt.registerTask("aichannel-mintest", tsTestActions("aichannel", true));
grunt.registerTask("offlinechannel", tsBuildActions("offlinechannel"));
grunt.registerTask("offlinechannel-min", minTasks("offlinechannel"));
grunt.registerTask("offlinechannel-restore", restoreTasks("offlinechannel"));
grunt.registerTask("offlinechanneltest", tsTestActions("offlinechannel"));
grunt.registerTask("offlinechannel-mintest", tsTestActions("offlinechannel", true));
grunt.registerTask("teechannel", tsBuildActions("teechannel"));
grunt.registerTask("teechannel-min", minTasks("teechannel"));
grunt.registerTask("teechannel-restore", restoreTasks("teechannel"));
grunt.registerTask("teechanneltest", tsTestActions("teechannel"));
grunt.registerTask("teechannel-mintest", tsTestActions("teechannel", true));
grunt.registerTask("rollupuglify", tsBuildActions("rollupuglify"));
grunt.registerTask("rollupes5", tsBuildActions("rollupes5"));
grunt.registerTask("rollupes5test", tsTestActions("rollupes5", false));
grunt.registerTask("shims", tsBuildActions("shims").concat(tsTestActions("shims", false)));
grunt.registerTask("shimstest", tsTestActions("shims", false));
TelemetryViewer: Add Chrome debug extension to master (#1713) * init commit * update rollup * Fixed popup - now runs the React application * Now building the popup and background task seperately so that one doesn't have to export the other to make it build * Updated browser extension code with latest from odsp-web * Update window title of the popup * Readme update * Added custom configuration UI for in-tool authoring of the configuration file * New icon * Name update * Filter text now uses column values from configuration instead of Stream hardcoded field names * Enable some more automatic eslint fixes (#1690) * Update dependencies in package.json * Add ability to zip the extension during build * Update SetVersion script to include the chrome-debug-extension Synchronize manifest.json version with package.json Add CDN publishing scripts Rework package zipping for more flexibility * Bump version to v0.1.1 Fixup Content-Type for publishing to CDN * Add archiver package to devDependencies * Update shrinkwrap for archiver * Update Stream URL * Break circular dependency * Add 'TimeDelta' column type, fix details view to allow for deep paths to be excluded via config * Network data source now handles arrays of events as well * Add default configuration feature * Default configuration updates to flag errors, perf events, add a dynamic value for each event type, and exclude the last tag field in consolidated view * Fix bug where boolean fields would not be displayed * Updated icons for better contrast on the task bar when in dark mode * Add sessionidRegex option * Added jsonFieldNames * Table header no longer scrolls * Update setActiveVersion script to support publishing an unversioned value * Update icons to ensure they are from the set we are allowed to use * Update to version 0.1.2 * Code tidy up and added prettier rule file * Chrome debug extension UI (#1703) * [BUG] Field 'ai.operation.name' on type 'ContextTagKeys' is too long. Expected: 1024 characters" #1692 (#1693) * [BUG] Multiple errors are getting thrown and swallowed during initialization when no instrumentation Key is provided #1691 (#1695) * Governance Updates -- update used dependencies (#1694) * init * working * add css * copy over helper and debugplugin ui * update style * Shrinkwrap update after rush update * Accessibility fixes * Fix accessibility in the configuration page * Fix missing red line between sessions * align styles * Added update instructions to the configuration page, and replaced placeholder link for preset creation instructions * fix build Co-authored-by: Nev <54870357+MSNev@users.noreply.github.com> Co-authored-by: Kevin Brown <kevbrown@microsoft.com> * Merge remote-tracking branch 'origin/master' into ChromeDebugExtension * Fixes - EsLint integration and auto fixes - Add integrity.json generation * Update Chrome Debug extension to use new v.2.7.1 base components * Add files via upload (#1711) * Update README.md in ChromeExtension (#1710) * Update README.md * chrome-extension-readme: Update to relative path * Add files via upload * Fix popup looping (causing dead UI) issue * Update file comments * Add DbgExtensionUtils to AI core with notification support and defaults for AI and OneDs * Performance improvements - Only populate the condensedDetails when required - dont save the condensed details to the "saved" files Functional changes - Add filter match highlighting to the lower window - Add option to include the event content when filtering - Add UI components to enable/disable networking and Sdk event capturing * Enable expand/collapse and address PR comments * Fix CodeScanning issues * Add wildcard support to event table filtering and match highlighting * Added tooltips to new optionsBar UI, removing the need for the "capture" label and explaining the "Content" checkbox, also fixing issue prevent mouse clicks on the new labels from toggling the checkboxes * Readme updates * Change default height to be taller, capitalize SDK * Fixed bug on fresh install when there is no saved filter state which prevented configurations from being loaded * Address Security issues identified by internal component governance services (#1715) * Fix package version differences * Make syntax highlighting in the detail (tree) view case-insensitive * Add Simple Hello World sample * Rename NetworkDataSource and clean up the data source type list * Add defaultNetworkCaptureValue and defaultSDKCaptureValue to IConfiguration * Extract DebugPlugin debug message to a function * Add capturing network requests for sendBeacon() ("ping" requests) * Consolidate the DebugPlugin logging functions Co-authored-by: xiao-lix <lixiao900921@gmail.com> Co-authored-by: Kevin Brown <kevbrown@microsoft.com> Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com> Co-authored-by: KevBrown-MSFT <51932180+KevBrown-MSFT@users.noreply.github.com>
2021-11-19 03:35:41 +03:00
grunt.registerTask("chromedebugextension", tsBuildActions("chrome-debug-extension"));
grunt.registerTask("chromedebugextension-min", minTasks("chrome-debug-extension"));
grunt.registerTask("chromedebugextension-restore", restoreTasks("chrome-debug-extension"));
grunt.registerTask("websnippet", tsBuildActions("applicationinsights-web-snippet"));
grunt.registerTask("snippetCopy", ["copy:snippet"]);
grunt.registerTask("originSnippetCopy", ["copy:originSnippet"]);
grunt.registerTask("websnippetReplace", ["string-replace:generate-expanded-JS", "copy:web-snippet", "string-replace:generate-expanded-min", "string-replace:generate-snippet-ikey", "string-replace:generate-snippet-connString", "string-replace:generate-snippet-origin"]);
grunt.registerTask("snippet-restore", restoreTasks("applicationinsights-web-snippet"));
grunt.registerTask("websnippettests", tsTestActions("applicationinsights-web-snippet"));
grunt.registerTask("clickanalytics", tsBuildActions("clickanalytics"));
grunt.registerTask("clickanalytics-min", minTasks("clickanalytics"));
grunt.registerTask("clickanalytics-restore", restoreTasks("clickanalytics"));
grunt.registerTask("clickanalyticstests", tsTestActions("clickanalytics"));
grunt.registerTask("clickanalytics-mintests", tsTestActions("clickanalytics", true));
grunt.registerTask("osplugin", tsBuildActions("osplugin"));
grunt.registerTask("osplugin-min", minTasks("osplugin"));
grunt.registerTask("osplugin-restore", restoreTasks("osplugin"));
grunt.registerTask("osplugintests", tsTestActions("osplugin"));
grunt.registerTask("osplugin-mintests", tsTestActions("osplugin", true));
grunt.registerTask("1dsCoreBuild", tsBuildActions("1dsCore"));
grunt.registerTask("1dsCoreTest", tsTestActions("1dsCore"));
grunt.registerTask("1dsCore", tsTestActions("1dsCore", true));
grunt.registerTask("1dsCore-min", minTasks("1dsCore"));
grunt.registerTask("1dsCore-restore", restoreTasks("1dsCore"));
grunt.registerTask("1dsPostBuild", tsBuildActions("1dsPost"));
grunt.registerTask("1dsPostTest", tsTestActions("1dsPost"));
grunt.registerTask("1dsPostMinTest", tsTestActions("1dsPost", true));
grunt.registerTask("1dsPost-min", minTasks("1dsPost"));
grunt.registerTask("1dsPost-restore", restoreTasks("1dsPost"));
grunt.registerTask("example-shared-worker", tsBuildActions("example-shared-worker"));
grunt.registerTask("example-shared-worker-test", tsTestActions("example-shared-worker"));
grunt.registerTask("tst-framework", tsBuildActions("tst-framework"));
grunt.registerTask("serve", ["connect:server:keepalive"]);
grunt.registerTask("copy-config", ["copy:config"]);
grunt.registerTask("example-aisku", tsBuildActions("example-aisku"));
grunt.registerTask("example-dependency", tsBuildActions("example-dependency"));
grunt.registerTask("example-cfgsync", tsBuildActions("example-cfgsync"));
} catch (e) {
console.error(e);
console.error("stack: '" + e.stack + "', message: '" + e.message + "', name: '" + e.name + "'");
}
};