From 5e7600f6696e5faf9d7977701354a82622795693 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Mon, 11 Nov 2024 15:52:32 +0100 Subject: [PATCH] chore(connections): send active and inactive connections with "New Connection" telemetry event COMPASS-8476 (#6464) * Add new fields telemetry event * Send active and inactive connections --- docs/tracking-plan.md | 4 ++++ .../src/stores/connections-store-redux.ts | 12 ++++++++++++ packages/compass-telemetry/src/telemetry-events.ts | 10 ++++++++++ 3 files changed, 26 insertions(+) diff --git a/docs/tracking-plan.md b/docs/tracking-plan.md index 04efab403c5..eab202408d1 100644 --- a/docs/tracking-plan.md +++ b/docs/tracking-plan.md @@ -854,6 +854,10 @@ This event is fired when user successfully connects to a new server/cluster. - The OS family of the connected server. - **topology_type** (required): `string` - The type of connected topology. +- **num_active_connections** (required): `number` + - The number of active connections. +- **num_inactive_connections** (required): `number` + - The number of inactive connections. - **auth_type** (optional): `string | undefined` - Desktop only. The authentication type used in the connection. - **tunnel** (optional): `string | undefined` diff --git a/packages/compass-connections/src/stores/connections-store-redux.ts b/packages/compass-connections/src/stores/connections-store-redux.ts index 368e5875e65..f40270a6503 100644 --- a/packages/compass-connections/src/stores/connections-store-redux.ts +++ b/packages/compass-connections/src/stores/connections-store-redux.ts @@ -1739,6 +1739,16 @@ const connectWithOptions = ( getExtraConnectionData(connectionInfo), ]); + const connections = getState().connections; + // Counting all connections, we need to filter out any connections currently being created + const totalConnectionsCount = Object.values( + connections.byId + ).filter(({ isBeingCreated }) => !isBeingCreated).length; + const activeConnectionsCount = + getActiveConnectionsCount(connections); + const inactiveConnectionsCount = + totalConnectionsCount - activeConnectionsCount; + return { is_atlas: isAtlas, atlas_hostname: isAtlas ? resolvedHostname : null, @@ -1751,6 +1761,8 @@ const connectWithOptions = ( server_arch: host.arch, server_os_family: host.os_family, topology_type: dataService.getCurrentTopologyType(), + num_active_connections: activeConnectionsCount, + num_inactive_connections: inactiveConnectionsCount, ...extraInfo, }; }, diff --git a/packages/compass-telemetry/src/telemetry-events.ts b/packages/compass-telemetry/src/telemetry-events.ts index 0355d5f2b97..3d1ec55d500 100644 --- a/packages/compass-telemetry/src/telemetry-events.ts +++ b/packages/compass-telemetry/src/telemetry-events.ts @@ -790,6 +790,16 @@ type NewConnectionEvent = ConnectionScoped<{ * The type of connected topology. */ topology_type: string; + + /** + * The number of active connections. + */ + num_active_connections: number; + + /** + * The number of inactive connections. + */ + num_inactive_connections: number; } & ExtraConnectionData; }>;