diff --git a/package-lock.json b/package-lock.json index 1cabbcbed..d9a600faa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3122,64 +3122,66 @@ } }, "@microsoft/applicationinsights-analytics-js": { - "version": "2.5.9", - "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-analytics-js/-/applicationinsights-analytics-js-2.5.9.tgz", - "integrity": "sha512-9L3fb1H1as+J3J2j2EDx1HEMdrucjgR4INqahy+ZAxDPFvR3HCOedYzx645zObBIPu7QkH2LAjPk4fuNGHR1rg==", + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-analytics-js/-/applicationinsights-analytics-js-2.6.1.tgz", + "integrity": "sha512-wRH67jZTPy6SP54ygAQsFXu5ZnfzGOoMkA6ll1pkhSC4hij7Cvzumr4PYkr2gIPBPxD354sLOjBL/lmOgBTc5g==", "requires": { - "@microsoft/applicationinsights-common": "2.5.9", - "@microsoft/applicationinsights-core-js": "2.5.9", + "@microsoft/applicationinsights-common": "2.6.1", + "@microsoft/applicationinsights-core-js": "2.6.1", "@microsoft/applicationinsights-shims": "1.0.3", - "@microsoft/dynamicproto-js": "^1.0.0" + "@microsoft/dynamicproto-js": "^1.1.1" } }, "@microsoft/applicationinsights-channel-js": { - "version": "2.5.9", - "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-channel-js/-/applicationinsights-channel-js-2.5.9.tgz", - "integrity": "sha512-NAQ/2wWmD+gaIZDCMzzwxm8RcbswDvUO5BYeuW9UHJaFuEZ9o9xpztKVz32u4CMv7OI/mLOqnmR4rb0d+kUMwQ==", + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-channel-js/-/applicationinsights-channel-js-2.6.1.tgz", + "integrity": "sha512-oatERKW3eAjVNm5ej2NpRvBCCtPtiINIKxLiWVHv2SC2rzGrUnxNWFlUJojRT+u5ZXXsB51Ktw9gx8iHexnDVw==", "requires": { - "@microsoft/applicationinsights-common": "2.5.9", - "@microsoft/applicationinsights-core-js": "2.5.9", + "@microsoft/applicationinsights-common": "2.6.1", + "@microsoft/applicationinsights-core-js": "2.6.1", "@microsoft/applicationinsights-shims": "1.0.3", - "@microsoft/dynamicproto-js": "^1.0.0" + "@microsoft/dynamicproto-js": "^1.1.1" } }, "@microsoft/applicationinsights-common": { - "version": "2.5.9", - "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-common/-/applicationinsights-common-2.5.9.tgz", - "integrity": "sha512-dKmXO9m55uRDhpoa0P7l+BApf+lsrqjgoLeKv+ABM8ygIyd9JH6CDcdaT3af+kUFtt9Oj3ChyfueKr1EVOdGkQ==", + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-common/-/applicationinsights-common-2.6.1.tgz", + "integrity": "sha512-kV/dI9UwTew3mq+3F3Tkl2dBn2C4+FOOG3S5cS7/SssVsUlvLrWXBrOOxfIJ7+EjQQ6ijcqlDus4Nz7Ms2Kk2Q==", "requires": { - "@microsoft/applicationinsights-core-js": "2.5.9", - "@microsoft/applicationinsights-shims": "1.0.3" + "@microsoft/applicationinsights-core-js": "2.6.1", + "@microsoft/applicationinsights-shims": "1.0.3", + "@microsoft/dynamicproto-js": "^1.1.1" } }, "@microsoft/applicationinsights-core-js": { - "version": "2.5.9", - "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-core-js/-/applicationinsights-core-js-2.5.9.tgz", - "integrity": "sha512-KE9h1wmC/Ckm7jYjsMF1SEWQnk0v0CRzZq1upSARgPH7BgmyClXz1kdnLtuTWz8Aha8IIH9dW2hUOfPCdR+BpQ==", + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-core-js/-/applicationinsights-core-js-2.6.1.tgz", + "integrity": "sha512-SFnTx48BGkmz6P9GvXFeIZ641vnfrKo0hB74Hp9GR7UE3hqIDuomIBQS17unnh05T5w3PWKlDCGNpiCbJV6kzQ==", "requires": { "@microsoft/applicationinsights-shims": "1.0.3", - "@microsoft/dynamicproto-js": "^1.0.0" + "@microsoft/dynamicproto-js": "^1.1.1" } }, "@microsoft/applicationinsights-dependencies-js": { - "version": "2.5.9", - "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-dependencies-js/-/applicationinsights-dependencies-js-2.5.9.tgz", - "integrity": "sha512-pNM/dkUOscV0ul/YJe928+77EBtRkRXO/le/VWzlunoUFaEEo4pirc7NycvPx9w/KxA62JMEogbQsWE6nAmqPg==", + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-dependencies-js/-/applicationinsights-dependencies-js-2.6.1.tgz", + "integrity": "sha512-Y7R6BjzyB6NrkIBTT6FJrr2jKr8MiLxy264b1xUQHjry3Bwu+fsPJ7EETV61dkOEHs6IlWxAtikNCv8f3zQydw==", "requires": { - "@microsoft/applicationinsights-common": "2.5.9", - "@microsoft/applicationinsights-core-js": "2.5.9", + "@microsoft/applicationinsights-common": "2.6.1", + "@microsoft/applicationinsights-core-js": "2.6.1", "@microsoft/applicationinsights-shims": "1.0.3", - "@microsoft/dynamicproto-js": "^1.0.0" + "@microsoft/dynamicproto-js": "^1.1.1" } }, "@microsoft/applicationinsights-properties-js": { - "version": "2.5.9", - "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-properties-js/-/applicationinsights-properties-js-2.5.9.tgz", - "integrity": "sha512-mZxaC8CZsURn38IwsPaUx+o9QXQU2vm81THZL+1Lc+7scPo55ATDTFgZ2awIj7CdTp69oGzUkpB7maOn6+OVOw==", + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-properties-js/-/applicationinsights-properties-js-2.6.1.tgz", + "integrity": "sha512-TQmKp9/j0yMGjUHBatRQ41E4S/1yTkJImh8csZxc4waMQmV9ITkNrDaC3bIPcrw+ASepI3QfP7sry+n7nvYLFw==", "requires": { - "@microsoft/applicationinsights-common": "2.5.9", - "@microsoft/applicationinsights-core-js": "2.5.9", - "@microsoft/applicationinsights-shims": "1.0.3" + "@microsoft/applicationinsights-common": "2.6.1", + "@microsoft/applicationinsights-core-js": "2.6.1", + "@microsoft/applicationinsights-shims": "1.0.3", + "@microsoft/dynamicproto-js": "^1.1.1" } }, "@microsoft/applicationinsights-shims": { @@ -3188,24 +3190,85 @@ "integrity": "sha512-+S17aqEkOYpyBpmclhgwcEplwnxSo5AxYBdRg38GBobI1GKPSpZfnLssLzcjJ6XZCS5tqB5xjyTZs6gHj7ZJWQ==" }, "@microsoft/applicationinsights-web": { - "version": "2.5.9", - "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-web/-/applicationinsights-web-2.5.9.tgz", - "integrity": "sha512-dxg5XXbQqjWw9QmGdgbd7knb1qFA58FFYj9ObqRmlqiihk25kper7H15HH8LaV0lV6goClmBWc9KsNGA2veyeA==", + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-web/-/applicationinsights-web-2.6.1.tgz", + "integrity": "sha512-jKF6hpPq3pzLqLSVxTMh7HU9tr/SPOFJN12pFYpNMU/rAMs/fgZsmFG/oBAzYTZxNilDTFljoblB66J9X+K6RQ==", "requires": { - "@microsoft/applicationinsights-analytics-js": "2.5.9", - "@microsoft/applicationinsights-channel-js": "2.5.9", - "@microsoft/applicationinsights-common": "2.5.9", - "@microsoft/applicationinsights-core-js": "2.5.9", - "@microsoft/applicationinsights-dependencies-js": "2.5.9", - "@microsoft/applicationinsights-properties-js": "2.5.9", + "@microsoft/applicationinsights-analytics-js": "2.6.1", + "@microsoft/applicationinsights-channel-js": "2.6.1", + "@microsoft/applicationinsights-common": "2.6.1", + "@microsoft/applicationinsights-core-js": "2.6.1", + "@microsoft/applicationinsights-dependencies-js": "2.6.1", + "@microsoft/applicationinsights-properties-js": "2.6.1", "@microsoft/applicationinsights-shims": "1.0.3", - "@microsoft/dynamicproto-js": "^1.0.0" + "@microsoft/dynamicproto-js": "^1.1.1" } }, "@microsoft/dynamicproto-js": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@microsoft/dynamicproto-js/-/dynamicproto-js-1.1.0.tgz", - "integrity": "sha512-pjcr+A6wTQHl/S4b5zQzeDMC6+9ekojCFHQAEYI4a8u9ZjWwbg4jmtO22CWEuRWWN/lBMjay9FKanlODWk5wqQ==" + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@microsoft/dynamicproto-js/-/dynamicproto-js-1.1.1.tgz", + "integrity": "sha512-SPY1PlXmg4FbJVItVdhDV+zigajPtSI8oZPrsKBEIzAF4FROuwWIq5C+RAF8VJshBqphcvU8Eoh4DrUEZOB31g==", + "requires": { + "findup-sync": "^4.0.0", + "nopt": "^5.0.0", + "pify": "^2.3.0" + }, + "dependencies": { + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "requires": { + "fill-range": "^7.0.1" + } + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "findup-sync": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-4.0.0.tgz", + "integrity": "sha512-6jvvn/12IC4quLBL1KNokxC7wWTvYncaVUYSoxWw7YykPLuRrnv4qdHcSOywOI5RpkOVGeQRtWM8/q+G6W6qfQ==", + "requires": { + "detect-file": "^1.0.0", + "is-glob": "^4.0.0", + "micromatch": "^4.0.2", + "resolve-dir": "^1.0.1" + } + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==" + }, + "micromatch": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.2.tgz", + "integrity": "sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q==", + "requires": { + "braces": "^3.0.1", + "picomatch": "^2.0.5" + } + }, + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "requires": { + "is-number": "^7.0.0" + } + } + } }, "@microsoft/load-themed-styles": { "version": "1.10.146", @@ -6205,6 +6268,11 @@ "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.5.tgz", "integrity": "sha512-9IK9EadsbHo6jLWIpxpR6pL0sazTXV6+SQv25ZB+F7Bj9mJNaOc4nCRabwd5M/JwmUa8idz6Eci6eKfJryPs6Q==" }, + "abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" + }, "abort-controller": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", @@ -16391,6 +16459,14 @@ "integrity": "sha1-lKKxYzxPExdVMAfYlm/Q6EG2pMI=", "optional": true }, + "nopt": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-5.0.0.tgz", + "integrity": "sha512-Tbj67rffqceeLpcRXrT7vKAN8CwfPeIBgM7E6iBkmKLV7bEMwpGgYLGv0jACUsECaa/vuxP0IjEont6umdMgtQ==", + "requires": { + "abbrev": "1" + } + }, "normalize-package-data": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", diff --git a/package.json b/package.json index 84812355e..e15deb826 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "@babel/plugin-proposal-decorators": "7.12.12", "@jupyterlab/services": "6.0.2", "@jupyterlab/terminal": "3.0.3", - "@microsoft/applicationinsights-web": "2.5.9", + "@microsoft/applicationinsights-web": "2.6.1", "@nteract/commutable": "7.4.2", "@nteract/connected-components": "6.8.2", "@nteract/core": "15.1.0", diff --git a/src/Common/Logger.ts b/src/Common/Logger.ts index 1e34609df..b53226d6a 100644 --- a/src/Common/Logger.ts +++ b/src/Common/Logger.ts @@ -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( diff --git a/src/Explorer/Explorer.tsx b/src/Explorer/Explorer.tsx index 19dce049b..3e2e39143 100644 --- a/src/Explorer/Explorer.tsx +++ b/src/Explorer/Explorer.tsx @@ -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, diff --git a/src/Explorer/Tabs/NotebookV2Tab.ts b/src/Explorer/Tabs/NotebookV2Tab.ts index b07b10a40..a7c2242c2 100644 --- a/src/Explorer/Tabs/NotebookV2Tab.ts +++ b/src/Explorer/Tabs/NotebookV2Tab.ts @@ -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, diff --git a/src/Shared/Telemetry/TelemetryProcessor.ts b/src/Shared/Telemetry/TelemetryProcessor.ts index e7280f147..855e3a56f 100644 --- a/src/Shared/Telemetry/TelemetryProcessor.ts +++ b/src/Shared/Telemetry/TelemetryProcessor.ts @@ -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; } diff --git a/src/Shared/appInsights.ts b/src/Shared/appInsights.ts index dd18682d5..bc5bdb454 100644 --- a/src/Shared/appInsights.ts +++ b/src/Shared/appInsights.ts @@ -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 };