@@ -10,7 +10,6 @@ import { once } from 'events';
10
10
import type {
11
11
BrowserWindowConstructorOptions ,
12
12
FindInPageOptions ,
13
- App ,
14
13
} from 'electron' ;
15
14
import { app as electronApp , shell , BrowserWindow } from 'electron' ;
16
15
import { enable } from '@electron/remote/main' ;
@@ -24,7 +23,7 @@ import {
24
23
registerMongoDbUrlForBrowserWindow ,
25
24
} from './auto-connect' ;
26
25
27
- const { track , debug } = createLoggerAndTelemetry ( 'COMPASS-WINDOW-MANAGER' ) ;
26
+ const { debug } = createLoggerAndTelemetry ( 'COMPASS-WINDOW-MANAGER' ) ;
28
27
29
28
const earlyOpenUrls : string [ ] = [ ] ;
30
29
function earlyOpenUrlListener (
@@ -221,67 +220,6 @@ async function onAppReady() {
221
220
}
222
221
}
223
222
224
- function trackWindowEvents ( electronApp : App ) {
225
- // Map of [Window id] -> [opening timestamp in milliseconds]
226
- const windowFocusedAt = new Map < number , number > ( ) ;
227
- let sessionStartedAt : number | undefined = undefined ;
228
- let openWindows = 0 ;
229
-
230
- electronApp . on ( 'browser-window-created' , ( event , win ) => {
231
- openWindows ++ ;
232
- track ( 'Window Open' , {
233
- number_of_windows_open : openWindows ,
234
- } ) ;
235
-
236
- win . once ( 'closed' , ( ) => {
237
- openWindows -- ;
238
- track ( 'Window Closed' , {
239
- number_of_windows_open : openWindows ,
240
- } ) ;
241
- } ) ;
242
- } ) ;
243
-
244
- electronApp . on ( 'browser-window-focus' , ( event , win ) => {
245
- const now = Date . now ( ) ;
246
- sessionStartedAt ??= now ;
247
- windowFocusedAt . set ( win . webContents . id , now ) ;
248
- track ( 'Window Focused' , {
249
- number_of_windows_open : openWindows ,
250
- } ) ;
251
- } ) ;
252
-
253
- electronApp . on ( 'browser-window-blur' , ( event , win ) => {
254
- if ( win . webContents . isDevToolsFocused ( ) ) {
255
- return ;
256
- }
257
-
258
- // causes focus to be emitted after blur, allowing us to track
259
- // when the focus moves from a Compass window to the other
260
- setTimeout ( ( ) => {
261
- const focusAt = windowFocusedAt . get ( win . webContents . id ) ;
262
- const movedToOtherCompassWin = windowFocusedAt . size === 2 ;
263
- windowFocusedAt . delete ( win . webContents . id ) ;
264
-
265
- if ( focusAt ) {
266
- const now = Date . now ( ) ;
267
- track ( 'Window Blurred' , {
268
- session_duration_secs : Math . round ( ( now - focusAt ) / 1000 ) ,
269
- focus_to_other_compass_window : movedToOtherCompassWin ,
270
- number_of_windows_open : openWindows ,
271
- } ) ;
272
-
273
- if ( sessionStartedAt && ! movedToOtherCompassWin ) {
274
- track ( 'Application Blurred' , {
275
- session_duration_secs : Math . round ( ( now - sessionStartedAt ) / 1000 ) ,
276
- number_of_windows_open : openWindows ,
277
- } ) ;
278
- sessionStartedAt = undefined ;
279
- }
280
- }
281
- } ) ;
282
- } ) ;
283
- }
284
-
285
223
class CompassWindowManager {
286
224
private static initPromise : Promise < void > | null = null ;
287
225
@@ -300,8 +238,6 @@ class CompassWindowManager {
300
238
}
301
239
} ) ;
302
240
303
- trackWindowEvents ( electronApp ) ;
304
-
305
241
compassApp . on ( 'show-connect-window' , ( ) => {
306
242
showConnectWindow ( compassApp ) ;
307
243
} ) ;
0 commit comments