@@ -10,7 +10,6 @@ import { once } from 'events';
1010import type {
1111 BrowserWindowConstructorOptions ,
1212 FindInPageOptions ,
13- App ,
1413} from 'electron' ;
1514import { app as electronApp , shell , BrowserWindow } from 'electron' ;
1615import { enable } from '@electron/remote/main' ;
@@ -24,7 +23,7 @@ import {
2423 registerMongoDbUrlForBrowserWindow ,
2524} from './auto-connect' ;
2625
27- const { track , debug } = createLoggerAndTelemetry ( 'COMPASS-WINDOW-MANAGER' ) ;
26+ const { debug } = createLoggerAndTelemetry ( 'COMPASS-WINDOW-MANAGER' ) ;
2827
2928const earlyOpenUrls : string [ ] = [ ] ;
3029function earlyOpenUrlListener (
@@ -221,67 +220,6 @@ async function onAppReady() {
221220 }
222221}
223222
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-
285223class CompassWindowManager {
286224 private static initPromise : Promise < void > | null = null ;
287225
@@ -300,8 +238,6 @@ class CompassWindowManager {
300238 }
301239 } ) ;
302240
303- trackWindowEvents ( electronApp ) ;
304-
305241 compassApp . on ( 'show-connect-window' , ( ) => {
306242 showConnectWindow ( compassApp ) ;
307243 } ) ;
0 commit comments