@@ -55,13 +55,13 @@ describe('setupLoggerAndTelemetry', () => {
55
55
}
56
56
57
57
bus . emit ( 'mongosh:setCtx' , { method : 'setCtx' } ) ;
58
- bus . emit ( 'mongosh:api-call' , { method : 'auth' , class : 'Database' , db : 'test-1603986682000' , arguments : { } } ) ;
59
- bus . emit ( 'mongosh:api-call' , { method :
'redactable' , arguments :
{ filter :
{ email :
'[email protected] ' } } } ) ;
58
+ bus . emit ( 'mongosh:api-call-with-arguments ' , { method : 'auth' , class : 'Database' , db : 'test-1603986682000' , arguments : { } } ) ;
59
+ bus . emit ( 'mongosh:api-call-with-arguments ' , { method :
'redactable' , arguments :
{ filter :
{ email :
'[email protected] ' } } } ) ;
60
60
bus . emit ( 'mongosh:evaluate-input' , { input : '1+1' } ) ;
61
61
62
62
const circular : any = { } ;
63
63
circular . circular = circular ;
64
- bus . emit ( 'mongosh:api-call' , { method : 'circulararg' , arguments : { options : { circular } } } ) ;
64
+ bus . emit ( 'mongosh:api-call-with-arguments ' , { method : 'circulararg' , arguments : { options : { circular } } } ) ;
65
65
expect ( circular . circular ) . to . equal ( circular ) ; // Make sure the argument is still intact afterwards
66
66
67
67
bus . emit ( 'mongosh:start-loading-cli-scripts' , { usesShellOption : true } ) ;
@@ -374,22 +374,26 @@ describe('setupLoggerAndTelemetry', () => {
374
374
logOutput = [ ] ;
375
375
analyticsOutput = [ ] ;
376
376
377
- bus . emit ( 'mongosh:deprecated-api-call' , { method : 'cloneDatabase' , class : 'Database' } ) ;
378
- bus . emit ( 'mongosh:deprecated-api-call' , { method : 'cloneDatabase' , class : 'Database' } ) ;
379
- bus . emit ( 'mongosh:deprecated-api-call' , { method : 'copyDatabase' , class : 'Database' } ) ;
380
- bus . emit ( 'mongosh:deprecated-api-call' , { method : 'cloneDatabase' , class : 'Database' } ) ;
377
+ bus . emit ( 'mongosh:api-call' , { method : 'cloneDatabase' , class : 'Database' , deprecated : true , callDepth : 0 , isAsync : true } ) ;
378
+ bus . emit ( 'mongosh:api-call' , { method : 'cloneDatabase' , class : 'Database' , deprecated : true , callDepth : 0 , isAsync : true } ) ;
379
+ bus . emit ( 'mongosh:api-call' , { method : 'copyDatabase' , class : 'Database' , deprecated : true , callDepth : 0 , isAsync : true } ) ;
380
+ bus . emit ( 'mongosh:api-call' , { method : 'cloneDatabase' , class : 'Database' , deprecated : true , callDepth : 0 , isAsync : true } ) ;
381
+ bus . emit ( 'mongosh:api-call' , { method : 'mangleDatabase' , class : 'Database' , deprecated : true , callDepth : 1 , isAsync : true } ) ;
382
+ bus . emit ( 'mongosh:api-call' , { method : 'getName' , class : 'Database' , deprecated : false , callDepth : 0 , isAsync : false } ) ;
381
383
382
384
expect ( logOutput ) . to . be . empty ;
383
385
expect ( analyticsOutput ) . to . be . empty ;
384
386
385
387
bus . emit ( 'mongosh:evaluate-finished' ) ;
386
- expect ( logOutput ) . to . have . length ( 2 ) ;
387
- expect ( analyticsOutput ) . to . have . length ( 2 ) ;
388
+ expect ( logOutput ) . to . have . length ( 3 ) ;
389
+ expect ( analyticsOutput ) . to . have . length ( 5 ) ;
388
390
389
391
expect ( logOutput [ 0 ] . msg ) . to . equal ( 'Deprecated API call' ) ;
390
392
expect ( logOutput [ 0 ] . attr ) . to . deep . equal ( { class : 'Database' , method : 'cloneDatabase' } ) ;
391
393
expect ( logOutput [ 1 ] . msg ) . to . equal ( 'Deprecated API call' ) ;
392
394
expect ( logOutput [ 1 ] . attr ) . to . deep . equal ( { class : 'Database' , method : 'copyDatabase' } ) ;
395
+ expect ( logOutput [ 2 ] . msg ) . to . equal ( 'Deprecated API call' ) ;
396
+ expect ( logOutput [ 2 ] . attr ) . to . deep . equal ( { class : 'Database' , method : 'mangleDatabase' } ) ;
393
397
expect ( analyticsOutput ) . to . deep . equal ( [
394
398
[
395
399
'track' ,
@@ -414,14 +418,52 @@ describe('setupLoggerAndTelemetry', () => {
414
418
method : 'copyDatabase' ,
415
419
}
416
420
}
417
- ]
421
+ ] ,
422
+ [
423
+ 'track' ,
424
+ {
425
+ userId : '53defe995fa47e6c13102d9d' ,
426
+ event : 'Deprecated Method' ,
427
+ properties : {
428
+ mongosh_version : '1.0.0' ,
429
+ class : 'Database' ,
430
+ method : 'mangleDatabase' ,
431
+ }
432
+ }
433
+ ] ,
434
+ [
435
+ 'track' ,
436
+ {
437
+ userId : '53defe995fa47e6c13102d9d' ,
438
+ event : 'API Call' ,
439
+ properties : {
440
+ mongosh_version : '1.0.0' ,
441
+ class : 'Database' ,
442
+ method : 'cloneDatabase' ,
443
+ count : 3
444
+ }
445
+ }
446
+ ] ,
447
+ [
448
+ 'track' ,
449
+ {
450
+ userId : '53defe995fa47e6c13102d9d' ,
451
+ event : 'API Call' ,
452
+ properties : {
453
+ mongosh_version : '1.0.0' ,
454
+ class : 'Database' ,
455
+ method : 'copyDatabase' ,
456
+ count : 1
457
+ }
458
+ }
459
+ ] ,
418
460
] ) ;
419
461
420
462
bus . emit ( 'mongosh:new-user' , userId , false ) ;
421
463
logOutput = [ ] ;
422
464
analyticsOutput = [ ] ;
423
465
424
- bus . emit ( 'mongosh:deprecated- api-call' , { method : 'cloneDatabase' , class : 'Database' } ) ;
466
+ bus . emit ( 'mongosh:api-call' , { method : 'cloneDatabase' , class : 'Database' , deprecated : true , callDepth : 0 , isAsync : true } ) ;
425
467
426
468
expect ( logOutput ) . to . be . empty ;
427
469
expect ( analyticsOutput ) . to . be . empty ;
0 commit comments