|
4 | 4 | *--------------------------------------------------------------------------------------------*/ |
5 | 5 |
|
6 | 6 | import { AzureSubscriptionProvider, getConfiguredAuthProviderId } from '@microsoft/vscode-azext-azureauth'; |
7 | | -import { nonNullProp, nonNullValueAndProp } from '@microsoft/vscode-azext-utils'; |
| 7 | +import { callWithTelemetryAndErrorHandling, IActionContext, nonNullProp, nonNullValueAndProp } from '@microsoft/vscode-azext-utils'; |
8 | 8 | import { ResourceModelBase } from 'api/src'; |
9 | 9 | import * as vscode from 'vscode'; |
10 | 10 | import { TenantResourceProviderManager } from '../../api/ResourceProviderManagers'; |
@@ -43,36 +43,39 @@ export class TenantResourceTreeDataProvider extends ResourceTreeDataProviderBase |
43 | 43 | } |
44 | 44 |
|
45 | 45 | async onGetChildren(element?: ResourceGroupsItem | undefined): Promise<ResourceGroupsItem[] | null | undefined> { |
46 | | - if (element) { |
47 | | - return await element.getChildren(); |
48 | | - } else { |
49 | | - const subscriptionProvider = await getAzureSubscriptionProvider(this); |
50 | | - const children: ResourceGroupsItem[] = await OnGetChildrenBase(subscriptionProvider); |
| 46 | + return await callWithTelemetryAndErrorHandling('azureTenantsView.getChildren', async (context: IActionContext) => { |
| 47 | + if (element) { |
| 48 | + return await element.getChildren(); |
| 49 | + } else { |
| 50 | + const subscriptionProvider = await getAzureSubscriptionProvider(this); |
| 51 | + const children: ResourceGroupsItem[] = await OnGetChildrenBase(subscriptionProvider); |
51 | 52 |
|
52 | | - if (children.length === 0) { |
53 | | - const accounts = await vscode.authentication.getAccounts(getConfiguredAuthProviderId()); |
54 | | - for (const account of accounts) { |
55 | | - const tenants = await subscriptionProvider.getTenants(account); |
56 | | - const tenantItems: ResourceGroupsItem[] = []; |
57 | | - for await (const tenant of tenants) { |
58 | | - const isSignedIn = await subscriptionProvider.isSignedIn(nonNullProp(tenant, 'tenantId'), account); |
59 | | - tenantItems.push(new TenantTreeItem(tenant, account, { |
60 | | - contextValue: isSignedIn ? 'tenantName' : 'tenantNameNotSignedIn', |
61 | | - checkboxState: (!isSignedIn || isTenantFilteredOut(nonNullProp(tenant, 'tenantId'), account.id)) ? |
62 | | - vscode.TreeItemCheckboxState.Unchecked : vscode.TreeItemCheckboxState.Checked, |
63 | | - description: tenant.tenantId |
| 53 | + if (children.length === 0) { |
| 54 | + const accounts = await vscode.authentication.getAccounts(getConfiguredAuthProviderId()); |
| 55 | + context.telemetry.properties.accountCount = accounts.length.toString(); |
| 56 | + for (const account of accounts) { |
| 57 | + const tenants = await subscriptionProvider.getTenants(account); |
| 58 | + const tenantItems: ResourceGroupsItem[] = []; |
| 59 | + for await (const tenant of tenants) { |
| 60 | + const isSignedIn = await subscriptionProvider.isSignedIn(nonNullProp(tenant, 'tenantId'), account); |
| 61 | + tenantItems.push(new TenantTreeItem(tenant, account, { |
| 62 | + contextValue: isSignedIn ? 'tenantName' : 'tenantNameNotSignedIn', |
| 63 | + checkboxState: (!isSignedIn || isTenantFilteredOut(nonNullProp(tenant, 'tenantId'), account.id)) ? |
| 64 | + vscode.TreeItemCheckboxState.Unchecked : vscode.TreeItemCheckboxState.Checked, |
| 65 | + description: tenant.tenantId |
| 66 | + })); |
| 67 | + } |
| 68 | + |
| 69 | + children.push(new GenericItem(nonNullValueAndProp(account, 'label'), { |
| 70 | + children: tenantItems, |
| 71 | + iconPath: new vscode.ThemeIcon('account'), |
| 72 | + contextValue: 'accountName', |
| 73 | + collapsibleState: vscode.TreeItemCollapsibleState.Expanded, |
64 | 74 | })); |
65 | 75 | } |
66 | | - |
67 | | - children.push(new GenericItem(nonNullValueAndProp(account, 'label'), { |
68 | | - children: tenantItems, |
69 | | - iconPath: new vscode.ThemeIcon('account'), |
70 | | - contextValue: 'accountName', |
71 | | - collapsibleState: vscode.TreeItemCollapsibleState.Expanded, |
72 | | - })); |
73 | 76 | } |
| 77 | + return children; |
74 | 78 | } |
75 | | - return children; |
76 | | - } |
| 79 | + }); |
77 | 80 | } |
78 | 81 | } |
0 commit comments