From 467aa189d8540fca3780787d9acf56b84ae49c23 Mon Sep 17 00:00:00 2001 From: Antti Viita Date: Fri, 26 Apr 2024 12:58:01 +0300 Subject: [PATCH] Link to bug and more complete repro * Added link to the [bug][1] into Readme * Added more complete instrumentation, by instrumenting App with an event - Would have been unnecessary though I think as default instrumentation seems to already send data * Commented telemetry.ts on what is the bug (error description) [1]: https://github.com/microsoft/ApplicationInsights-JS/issues/2336 --- README.md | 5 ++++- src/App.tsx | 14 +++++++++++++- src/telemetry.ts | 2 ++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b87cb00..d77c2ff 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ # Getting Started with Create React App -This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). +This is a repro for [github issue 2336 in *microsoft/ApplicationInsights-JS* repo](https://github.com/microsoft/ApplicationInsights-JS/issues/2336). + +Just run `npm run build` to get the build error on `ignoreHeaders`. + ## Available Scripts diff --git a/src/App.tsx b/src/App.tsx index a53698a..bbf3ff8 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,8 +1,20 @@ -import React from 'react'; +import React, { useEffect } from 'react'; import logo from './logo.svg'; import './App.css'; +import {appInsights} from './telemetry'; +import { useAppInsightsContext } from '@microsoft/applicationinsights-react-js'; function App() { + // const appInsights = useAppInsightsContext(); + + useEffect(() => { + if (appInsights) { + console.log("AppLoaded"); + appInsights.trackEvent({ name: "AppLoaded" }); + alert("AppLoaded"); + } + }, [appInsights]); + return (
diff --git a/src/telemetry.ts b/src/telemetry.ts index e3583e9..28a37be 100644 --- a/src/telemetry.ts +++ b/src/telemetry.ts @@ -15,6 +15,8 @@ const appInsights = new ApplicationInsights({ disableFetchTracking: false, //enableRequestHeaderTracking: true, // Enable to get request headers in dependency logs enableResponseHeaderTracking: true, // Enable to get response headers in dependency logs + // BUG: FOLLOWING LINE GIVES ERROR ON BUILD + // Object literal may only specify known properties, and 'ignoreHeaders' does not exist in type 'IConfiguration & IConfig'.ts(2353) ignoreHeaders: [ "Authorization", "X-API-Key",