diff --git a/utils/package-lock.json b/utils/package-lock.json index 5ae92f0623..8ecfa183ba 100644 --- a/utils/package-lock.json +++ b/utils/package-lock.json @@ -1,12 +1,12 @@ { "name": "@microsoft/vscode-azext-utils", - "version": "2.6.2", + "version": "2.6.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@microsoft/vscode-azext-utils", - "version": "2.6.2", + "version": "2.6.3", "license": "MIT", "dependencies": { "@microsoft/vscode-azureresources-api": "^2.3.1", diff --git a/utils/package.json b/utils/package.json index 0211ae7eeb..a33314cdd3 100644 --- a/utils/package.json +++ b/utils/package.json @@ -1,7 +1,7 @@ { "name": "@microsoft/vscode-azext-utils", "author": "Microsoft Corporation", - "version": "2.6.2", + "version": "2.6.3", "description": "Common UI tools for developing Azure extensions for VS Code", "tags": [ "azure", diff --git a/utils/src/pickTreeItem/quickPickAzureResource/QuickPickAzureResourceStep.ts b/utils/src/pickTreeItem/quickPickAzureResource/QuickPickAzureResourceStep.ts index 2ba0e2a49e..6fe50541e8 100644 --- a/utils/src/pickTreeItem/quickPickAzureResource/QuickPickAzureResourceStep.ts +++ b/utils/src/pickTreeItem/quickPickAzureResource/QuickPickAzureResourceStep.ts @@ -26,11 +26,16 @@ export class QuickPickAzureResourceStep extends GenericQuickPickStep { if (args.length > 0) { - await setTelemetryProperties(context, args); + try { + await setTelemetryProperties(context, args); + } catch (e: unknown) { + const error = parseError(e); + // if we fail to set telemetry properties, we don't want to throw an error and prevent the command from executing + ext.outputChannel.appendLine(`registerCommand: Failed to set telemetry properties: ${e}`); + context.telemetry.properties.telemetryError = error.message; + } } return callback(context, ...args); @@ -77,8 +85,15 @@ async function setTelemetryProperties(context: types.IActionContext, args: unkno // handles items from v1 extensions for (const arg of args) { if (arg instanceof AzExtTreeItem) { - context.telemetry.properties.resourceId = arg.id; - context.telemetry.properties.subscriptionId = arg.subscription.subscriptionId; + try { + context.telemetry.properties.resourceId = arg.id; + // it's possible that if subscription is not set on AzExtTreeItems, an error is thrown + // see https://github.com/microsoft/vscode-azuretools/blob/cc1feb3a819dd503eb59ebcc1a70051d4e9a3432/utils/src/tree/AzExtTreeItem.ts#L154 + context.telemetry.properties.subscriptionId = arg.subscription.subscriptionId; + } catch (e) { + // we don't want to block execution of the command just because we can't set the telemetry properties + // see https://github.com/microsoft/vscode-azureresourcegroups/issues/1080 + } addTreeItemValuesToMask(context, arg, 'command'); } }