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
13 changes: 13 additions & 0 deletions docs/telemetry-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions src/constants.telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
Expand Down
25 changes: 24 additions & 1 deletion src/plus/integrations/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
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':
Expand Down Expand Up @@ -327,6 +338,7 @@ export abstract class IntegrationBase<
return defaultValue;
}

private missingExpirityReported = false;
@gate()
protected async refreshSessionIfExpired(scope?: LogScope): Promise<void> {
if (this._session?.expiresAt != null && this._session.expiresAt < new Date()) {
Expand All @@ -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;
}
}

Expand Down