Add second App Insights instance (#609)

This commit is contained in:
Steve Faulkner
2021-04-05 18:03:17 -05:00
committed by GitHub
parent 250faa5206
commit ba3f4829fa
7 changed files with 200 additions and 93 deletions

View File

@@ -1,5 +1,8 @@
import { ApplicationInsights } from "@microsoft/applicationinsights-web";
// TODO: Remove this after 06/01/21.
// This points to an old app insights instance that is difficult to access
// For now we are sending data to two instances of app insights
const appInsights = new ApplicationInsights({
config: {
instrumentationKey: "fa645d97-6237-4656-9559-0ee0cb55ee49",
@@ -7,7 +10,38 @@ const appInsights = new ApplicationInsights({
disableCorrelationHeaders: true,
},
});
appInsights.loadAppInsights();
appInsights.trackPageView(); // Manually call trackPageView to establish the current user/session/pageview
export { appInsights };
const appInsights2 = new ApplicationInsights({
config: {
instrumentationKey: "023d2c39-8f86-468e-bb8f-bcaebd9025c7",
disableFetchTracking: false,
disableCorrelationHeaders: true,
},
});
appInsights.loadAppInsights();
appInsights.trackPageView();
appInsights2.loadAppInsights();
appInsights2.trackPageView();
const trackEvent: typeof appInsights.trackEvent = (...args) => {
appInsights.trackEvent(...args);
appInsights2.trackEvent(...args);
};
const startTrackEvent: typeof appInsights.startTrackEvent = (...args) => {
appInsights.startTrackEvent(...args);
appInsights2.startTrackEvent(...args);
};
const stopTrackEvent: typeof appInsights.stopTrackEvent = (...args) => {
appInsights.stopTrackEvent(...args);
appInsights2.stopTrackEvent(...args);
};
const trackTrace: typeof appInsights.trackTrace = (...args) => {
appInsights.trackTrace(...args);
appInsights2.trackTrace(...args);
};
export { trackEvent, startTrackEvent, stopTrackEvent, trackTrace };