Skip to content

Commit a98c2a8

Browse files
committed
Adds a new telemetry event for a rare token to refresh.
1. Sends a telemetry event for missing expirity dates. 2. Sends a telemetry events when we skip refreshing of a non-cloud sessions. We skip refreshing a non-cloud sessions, because we expect it to be a PAT. But now it's rather unexpected situation, so we send an event to be aware about it. (#4315)
1 parent 2971d0d commit a98c2a8

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

docs/telemetry-events.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,19 @@ or
521521
}
522522
```
523523

524+
### cloudIntegrations/refreshConnection/skippedUnusualToken
525+
526+
> Sent when a connection session has a missing expiry date
527+
or when connection refresh is skipped due to being a non-cloud session
528+
529+
```typescript
530+
{
531+
'cloud': boolean,
532+
'integration.id': string,
533+
'reason': 'skip-non-cloud' | 'missing-expiry'
534+
}
535+
```
536+
524537
### cloudIntegrations/settingsOpened
525538

526539
> Sent when a user chooses to manage the cloud integrations

src/constants.telemetry.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ export interface TelemetryEvents extends WebviewShowAbortedEvents, WebviewShownE
8484
/** Sent when refreshing a provider token from the api fails */
8585
'cloudIntegrations/refreshConnection/failed': CloudIntegrationsRefreshConnectionFailedEvent;
8686

87+
/** Sent when a connection session has a missing expiry date
88+
* or when connection refresh is skipped due to being a non-cloud session */
89+
'cloudIntegrations/refreshConnection/skippedUnusualToken': CloudIntegrationsRefreshConnectionSkipUnusualTokenEvent;
90+
8791
/** Sent when a cloud-based hosting provider is connected */
8892
'cloudIntegrations/hosting/connected': CloudIntegrationsHostingConnectedEvent;
8993
/** Sent when a cloud-based hosting provider is disconnected */
@@ -407,6 +411,12 @@ interface CloudIntegrationsRefreshConnectionFailedEvent {
407411
'integration.id': string | undefined;
408412
}
409413

414+
interface CloudIntegrationsRefreshConnectionSkipUnusualTokenEvent {
415+
'integration.id': string;
416+
reason: 'skip-non-cloud' | 'missing-expiry';
417+
cloud: boolean | undefined;
418+
}
419+
410420
interface CloudIntegrationsHostingConnectedEvent {
411421
'hostingProvider.provider': IntegrationId;
412422
'hostingProvider.key': string;

src/plus/integrations/integration.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,16 @@ export abstract class IntegrationBase<
282282

283283
@log()
284284
async syncCloudConnection(state: 'connected' | 'disconnected', forceSync: boolean): Promise<void> {
285-
if (this._session?.cloud === false) return;
285+
if (this._session?.cloud === false) {
286+
if (this.id !== HostingIntegrationId.GitHub) {
287+
this.container.telemetry.sendEvent('cloudIntegrations/refreshConnection/skippedUnusualToken', {
288+
'integration.id': this.id,
289+
reason: 'skip-non-cloud',
290+
cloud: false,
291+
});
292+
}
293+
return;
294+
}
286295

287296
switch (state) {
288297
case 'connected':
@@ -336,6 +345,12 @@ export abstract class IntegrationBase<
336345
} catch (ex) {
337346
Logger.error(ex, scope);
338347
}
348+
} else if (this._session?.expiresAt == null && this.id !== HostingIntegrationId.GitHub) {
349+
this.container.telemetry.sendEvent('cloudIntegrations/refreshConnection/skippedUnusualToken', {
350+
'integration.id': this.id,
351+
reason: 'missing-expiry',
352+
cloud: this._session?.cloud,
353+
});
339354
}
340355
}
341356

0 commit comments

Comments
 (0)