From 500dfd628c4acd94ec719f2f8349710ed118aaea Mon Sep 17 00:00:00 2001 From: Matthew Fisher <40250218+MicroFish91@users.noreply.github.com> Date: Tue, 27 Aug 2024 10:16:20 -0700 Subject: [PATCH] utils & azure: Add new error telemetry properties (#1776) --- azure/src/wizard/VerifyProvidersStep.ts | 15 +++++++++++++-- utils/src/callWithTelemetryAndErrorHandling.ts | 11 +++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/azure/src/wizard/VerifyProvidersStep.ts b/azure/src/wizard/VerifyProvidersStep.ts index 02a31f6d8b..6a860eca40 100644 --- a/azure/src/wizard/VerifyProvidersStep.ts +++ b/azure/src/wizard/VerifyProvidersStep.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import type { Provider, ResourceManagementClient } from '@azure/arm-resources'; -import { AzureWizardExecuteStep, ISubscriptionActionContext, parseError } from '@microsoft/vscode-azext-utils'; +import { AzureWizardExecuteStep, IParsedError, ISubscriptionActionContext, parseError } from '@microsoft/vscode-azext-utils'; import { l10n, Progress } from 'vscode'; import * as types from '../../index'; import { createResourcesClient } from '../clients'; @@ -39,7 +39,18 @@ export class VerifyProvidersStep extends A } } catch (error) { // ignore and continue with wizard. An error here would likely be confusing and un-actionable - context.telemetry.properties.providerError = parseError(error).message; + const perror: IParsedError = parseError(error); + + /** + * @param providerError + * @deprecated + * Continue to emit telemetry for clients who are still using this property. You should suppress this property if you need to migrate to the new replacement. + * + * @param providerErrorV2 + * A duplicate replacement of the `providerError` telemetry property. + */ + context.telemetry.properties.providerError = perror.message; + context.telemetry.properties.providerErrorV2 = perror.message; } })); } diff --git a/utils/src/callWithTelemetryAndErrorHandling.ts b/utils/src/callWithTelemetryAndErrorHandling.ts index badff50597..b9813c294b 100644 --- a/utils/src/callWithTelemetryAndErrorHandling.ts +++ b/utils/src/callWithTelemetryAndErrorHandling.ts @@ -136,7 +136,18 @@ function handleError(context: types.IActionContext, callbackId: string, error: u } else { context.telemetry.properties.result = 'Failed'; context.telemetry.properties.error = errorData.errorType; + + /** + * @param errorMessage + * @deprecated + * Continue to emit telemetry for clients who are still using this property. You should suppress this property if you need to migrate to the new replacement. + * + * @param errorMessageV2 + * A duplicate replacement of the `errorMessage` telemetry property which should be used instead. + */ context.telemetry.properties.errorMessage = errorData.message; + context.telemetry.properties.errorMessageV2 = errorData.message; + context.telemetry.properties.stack = errorData.stack ? limitLines(errorData.stack, maxStackLines) : undefined; if (context.telemetry.suppressIfSuccessful || context.telemetry.suppressAll) { context.telemetry.properties.suppressTelemetry = 'true';