Skip to content

Commit fb457b3

Browse files
Adds cloudIntegrations/connected event and global telemetry attributes
1 parent ba069a4 commit fb457b3

File tree

2 files changed

+39
-5
lines changed

2 files changed

+39
-5
lines changed

src/constants.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,6 +1220,8 @@ export type StoredFocusGroup =
12201220
| 'snoozed';
12211221

12221222
export type TelemetryGlobalContext = {
1223+
'cloudIntegrations.connectedCount': number;
1224+
'cloudIntegrations.connectedIds': string;
12231225
debugging: boolean;
12241226
enabled: boolean;
12251227
prerelease: boolean;
@@ -1272,6 +1274,11 @@ export type TelemetryEvents = {
12721274
'integration.ids': string | undefined;
12731275
};
12741276

1277+
/** Sent when connected to one or more cloud-based integrations from gkdev*/
1278+
'cloudIntegrations/connected': {
1279+
'integration.ids': string | undefined;
1280+
};
1281+
12751282
/** Sent when a cloud-based hosting provider is connected */
12761283
'cloudIntegrations/hosting/connected': {
12771284
'hostingProvider.provider': IntegrationId;

src/plus/integrations/integrationService.ts

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { configuration } from '../../system/configuration';
1313
import { gate } from '../../system/decorators/gate';
1414
import { debug, log } from '../../system/decorators/log';
1515
import { promisifyDeferred, take } from '../../system/event';
16-
import { filterMap, flatten } from '../../system/iterable';
16+
import { filterMap, flatten, join } from '../../system/iterable';
1717
import { Logger } from '../../system/logger';
1818
import { getLogScope } from '../../system/logger.scope';
1919
import { openUrl } from '../../system/utils';
@@ -95,7 +95,12 @@ export class IntegrationService implements Disposable {
9595
const connections = await cloudIntegrations?.getConnections();
9696
if (connections == null) return;
9797

98-
connections.map(p => connectedIntegrations.add(toIntegrationId[p.provider]));
98+
connections.map(p => {
99+
const integrationId = toIntegrationId[p.provider];
100+
// GKDev includes some integrations like "google" that we don't support
101+
if (integrationId == null) return;
102+
connectedIntegrations.add(toIntegrationId[p.provider]);
103+
});
99104
}
100105

101106
for await (const integration of this.getSupportedCloudIntegrations()) {
@@ -104,6 +109,14 @@ export class IntegrationService implements Disposable {
104109
forceConnect,
105110
);
106111
}
112+
113+
if (this.container.telemetry.enabled) {
114+
this.container.telemetry.setGlobalAttributes({
115+
'cloudIntegrations.connectedCount': connectedIntegrations.size,
116+
'cloudIntegrations.connectedIds': join(connectedIntegrations.values(), ','),
117+
});
118+
}
119+
107120
return connectedIntegrations;
108121
}
109122

@@ -149,9 +162,16 @@ export class IntegrationService implements Disposable {
149162
take(
150163
window.onDidChangeWindowState,
151164
2,
152-
)(e => {
165+
)(async e => {
153166
if (e.focused) {
154-
void this.syncCloudIntegrations(true);
167+
const connected = await this.syncCloudIntegrations(true);
168+
if (this.container.telemetry.enabled) {
169+
this.container.telemetry.sendEvent(
170+
'cloudIntegrations/connected',
171+
{ 'integration.ids': connected ? join(connected.values(), ',') : undefined },
172+
source,
173+
);
174+
}
155175
}
156176
});
157177
}
@@ -269,7 +289,14 @@ export class IntegrationService implements Disposable {
269289
if (account == null) return false;
270290
}
271291

272-
await this.syncCloudIntegrations(true);
292+
const connected = await this.syncCloudIntegrations(true);
293+
if (this.container.telemetry.enabled) {
294+
this.container.telemetry.sendEvent(
295+
'cloudIntegrations/connected',
296+
{ 'integration.ids': connected ? join(connected.values(), ',') : undefined },
297+
source,
298+
);
299+
}
273300

274301
if (integrationIds != null) {
275302
for (const integrationId of integrationIds) {

0 commit comments

Comments
 (0)