From d6a492471047f2e61b7e5b85cca0d85c98ab1746 Mon Sep 17 00:00:00 2001 From: Tanuj Mittal Date: Tue, 15 Sep 2020 11:21:18 -0700 Subject: [PATCH] Add actionModifier to appInsights telemetry (#202) --- src/Shared/Telemetry/TelemetryProcessor.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Shared/Telemetry/TelemetryProcessor.ts b/src/Shared/Telemetry/TelemetryProcessor.ts index 950d48dd6..308ac68f1 100644 --- a/src/Shared/Telemetry/TelemetryProcessor.ts +++ b/src/Shared/Telemetry/TelemetryProcessor.ts @@ -19,7 +19,7 @@ export function trace(action: Action, actionModifier: string = ActionModifiers.M } }); - appInsights.trackEvent({ name: Action[action] }, getData(data)); + appInsights.trackEvent({ name: Action[action] }, getData(actionModifier, data)); } export function traceStart(action: Action, data?: unknown): number { @@ -49,7 +49,7 @@ export function traceSuccess(action: Action, data?: unknown, timestamp?: number) } }); - appInsights.stopTrackEvent(Action[action], getData(data)); + appInsights.stopTrackEvent(Action[action], getData(ActionModifiers.Success, data)); } export function traceFailure(action: Action, data?: unknown, timestamp?: number): void { @@ -63,7 +63,7 @@ export function traceFailure(action: Action, data?: unknown, timestamp?: number) } }); - appInsights.stopTrackEvent(Action[action], getData(data)); + appInsights.stopTrackEvent(Action[action], getData(ActionModifiers.Failed, data)); } export function traceCancel(action: Action, data?: unknown, timestamp?: number): void { @@ -77,7 +77,7 @@ export function traceCancel(action: Action, data?: unknown, timestamp?: number): } }); - appInsights.stopTrackEvent(Action[action], getData(data)); + appInsights.stopTrackEvent(Action[action], getData(ActionModifiers.Cancel, data)); } export function traceOpen(action: Action, data?: unknown, timestamp?: number): number { @@ -112,7 +112,7 @@ export function traceMark(action: Action, data?: unknown, timestamp?: number): n return validTimestamp; } -function getData(data: unknown = {}): { [key: string]: string } | undefined { +function getData(actionModifier: string, data: unknown = {}): { [key: string]: string } | undefined { if (typeof data === "string") { data = { message: data }; } @@ -124,6 +124,7 @@ function getData(data: unknown = {}): { [key: string]: string } | undefined { subscriptionId: userContext.subscriptionId as string, platform: configContext.platform, env: process.env.NODE_ENV as string, + actionModifier, ...data }; }