Skip to content

Commit 89ba0e3

Browse files
committed
Ensures that telemetry missingExpirity and skippedNonCloud events sent once
Makes sure that we don't send them too frequently: once per session, that's because we basically want to know if there are such cases at all and how many, rather than knowing exact numbes. (#4315)
1 parent a98c2a8 commit 89ba0e3

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/plus/integrations/integration.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,15 +280,17 @@ export abstract class IntegrationBase<
280280
await this.container.storage.deleteWorkspace(this.connectedKey);
281281
}
282282

283+
private skippedNonCloudReported = false;
283284
@log()
284285
async syncCloudConnection(state: 'connected' | 'disconnected', forceSync: boolean): Promise<void> {
285286
if (this._session?.cloud === false) {
286-
if (this.id !== HostingIntegrationId.GitHub) {
287+
if (this.id !== HostingIntegrationId.GitHub && !this.skippedNonCloudReported) {
287288
this.container.telemetry.sendEvent('cloudIntegrations/refreshConnection/skippedUnusualToken', {
288289
'integration.id': this.id,
289290
reason: 'skip-non-cloud',
290291
cloud: false,
291292
});
293+
this.skippedNonCloudReported = true;
292294
}
293295
return;
294296
}
@@ -336,6 +338,7 @@ export abstract class IntegrationBase<
336338
return defaultValue;
337339
}
338340

341+
private missingExpirityReported = false;
339342
@gate()
340343
protected async refreshSessionIfExpired(scope?: LogScope): Promise<void> {
341344
if (this._session?.expiresAt != null && this._session.expiresAt < new Date()) {
@@ -345,12 +348,17 @@ export abstract class IntegrationBase<
345348
} catch (ex) {
346349
Logger.error(ex, scope);
347350
}
348-
} else if (this._session?.expiresAt == null && this.id !== HostingIntegrationId.GitHub) {
351+
} else if (
352+
this._session?.expiresAt == null &&
353+
this.id !== HostingIntegrationId.GitHub &&
354+
!this.missingExpirityReported
355+
) {
349356
this.container.telemetry.sendEvent('cloudIntegrations/refreshConnection/skippedUnusualToken', {
350357
'integration.id': this.id,
351358
reason: 'missing-expiry',
352359
cloud: this._session?.cloud,
353360
});
361+
this.missingExpirityReported = true;
354362
}
355363
}
356364

0 commit comments

Comments
 (0)