Skip to content

Commit

Permalink
App insights SDK initialization
Browse files Browse the repository at this point in the history
Added `telemetry.ts`, which reproduces the issue:
> Object literal may only specify known properties, and 'ignoreHeaders' does not exist in type 'IConfiguration & IConfig'.ts(2353)

Run build or just see the eslint highlight from the file.

Also installed latest `@microsoft/applicationinsights-web` and `@microsoft/applicationinsights-react-js`.
  • Loading branch information
avi-vw committed Apr 26, 2024
1 parent 68c4987 commit 031ab8d
Show file tree
Hide file tree
Showing 3 changed files with 257 additions and 4 deletions.
204 changes: 200 additions & 4 deletions package-lock.json

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

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@microsoft/applicationinsights-react-js": "^17.1.2",
"@microsoft/applicationinsights-web": "^3.2.0",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.5.2",
"@types/node": "^16.18.96",
"@types/react": "^18.3.0",
"@types/react-dom": "^18.3.0",
"dotenv": "^16.4.5",
"react": "^18.3.0",
"react-dom": "^18.3.0",
"react-scripts": "5.0.1",
Expand Down
54 changes: 54 additions & 0 deletions src/telemetry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import {
ApplicationInsights,
ITelemetryItem,
} from "@microsoft/applicationinsights-web";
import { ReactPlugin } from "@microsoft/applicationinsights-react-js";
import { createBrowserHistory } from "history";

const history = createBrowserHistory();

const reactPlugin = new ReactPlugin();

const appInsights = new ApplicationInsights({
config: {
connectionString: process.env.VITE_APP_AI_INSTRUMENTATION_CONNECTION_STRING,
disableFetchTracking: false,
//enableRequestHeaderTracking: true, // Enable to get request headers in dependency logs
enableResponseHeaderTracking: true, // Enable to get response headers in dependency logs
ignoreHeaders: [
"Authorization",
"X-API-Key",
"WWW-Authenticate",
"date",
"x-ms-blob-type",
"x-ms-lease-status",
"x-ms-request-id",
"x-ms-version",
"content-type",
"X-Powered-By",
"X-Firefox-Spdy",
"Set-Cookie",
"Request-Context",
"Content-Encoding",
"Access-Control-Allow-Origin",
"Content-Encoding",
"Vary",
], // Ignore these headers in dependency logs
disableAjaxTracking: false,
enableCorsCorrelation: true,
extensions: [reactPlugin /* debugPluginInstance */],
extensionConfig: {
[reactPlugin.identifier]: {
history,
},
/*
[DebugPlugin.identifier]: {
trackers: toTrack
}
*/
},
},
});

appInsights.loadAppInsights();
export { reactPlugin, appInsights };

0 comments on commit 031ab8d

Please sign in to comment.