|
5 | 5 |
|
6 | 6 | import type { Registry as AcrRegistry, RegistryListCredentialsResult } from '@azure/arm-containerregistry'; |
7 | 7 | import { AzureSubscription, VSCodeAzureSubscriptionProvider } from '@microsoft/vscode-azext-azureauth'; |
| 8 | +import { IActionContext, callWithTelemetryAndErrorHandling } from '@microsoft/vscode-azext-utils'; |
8 | 9 | import { RegistryV2DataProvider, V2Registry, V2RegistryItem, V2Repository, V2Tag, getContextValue, registryV2Request } from '@microsoft/vscode-docker-registries'; |
9 | 10 | import { CommonRegistryItem, isRegistry, isRegistryRoot, isRepository, isTag } from '@microsoft/vscode-docker-registries/lib/clients/Common/models'; |
10 | 11 | import * as vscode from 'vscode'; |
@@ -65,6 +66,7 @@ export class AzureRegistryDataProvider extends RegistryV2DataProvider implements |
65 | 66 | } |
66 | 67 |
|
67 | 68 | const subscriptions = await this.subscriptionProvider.getSubscriptions(); |
| 69 | + this.sendSubscriptionTelemetryIfNeeded(); |
68 | 70 |
|
69 | 71 | return subscriptions.map(sub => { |
70 | 72 | return { |
@@ -196,4 +198,33 @@ export class AzureRegistryDataProvider extends RegistryV2DataProvider implements |
196 | 198 | // eslint-disable-next-line @typescript-eslint/no-non-null-assertion |
197 | 199 | return this.authenticationProviders.get(registryString)!; |
198 | 200 | } |
| 201 | + |
| 202 | + private hasSentSubscriptionTelemetry = false; |
| 203 | + private sendSubscriptionTelemetryIfNeeded(): void { |
| 204 | + if (this.hasSentSubscriptionTelemetry) { |
| 205 | + return; |
| 206 | + } |
| 207 | + this.hasSentSubscriptionTelemetry = true; |
| 208 | + |
| 209 | + // This event is relied upon by the DevDiv Analytics and Growth Team |
| 210 | + void callWithTelemetryAndErrorHandling('updateSubscriptionsAndTenants', async (context: IActionContext) => { |
| 211 | + context.telemetry.properties.isActivationEvent = 'true'; |
| 212 | + context.errorHandling.suppressDisplay = true; |
| 213 | + |
| 214 | + const subscriptions = await this.subscriptionProvider.getSubscriptions(false); |
| 215 | + |
| 216 | + const tenantSet = new Set<string>(); |
| 217 | + const subscriptionSet = new Set<string>(); |
| 218 | + subscriptions.forEach(sub => { |
| 219 | + tenantSet.add(sub.tenantId); |
| 220 | + subscriptionSet.add(sub.subscriptionId); |
| 221 | + }); |
| 222 | + |
| 223 | + // Number of tenants and subscriptions really belong in Measurements but for backwards compatibility |
| 224 | + // they will be put into Properties instead. |
| 225 | + context.telemetry.properties.numtenants = tenantSet.size.toString(); |
| 226 | + context.telemetry.properties.numsubscriptions = subscriptionSet.size.toString(); |
| 227 | + context.telemetry.properties.subscriptions = JSON.stringify(Array.from(subscriptionSet)); |
| 228 | + }); |
| 229 | + } |
199 | 230 | } |
0 commit comments