Skip to content

Commit 12f47a6

Browse files
committed
Automate hand patching node modules
1 parent f5b3808 commit 12f47a6

File tree

5 files changed

+18
-6
lines changed

5 files changed

+18
-6
lines changed

.esbuild.config.js

+11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
const esbuild = require('esbuild');
2+
const fs = require('fs');
3+
const path = require('path');
4+
5+
// Removes the warning from the app insights module since we don't want it to spam the console
6+
function patchAppInsightsModules() {
7+
const nodeAppInsightsModule = fs.readFileSync(path.join(__dirname, 'node_modules/applicationinsights/out/Library/Config.js'), 'utf8');
8+
const fileWithRemovedWarning = nodeAppInsightsModule.replace(/Logging.warn\([^)]*invalid instrumentation key[^)]*\)/, '/* $& */');
9+
fs.writeFileSync(path.join(__dirname, 'node_modules/applicationinsights/out/Library/Config.js'), fileWithRemovedWarning, 'utf8');
10+
}
11+
12+
patchAppInsightsModules();
213

314
// Build node packages and their minifed versions
415
esbuild.build({

.npmignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.vscode
22
lib/*.js.map
3-
!lib/*.js
4-
lib/*.min.js
3+
lib/*.js
4+
!lib/*.min.js
55
node_modules
66
src
77
typings_patches

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"author": {
66
"name": "Microsoft Corporation"
77
},
8-
"main": "./lib/telemetryReporter.node.js",
9-
"browser": "./lib/telemetryReporter.web.js",
8+
"main": "./lib/telemetryReporter.node.min.js",
9+
"browser": "./lib/telemetryReporter.web.min.js",
1010
"types": "./lib/telemetryReporter.d.ts",
1111
"license": "MIT",
1212
"engines": {

src/browser/telemetryReporter.ts

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class WebAppInsightsAppender implements ITelemetryAppender {
2727
disableCookiesUsage: true,
2828
autoTrackPageVisitTime: false,
2929
emitLineDelimitedJson: true,
30+
disableInstrumentationKeyValidation: true
3031
},
3132
});
3233
this._aiClient.loadAppInsights();

0 commit comments

Comments
 (0)