@mongosh/logging 1.10.1 → 1.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.depcheckrc +11 -2
- package/.eslintrc.js +10 -1
- package/.prettierignore +6 -0
- package/.prettierrc.json +1 -0
- package/README.md +1 -1
- package/lib/analytics-helpers.d.ts +59 -15
- package/lib/analytics-helpers.js +203 -36
- package/lib/analytics-helpers.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/setup-logger-and-telemetry.d.ts +2 -2
- package/lib/setup-logger-and-telemetry.js +35 -34
- package/lib/setup-logger-and-telemetry.js.map +1 -1
- package/package.json +20 -11
- package/src/analytics-helpers.spec.ts +204 -33
- package/src/analytics-helpers.ts +301 -53
- package/src/index.ts +6 -1
- package/src/setup-logger-and-telemetry.spec.ts +306 -116
- package/src/setup-logger-and-telemetry.ts +465 -194
- package/tsconfig-lint.json +5 -0
- package/tsconfig.json +3 -7
- package/tsconfig.lint.json +0 -8
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable camelcase */
|
|
2
1
|
import redactInfo from 'mongodb-redact';
|
|
3
2
|
import { redactURICredentials } from '@mongosh/history';
|
|
4
3
|
import type {
|
|
@@ -28,17 +27,18 @@ import type {
|
|
|
28
27
|
SnippetsTransformErrorEvent,
|
|
29
28
|
EditorRunEditCommandEvent,
|
|
30
29
|
EditorReadVscodeExtensionsDoneEvent,
|
|
31
|
-
EditorReadVscodeExtensionsFailedEvent
|
|
30
|
+
EditorReadVscodeExtensionsFailedEvent,
|
|
32
31
|
} from '@mongosh/types';
|
|
33
32
|
import { inspect } from 'util';
|
|
34
|
-
import { MongoLogWriter
|
|
33
|
+
import type { MongoLogWriter } from 'mongodb-log-writer';
|
|
34
|
+
import { mongoLogId } from 'mongodb-log-writer';
|
|
35
35
|
import { hookLogger as devtoolsConnectHookLogger } from '@mongodb-js/devtools-connect';
|
|
36
|
-
import { MongoshAnalytics } from './analytics-helpers';
|
|
36
|
+
import type { MongoshAnalytics } from './analytics-helpers';
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* A helper class for keeping track of how often specific events occurred.
|
|
40
40
|
*/
|
|
41
|
-
class MultiSet<T
|
|
41
|
+
class MultiSet<T extends Record<string, any>> {
|
|
42
42
|
_entries: Map<string, number> = new Map();
|
|
43
43
|
|
|
44
44
|
add(entry: T): void {
|
|
@@ -69,7 +69,8 @@ export function setupLoggerAndTelemetry(
|
|
|
69
69
|
log: MongoLogWriter,
|
|
70
70
|
analytics: MongoshAnalytics,
|
|
71
71
|
userTraits: any,
|
|
72
|
-
mongosh_version: string
|
|
72
|
+
mongosh_version: string
|
|
73
|
+
): void {
|
|
73
74
|
const { logId } = log;
|
|
74
75
|
let userId: string;
|
|
75
76
|
let telemetryAnonymousId: string;
|
|
@@ -77,7 +78,7 @@ export function setupLoggerAndTelemetry(
|
|
|
77
78
|
const getTelemetryUserIdentity = () => {
|
|
78
79
|
if (telemetryAnonymousId) {
|
|
79
80
|
return {
|
|
80
|
-
anonymousId: telemetryAnonymousId
|
|
81
|
+
anonymousId: telemetryAnonymousId,
|
|
81
82
|
};
|
|
82
83
|
}
|
|
83
84
|
|
|
@@ -95,22 +96,36 @@ export function setupLoggerAndTelemetry(
|
|
|
95
96
|
});
|
|
96
97
|
|
|
97
98
|
let usesShellOption = false;
|
|
98
|
-
bus.on(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
bus.on(
|
|
100
|
+
'mongosh:start-loading-cli-scripts',
|
|
101
|
+
(event: StartLoadingCliScriptsEvent) => {
|
|
102
|
+
log.info(
|
|
103
|
+
'MONGOSH',
|
|
104
|
+
mongoLogId(1_000_000_003),
|
|
105
|
+
'repl',
|
|
106
|
+
'Start loading CLI scripts'
|
|
107
|
+
);
|
|
108
|
+
usesShellOption = event.usesShellOption;
|
|
109
|
+
}
|
|
110
|
+
);
|
|
102
111
|
|
|
103
|
-
bus.on('mongosh:connect', function(args: ConnectEvent) {
|
|
112
|
+
bus.on('mongosh:connect', function (args: ConnectEvent) {
|
|
104
113
|
const connectionUri = redactURICredentials(args.uri);
|
|
105
|
-
const { uri: _uri, ...argsWithoutUri } = args;
|
|
114
|
+
const { uri: _uri, ...argsWithoutUri } = args;
|
|
106
115
|
const params = {
|
|
107
116
|
session_id: logId,
|
|
108
117
|
userId,
|
|
109
118
|
telemetryAnonymousId,
|
|
110
119
|
connectionUri,
|
|
111
|
-
...argsWithoutUri
|
|
120
|
+
...argsWithoutUri,
|
|
112
121
|
};
|
|
113
|
-
log.info(
|
|
122
|
+
log.info(
|
|
123
|
+
'MONGOSH',
|
|
124
|
+
mongoLogId(1_000_000_004),
|
|
125
|
+
'connect',
|
|
126
|
+
'Connecting to server',
|
|
127
|
+
params
|
|
128
|
+
);
|
|
114
129
|
|
|
115
130
|
analytics.track({
|
|
116
131
|
...getTelemetryUserIdentity(),
|
|
@@ -118,44 +133,76 @@ export function setupLoggerAndTelemetry(
|
|
|
118
133
|
properties: {
|
|
119
134
|
mongosh_version,
|
|
120
135
|
session_id: logId,
|
|
121
|
-
...argsWithoutUri
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
bus.on('mongosh:new-user', function(newTelemetryUserIdentity: { userId: string; anonymousId: string }) {
|
|
127
|
-
if (!newTelemetryUserIdentity.anonymousId) {
|
|
128
|
-
userId = newTelemetryUserIdentity.userId;
|
|
129
|
-
}
|
|
130
|
-
telemetryAnonymousId = newTelemetryUserIdentity.anonymousId;
|
|
131
|
-
analytics.identify({
|
|
132
|
-
anonymousId: newTelemetryUserIdentity.anonymousId,
|
|
133
|
-
traits: userTraits
|
|
136
|
+
...argsWithoutUri,
|
|
137
|
+
},
|
|
134
138
|
});
|
|
135
139
|
});
|
|
136
140
|
|
|
137
|
-
bus.on(
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
141
|
+
bus.on(
|
|
142
|
+
'mongosh:new-user',
|
|
143
|
+
function (newTelemetryUserIdentity: {
|
|
144
|
+
userId: string;
|
|
145
|
+
anonymousId: string;
|
|
146
|
+
}) {
|
|
147
|
+
if (!newTelemetryUserIdentity.anonymousId) {
|
|
148
|
+
userId = newTelemetryUserIdentity.userId;
|
|
149
|
+
}
|
|
150
|
+
telemetryAnonymousId = newTelemetryUserIdentity.anonymousId;
|
|
146
151
|
analytics.identify({
|
|
147
|
-
|
|
148
|
-
traits: userTraits
|
|
152
|
+
anonymousId: newTelemetryUserIdentity.anonymousId,
|
|
153
|
+
traits: userTraits,
|
|
149
154
|
});
|
|
150
155
|
}
|
|
151
|
-
|
|
152
|
-
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
bus.on(
|
|
159
|
+
'mongosh:update-user',
|
|
160
|
+
function (updatedTelemetryUserIdentity: {
|
|
161
|
+
userId: string;
|
|
162
|
+
anonymousId?: string;
|
|
163
|
+
}) {
|
|
164
|
+
if (updatedTelemetryUserIdentity.anonymousId) {
|
|
165
|
+
telemetryAnonymousId = updatedTelemetryUserIdentity.anonymousId;
|
|
166
|
+
analytics.identify({
|
|
167
|
+
anonymousId: updatedTelemetryUserIdentity.anonymousId,
|
|
168
|
+
traits: userTraits,
|
|
169
|
+
});
|
|
170
|
+
} else {
|
|
171
|
+
userId = updatedTelemetryUserIdentity.userId;
|
|
172
|
+
analytics.identify({
|
|
173
|
+
userId: updatedTelemetryUserIdentity.userId,
|
|
174
|
+
traits: userTraits,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
log.info('MONGOSH', mongoLogId(1_000_000_005), 'config', 'User updated');
|
|
178
|
+
}
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
bus.on('mongosh:error', function (error: Error, context: string) {
|
|
182
|
+
const mongoshError = error as {
|
|
183
|
+
name: string;
|
|
184
|
+
message: string;
|
|
185
|
+
code: any;
|
|
186
|
+
scope: any;
|
|
187
|
+
metadata: any;
|
|
188
|
+
};
|
|
153
189
|
|
|
154
|
-
bus.on('mongosh:error', function(error: any, context: string) {
|
|
155
190
|
if (context === 'fatal') {
|
|
156
|
-
log.fatal(
|
|
191
|
+
log.fatal(
|
|
192
|
+
'MONGOSH',
|
|
193
|
+
mongoLogId(1_000_000_006),
|
|
194
|
+
context,
|
|
195
|
+
`${mongoshError.name}: ${mongoshError.message}`,
|
|
196
|
+
error
|
|
197
|
+
);
|
|
157
198
|
} else {
|
|
158
|
-
log.error(
|
|
199
|
+
log.error(
|
|
200
|
+
'MONGOSH',
|
|
201
|
+
mongoLogId(1_000_000_006),
|
|
202
|
+
context,
|
|
203
|
+
`${mongoshError.name}: ${mongoshError.message}`,
|
|
204
|
+
error
|
|
205
|
+
);
|
|
159
206
|
}
|
|
160
207
|
|
|
161
208
|
if (error.name.includes('Mongosh')) {
|
|
@@ -164,65 +211,113 @@ export function setupLoggerAndTelemetry(
|
|
|
164
211
|
event: 'Error',
|
|
165
212
|
properties: {
|
|
166
213
|
mongosh_version,
|
|
167
|
-
name:
|
|
168
|
-
code:
|
|
169
|
-
scope:
|
|
170
|
-
metadata:
|
|
171
|
-
}
|
|
214
|
+
name: mongoshError.name,
|
|
215
|
+
code: mongoshError.code,
|
|
216
|
+
scope: mongoshError.scope,
|
|
217
|
+
metadata: mongoshError.metadata,
|
|
218
|
+
},
|
|
172
219
|
});
|
|
173
220
|
}
|
|
174
221
|
});
|
|
175
222
|
|
|
176
|
-
bus.on(
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
223
|
+
bus.on(
|
|
224
|
+
'mongosh:globalconfig-load',
|
|
225
|
+
function (args: GlobalConfigFileLoadEvent) {
|
|
226
|
+
log.info(
|
|
227
|
+
'MONGOSH',
|
|
228
|
+
mongoLogId(1_000_000_048),
|
|
229
|
+
'config',
|
|
230
|
+
'Loading global configuration file',
|
|
231
|
+
args
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
);
|
|
235
|
+
|
|
236
|
+
bus.on('mongosh:evaluate-input', function (args: EvaluateInputEvent) {
|
|
237
|
+
log.info(
|
|
238
|
+
'MONGOSH',
|
|
239
|
+
mongoLogId(1_000_000_007),
|
|
240
|
+
'repl',
|
|
241
|
+
'Evaluating input',
|
|
242
|
+
args
|
|
243
|
+
);
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
bus.on('mongosh:use', function (args: UseEvent) {
|
|
247
|
+
log.info(
|
|
248
|
+
'MONGOSH',
|
|
249
|
+
mongoLogId(1_000_000_008),
|
|
250
|
+
'shell-api',
|
|
251
|
+
'Used "use" command',
|
|
252
|
+
args
|
|
253
|
+
);
|
|
186
254
|
|
|
187
255
|
analytics.track({
|
|
188
256
|
...getTelemetryUserIdentity(),
|
|
189
257
|
event: 'Use',
|
|
190
258
|
properties: {
|
|
191
|
-
mongosh_version
|
|
192
|
-
}
|
|
259
|
+
mongosh_version,
|
|
260
|
+
},
|
|
193
261
|
});
|
|
194
262
|
});
|
|
195
263
|
|
|
196
|
-
bus.on('mongosh:show', function(args: ShowEvent) {
|
|
197
|
-
log.info(
|
|
264
|
+
bus.on('mongosh:show', function (args: ShowEvent) {
|
|
265
|
+
log.info(
|
|
266
|
+
'MONGOSH',
|
|
267
|
+
mongoLogId(1_000_000_009),
|
|
268
|
+
'shell-api',
|
|
269
|
+
'Used "show" command',
|
|
270
|
+
args
|
|
271
|
+
);
|
|
198
272
|
|
|
199
273
|
analytics.track({
|
|
200
274
|
...getTelemetryUserIdentity(),
|
|
201
275
|
event: 'Show',
|
|
202
276
|
properties: {
|
|
203
277
|
mongosh_version,
|
|
204
|
-
method: args.method
|
|
205
|
-
}
|
|
278
|
+
method: args.method,
|
|
279
|
+
},
|
|
206
280
|
});
|
|
207
281
|
});
|
|
208
282
|
|
|
209
|
-
bus.on('mongosh:setCtx', function(args: ApiEventWithArguments) {
|
|
210
|
-
log.info(
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
283
|
+
bus.on('mongosh:setCtx', function (args: ApiEventWithArguments) {
|
|
284
|
+
log.info(
|
|
285
|
+
'MONGOSH',
|
|
286
|
+
mongoLogId(1_000_000_010),
|
|
287
|
+
'shell-api',
|
|
288
|
+
'Initialized context',
|
|
289
|
+
args
|
|
290
|
+
);
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
bus.on(
|
|
294
|
+
'mongosh:api-call-with-arguments',
|
|
295
|
+
function (args: ApiEventWithArguments) {
|
|
296
|
+
// TODO: redactInfo cannot handle circular or otherwise nontrivial input
|
|
297
|
+
let arg;
|
|
298
|
+
try {
|
|
299
|
+
arg = JSON.parse(JSON.stringify(args));
|
|
300
|
+
} catch {
|
|
301
|
+
arg = { _inspected: inspect(args) };
|
|
302
|
+
}
|
|
303
|
+
log.info(
|
|
304
|
+
'MONGOSH',
|
|
305
|
+
mongoLogId(1_000_000_011),
|
|
306
|
+
'shell-api',
|
|
307
|
+
'Performed API call',
|
|
308
|
+
redactInfo(arg)
|
|
309
|
+
);
|
|
220
310
|
}
|
|
221
|
-
|
|
222
|
-
});
|
|
311
|
+
);
|
|
223
312
|
|
|
224
|
-
bus.on('mongosh:api-load-file', function(args: ScriptLoadFileEvent) {
|
|
225
|
-
log.info(
|
|
313
|
+
bus.on('mongosh:api-load-file', function (args: ScriptLoadFileEvent) {
|
|
314
|
+
log.info(
|
|
315
|
+
'MONGOSH',
|
|
316
|
+
mongoLogId(1_000_000_012),
|
|
317
|
+
'shell-api',
|
|
318
|
+
'Loading file via load()',
|
|
319
|
+
args
|
|
320
|
+
);
|
|
226
321
|
|
|
227
322
|
analytics.track({
|
|
228
323
|
...getTelemetryUserIdentity(),
|
|
@@ -230,128 +325,266 @@ export function setupLoggerAndTelemetry(
|
|
|
230
325
|
properties: {
|
|
231
326
|
mongosh_version,
|
|
232
327
|
nested: args.nested,
|
|
233
|
-
...(hasStartedMongoshRepl ? {} : { shell: usesShellOption })
|
|
234
|
-
}
|
|
328
|
+
...(hasStartedMongoshRepl ? {} : { shell: usesShellOption }),
|
|
329
|
+
},
|
|
235
330
|
});
|
|
236
331
|
});
|
|
237
332
|
|
|
238
|
-
bus.on('mongosh:eval-cli-script', function() {
|
|
239
|
-
log.info(
|
|
333
|
+
bus.on('mongosh:eval-cli-script', function () {
|
|
334
|
+
log.info(
|
|
335
|
+
'MONGOSH',
|
|
336
|
+
mongoLogId(1_000_000_013),
|
|
337
|
+
'repl',
|
|
338
|
+
'Evaluating script passed on the command line'
|
|
339
|
+
);
|
|
240
340
|
|
|
241
341
|
analytics.track({
|
|
242
342
|
...getTelemetryUserIdentity(),
|
|
243
343
|
event: 'Script Evaluated',
|
|
244
344
|
properties: {
|
|
245
345
|
mongosh_version,
|
|
246
|
-
shell: usesShellOption
|
|
247
|
-
}
|
|
346
|
+
shell: usesShellOption,
|
|
347
|
+
},
|
|
248
348
|
});
|
|
249
349
|
});
|
|
250
350
|
|
|
251
|
-
bus.on('mongosh:mongoshrc-load', function() {
|
|
252
|
-
log.info(
|
|
351
|
+
bus.on('mongosh:mongoshrc-load', function () {
|
|
352
|
+
log.info(
|
|
353
|
+
'MONGOSH',
|
|
354
|
+
mongoLogId(1_000_000_014),
|
|
355
|
+
'repl',
|
|
356
|
+
'Loading .mongoshrc.js'
|
|
357
|
+
);
|
|
253
358
|
|
|
254
359
|
analytics.track({
|
|
255
360
|
...getTelemetryUserIdentity(),
|
|
256
361
|
event: 'Mongoshrc Loaded',
|
|
257
362
|
properties: {
|
|
258
|
-
mongosh_version
|
|
259
|
-
}
|
|
363
|
+
mongosh_version,
|
|
364
|
+
},
|
|
260
365
|
});
|
|
261
366
|
});
|
|
262
367
|
|
|
263
|
-
bus.on('mongosh:mongoshrc-mongorc-warn', function() {
|
|
264
|
-
log.info(
|
|
368
|
+
bus.on('mongosh:mongoshrc-mongorc-warn', function () {
|
|
369
|
+
log.info(
|
|
370
|
+
'MONGOSH',
|
|
371
|
+
mongoLogId(1_000_000_015),
|
|
372
|
+
'repl',
|
|
373
|
+
'Warning about .mongorc.js/.mongoshrc.js mismatch'
|
|
374
|
+
);
|
|
265
375
|
|
|
266
376
|
analytics.track({
|
|
267
377
|
...getTelemetryUserIdentity(),
|
|
268
378
|
event: 'Mongorc Warning',
|
|
269
379
|
properties: {
|
|
270
|
-
mongosh_version
|
|
271
|
-
}
|
|
272
|
-
});
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
bus.on('mongosh:crypt-library-load-skip', function(ev: CryptLibrarySkipEvent) {
|
|
276
|
-
log.info('AUTO-ENCRYPTION', mongoLogId(1_000_000_050), 'crypt-library', 'Skipping shared library candidate', ev);
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
bus.on('mongosh:crypt-library-load-found', function(ev: CryptLibraryFoundEvent) {
|
|
280
|
-
log.warn('AUTO-ENCRYPTION', mongoLogId(1_000_000_051), 'crypt-library', 'Accepted shared library candidate', {
|
|
281
|
-
cryptSharedLibPath: ev.cryptSharedLibPath,
|
|
282
|
-
expectedVersion: ev.expectedVersion.versionStr
|
|
380
|
+
mongosh_version,
|
|
381
|
+
},
|
|
283
382
|
});
|
|
284
383
|
});
|
|
285
384
|
|
|
286
|
-
bus.on(
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
bus.on('mongosh-snippets:fetch-cache-invalid', function() {
|
|
311
|
-
log.info('MONGOSH-SNIPPETS', mongoLogId(1_000_000_025), 'snippets', 'Snippet cache invalid');
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
bus.on('mongosh-snippets:fetch-index-error', function(ev: SnippetsFetchIndexErrorEvent) {
|
|
315
|
-
log.info('MONGOSH-SNIPPETS', mongoLogId(1_000_000_026), 'snippets', 'Fetching snippet index failed', ev);
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
bus.on('mongosh-snippets:fetch-index-done', function() {
|
|
319
|
-
log.info('MONGOSH-SNIPPETS', mongoLogId(1_000_000_027), 'snippets', 'Fetching snippet index done');
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
bus.on('mongosh-snippets:package-json-edit-error', function(ev: SnippetsErrorEvent) {
|
|
323
|
-
log.info('MONGOSH-SNIPPETS', mongoLogId(1_000_000_028), 'snippets', 'Modifying snippets package.json failed', ev);
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
bus.on('mongosh-snippets:spawn-child', function(ev: SnippetsRunNpmEvent) {
|
|
327
|
-
log.info('MONGOSH-SNIPPETS', mongoLogId(1_000_000_029), 'snippets', 'Spawning helper', ev);
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
bus.on('mongosh-snippets:load-snippet', function(ev: SnippetsLoadSnippetEvent) {
|
|
331
|
-
log.info('MONGOSH-SNIPPETS', mongoLogId(1_000_000_030), 'snippets', 'Loading snippet', ev);
|
|
332
|
-
});
|
|
333
|
-
|
|
334
|
-
bus.on('mongosh-snippets:snippet-command', function(ev: SnippetsCommandEvent) {
|
|
335
|
-
log.info('MONGOSH-SNIPPETS', mongoLogId(1_000_000_031), 'snippets', 'Running snippet command', ev);
|
|
336
|
-
|
|
337
|
-
if (ev.args[0] === 'install') {
|
|
338
|
-
analytics.track({
|
|
339
|
-
...getTelemetryUserIdentity(),
|
|
340
|
-
event: 'Snippet Install',
|
|
341
|
-
properties: {
|
|
342
|
-
mongosh_version
|
|
385
|
+
bus.on(
|
|
386
|
+
'mongosh:crypt-library-load-skip',
|
|
387
|
+
function (ev: CryptLibrarySkipEvent) {
|
|
388
|
+
log.info(
|
|
389
|
+
'AUTO-ENCRYPTION',
|
|
390
|
+
mongoLogId(1_000_000_050),
|
|
391
|
+
'crypt-library',
|
|
392
|
+
'Skipping shared library candidate',
|
|
393
|
+
ev
|
|
394
|
+
);
|
|
395
|
+
}
|
|
396
|
+
);
|
|
397
|
+
|
|
398
|
+
bus.on(
|
|
399
|
+
'mongosh:crypt-library-load-found',
|
|
400
|
+
function (ev: CryptLibraryFoundEvent) {
|
|
401
|
+
log.warn(
|
|
402
|
+
'AUTO-ENCRYPTION',
|
|
403
|
+
mongoLogId(1_000_000_051),
|
|
404
|
+
'crypt-library',
|
|
405
|
+
'Accepted shared library candidate',
|
|
406
|
+
{
|
|
407
|
+
cryptSharedLibPath: ev.cryptSharedLibPath,
|
|
408
|
+
expectedVersion: ev.expectedVersion.versionStr,
|
|
343
409
|
}
|
|
344
|
-
|
|
410
|
+
);
|
|
345
411
|
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
bus.on('mongosh-snippets:
|
|
349
|
-
log.info(
|
|
350
|
-
|
|
412
|
+
);
|
|
413
|
+
|
|
414
|
+
bus.on('mongosh-snippets:loaded', function (ev: SnippetsLoadedEvent) {
|
|
415
|
+
log.info(
|
|
416
|
+
'MONGOSH-SNIPPETS',
|
|
417
|
+
mongoLogId(1_000_000_019),
|
|
418
|
+
'snippets',
|
|
419
|
+
'Loaded snippets',
|
|
420
|
+
ev
|
|
421
|
+
);
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
bus.on('mongosh-snippets:npm-lookup', function (ev: SnippetsNpmLookupEvent) {
|
|
425
|
+
log.info(
|
|
426
|
+
'MONGOSH-SNIPPETS',
|
|
427
|
+
mongoLogId(1_000_000_020),
|
|
428
|
+
'snippets',
|
|
429
|
+
'Performing npm lookup',
|
|
430
|
+
ev
|
|
431
|
+
);
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
bus.on('mongosh-snippets:npm-lookup-stopped', function () {
|
|
435
|
+
log.info(
|
|
436
|
+
'MONGOSH-SNIPPETS',
|
|
437
|
+
mongoLogId(1_000_000_021),
|
|
438
|
+
'snippets',
|
|
439
|
+
'npm lookup stopped'
|
|
440
|
+
);
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
bus.on(
|
|
444
|
+
'mongosh-snippets:npm-download-failed',
|
|
445
|
+
function (ev: SnippetsNpmDownloadFailedEvent) {
|
|
446
|
+
log.info(
|
|
447
|
+
'MONGOSH-SNIPPETS',
|
|
448
|
+
mongoLogId(1_000_000_022),
|
|
449
|
+
'snippets',
|
|
450
|
+
'npm download failed',
|
|
451
|
+
ev
|
|
452
|
+
);
|
|
453
|
+
}
|
|
454
|
+
);
|
|
455
|
+
|
|
456
|
+
bus.on(
|
|
457
|
+
'mongosh-snippets:npm-download-active',
|
|
458
|
+
function (ev: SnippetsNpmDownloadActiveEvent) {
|
|
459
|
+
log.info(
|
|
460
|
+
'MONGOSH-SNIPPETS',
|
|
461
|
+
mongoLogId(1_000_000_023),
|
|
462
|
+
'snippets',
|
|
463
|
+
'npm download active',
|
|
464
|
+
ev
|
|
465
|
+
);
|
|
466
|
+
}
|
|
467
|
+
);
|
|
468
|
+
|
|
469
|
+
bus.on(
|
|
470
|
+
'mongosh-snippets:fetch-index',
|
|
471
|
+
function (ev: SnippetsFetchIndexEvent) {
|
|
472
|
+
log.info(
|
|
473
|
+
'MONGOSH-SNIPPETS',
|
|
474
|
+
mongoLogId(1_000_000_024),
|
|
475
|
+
'snippets',
|
|
476
|
+
'Fetching snippet index',
|
|
477
|
+
ev
|
|
478
|
+
);
|
|
479
|
+
}
|
|
480
|
+
);
|
|
481
|
+
|
|
482
|
+
bus.on('mongosh-snippets:fetch-cache-invalid', function () {
|
|
483
|
+
log.info(
|
|
484
|
+
'MONGOSH-SNIPPETS',
|
|
485
|
+
mongoLogId(1_000_000_025),
|
|
486
|
+
'snippets',
|
|
487
|
+
'Snippet cache invalid'
|
|
488
|
+
);
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
bus.on(
|
|
492
|
+
'mongosh-snippets:fetch-index-error',
|
|
493
|
+
function (ev: SnippetsFetchIndexErrorEvent) {
|
|
494
|
+
log.info(
|
|
495
|
+
'MONGOSH-SNIPPETS',
|
|
496
|
+
mongoLogId(1_000_000_026),
|
|
497
|
+
'snippets',
|
|
498
|
+
'Fetching snippet index failed',
|
|
499
|
+
ev
|
|
500
|
+
);
|
|
501
|
+
}
|
|
502
|
+
);
|
|
503
|
+
|
|
504
|
+
bus.on('mongosh-snippets:fetch-index-done', function () {
|
|
505
|
+
log.info(
|
|
506
|
+
'MONGOSH-SNIPPETS',
|
|
507
|
+
mongoLogId(1_000_000_027),
|
|
508
|
+
'snippets',
|
|
509
|
+
'Fetching snippet index done'
|
|
510
|
+
);
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
bus.on(
|
|
514
|
+
'mongosh-snippets:package-json-edit-error',
|
|
515
|
+
function (ev: SnippetsErrorEvent) {
|
|
516
|
+
log.info(
|
|
517
|
+
'MONGOSH-SNIPPETS',
|
|
518
|
+
mongoLogId(1_000_000_028),
|
|
519
|
+
'snippets',
|
|
520
|
+
'Modifying snippets package.json failed',
|
|
521
|
+
ev
|
|
522
|
+
);
|
|
523
|
+
}
|
|
524
|
+
);
|
|
525
|
+
|
|
526
|
+
bus.on('mongosh-snippets:spawn-child', function (ev: SnippetsRunNpmEvent) {
|
|
527
|
+
log.info(
|
|
528
|
+
'MONGOSH-SNIPPETS',
|
|
529
|
+
mongoLogId(1_000_000_029),
|
|
530
|
+
'snippets',
|
|
531
|
+
'Spawning helper',
|
|
532
|
+
ev
|
|
533
|
+
);
|
|
534
|
+
});
|
|
535
|
+
|
|
536
|
+
bus.on(
|
|
537
|
+
'mongosh-snippets:load-snippet',
|
|
538
|
+
function (ev: SnippetsLoadSnippetEvent) {
|
|
539
|
+
log.info(
|
|
540
|
+
'MONGOSH-SNIPPETS',
|
|
541
|
+
mongoLogId(1_000_000_030),
|
|
542
|
+
'snippets',
|
|
543
|
+
'Loading snippet',
|
|
544
|
+
ev
|
|
545
|
+
);
|
|
546
|
+
}
|
|
547
|
+
);
|
|
548
|
+
|
|
549
|
+
bus.on(
|
|
550
|
+
'mongosh-snippets:snippet-command',
|
|
551
|
+
function (ev: SnippetsCommandEvent) {
|
|
552
|
+
log.info(
|
|
553
|
+
'MONGOSH-SNIPPETS',
|
|
554
|
+
mongoLogId(1_000_000_031),
|
|
555
|
+
'snippets',
|
|
556
|
+
'Running snippet command',
|
|
557
|
+
ev
|
|
558
|
+
);
|
|
559
|
+
|
|
560
|
+
if (ev.args[0] === 'install') {
|
|
561
|
+
analytics.track({
|
|
562
|
+
...getTelemetryUserIdentity(),
|
|
563
|
+
event: 'Snippet Install',
|
|
564
|
+
properties: {
|
|
565
|
+
mongosh_version,
|
|
566
|
+
},
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
);
|
|
571
|
+
|
|
572
|
+
bus.on(
|
|
573
|
+
'mongosh-snippets:transform-error',
|
|
574
|
+
function (ev: SnippetsTransformErrorEvent) {
|
|
575
|
+
log.info(
|
|
576
|
+
'MONGOSH-SNIPPETS',
|
|
577
|
+
mongoLogId(1_000_000_032),
|
|
578
|
+
'snippets',
|
|
579
|
+
'Rewrote error message',
|
|
580
|
+
ev
|
|
581
|
+
);
|
|
582
|
+
}
|
|
583
|
+
);
|
|
351
584
|
|
|
352
585
|
const deprecatedApiCalls = new MultiSet<Pick<ApiEvent, 'class' | 'method'>>();
|
|
353
586
|
const apiCalls = new MultiSet<Pick<ApiEvent, 'class' | 'method'>>();
|
|
354
|
-
bus.on('mongosh:api-call', function(ev: ApiEvent) {
|
|
587
|
+
bus.on('mongosh:api-call', function (ev: ApiEvent) {
|
|
355
588
|
if (ev.deprecated) {
|
|
356
589
|
deprecatedApiCalls.add({ class: ev.class, method: ev.method });
|
|
357
590
|
}
|
|
@@ -359,7 +592,7 @@ export function setupLoggerAndTelemetry(
|
|
|
359
592
|
apiCalls.add({ class: ev.class, method: ev.method });
|
|
360
593
|
}
|
|
361
594
|
});
|
|
362
|
-
bus.on('mongosh:evaluate-started', function() {
|
|
595
|
+
bus.on('mongosh:evaluate-started', function () {
|
|
363
596
|
// Clear API calls before evaluation starts. This is important because
|
|
364
597
|
// some API calls are also emitted by mongosh CLI repl internals,
|
|
365
598
|
// but we only care about those emitted from user code (i.e. during
|
|
@@ -367,17 +600,23 @@ export function setupLoggerAndTelemetry(
|
|
|
367
600
|
deprecatedApiCalls.clear();
|
|
368
601
|
apiCalls.clear();
|
|
369
602
|
});
|
|
370
|
-
bus.on('mongosh:evaluate-finished', function() {
|
|
603
|
+
bus.on('mongosh:evaluate-finished', function () {
|
|
371
604
|
for (const [entry] of deprecatedApiCalls) {
|
|
372
|
-
log.warn(
|
|
605
|
+
log.warn(
|
|
606
|
+
'MONGOSH',
|
|
607
|
+
mongoLogId(1_000_000_033),
|
|
608
|
+
'shell-api',
|
|
609
|
+
'Deprecated API call',
|
|
610
|
+
entry
|
|
611
|
+
);
|
|
373
612
|
|
|
374
613
|
analytics.track({
|
|
375
614
|
...getTelemetryUserIdentity(),
|
|
376
615
|
event: 'Deprecated Method',
|
|
377
616
|
properties: {
|
|
378
617
|
mongosh_version,
|
|
379
|
-
...entry
|
|
380
|
-
}
|
|
618
|
+
...entry,
|
|
619
|
+
},
|
|
381
620
|
});
|
|
382
621
|
}
|
|
383
622
|
for (const [entry, count] of apiCalls) {
|
|
@@ -387,8 +626,8 @@ export function setupLoggerAndTelemetry(
|
|
|
387
626
|
properties: {
|
|
388
627
|
mongosh_version,
|
|
389
628
|
...entry,
|
|
390
|
-
count
|
|
391
|
-
}
|
|
629
|
+
count,
|
|
630
|
+
},
|
|
392
631
|
});
|
|
393
632
|
}
|
|
394
633
|
deprecatedApiCalls.clear();
|
|
@@ -399,24 +638,56 @@ export function setupLoggerAndTelemetry(
|
|
|
399
638
|
// devtools-connect package which was split out from mongosh.
|
|
400
639
|
devtoolsConnectHookLogger(bus, log, 'mongosh', redactURICredentials);
|
|
401
640
|
|
|
402
|
-
bus.on('mongosh-sp:reset-connection-options', function() {
|
|
403
|
-
log.info(
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
641
|
+
bus.on('mongosh-sp:reset-connection-options', function () {
|
|
642
|
+
log.info(
|
|
643
|
+
'MONGOSH-SP',
|
|
644
|
+
mongoLogId(1_000_000_040),
|
|
645
|
+
'connect',
|
|
646
|
+
'Reconnect because of changed connection options'
|
|
647
|
+
);
|
|
648
|
+
});
|
|
649
|
+
|
|
650
|
+
bus.on(
|
|
651
|
+
'mongosh-editor:run-edit-command',
|
|
652
|
+
function (ev: EditorRunEditCommandEvent) {
|
|
653
|
+
log.error(
|
|
654
|
+
'MONGOSH-EDITOR',
|
|
655
|
+
mongoLogId(1_000_000_047),
|
|
656
|
+
'editor',
|
|
657
|
+
'Open external editor',
|
|
658
|
+
redactInfo(ev)
|
|
659
|
+
);
|
|
660
|
+
}
|
|
661
|
+
);
|
|
662
|
+
|
|
663
|
+
bus.on(
|
|
664
|
+
'mongosh-editor:read-vscode-extensions-done',
|
|
665
|
+
function (ev: EditorReadVscodeExtensionsDoneEvent) {
|
|
666
|
+
log.error(
|
|
667
|
+
'MONGOSH-EDITOR',
|
|
668
|
+
mongoLogId(1_000_000_043),
|
|
669
|
+
'editor',
|
|
670
|
+
'Reading vscode extensions from file system succeeded',
|
|
671
|
+
ev
|
|
672
|
+
);
|
|
673
|
+
}
|
|
674
|
+
);
|
|
675
|
+
|
|
676
|
+
bus.on(
|
|
677
|
+
'mongosh-editor:read-vscode-extensions-failed',
|
|
678
|
+
function (ev: EditorReadVscodeExtensionsFailedEvent) {
|
|
679
|
+
log.error(
|
|
680
|
+
'MONGOSH-EDITOR',
|
|
681
|
+
mongoLogId(1_000_000_044),
|
|
682
|
+
'editor',
|
|
683
|
+
'Reading vscode extensions from file system failed',
|
|
684
|
+
{
|
|
685
|
+
...ev,
|
|
686
|
+
error: ev.error.message,
|
|
687
|
+
}
|
|
688
|
+
);
|
|
689
|
+
}
|
|
690
|
+
);
|
|
420
691
|
|
|
421
692
|
// NB: mongoLogId(1_000_000_045) is used in cli-repl itself
|
|
422
693
|
// NB: mongoLogId(1_000_000_034) through mongoLogId(1_000_000_042) are used in devtools-connect
|