Skip to content

Commit 74d12ce

Browse files
committed
chore(compass-shell): update mongosh logging
1 parent 214b817 commit 74d12ce

File tree

3 files changed

+112
-62
lines changed

3 files changed

+112
-62
lines changed

package-lock.json

Lines changed: 96 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/compass-shell/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"@mongodb-js/compass-utils": "^0.8.2",
5959
"@mongodb-js/compass-workspaces": "^0.31.2",
6060
"@mongosh/browser-repl": "^3.2.0",
61-
"@mongosh/logging": "^3.2.0",
61+
"@mongosh/logging": "^3.5.0",
6262
"@mongosh/node-runtime-worker-thread": "^3.0.2",
6363
"bson": "^6.10.1",
6464
"compass-preferences-model": "^2.33.2",

packages/compass-shell/src/modules/worker-runtime.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type {
44
} from '@mongodb-js/compass-connections/provider';
55
import type { MongoLogWriter } from '@mongodb-js/compass-logging/provider';
66
import type { TrackFunction } from '@mongodb-js/compass-telemetry/provider';
7-
import { setupLoggerAndTelemetry } from '@mongosh/logging';
7+
import { setupLoggingAndTelemetry } from '@mongosh/logging';
88
import { EventEmitter } from 'events';
99

1010
declare const __webpack_require__: typeof require;
@@ -52,30 +52,36 @@ export function createWorkerRuntime(
5252
): typeof WorkerRuntime['prototype'] {
5353
const emitter = new EventEmitter();
5454

55-
setupLoggerAndTelemetry(
56-
emitter,
57-
log,
58-
{
55+
const loggingAndTelemetry = setupLoggingAndTelemetry({
56+
bus: emitter,
57+
analytics: {
5958
identify: () => {
6059
/* not needed */
6160
},
6261
// Prefix Segment events with `Shell ` to avoid event name collisions.
6362
// We always enable telemetry here, since the track call will
6463
// already check whether Compass telemetry is enabled or not.
6564
track: ({ event, properties }) => {
66-
return track(`Shell ${event}`, properties, connectionInfo.current);
65+
return track(
66+
`Shell ${event as string}`,
67+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
68+
properties,
69+
connectionInfo.current
70+
);
6771
},
6872
flush: () => {
6973
return Promise.resolve(); // not needed
7074
},
7175
},
72-
{
76+
userTraits: {
7377
platform: process.platform,
7478
arch: process.arch,
7579
},
7680
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-var-requires
77-
require('../../package.json').version
78-
);
81+
mongoshVersion: require('../../package.json').version,
82+
});
83+
84+
loggingAndTelemetry.attachLogger(log);
7985

8086
// We also don't need to pass a proper user id, since that is
8187
// handled by the Compass tracking code.

0 commit comments

Comments
 (0)