Skip to content

Commit

Permalink
chore(connections): send active and inactive connections with "New Co…
Browse files Browse the repository at this point in the history
…nnection" telemetry event COMPASS-8476 (#6464)

* Add new fields telemetry event

* Send active and inactive connections
  • Loading branch information
kraenhansen authored Nov 11, 2024
1 parent cc1b634 commit 5e7600f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/tracking-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
12 changes: 12 additions & 0 deletions packages/compass-connections/src/stores/connections-store-redux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
};
},
Expand Down
10 changes: 10 additions & 0 deletions packages/compass-telemetry/src/telemetry-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}>;

Expand Down

0 comments on commit 5e7600f

Please sign in to comment.