From cdf83e6efab8af9bab4a752c1e4627f387461100 Mon Sep 17 00:00:00 2001 From: Kevin Mas Ruiz Date: Tue, 28 Nov 2023 12:39:44 +0100 Subject: [PATCH] chore: fix sent errors --- packages/shell-api/src/mongo.ts | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/shell-api/src/mongo.ts b/packages/shell-api/src/mongo.ts index 8d2772cf5..be66a3592 100644 --- a/packages/shell-api/src/mongo.ts +++ b/packages/shell-api/src/mongo.ts @@ -373,18 +373,10 @@ export default class Mongo extends ShellApiClass { // legacy shell: // https://github.com/mongodb/mongo/blob/a6df396047a77b90bf1ce9463eecffbee16fb864/src/mongo/shell/utils.js#L900-L1226 - const sendTelemetry = ( - event: K, - ...args: MongoshBusEventsMap[K] extends (...args: infer P) => any - ? P - : never - ) => { - tracked && this._instanceState.messageBus.emit(event, ...args); - }; - - sendTelemetry('mongosh:show', { - method: `show ${cmd}`, - }); + tracked && + this._instanceState.messageBus.emit('mongosh:show', { + method: `show ${cmd}`, + }); switch (cmd) { case 'databases': @@ -444,7 +436,11 @@ export default class Mongo extends ShellApiClass { ); } } catch (error: any) { - sendTelemetry('mongosh:error', error, 'shell-api'); + this._instanceState.messageBus.emit( + 'mongosh:error', + error, + 'shell-api' + ); return new CommandResult('ShowBannerResult', null); } @@ -470,7 +466,11 @@ export default class Mongo extends ShellApiClass { try { helloResult = await db.hello(); } catch (error: any) { - sendTelemetry('mongosh:error', error, 'shell-api'); + this._instanceState.messageBus.emit( + 'mongosh:error', + error, + 'shell-api' + ); return new CommandResult('ShowBannerResult', null); } if (helloResult.automationServiceDescriptor) { @@ -505,7 +505,7 @@ export default class Mongo extends ShellApiClass { `'${cmd}' is not a valid argument for "show".`, CommonErrors.InvalidArgument ); - sendTelemetry('mongosh:error', err, 'shell-api'); + this._instanceState.messageBus.emit('mongosh:error', err, 'shell-api'); throw err; } }