@mongosh/logging 1.10.0 → 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 +21 -12
- 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
|
@@ -3,36 +3,52 @@ import { MongoLogWriter } from 'mongodb-log-writer';
|
|
|
3
3
|
import { setupLoggerAndTelemetry } from './';
|
|
4
4
|
import { EventEmitter } from 'events';
|
|
5
5
|
import { MongoshInvalidInputError } from '@mongosh/errors';
|
|
6
|
-
import { MongoshBus } from '@mongosh/types';
|
|
6
|
+
import type { MongoshBus } from '@mongosh/types';
|
|
7
7
|
|
|
8
|
-
describe('setupLoggerAndTelemetry', ()
|
|
8
|
+
describe('setupLoggerAndTelemetry', function () {
|
|
9
9
|
let logOutput: any[];
|
|
10
|
-
let analyticsOutput: ['identify'|'track'|'log', any][];
|
|
10
|
+
let analyticsOutput: ['identify' | 'track' | 'log', any][];
|
|
11
11
|
let bus: MongoshBus;
|
|
12
12
|
|
|
13
13
|
const userId = '53defe995fa47e6c13102d9d';
|
|
14
14
|
const logId = '5fb3c20ee1507e894e5340f3';
|
|
15
15
|
|
|
16
16
|
const logger = new MongoLogWriter(logId, `/tmp/${logId}_log`, {
|
|
17
|
-
write(chunk: string, cb: () => void) {
|
|
18
|
-
|
|
17
|
+
write(chunk: string, cb: () => void) {
|
|
18
|
+
logOutput.push(JSON.parse(chunk));
|
|
19
|
+
cb();
|
|
20
|
+
},
|
|
21
|
+
end(cb: () => void) {
|
|
22
|
+
cb();
|
|
23
|
+
},
|
|
19
24
|
} as any);
|
|
20
25
|
const analytics = {
|
|
21
|
-
identify(info: any) {
|
|
22
|
-
|
|
26
|
+
identify(info: any) {
|
|
27
|
+
analyticsOutput.push(['identify', info]);
|
|
28
|
+
},
|
|
29
|
+
track(info: any) {
|
|
30
|
+
analyticsOutput.push(['track', info]);
|
|
31
|
+
},
|
|
32
|
+
flush() {},
|
|
23
33
|
};
|
|
24
34
|
|
|
25
|
-
beforeEach(()
|
|
35
|
+
beforeEach(function () {
|
|
26
36
|
logOutput = [];
|
|
27
37
|
analyticsOutput = [];
|
|
28
38
|
bus = new EventEmitter();
|
|
29
39
|
});
|
|
30
40
|
|
|
31
|
-
it('works', ()
|
|
32
|
-
setupLoggerAndTelemetry(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
41
|
+
it('works', function () {
|
|
42
|
+
setupLoggerAndTelemetry(
|
|
43
|
+
bus,
|
|
44
|
+
logger,
|
|
45
|
+
analytics,
|
|
46
|
+
{
|
|
47
|
+
platform: process.platform,
|
|
48
|
+
arch: process.arch,
|
|
49
|
+
},
|
|
50
|
+
'1.0.0'
|
|
51
|
+
);
|
|
36
52
|
expect(logOutput).to.have.lengthOf(0);
|
|
37
53
|
expect(analyticsOutput).to.be.empty;
|
|
38
54
|
|
|
@@ -42,21 +58,40 @@ describe('setupLoggerAndTelemetry', () => {
|
|
|
42
58
|
uri: 'mongodb://localhost/',
|
|
43
59
|
is_localhost: true,
|
|
44
60
|
is_atlas: false,
|
|
45
|
-
node_version: 'v12.19.0'
|
|
61
|
+
node_version: 'v12.19.0',
|
|
46
62
|
} as any);
|
|
47
|
-
bus.emit(
|
|
48
|
-
|
|
63
|
+
bus.emit(
|
|
64
|
+
'mongosh:error',
|
|
65
|
+
new MongoshInvalidInputError('meow', 'CLIREPL-1005', { cause: 'x' }),
|
|
66
|
+
'repl'
|
|
67
|
+
);
|
|
68
|
+
bus.emit(
|
|
69
|
+
'mongosh:error',
|
|
70
|
+
new MongoshInvalidInputError('meow', 'CLIREPL-1005', { cause: 'x' }),
|
|
71
|
+
'fatal'
|
|
72
|
+
);
|
|
49
73
|
bus.emit('mongosh:use', { db: 'admin' });
|
|
50
74
|
bus.emit('mongosh:show', { method: 'dbs' });
|
|
51
75
|
|
|
52
76
|
bus.emit('mongosh:setCtx', { method: 'setCtx' });
|
|
53
|
-
bus.emit('mongosh:api-call-with-arguments', {
|
|
54
|
-
|
|
77
|
+
bus.emit('mongosh:api-call-with-arguments', {
|
|
78
|
+
method: 'auth',
|
|
79
|
+
class: 'Database',
|
|
80
|
+
db: 'test-1603986682000',
|
|
81
|
+
arguments: {},
|
|
82
|
+
});
|
|
83
|
+
bus.emit('mongosh:api-call-with-arguments', {
|
|
84
|
+
method: 'redactable',
|
|
85
|
+
arguments: { filter: { email: 'mongosh@example.com' } },
|
|
86
|
+
});
|
|
55
87
|
bus.emit('mongosh:evaluate-input', { input: '1+1' });
|
|
56
88
|
|
|
57
89
|
const circular: any = {};
|
|
58
90
|
circular.circular = circular;
|
|
59
|
-
bus.emit('mongosh:api-call-with-arguments', {
|
|
91
|
+
bus.emit('mongosh:api-call-with-arguments', {
|
|
92
|
+
method: 'circulararg',
|
|
93
|
+
arguments: { options: { circular } },
|
|
94
|
+
});
|
|
60
95
|
expect(circular.circular).to.equal(circular); // Make sure the argument is still intact afterwards
|
|
61
96
|
|
|
62
97
|
bus.emit('mongosh:start-loading-cli-scripts', { usesShellOption: true });
|
|
@@ -66,60 +101,106 @@ describe('setupLoggerAndTelemetry', () => {
|
|
|
66
101
|
bus.emit('mongosh:mongoshrc-load');
|
|
67
102
|
bus.emit('mongosh:mongoshrc-mongorc-warn');
|
|
68
103
|
bus.emit('mongosh:eval-cli-script');
|
|
69
|
-
bus.emit('mongosh:globalconfig-load', {
|
|
104
|
+
bus.emit('mongosh:globalconfig-load', {
|
|
105
|
+
filename: '/etc/mongosh.conf',
|
|
106
|
+
found: true,
|
|
107
|
+
});
|
|
70
108
|
|
|
71
|
-
bus.emit('mongosh:crypt-library-load-skip', {
|
|
72
|
-
|
|
109
|
+
bus.emit('mongosh:crypt-library-load-skip', {
|
|
110
|
+
cryptSharedLibPath: 'path',
|
|
111
|
+
reason: 'reason',
|
|
112
|
+
});
|
|
113
|
+
bus.emit('mongosh:crypt-library-load-found', {
|
|
114
|
+
cryptSharedLibPath: 'path',
|
|
115
|
+
expectedVersion: { versionStr: 'someversion' },
|
|
116
|
+
});
|
|
73
117
|
|
|
74
118
|
bus.emit('mongosh-snippets:loaded', { installdir: '/' });
|
|
75
119
|
bus.emit('mongosh-snippets:npm-lookup', { existingVersion: 'v1.2.3' });
|
|
76
120
|
bus.emit('mongosh-snippets:npm-lookup-stopped');
|
|
77
|
-
bus.emit('mongosh-snippets:npm-download-failed', {
|
|
78
|
-
|
|
121
|
+
bus.emit('mongosh-snippets:npm-download-failed', {
|
|
122
|
+
npmMetadataURL: 'https://example.com',
|
|
123
|
+
});
|
|
124
|
+
bus.emit('mongosh-snippets:npm-download-active', {
|
|
125
|
+
npmMetadataURL: 'https://example.com',
|
|
126
|
+
npmTarballURL: 'https://example.net',
|
|
127
|
+
});
|
|
79
128
|
bus.emit('mongosh-snippets:fetch-index', { refreshMode: 'always' });
|
|
80
129
|
bus.emit('mongosh-snippets:fetch-cache-invalid');
|
|
81
|
-
bus.emit('mongosh-snippets:fetch-index-error', {
|
|
130
|
+
bus.emit('mongosh-snippets:fetch-index-error', {
|
|
131
|
+
action: 'fetch',
|
|
132
|
+
url: 'https://localhost',
|
|
133
|
+
});
|
|
82
134
|
bus.emit('mongosh-snippets:fetch-index-done');
|
|
83
135
|
bus.emit('mongosh-snippets:package-json-edit-error', { error: 'failed' });
|
|
84
136
|
bus.emit('mongosh-snippets:spawn-child', { args: ['npm', 'install'] });
|
|
85
|
-
bus.emit('mongosh-snippets:load-snippet', {
|
|
137
|
+
bus.emit('mongosh-snippets:load-snippet', {
|
|
138
|
+
source: 'load-all',
|
|
139
|
+
name: 'foo',
|
|
140
|
+
});
|
|
86
141
|
bus.emit('mongosh-snippets:snippet-command', { args: ['install', 'foo'] });
|
|
87
|
-
bus.emit('mongosh-snippets:transform-error', {
|
|
142
|
+
bus.emit('mongosh-snippets:transform-error', {
|
|
143
|
+
error: 'failed',
|
|
144
|
+
addition: 'oh no',
|
|
145
|
+
name: 'foo',
|
|
146
|
+
});
|
|
88
147
|
|
|
89
148
|
const connAttemptData = {
|
|
90
149
|
driver: { name: 'nodejs', version: '3.6.1' },
|
|
91
150
|
devtoolsConnectVersion: '1.0.0',
|
|
92
151
|
host: 'localhost',
|
|
93
|
-
uri: 'mongodb://localhost/'
|
|
152
|
+
uri: 'mongodb://localhost/',
|
|
94
153
|
};
|
|
95
154
|
bus.emit('devtools-connect:connect-attempt-initialized', connAttemptData);
|
|
96
|
-
bus.emit('devtools-connect:connect-heartbeat-failure', {
|
|
97
|
-
|
|
155
|
+
bus.emit('devtools-connect:connect-heartbeat-failure', {
|
|
156
|
+
connectionId: 'localhost',
|
|
157
|
+
failure: new Error('cause'),
|
|
158
|
+
isFailFast: true,
|
|
159
|
+
isKnownServer: true,
|
|
160
|
+
});
|
|
161
|
+
bus.emit('devtools-connect:connect-heartbeat-succeeded', {
|
|
162
|
+
connectionId: 'localhost',
|
|
163
|
+
});
|
|
98
164
|
bus.emit('devtools-connect:connect-fail-early');
|
|
99
165
|
bus.emit('devtools-connect:connect-attempt-finished', {});
|
|
100
166
|
bus.emit('devtools-connect:resolve-srv-error', {
|
|
101
167
|
from: 'mongodb+srv://foo:bar@hello.world/',
|
|
102
168
|
error: new Error('failed'),
|
|
103
169
|
duringLoad: false,
|
|
104
|
-
resolutionDetails: []
|
|
170
|
+
resolutionDetails: [],
|
|
105
171
|
});
|
|
106
172
|
bus.emit('devtools-connect:resolve-srv-succeeded', {
|
|
107
173
|
from: 'mongodb+srv://foo:bar@hello.world/',
|
|
108
174
|
to: 'mongodb://foo:bar@db.hello.world/',
|
|
109
|
-
resolutionDetails: []
|
|
175
|
+
resolutionDetails: [],
|
|
176
|
+
});
|
|
177
|
+
bus.emit('devtools-connect:missing-optional-dependency', {
|
|
178
|
+
name: 'kerberos',
|
|
179
|
+
error: new Error('no kerberos'),
|
|
110
180
|
});
|
|
111
|
-
bus.emit('devtools-connect:missing-optional-dependency', { name: 'kerberos', error: new Error('no kerberos') });
|
|
112
181
|
bus.emit('mongosh-sp:reset-connection-options');
|
|
113
182
|
|
|
114
|
-
bus.emit('mongosh-editor:run-edit-command', {
|
|
115
|
-
|
|
116
|
-
|
|
183
|
+
bus.emit('mongosh-editor:run-edit-command', {
|
|
184
|
+
tmpDoc: 'tmpDoc',
|
|
185
|
+
editor: 'editor',
|
|
186
|
+
code: '<code>',
|
|
187
|
+
});
|
|
188
|
+
bus.emit('mongosh-editor:read-vscode-extensions-done', {
|
|
189
|
+
vscodeDir: 'vscodir',
|
|
190
|
+
hasMongodbExtension: false,
|
|
191
|
+
});
|
|
192
|
+
bus.emit('mongosh-editor:read-vscode-extensions-failed', {
|
|
193
|
+
vscodeDir: 'vscodir',
|
|
194
|
+
error: new Error('failed'),
|
|
195
|
+
});
|
|
117
196
|
|
|
118
197
|
let i = 0;
|
|
119
198
|
expect(logOutput[i++].msg).to.equal('User updated');
|
|
120
199
|
expect(logOutput[i].msg).to.equal('Connecting to server');
|
|
121
200
|
expect(logOutput[i].attr.session_id).to.equal('5fb3c20ee1507e894e5340f3');
|
|
122
|
-
expect(logOutput[i].attr.telemetryAnonymousId).to.equal(
|
|
201
|
+
expect(logOutput[i].attr.telemetryAnonymousId).to.equal(
|
|
202
|
+
'53defe995fa47e6c13102d9d'
|
|
203
|
+
);
|
|
123
204
|
expect(logOutput[i].attr.connectionUri).to.equal('mongodb://localhost/');
|
|
124
205
|
expect(logOutput[i].attr.is_localhost).to.equal(true);
|
|
125
206
|
expect(logOutput[i].attr.is_atlas).to.equal(false);
|
|
@@ -150,14 +231,24 @@ describe('setupLoggerAndTelemetry', () => {
|
|
|
150
231
|
expect(logOutput[i].attr.nested).to.equal(false);
|
|
151
232
|
expect(logOutput[i++].attr.filename).to.equal('foobar.js');
|
|
152
233
|
expect(logOutput[i++].msg).to.equal('Loading .mongoshrc.js');
|
|
153
|
-
expect(logOutput[i++].msg).to.equal(
|
|
154
|
-
|
|
234
|
+
expect(logOutput[i++].msg).to.equal(
|
|
235
|
+
'Warning about .mongorc.js/.mongoshrc.js mismatch'
|
|
236
|
+
);
|
|
237
|
+
expect(logOutput[i++].msg).to.equal(
|
|
238
|
+
'Evaluating script passed on the command line'
|
|
239
|
+
);
|
|
155
240
|
expect(logOutput[i].msg).to.equal('Loading global configuration file');
|
|
156
241
|
expect(logOutput[i++].attr.filename).to.equal('/etc/mongosh.conf');
|
|
157
242
|
expect(logOutput[i].msg).to.equal('Skipping shared library candidate');
|
|
158
|
-
expect(logOutput[i++].attr).to.deep.equal({
|
|
243
|
+
expect(logOutput[i++].attr).to.deep.equal({
|
|
244
|
+
cryptSharedLibPath: 'path',
|
|
245
|
+
reason: 'reason',
|
|
246
|
+
});
|
|
159
247
|
expect(logOutput[i].msg).to.equal('Accepted shared library candidate');
|
|
160
|
-
expect(logOutput[i++].attr).to.deep.equal({
|
|
248
|
+
expect(logOutput[i++].attr).to.deep.equal({
|
|
249
|
+
cryptSharedLibPath: 'path',
|
|
250
|
+
expectedVersion: 'someversion',
|
|
251
|
+
});
|
|
161
252
|
expect(logOutput[i].msg).to.equal('Loaded snippets');
|
|
162
253
|
expect(logOutput[i++].attr).to.deep.equal({ installdir: '/' });
|
|
163
254
|
expect(logOutput[i].msg).to.equal('Performing npm lookup');
|
|
@@ -172,39 +263,84 @@ describe('setupLoggerAndTelemetry', () => {
|
|
|
172
263
|
expect(logOutput[i++].attr.refreshMode).to.equal('always');
|
|
173
264
|
expect(logOutput[i++].msg).to.equal('Snippet cache invalid');
|
|
174
265
|
expect(logOutput[i].msg).to.equal('Fetching snippet index failed');
|
|
175
|
-
expect(logOutput[i++].attr).to.deep.equal({
|
|
266
|
+
expect(logOutput[i++].attr).to.deep.equal({
|
|
267
|
+
action: 'fetch',
|
|
268
|
+
url: 'https://localhost',
|
|
269
|
+
});
|
|
176
270
|
expect(logOutput[i++].msg).to.equal('Fetching snippet index done');
|
|
177
271
|
expect(logOutput[i].msg).to.equal('Modifying snippets package.json failed');
|
|
178
272
|
expect(logOutput[i++].attr).to.deep.equal({ error: 'failed' });
|
|
179
273
|
expect(logOutput[i].msg).to.equal('Spawning helper');
|
|
180
274
|
expect(logOutput[i++].attr).to.deep.equal({ args: ['npm', 'install'] });
|
|
181
275
|
expect(logOutput[i].msg).to.equal('Loading snippet');
|
|
182
|
-
expect(logOutput[i++].attr).to.deep.equal({
|
|
276
|
+
expect(logOutput[i++].attr).to.deep.equal({
|
|
277
|
+
source: 'load-all',
|
|
278
|
+
name: 'foo',
|
|
279
|
+
});
|
|
183
280
|
expect(logOutput[i].msg).to.equal('Running snippet command');
|
|
184
281
|
expect(logOutput[i++].attr).to.deep.equal({ args: ['install', 'foo'] });
|
|
185
282
|
expect(logOutput[i].msg).to.equal('Rewrote error message');
|
|
186
|
-
expect(logOutput[i++].attr).to.deep.equal({
|
|
283
|
+
expect(logOutput[i++].attr).to.deep.equal({
|
|
284
|
+
error: 'failed',
|
|
285
|
+
addition: 'oh no',
|
|
286
|
+
name: 'foo',
|
|
287
|
+
});
|
|
187
288
|
expect(logOutput[i].msg).to.equal('Initiating connection attempt');
|
|
188
289
|
expect(logOutput[i++].attr).to.deep.equal(connAttemptData);
|
|
189
290
|
expect(logOutput[i].msg).to.equal('Server heartbeat failure');
|
|
190
|
-
expect(logOutput[i++].attr).to.deep.equal({
|
|
291
|
+
expect(logOutput[i++].attr).to.deep.equal({
|
|
292
|
+
connectionId: 'localhost',
|
|
293
|
+
failure: 'cause',
|
|
294
|
+
isFailFast: true,
|
|
295
|
+
isKnownServer: true,
|
|
296
|
+
});
|
|
191
297
|
expect(logOutput[i].msg).to.equal('Server heartbeat succeeded');
|
|
192
298
|
expect(logOutput[i++].attr).to.deep.equal({ connectionId: 'localhost' });
|
|
193
|
-
expect(logOutput[i++].msg).to.equal(
|
|
299
|
+
expect(logOutput[i++].msg).to.equal(
|
|
300
|
+
'Aborting connection attempt as irrecoverable'
|
|
301
|
+
);
|
|
194
302
|
expect(logOutput[i++].msg).to.equal('Connection attempt finished');
|
|
195
303
|
expect(logOutput[i].msg).to.equal('Resolving SRV record failed');
|
|
196
|
-
expect(logOutput[i++].attr).to.deep.equal({
|
|
304
|
+
expect(logOutput[i++].attr).to.deep.equal({
|
|
305
|
+
from: 'mongodb+srv://<credentials>@hello.world/',
|
|
306
|
+
error: 'failed',
|
|
307
|
+
duringLoad: false,
|
|
308
|
+
resolutionDetails: [],
|
|
309
|
+
});
|
|
197
310
|
expect(logOutput[i].msg).to.equal('Resolving SRV record succeeded');
|
|
198
|
-
expect(logOutput[i++].attr).to.deep.equal({
|
|
311
|
+
expect(logOutput[i++].attr).to.deep.equal({
|
|
312
|
+
from: 'mongodb+srv://<credentials>@hello.world/',
|
|
313
|
+
to: 'mongodb://<credentials>@db.hello.world/',
|
|
314
|
+
resolutionDetails: [],
|
|
315
|
+
});
|
|
199
316
|
expect(logOutput[i].msg).to.equal('Missing optional dependency');
|
|
200
|
-
expect(logOutput[i++].attr).to.deep.equal({
|
|
201
|
-
|
|
317
|
+
expect(logOutput[i++].attr).to.deep.equal({
|
|
318
|
+
name: 'kerberos',
|
|
319
|
+
error: 'no kerberos',
|
|
320
|
+
});
|
|
321
|
+
expect(logOutput[i++].msg).to.equal(
|
|
322
|
+
'Reconnect because of changed connection options'
|
|
323
|
+
);
|
|
202
324
|
expect(logOutput[i].msg).to.equal('Open external editor');
|
|
203
|
-
expect(logOutput[i++].attr).to.deep.equal({
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
325
|
+
expect(logOutput[i++].attr).to.deep.equal({
|
|
326
|
+
tmpDoc: 'tmpDoc',
|
|
327
|
+
editor: 'editor',
|
|
328
|
+
code: '<code>',
|
|
329
|
+
});
|
|
330
|
+
expect(logOutput[i].msg).to.equal(
|
|
331
|
+
'Reading vscode extensions from file system succeeded'
|
|
332
|
+
);
|
|
333
|
+
expect(logOutput[i++].attr).to.deep.equal({
|
|
334
|
+
vscodeDir: 'vscodir',
|
|
335
|
+
hasMongodbExtension: false,
|
|
336
|
+
});
|
|
337
|
+
expect(logOutput[i].msg).to.equal(
|
|
338
|
+
'Reading vscode extensions from file system failed'
|
|
339
|
+
);
|
|
340
|
+
expect(logOutput[i++].attr).to.deep.equal({
|
|
341
|
+
vscodeDir: 'vscodir',
|
|
342
|
+
error: 'failed',
|
|
343
|
+
});
|
|
208
344
|
expect(i).to.equal(logOutput.length);
|
|
209
345
|
|
|
210
346
|
expect(analyticsOutput).to.deep.equal([
|
|
@@ -214,9 +350,9 @@ describe('setupLoggerAndTelemetry', () => {
|
|
|
214
350
|
anonymousId: '53defe995fa47e6c13102d9d',
|
|
215
351
|
traits: {
|
|
216
352
|
platform: process.platform,
|
|
217
|
-
arch: process.arch
|
|
218
|
-
}
|
|
219
|
-
}
|
|
353
|
+
arch: process.arch,
|
|
354
|
+
},
|
|
355
|
+
},
|
|
220
356
|
],
|
|
221
357
|
[
|
|
222
358
|
'identify',
|
|
@@ -224,9 +360,9 @@ describe('setupLoggerAndTelemetry', () => {
|
|
|
224
360
|
anonymousId: '53defe995fa47e6c13102d9d',
|
|
225
361
|
traits: {
|
|
226
362
|
platform: process.platform,
|
|
227
|
-
arch: process.arch
|
|
228
|
-
}
|
|
229
|
-
}
|
|
363
|
+
arch: process.arch,
|
|
364
|
+
},
|
|
365
|
+
},
|
|
230
366
|
],
|
|
231
367
|
[
|
|
232
368
|
'track',
|
|
@@ -238,9 +374,9 @@ describe('setupLoggerAndTelemetry', () => {
|
|
|
238
374
|
session_id: '5fb3c20ee1507e894e5340f3',
|
|
239
375
|
is_localhost: true,
|
|
240
376
|
is_atlas: false,
|
|
241
|
-
node_version: 'v12.19.0'
|
|
242
|
-
}
|
|
243
|
-
}
|
|
377
|
+
node_version: 'v12.19.0',
|
|
378
|
+
},
|
|
379
|
+
},
|
|
244
380
|
],
|
|
245
381
|
[
|
|
246
382
|
'track',
|
|
@@ -252,9 +388,9 @@ describe('setupLoggerAndTelemetry', () => {
|
|
|
252
388
|
name: 'MongoshInvalidInputError',
|
|
253
389
|
code: 'CLIREPL-1005',
|
|
254
390
|
scope: 'CLIREPL',
|
|
255
|
-
metadata: { cause: 'x' }
|
|
256
|
-
}
|
|
257
|
-
}
|
|
391
|
+
metadata: { cause: 'x' },
|
|
392
|
+
},
|
|
393
|
+
},
|
|
258
394
|
],
|
|
259
395
|
[
|
|
260
396
|
'track',
|
|
@@ -266,17 +402,17 @@ describe('setupLoggerAndTelemetry', () => {
|
|
|
266
402
|
name: 'MongoshInvalidInputError',
|
|
267
403
|
code: 'CLIREPL-1005',
|
|
268
404
|
scope: 'CLIREPL',
|
|
269
|
-
metadata: { cause: 'x' }
|
|
270
|
-
}
|
|
271
|
-
}
|
|
405
|
+
metadata: { cause: 'x' },
|
|
406
|
+
},
|
|
407
|
+
},
|
|
272
408
|
],
|
|
273
409
|
[
|
|
274
410
|
'track',
|
|
275
411
|
{
|
|
276
412
|
anonymousId: '53defe995fa47e6c13102d9d',
|
|
277
413
|
event: 'Use',
|
|
278
|
-
properties: { mongosh_version: '1.0.0' }
|
|
279
|
-
}
|
|
414
|
+
properties: { mongosh_version: '1.0.0' },
|
|
415
|
+
},
|
|
280
416
|
],
|
|
281
417
|
[
|
|
282
418
|
'track',
|
|
@@ -285,9 +421,9 @@ describe('setupLoggerAndTelemetry', () => {
|
|
|
285
421
|
event: 'Show',
|
|
286
422
|
properties: {
|
|
287
423
|
mongosh_version: '1.0.0',
|
|
288
|
-
method: 'dbs'
|
|
289
|
-
}
|
|
290
|
-
}
|
|
424
|
+
method: 'dbs',
|
|
425
|
+
},
|
|
426
|
+
},
|
|
291
427
|
],
|
|
292
428
|
[
|
|
293
429
|
'track',
|
|
@@ -296,10 +432,10 @@ describe('setupLoggerAndTelemetry', () => {
|
|
|
296
432
|
properties: {
|
|
297
433
|
mongosh_version: '1.0.0',
|
|
298
434
|
nested: true,
|
|
299
|
-
shell: true
|
|
435
|
+
shell: true,
|
|
300
436
|
},
|
|
301
|
-
anonymousId: '53defe995fa47e6c13102d9d'
|
|
302
|
-
}
|
|
437
|
+
anonymousId: '53defe995fa47e6c13102d9d',
|
|
438
|
+
},
|
|
303
439
|
],
|
|
304
440
|
[
|
|
305
441
|
'track',
|
|
@@ -307,10 +443,10 @@ describe('setupLoggerAndTelemetry', () => {
|
|
|
307
443
|
event: 'Script Loaded',
|
|
308
444
|
properties: {
|
|
309
445
|
mongosh_version: '1.0.0',
|
|
310
|
-
nested: false
|
|
446
|
+
nested: false,
|
|
311
447
|
},
|
|
312
|
-
anonymousId: '53defe995fa47e6c13102d9d'
|
|
313
|
-
}
|
|
448
|
+
anonymousId: '53defe995fa47e6c13102d9d',
|
|
449
|
+
},
|
|
314
450
|
],
|
|
315
451
|
[
|
|
316
452
|
'track',
|
|
@@ -319,8 +455,8 @@ describe('setupLoggerAndTelemetry', () => {
|
|
|
319
455
|
properties: {
|
|
320
456
|
mongosh_version: '1.0.0',
|
|
321
457
|
},
|
|
322
|
-
anonymousId: '53defe995fa47e6c13102d9d'
|
|
323
|
-
}
|
|
458
|
+
anonymousId: '53defe995fa47e6c13102d9d',
|
|
459
|
+
},
|
|
324
460
|
],
|
|
325
461
|
[
|
|
326
462
|
'track',
|
|
@@ -329,8 +465,8 @@ describe('setupLoggerAndTelemetry', () => {
|
|
|
329
465
|
properties: {
|
|
330
466
|
mongosh_version: '1.0.0',
|
|
331
467
|
},
|
|
332
|
-
anonymousId: '53defe995fa47e6c13102d9d'
|
|
333
|
-
}
|
|
468
|
+
anonymousId: '53defe995fa47e6c13102d9d',
|
|
469
|
+
},
|
|
334
470
|
],
|
|
335
471
|
[
|
|
336
472
|
'track',
|
|
@@ -338,10 +474,10 @@ describe('setupLoggerAndTelemetry', () => {
|
|
|
338
474
|
event: 'Script Evaluated',
|
|
339
475
|
properties: {
|
|
340
476
|
mongosh_version: '1.0.0',
|
|
341
|
-
shell: true
|
|
477
|
+
shell: true,
|
|
342
478
|
},
|
|
343
|
-
anonymousId: '53defe995fa47e6c13102d9d'
|
|
344
|
-
}
|
|
479
|
+
anonymousId: '53defe995fa47e6c13102d9d',
|
|
480
|
+
},
|
|
345
481
|
],
|
|
346
482
|
[
|
|
347
483
|
'track',
|
|
@@ -349,14 +485,14 @@ describe('setupLoggerAndTelemetry', () => {
|
|
|
349
485
|
anonymousId: '53defe995fa47e6c13102d9d',
|
|
350
486
|
event: 'Snippet Install',
|
|
351
487
|
properties: {
|
|
352
|
-
mongosh_version: '1.0.0'
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
]
|
|
488
|
+
mongosh_version: '1.0.0',
|
|
489
|
+
},
|
|
490
|
+
},
|
|
491
|
+
],
|
|
356
492
|
]);
|
|
357
493
|
});
|
|
358
494
|
|
|
359
|
-
it('buffers deprecated API calls', ()
|
|
495
|
+
it('buffers deprecated API calls', function () {
|
|
360
496
|
setupLoggerAndTelemetry(bus, logger, analytics, {}, '1.0.0');
|
|
361
497
|
expect(logOutput).to.have.lengthOf(0);
|
|
362
498
|
expect(analyticsOutput).to.be.empty;
|
|
@@ -366,12 +502,48 @@ describe('setupLoggerAndTelemetry', () => {
|
|
|
366
502
|
logOutput = [];
|
|
367
503
|
analyticsOutput = [];
|
|
368
504
|
|
|
369
|
-
bus.emit('mongosh:api-call', {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
505
|
+
bus.emit('mongosh:api-call', {
|
|
506
|
+
method: 'cloneDatabase',
|
|
507
|
+
class: 'Database',
|
|
508
|
+
deprecated: true,
|
|
509
|
+
callDepth: 0,
|
|
510
|
+
isAsync: true,
|
|
511
|
+
});
|
|
512
|
+
bus.emit('mongosh:api-call', {
|
|
513
|
+
method: 'cloneDatabase',
|
|
514
|
+
class: 'Database',
|
|
515
|
+
deprecated: true,
|
|
516
|
+
callDepth: 0,
|
|
517
|
+
isAsync: true,
|
|
518
|
+
});
|
|
519
|
+
bus.emit('mongosh:api-call', {
|
|
520
|
+
method: 'copyDatabase',
|
|
521
|
+
class: 'Database',
|
|
522
|
+
deprecated: true,
|
|
523
|
+
callDepth: 0,
|
|
524
|
+
isAsync: true,
|
|
525
|
+
});
|
|
526
|
+
bus.emit('mongosh:api-call', {
|
|
527
|
+
method: 'cloneDatabase',
|
|
528
|
+
class: 'Database',
|
|
529
|
+
deprecated: true,
|
|
530
|
+
callDepth: 0,
|
|
531
|
+
isAsync: true,
|
|
532
|
+
});
|
|
533
|
+
bus.emit('mongosh:api-call', {
|
|
534
|
+
method: 'mangleDatabase',
|
|
535
|
+
class: 'Database',
|
|
536
|
+
deprecated: true,
|
|
537
|
+
callDepth: 1,
|
|
538
|
+
isAsync: true,
|
|
539
|
+
});
|
|
540
|
+
bus.emit('mongosh:api-call', {
|
|
541
|
+
method: 'getName',
|
|
542
|
+
class: 'Database',
|
|
543
|
+
deprecated: false,
|
|
544
|
+
callDepth: 0,
|
|
545
|
+
isAsync: false,
|
|
546
|
+
});
|
|
375
547
|
|
|
376
548
|
expect(logOutput).to.be.empty;
|
|
377
549
|
expect(analyticsOutput).to.be.empty;
|
|
@@ -381,11 +553,20 @@ describe('setupLoggerAndTelemetry', () => {
|
|
|
381
553
|
expect(analyticsOutput).to.have.length(5);
|
|
382
554
|
|
|
383
555
|
expect(logOutput[0].msg).to.equal('Deprecated API call');
|
|
384
|
-
expect(logOutput[0].attr).to.deep.equal({
|
|
556
|
+
expect(logOutput[0].attr).to.deep.equal({
|
|
557
|
+
class: 'Database',
|
|
558
|
+
method: 'cloneDatabase',
|
|
559
|
+
});
|
|
385
560
|
expect(logOutput[1].msg).to.equal('Deprecated API call');
|
|
386
|
-
expect(logOutput[1].attr).to.deep.equal({
|
|
561
|
+
expect(logOutput[1].attr).to.deep.equal({
|
|
562
|
+
class: 'Database',
|
|
563
|
+
method: 'copyDatabase',
|
|
564
|
+
});
|
|
387
565
|
expect(logOutput[2].msg).to.equal('Deprecated API call');
|
|
388
|
-
expect(logOutput[2].attr).to.deep.equal({
|
|
566
|
+
expect(logOutput[2].attr).to.deep.equal({
|
|
567
|
+
class: 'Database',
|
|
568
|
+
method: 'mangleDatabase',
|
|
569
|
+
});
|
|
389
570
|
expect(analyticsOutput).to.deep.equal([
|
|
390
571
|
[
|
|
391
572
|
'track',
|
|
@@ -396,8 +577,8 @@ describe('setupLoggerAndTelemetry', () => {
|
|
|
396
577
|
mongosh_version: '1.0.0',
|
|
397
578
|
class: 'Database',
|
|
398
579
|
method: 'cloneDatabase',
|
|
399
|
-
}
|
|
400
|
-
}
|
|
580
|
+
},
|
|
581
|
+
},
|
|
401
582
|
],
|
|
402
583
|
[
|
|
403
584
|
'track',
|
|
@@ -408,8 +589,8 @@ describe('setupLoggerAndTelemetry', () => {
|
|
|
408
589
|
mongosh_version: '1.0.0',
|
|
409
590
|
class: 'Database',
|
|
410
591
|
method: 'copyDatabase',
|
|
411
|
-
}
|
|
412
|
-
}
|
|
592
|
+
},
|
|
593
|
+
},
|
|
413
594
|
],
|
|
414
595
|
[
|
|
415
596
|
'track',
|
|
@@ -420,8 +601,8 @@ describe('setupLoggerAndTelemetry', () => {
|
|
|
420
601
|
mongosh_version: '1.0.0',
|
|
421
602
|
class: 'Database',
|
|
422
603
|
method: 'mangleDatabase',
|
|
423
|
-
}
|
|
424
|
-
}
|
|
604
|
+
},
|
|
605
|
+
},
|
|
425
606
|
],
|
|
426
607
|
[
|
|
427
608
|
'track',
|
|
@@ -432,9 +613,9 @@ describe('setupLoggerAndTelemetry', () => {
|
|
|
432
613
|
mongosh_version: '1.0.0',
|
|
433
614
|
class: 'Database',
|
|
434
615
|
method: 'cloneDatabase',
|
|
435
|
-
count: 3
|
|
436
|
-
}
|
|
437
|
-
}
|
|
616
|
+
count: 3,
|
|
617
|
+
},
|
|
618
|
+
},
|
|
438
619
|
],
|
|
439
620
|
[
|
|
440
621
|
'track',
|
|
@@ -445,9 +626,9 @@ describe('setupLoggerAndTelemetry', () => {
|
|
|
445
626
|
mongosh_version: '1.0.0',
|
|
446
627
|
class: 'Database',
|
|
447
628
|
method: 'copyDatabase',
|
|
448
|
-
count: 1
|
|
449
|
-
}
|
|
450
|
-
}
|
|
629
|
+
count: 1,
|
|
630
|
+
},
|
|
631
|
+
},
|
|
451
632
|
],
|
|
452
633
|
]);
|
|
453
634
|
|
|
@@ -455,7 +636,13 @@ describe('setupLoggerAndTelemetry', () => {
|
|
|
455
636
|
logOutput = [];
|
|
456
637
|
analyticsOutput = [];
|
|
457
638
|
|
|
458
|
-
bus.emit('mongosh:api-call', {
|
|
639
|
+
bus.emit('mongosh:api-call', {
|
|
640
|
+
method: 'cloneDatabase',
|
|
641
|
+
class: 'Database',
|
|
642
|
+
deprecated: true,
|
|
643
|
+
callDepth: 0,
|
|
644
|
+
isAsync: true,
|
|
645
|
+
});
|
|
459
646
|
|
|
460
647
|
expect(logOutput).to.be.empty;
|
|
461
648
|
expect(analyticsOutput).to.be.empty;
|
|
@@ -463,7 +650,10 @@ describe('setupLoggerAndTelemetry', () => {
|
|
|
463
650
|
bus.emit('mongosh:evaluate-finished');
|
|
464
651
|
expect(logOutput).to.have.length(1);
|
|
465
652
|
expect(logOutput[0].msg).to.equal('Deprecated API call');
|
|
466
|
-
expect(logOutput[0].attr).to.deep.equal({
|
|
653
|
+
expect(logOutput[0].attr).to.deep.equal({
|
|
654
|
+
class: 'Database',
|
|
655
|
+
method: 'cloneDatabase',
|
|
656
|
+
});
|
|
467
657
|
expect(analyticsOutput).to.have.lengthOf(2);
|
|
468
658
|
});
|
|
469
659
|
});
|