Skip to content

Commit

Permalink
Automate hand patching node modules
Browse files Browse the repository at this point in the history
  • Loading branch information
lramos15 committed Aug 27, 2021
1 parent f5b3808 commit 12f47a6
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
11 changes: 11 additions & 0 deletions .esbuild.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
const esbuild = require('esbuild');
const fs = require('fs');
const path = require('path');

// Removes the warning from the app insights module since we don't want it to spam the console
function patchAppInsightsModules() {
const nodeAppInsightsModule = fs.readFileSync(path.join(__dirname, 'node_modules/applicationinsights/out/Library/Config.js'), 'utf8');
const fileWithRemovedWarning = nodeAppInsightsModule.replace(/Logging.warn\([^)]*invalid instrumentation key[^)]*\)/, '/* $& */');
fs.writeFileSync(path.join(__dirname, 'node_modules/applicationinsights/out/Library/Config.js'), fileWithRemovedWarning, 'utf8');
}

patchAppInsightsModules();

// Build node packages and their minifed versions
esbuild.build({
Expand Down
4 changes: 2 additions & 2 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.vscode
lib/*.js.map
!lib/*.js
lib/*.min.js
lib/*.js
!lib/*.min.js
node_modules
src
typings_patches
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"author": {
"name": "Microsoft Corporation"
},
"main": "./lib/telemetryReporter.node.js",
"browser": "./lib/telemetryReporter.web.js",
"main": "./lib/telemetryReporter.node.min.js",
"browser": "./lib/telemetryReporter.web.min.js",
"types": "./lib/telemetryReporter.d.ts",
"license": "MIT",
"engines": {
Expand Down
1 change: 1 addition & 0 deletions src/browser/telemetryReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class WebAppInsightsAppender implements ITelemetryAppender {
disableCookiesUsage: true,
autoTrackPageVisitTime: false,
emitLineDelimitedJson: true,
disableInstrumentationKeyValidation: true
},
});
this._aiClient.loadAppInsights();
Expand Down

0 comments on commit 12f47a6

Please sign in to comment.