11import { createIpcTrack } from './' ;
22import { expect } from 'chai' ;
33
4+ // So that we don't need to override types in all tests
5+ function createTrackFn ( ) {
6+ return createIpcTrack ( ) as ( name : string , ...args : any [ ] ) => void ;
7+ }
8+
49describe ( 'Telemetry' , ( ) => {
510 it ( 'sends track events over ipc' , async function ( ) {
6- const track = createIpcTrack ( ) ;
11+ const track = createTrackFn ( ) ;
712
813 const trackingLogs : any [ ] = [ ] ;
914 process . on ( 'compass:track' , ( event ) => trackingLogs . push ( event ) ) ;
1015
11- track ( 'Test Event1' as any , {
16+ track ( 'Test Event1' , {
1217 some_attribute : 123 ,
1318 } ) ;
1419
@@ -25,12 +30,12 @@ describe('Telemetry', () => {
2530 } ) ;
2631
2732 it ( 'resolves track event attributes' , async function ( ) {
28- const track = createIpcTrack ( ) ;
33+ const track = createTrackFn ( ) ;
2934
3035 const trackingLogs : any [ ] = [ ] ;
3136 process . on ( 'compass:track' , ( event ) => trackingLogs . push ( event ) ) ;
3237
33- track ( 'Test Event2' as any , async ( ) => {
38+ track ( 'Test Event2' , async ( ) => {
3439 await new Promise ( ( resolve ) => setTimeout ( resolve , 3 ) ) ;
3540
3641 return {
@@ -52,12 +57,12 @@ describe('Telemetry', () => {
5257 } ) ;
5358
5459 it ( 'tracks events even when fetching the attributes fails' , async function ( ) {
55- const track = createIpcTrack ( ) ;
60+ const track = createTrackFn ( ) ;
5661
5762 const trackingLogs : any [ ] = [ ] ;
5863 process . on ( 'compass:track' , ( event ) => trackingLogs . push ( event ) ) ;
5964
60- track ( 'Test Event3' as any , ( ) => {
65+ track ( 'Test Event3' , ( ) => {
6166 throw new Error ( 'test error' ) ;
6267 } ) ;
6368
0 commit comments