Skip to content

Commit 5e7600f

Browse files
authored
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
1 parent cc1b634 commit 5e7600f

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

docs/tracking-plan.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,10 @@ This event is fired when user successfully connects to a new server/cluster.
854854
- The OS family of the connected server.
855855
- **topology_type** (required): `string`
856856
- The type of connected topology.
857+
- **num_active_connections** (required): `number`
858+
- The number of active connections.
859+
- **num_inactive_connections** (required): `number`
860+
- The number of inactive connections.
857861
- **auth_type** (optional): `string | undefined`
858862
- Desktop only. The authentication type used in the connection.
859863
- **tunnel** (optional): `string | undefined`

packages/compass-connections/src/stores/connections-store-redux.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1739,6 +1739,16 @@ const connectWithOptions = (
17391739
getExtraConnectionData(connectionInfo),
17401740
]);
17411741

1742+
const connections = getState().connections;
1743+
// Counting all connections, we need to filter out any connections currently being created
1744+
const totalConnectionsCount = Object.values(
1745+
connections.byId
1746+
).filter(({ isBeingCreated }) => !isBeingCreated).length;
1747+
const activeConnectionsCount =
1748+
getActiveConnectionsCount(connections);
1749+
const inactiveConnectionsCount =
1750+
totalConnectionsCount - activeConnectionsCount;
1751+
17421752
return {
17431753
is_atlas: isAtlas,
17441754
atlas_hostname: isAtlas ? resolvedHostname : null,
@@ -1751,6 +1761,8 @@ const connectWithOptions = (
17511761
server_arch: host.arch,
17521762
server_os_family: host.os_family,
17531763
topology_type: dataService.getCurrentTopologyType(),
1764+
num_active_connections: activeConnectionsCount,
1765+
num_inactive_connections: inactiveConnectionsCount,
17541766
...extraInfo,
17551767
};
17561768
},

packages/compass-telemetry/src/telemetry-events.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,16 @@ type NewConnectionEvent = ConnectionScoped<{
790790
* The type of connected topology.
791791
*/
792792
topology_type: string;
793+
794+
/**
795+
* The number of active connections.
796+
*/
797+
num_active_connections: number;
798+
799+
/**
800+
* The number of inactive connections.
801+
*/
802+
num_inactive_connections: number;
793803
} & ExtraConnectionData;
794804
}>;
795805

0 commit comments

Comments
 (0)