mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-19 17:01:13 +00:00
Add second App Insights instance (#609)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { sendMessage } from "./MessageHandler";
|
||||
import { Diagnostics, MessageTypes } from "../Contracts/ExplorerContracts";
|
||||
import { appInsights } from "../Shared/appInsights";
|
||||
import { SeverityLevel } from "@microsoft/applicationinsights-web";
|
||||
import { Diagnostics, MessageTypes } from "../Contracts/ExplorerContracts";
|
||||
import { trackTrace } from "../Shared/appInsights";
|
||||
import { sendMessage } from "./MessageHandler";
|
||||
|
||||
// TODO: Move to a separate Diagnostics folder
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
@@ -46,7 +46,7 @@ function _logEntry(entry: Diagnostics.LogEntry): void {
|
||||
return SeverityLevel.Information;
|
||||
}
|
||||
})(entry.level);
|
||||
appInsights.trackTrace({ message: entry.message, severityLevel }, { area: entry.area });
|
||||
trackTrace({ message: entry.message, severityLevel }, { area: entry.area });
|
||||
}
|
||||
|
||||
function _generateLogEntry(
|
||||
|
||||
@@ -25,7 +25,7 @@ import { IGalleryItem } from "../Juno/JunoClient";
|
||||
import { NotebookWorkspaceManager } from "../NotebookWorkspaceManager/NotebookWorkspaceManager";
|
||||
import { ResourceProviderClientFactory } from "../ResourceProvider/ResourceProviderClientFactory";
|
||||
import { RouteHandler } from "../RouteHandlers/RouteHandler";
|
||||
import { appInsights } from "../Shared/appInsights";
|
||||
import { trackEvent } from "../Shared/appInsights";
|
||||
import * as SharedConstants from "../Shared/Constants";
|
||||
import { DefaultExperienceUtility } from "../Shared/DefaultExperienceUtility";
|
||||
import { ExplorerSettings } from "../Shared/ExplorerSettings";
|
||||
@@ -342,7 +342,7 @@ export default class Explorer {
|
||||
userContext.features.enableSpark
|
||||
);
|
||||
if (this.isSparkEnabled()) {
|
||||
appInsights.trackEvent(
|
||||
trackEvent(
|
||||
{ name: "LoadedWithSparkEnabled" },
|
||||
{
|
||||
subscriptionId: userContext.subscriptionId,
|
||||
|
||||
@@ -1,39 +1,36 @@
|
||||
import * as _ from "underscore";
|
||||
import * as Q from "q";
|
||||
import { stringifyNotebook, toJS } from "@nteract/commutable";
|
||||
import * as ko from "knockout";
|
||||
|
||||
import * as ViewModels from "../../Contracts/ViewModels";
|
||||
import * as DataModels from "../../Contracts/DataModels";
|
||||
import TabsBase from "./TabsBase";
|
||||
|
||||
import NewCellIcon from "../../../images/notebook/Notebook-insert-cell.svg";
|
||||
import CutIcon from "../../../images/notebook/Notebook-cut.svg";
|
||||
import CopyIcon from "../../../images/notebook/Notebook-copy.svg";
|
||||
import PasteIcon from "../../../images/notebook/Notebook-paste.svg";
|
||||
import RunIcon from "../../../images/notebook/Notebook-run.svg";
|
||||
import RunAllIcon from "../../../images/notebook/Notebook-run-all.svg";
|
||||
import RestartIcon from "../../../images/notebook/Notebook-restart.svg";
|
||||
import SaveIcon from "../../../images/save-cosmos.svg";
|
||||
import * as Q from "q";
|
||||
import * as _ from "underscore";
|
||||
import ClearAllOutputsIcon from "../../../images/notebook/Notebook-clear-all-outputs.svg";
|
||||
import InterruptKernelIcon from "../../../images/notebook/Notebook-stop.svg";
|
||||
import KillKernelIcon from "../../../images/notebook/Notebook-stop.svg";
|
||||
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||
import { Action, ActionModifiers, Source } from "../../Shared/Telemetry/TelemetryConstants";
|
||||
import CopyIcon from "../../../images/notebook/Notebook-copy.svg";
|
||||
import CutIcon from "../../../images/notebook/Notebook-cut.svg";
|
||||
import NewCellIcon from "../../../images/notebook/Notebook-insert-cell.svg";
|
||||
import PasteIcon from "../../../images/notebook/Notebook-paste.svg";
|
||||
import RestartIcon from "../../../images/notebook/Notebook-restart.svg";
|
||||
import RunAllIcon from "../../../images/notebook/Notebook-run-all.svg";
|
||||
import RunIcon from "../../../images/notebook/Notebook-run.svg";
|
||||
import { default as InterruptKernelIcon, default as KillKernelIcon } from "../../../images/notebook/Notebook-stop.svg";
|
||||
import SaveIcon from "../../../images/save-cosmos.svg";
|
||||
import { Areas, ArmApiVersions } from "../../Common/Constants";
|
||||
import { configContext } from "../../ConfigContext";
|
||||
import * as DataModels from "../../Contracts/DataModels";
|
||||
import * as ViewModels from "../../Contracts/ViewModels";
|
||||
import { trackEvent } from "../../Shared/appInsights";
|
||||
import { Action, ActionModifiers, Source } from "../../Shared/Telemetry/TelemetryConstants";
|
||||
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||
import { userContext } from "../../UserContext";
|
||||
import * as NotebookConfigurationUtils from "../../Utils/NotebookConfigurationUtils";
|
||||
import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils";
|
||||
import { CommandButtonComponentProps } from "../Controls/CommandButton/CommandButtonComponent";
|
||||
import Explorer from "../Explorer";
|
||||
import * as CommandBarComponentButtonFactory from "../Menus/CommandBar/CommandBarComponentButtonFactory";
|
||||
import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils";
|
||||
import { NotebookComponentAdapter } from "../Notebook/NotebookComponent/NotebookComponentAdapter";
|
||||
import * as NotebookConfigurationUtils from "../../Utils/NotebookConfigurationUtils";
|
||||
import { KernelSpecsDisplay, NotebookClientV2 } from "../Notebook/NotebookClientV2";
|
||||
import { configContext } from "../../ConfigContext";
|
||||
import Explorer from "../Explorer";
|
||||
import { NotebookComponentAdapter } from "../Notebook/NotebookComponent/NotebookComponentAdapter";
|
||||
import { NotebookContentItem } from "../Notebook/NotebookContentItem";
|
||||
import { CommandButtonComponentProps } from "../Controls/CommandButton/CommandButtonComponent";
|
||||
import { toJS, stringifyNotebook } from "@nteract/commutable";
|
||||
import { appInsights } from "../../Shared/appInsights";
|
||||
import { userContext } from "../../UserContext";
|
||||
import template from "./NotebookV2Tab.html";
|
||||
import TabsBase from "./TabsBase";
|
||||
|
||||
export interface NotebookTabOptions extends ViewModels.TabOptions {
|
||||
account: DataModels.DatabaseAccount;
|
||||
@@ -428,7 +425,7 @@ export default class NotebookTabV2 extends TabsBase {
|
||||
return;
|
||||
}
|
||||
|
||||
appInsights.trackEvent(
|
||||
trackEvent(
|
||||
{ name: "SparkPoolSelected" },
|
||||
{
|
||||
subscriptionId: userContext.subscriptionId,
|
||||
|
||||
@@ -3,7 +3,7 @@ import { configContext } from "../../ConfigContext";
|
||||
import { MessageTypes } from "../../Contracts/ExplorerContracts";
|
||||
import { SelfServeMessageTypes } from "../../Contracts/SelfServeContracts";
|
||||
import { userContext } from "../../UserContext";
|
||||
import { appInsights } from "../appInsights";
|
||||
import { startTrackEvent, stopTrackEvent, trackEvent } from "../appInsights";
|
||||
import { Action, ActionModifiers } from "./TelemetryConstants";
|
||||
|
||||
// Right now, the ExplorerContracts has MessageTypes as a numeric enum (TelemetryInfo = 0) while the SelfServeContracts
|
||||
@@ -27,7 +27,7 @@ export function trace(
|
||||
},
|
||||
});
|
||||
|
||||
appInsights.trackEvent({ name: Action[action] }, decorateData(data, actionModifier));
|
||||
trackEvent({ name: Action[action] }, decorateData(data, actionModifier));
|
||||
}
|
||||
|
||||
export function traceStart(
|
||||
@@ -46,7 +46,7 @@ export function traceStart(
|
||||
},
|
||||
});
|
||||
|
||||
appInsights.startTrackEvent(Action[action]);
|
||||
startTrackEvent(Action[action]);
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ export function traceSuccess(
|
||||
},
|
||||
});
|
||||
|
||||
appInsights.stopTrackEvent(Action[action], decorateData(data, ActionModifiers.Success));
|
||||
stopTrackEvent(Action[action], decorateData(data, ActionModifiers.Success));
|
||||
}
|
||||
|
||||
export function traceFailure(
|
||||
@@ -85,7 +85,7 @@ export function traceFailure(
|
||||
},
|
||||
});
|
||||
|
||||
appInsights.stopTrackEvent(Action[action], decorateData(data, ActionModifiers.Failed));
|
||||
stopTrackEvent(Action[action], decorateData(data, ActionModifiers.Failed));
|
||||
}
|
||||
|
||||
export function traceCancel(
|
||||
@@ -104,7 +104,7 @@ export function traceCancel(
|
||||
},
|
||||
});
|
||||
|
||||
appInsights.stopTrackEvent(Action[action], decorateData(data, ActionModifiers.Cancel));
|
||||
stopTrackEvent(Action[action], decorateData(data, ActionModifiers.Cancel));
|
||||
}
|
||||
|
||||
export function traceOpen(
|
||||
@@ -124,7 +124,7 @@ export function traceOpen(
|
||||
},
|
||||
});
|
||||
|
||||
appInsights.startTrackEvent(Action[action]);
|
||||
startTrackEvent(Action[action]);
|
||||
return validTimestamp;
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ export function traceMark(
|
||||
},
|
||||
});
|
||||
|
||||
appInsights.startTrackEvent(Action[action]);
|
||||
startTrackEvent(Action[action]);
|
||||
return validTimestamp;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user