diff --git a/docs/telemetry-events.md b/docs/telemetry-events.md index 141c7a60ef007..8e2d30d1b2c3e 100644 --- a/docs/telemetry-events.md +++ b/docs/telemetry-events.md @@ -521,6 +521,19 @@ or } ``` +### cloudIntegrations/refreshConnection/skippedUnusualToken + +> Sent when a connection session has a missing expiry date +or when connection refresh is skipped due to being a non-cloud session + +```typescript +{ + 'cloud': boolean, + 'integration.id': string, + 'reason': 'skip-non-cloud' | 'missing-expiry' +} +``` + ### cloudIntegrations/settingsOpened > Sent when a user chooses to manage the cloud integrations diff --git a/src/constants.telemetry.ts b/src/constants.telemetry.ts index a904344175177..c757c862b7b45 100644 --- a/src/constants.telemetry.ts +++ b/src/constants.telemetry.ts @@ -84,6 +84,10 @@ export interface TelemetryEvents extends WebviewShowAbortedEvents, WebviewShownE /** Sent when refreshing a provider token from the api fails */ 'cloudIntegrations/refreshConnection/failed': CloudIntegrationsRefreshConnectionFailedEvent; + /** Sent when a connection session has a missing expiry date + * or when connection refresh is skipped due to being a non-cloud session */ + 'cloudIntegrations/refreshConnection/skippedUnusualToken': CloudIntegrationsRefreshConnectionSkipUnusualTokenEvent; + /** Sent when a cloud-based hosting provider is connected */ 'cloudIntegrations/hosting/connected': CloudIntegrationsHostingConnectedEvent; /** Sent when a cloud-based hosting provider is disconnected */ @@ -407,6 +411,12 @@ interface CloudIntegrationsRefreshConnectionFailedEvent { 'integration.id': string | undefined; } +interface CloudIntegrationsRefreshConnectionSkipUnusualTokenEvent { + 'integration.id': string; + reason: 'skip-non-cloud' | 'missing-expiry'; + cloud: boolean | undefined; +} + interface CloudIntegrationsHostingConnectedEvent { 'hostingProvider.provider': IntegrationId; 'hostingProvider.key': string; diff --git a/src/plus/integrations/integration.ts b/src/plus/integrations/integration.ts index 07ce8432cf533..c6b58bb5c202a 100644 --- a/src/plus/integrations/integration.ts +++ b/src/plus/integrations/integration.ts @@ -280,9 +280,20 @@ export abstract class IntegrationBase< await this.container.storage.deleteWorkspace(this.connectedKey); } + private skippedNonCloudReported = false; @log() async syncCloudConnection(state: 'connected' | 'disconnected', forceSync: boolean): Promise { - if (this._session?.cloud === false) return; + if (this._session?.cloud === false) { + if (this.id !== HostingIntegrationId.GitHub && !this.skippedNonCloudReported) { + this.container.telemetry.sendEvent('cloudIntegrations/refreshConnection/skippedUnusualToken', { + 'integration.id': this.id, + reason: 'skip-non-cloud', + cloud: false, + }); + this.skippedNonCloudReported = true; + } + return; + } switch (state) { case 'connected': @@ -327,6 +338,7 @@ export abstract class IntegrationBase< return defaultValue; } + private missingExpirityReported = false; @gate() protected async refreshSessionIfExpired(scope?: LogScope): Promise { if (this._session?.expiresAt != null && this._session.expiresAt < new Date()) { @@ -336,6 +348,17 @@ export abstract class IntegrationBase< } catch (ex) { Logger.error(ex, scope); } + } else if ( + this._session?.expiresAt == null && + this.id !== HostingIntegrationId.GitHub && + !this.missingExpirityReported + ) { + this.container.telemetry.sendEvent('cloudIntegrations/refreshConnection/skippedUnusualToken', { + 'integration.id': this.id, + reason: 'missing-expiry', + cloud: this._session?.cloud, + }); + this.missingExpirityReported = true; } }