Skip to content

Commit

Permalink
use existing event
Browse files Browse the repository at this point in the history
  • Loading branch information
paula-stacho committed Jul 12, 2024
1 parent 1217cb6 commit 316744d
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions packages/compass-connection-import-export/src/hooks/use-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
useConnectionsManagerContext,
} from '@mongodb-js/compass-connections/provider';
import { usePreference } from 'compass-preferences-model/provider';
import { useTelemetry } from '@mongodb-js/compass-telemetry/provider';

type ConnectionImportInfo = ConnectionShortInfo & {
isExistingConnection: boolean;
Expand Down Expand Up @@ -110,7 +109,6 @@ export function useImportConnections({
);
const { favoriteConnections, nonFavoriteConnections } =
useConnectionRepository();
const track = useTelemetry();
const connectionsManager = useConnectionsManagerContext();
const existingConnections = useMemo(() => {
// in case of multiple connections all the connections are saved (that used
Expand Down Expand Up @@ -160,26 +158,26 @@ export function useImportConnections({
.filter((x) => x.selected)
.map((x) => x.id);
try {
const activeConnectionsCount =
connectionsManager.getConnectionIdsByStatus(
ConnectionStatus.Connected
).length || 0;
await importConnectionsImpl({
content: fileContents,
options: {
passphrase,
filterConnectionIds,
trackingProps,
trackingProps: {
...trackingProps,
connection_ids: filterConnectionIds,
active_connections_count: activeConnectionsCount,
inactive_connections_count:
existingConnectionIds.length +
filterConnectionIds.length -
activeConnectionsCount,
},
},
});
const activeConnectionsCount =
connectionsManager.getConnectionIdsByStatus(
ConnectionStatus.Connected
).length || 0;
track('Connections Imported', {
connection_ids: filterConnectionIds,
active_connections_count: activeConnectionsCount,
inactive_connections_count:
existingConnectionIds.length +
filterConnectionIds.length -
activeConnectionsCount,
});
} catch (err: any) {
setState((prevState) => {
return {
Expand Down

0 comments on commit 316744d

Please sign in to comment.