Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions utils/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion utils/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,16 @@ export class QuickPickAzureResourceStep extends GenericQuickPickStep<AzureResour
// TODO
wizardContext.resource = pickedAzureResource.resource;
wizardContext.resourceGroup = pickedAzureResource.resource.resourceGroup;
wizardContext.resourceId = pickedAzureResource.resource.id;
wizardContext.subscriptionId = pickedAzureResource.resource.subscription.subscriptionId;

wizardContext.telemetry.properties.subscriptionId = pickedAzureResource.resource.subscription.subscriptionId;
wizardContext.telemetry.properties.resourceId = pickedAzureResource.resource.id;
try {
// 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
wizardContext.telemetry.properties.subscriptionId = pickedAzureResource.resource.subscription.subscriptionId;
wizardContext.telemetry.properties.resourceId = pickedAzureResource.resource.id;
} catch (e) {
// we don't want to block execution just because we can't set the telemetry property
// see https://github.com/microsoft/vscode-azureresourcegroups/issues/1081
}

return pickedAzureResource;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ export class QuickPickAzureSubscriptionStep extends GenericQuickPickStepWithComm
// TODO
wizardContext.subscription = pickedSubscription.subscription;

wizardContext.telemetry.properties.subscriptionId = pickedSubscription.subscription.subscriptionId;
try {
// 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
wizardContext.telemetry.properties.subscriptionId = pickedSubscription.subscription.subscriptionId;
} catch (e) {
// we don't want to block execution just because we can't set the telemetry property
// see https://github.com/microsoft/vscode-azureresourcegroups/issues/1081
}

return pickedSubscription;
}
Expand Down
21 changes: 18 additions & 3 deletions utils/src/registerCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ext } from './extensionVariables';
import { addTreeItemValuesToMask } from './tree/addTreeItemValuesToMask';
import { AzExtTreeItem } from './tree/AzExtTreeItem';
import { unwrapArgs } from '@microsoft/vscode-azureresources-api';
import { parseError } from './parseError';

function isTreeElementBase(object?: unknown): object is types.TreeElementBase {
return typeof object === 'object' && object !== null && 'getTreeItem' in object;
Expand Down Expand Up @@ -41,7 +42,14 @@ export function registerCommand(commandId: string, callback: (context: types.IAc
telemetryId || commandId,
async (context: types.IActionContext) => {
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);
Expand Down Expand Up @@ -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');
}
}
Expand Down