From 2c6862773ad284fd209ba1f1aff1148e0ba8801c Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Sat, 12 Nov 2022 01:36:12 -0500 Subject: [PATCH] Ensures visibility calculation --- src/git/gitProviderService.ts | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/git/gitProviderService.ts b/src/git/gitProviderService.ts index b1c4774..3cbdc4d 100644 --- a/src/git/gitProviderService.ts +++ b/src/git/gitProviderService.ts @@ -116,17 +116,14 @@ export class GitProviderService implements Disposable { 'providers.count': this._providers.size, 'providers.ids': join(this._providers.keys(), ','), }); + this.container.telemetry.sendEvent('providers/changed', { + 'providers.added': added?.length ?? 0, + 'providers.removed': removed?.length ?? 0, + }); this._etag = Date.now(); this._onDidChangeProviders.fire({ added: added ?? [], removed: removed ?? [], etag: this._etag }); - - queueMicrotask(() => { - this.container.telemetry.sendEvent('providers/changed', { - 'providers.added': added?.length ?? 0, - 'providers.removed': removed?.length ?? 0, - }); - }); } private _onDidChangeRepositories = new EventEmitter(); @@ -139,6 +136,10 @@ export class GitProviderService implements Disposable { 'repositories.count': openSchemes.length, 'repositories.schemes': joinUnique(openSchemes, ','), }); + this.container.telemetry.sendEvent('repositories/changed', { + 'repositories.added': added?.length ?? 0, + 'repositories.removed': removed?.length ?? 0, + }); this._etag = Date.now(); @@ -149,13 +150,8 @@ export class GitProviderService implements Disposable { } this._onDidChangeRepositories.fire({ added: added ?? [], removed: removed ?? [], etag: this._etag }); - queueMicrotask(() => { - this.container.telemetry.sendEvent('repositories/changed', { - 'repositories.added': added?.length ?? 0, - 'repositories.removed': removed?.length ?? 0, - }); - - if (added?.length) { + if (added?.length) { + queueMicrotask(() => { for (const repo of added) { this.container.telemetry.sendEvent('repository/opened', { 'repository.id': repo.idHash, @@ -165,8 +161,8 @@ export class GitProviderService implements Disposable { 'repository.provider.id': repo.provider.id, }); } - } - }); + }); + } } private readonly _onDidChangeRepository = new EventEmitter(); @@ -605,6 +601,10 @@ export class GitProviderService implements Disposable { ): Promise { const subscription = await this.getSubscription(); + if (this.container.telemetry.enabled) { + queueMicrotask(() => void this.visibility()); + } + const plan = subscription.plan.effective.id; if (isSubscriptionPaidPlan(plan)) { return { allowed: subscription.account?.verified !== false, subscription: { current: subscription } };