diff --git a/spec/snippingTool.spec.tsx b/spec/snippingTool.spec.tsx index aa241f69..96d1335f 100644 --- a/spec/snippingTool.spec.tsx +++ b/spec/snippingTool.spec.tsx @@ -1,6 +1,6 @@ jest.mock('save-svg-as-png', function () { return { - svgAsPngUri: async function (svg) { + async svgAsPngUri(svg) { return Promise.resolve(svg); }, }; @@ -8,7 +8,7 @@ jest.mock('save-svg-as-png', function () { import { mount, shallow } from 'enzyme'; import * as React from 'react'; -import { ScreenSnippetActionTypes } from '../src/app/bi/analytics-handler'; +import { ScreenSnippetActionTypes } from '../src/app/bi/interface'; import { ScreenShotAnnotation } from '../src/common/ipcEvent'; import SnippingTool from '../src/renderer/components/snipping-tool'; import { ipcRenderer } from './__mocks__/electron'; diff --git a/src/app/app-menu.ts b/src/app/app-menu.ts index cb66da21..585cd5f6 100644 --- a/src/app/app-menu.ts +++ b/src/app/app-menu.ts @@ -10,12 +10,7 @@ import { apiName } from '../common/api-interface'; import { isLinux, isMac, isWindowsOS } from '../common/env'; import { i18n, LocaleType } from '../common/i18n'; import { logger } from '../common/logger'; -import { - analytics, - AnalyticsActions, - AnalyticsElements, - MenuActionTypes, -} from './bi/analytics-handler'; +import { analytics } from './bi/analytics-handler'; import { CloudConfigDataTypes, config, IConfig } from './config-handler'; import { restartDialog, titleBarChangeDialog } from './dialog-handler'; import { exportCrashDumps, exportLogs } from './reports-handler'; @@ -39,6 +34,11 @@ import { import { autoLaunchInstance as autoLaunch } from './auto-launch-controller'; import { autoUpdate, AutoUpdateTrigger } from './auto-update-handler'; +import { + AnalyticsActions, + AnalyticsElements, + MenuActionTypes, +} from './bi/interface'; export const menuSections = { about: 'about', diff --git a/src/app/auto-update-handler.ts b/src/app/auto-update-handler.ts index ec4ac97b..87620a86 100644 --- a/src/app/auto-update-handler.ts +++ b/src/app/auto-update-handler.ts @@ -6,8 +6,8 @@ import { isMac, isWindowsOS } from '../common/env'; import { logger } from '../common/logger'; import { isUrl } from '../common/utils'; import { whitelistHandler } from '../common/whitelist-handler'; -import { InstallActionTypes, InstallTypes } from './bi/analytics-handler'; import { sendAutoUpdateAnalytics } from './bi/auto-update-analytics'; +import { InstallActionTypes, InstallTypes } from './bi/interface'; import { config } from './config-handler'; import { retrieveWindowsRegistry } from './registry-handler'; import { EChannelRegistry, RegistryStore } from './stores/registry-store'; diff --git a/src/app/bi/analytics-handler.ts b/src/app/bi/analytics-handler.ts index 87c67f70..af0b6a90 100644 --- a/src/app/bi/analytics-handler.ts +++ b/src/app/bi/analytics-handler.ts @@ -2,135 +2,14 @@ import { app, WebContents } from 'electron'; import * as fs from 'fs'; import * as path from 'path'; import { logger } from '../../common/logger'; - -export interface IAnalyticsData { - element: AnalyticsElements; - action_type?: - | MenuActionTypes - | ScreenSnippetActionTypes - | ToastNotificationActionTypes - | SDAUserSessionActionTypes - | InstallActionTypes; - action_result?: AnalyticsActions; - extra_data?: object; -} - -export interface ICrashData extends IAnalyticsData { - process: SDACrashProcess; - crashCause: string; - windowName: string; - miniDump?: string; -} - -export interface ISessionData extends IAnalyticsData { - extra_data?: { - sessionStartDatetime?: string; - machineStartDatetime?: string; - machineId?: string; - InstallVariant?: string; - osName?: string; - osVersion?: string; - osLanguage?: string; - osTimeZone?: string; - cpuNumberOfCores?: number; - cpuMaxFrequency?: number; - cpuUsagePercent?: number; - maxCPUUsagePercent?: number; - memoryTotal?: number; - memoryUsedPercent?: number; - maxMemoryUsedPercent?: number; - sdaUsedMemory?: number; - memoryAvailable?: number; - vdi?: boolean; - endReason?: string; - crashProcess?: string; - }; -} - -export interface IInstallData extends IAnalyticsData { - extra_data?: { - installLocation: string; - installType: string; - }; -} - -export enum MenuActionTypes { - AUTO_LAUNCH_ON_START_UP = 'auto_launch_on_start_up', - ALWAYS_ON_TOP = 'always_on_top', - MINIMIZE_ON_CLOSE = 'minimize_on_close', - FLASH_NOTIFICATION_IN_TASK_BAR = 'flash_notification_in_task_bar', - HAMBURGER_MENU = 'hamburger_menu', - REFRESH_APP_IN_IDLE = 'refresh_app_in_idle', -} - -export enum ScreenSnippetActionTypes { - SCREENSHOT_TAKEN = 'screenshot_taken', - ANNOTATE_ADDED_PEN = 'annotate_added_pen', - ANNOTATE_ADDED_HIGHLIGHT = 'annotate_added_highlight', - ANNOTATE_ADD = 'annotate_done', - ANNOTATE_CLEARED = 'annotate_cleared', - ANNOTATE_ERASED = 'annotate_erased', - ANNOTATE_COPY = 'annotate_copy', - ANNOTATE_SAVE_AS = 'annotate_save_as', - ANNOTATE_CLOSE = 'annotate_close', -} - -export enum ToastNotificationActionTypes { - TOAST_CLOSED = 'toast_closed', -} - -export enum SDAUserSessionActionTypes { - Start = 'Start', - End = 'End', - Login = 'Login', - Logout = 'Logout', - Crash = 'Crash', - ForceReload = 'Force_reload', -} - -export enum InstallActionTypes { - InstallStarted = 'Install_started', - InstallCompleted = 'Install_completed', - InstallFailed = 'Install_failed', -} - -export enum InstallTypes { - Auto = 'auto', - Manual = 'manual', -} - -export enum InstallLocationTypes { - PROG_FILES = 'PROG_FILES', - REMOTE = 'REMOTE', - LOCAL = 'LOCAL', - CUSTOM = 'CUSTOM', -} - -export enum SDAEndReasonTypes { - Reboot = 'Reboot', - Closed = 'Closed', - Crashed = 'Crashed', -} - -export enum AnalyticsActions { - ENABLED = 'ON', - DISABLED = 'OFF', -} - -export enum AnalyticsElements { - MENU = 'Menu', - SCREEN_CAPTURE_ANNOTATE = 'screen_capture_annotate', - TOAST_NOTIFICATION = 'toast_notification', - SDA_CRASH = 'sda_crash', - SDA_SESSION = 'sda_session', - SDA_INSTALL = 'sda_install', -} - -export enum SDACrashProcess { - MAIN = 'main', - RENDERER = 'renderer', - GPU = 'gpu', -} +import { + AnalyticsElements, + IAnalyticsData, + ICrashData, + InstallActionTypes, + ISessionData, + SDAUserSessionActionTypes, +} from './interface'; const MAX_EVENT_QUEUE_LENGTH = 50; const analyticsCallback = 'analytics-callback'; diff --git a/src/app/bi/auto-update-analytics.ts b/src/app/bi/auto-update-analytics.ts index 47d16fab..aa7635be 100644 --- a/src/app/bi/auto-update-analytics.ts +++ b/src/app/bi/auto-update-analytics.ts @@ -1,13 +1,13 @@ import { app } from 'electron'; import { isMac, isWindowsOS } from '../../common/env'; +import { analytics } from './analytics-handler'; import { - analytics, AnalyticsElements, IInstallData, InstallActionTypes, InstallLocationTypes, InstallTypes, -} from './analytics-handler'; +} from './interface'; /** * Sends auto update analytics event diff --git a/src/app/bi/interface.ts b/src/app/bi/interface.ts new file mode 100644 index 00000000..ef86d51d --- /dev/null +++ b/src/app/bi/interface.ts @@ -0,0 +1,128 @@ +export enum SDACrashProcess { + MAIN = 'main', + RENDERER = 'renderer', + GPU = 'gpu', +} + +export interface ICrashData extends IAnalyticsData { + process: SDACrashProcess; + crashCause: string; + windowName: string; + miniDump?: string; +} + +export interface IInstallData extends IAnalyticsData { + extra_data?: { + installLocation: string; + installType: string; + }; +} + +export enum MenuActionTypes { + AUTO_LAUNCH_ON_START_UP = 'auto_launch_on_start_up', + ALWAYS_ON_TOP = 'always_on_top', + MINIMIZE_ON_CLOSE = 'minimize_on_close', + FLASH_NOTIFICATION_IN_TASK_BAR = 'flash_notification_in_task_bar', + HAMBURGER_MENU = 'hamburger_menu', + REFRESH_APP_IN_IDLE = 'refresh_app_in_idle', +} + +export enum ScreenSnippetActionTypes { + SCREENSHOT_TAKEN = 'screenshot_taken', + ANNOTATE_ADDED_PEN = 'annotate_added_pen', + ANNOTATE_ADDED_HIGHLIGHT = 'annotate_added_highlight', + ANNOTATE_ADD = 'annotate_done', + ANNOTATE_CLEARED = 'annotate_cleared', + ANNOTATE_ERASED = 'annotate_erased', + ANNOTATE_COPY = 'annotate_copy', + ANNOTATE_SAVE_AS = 'annotate_save_as', + ANNOTATE_CLOSE = 'annotate_close', +} + +export enum ToastNotificationActionTypes { + TOAST_CLOSED = 'toast_closed', +} + +export enum SDAUserSessionActionTypes { + Start = 'Start', + End = 'End', + Login = 'Login', + Logout = 'Logout', + Crash = 'Crash', + ForceReload = 'Force_reload', +} + +export enum InstallActionTypes { + InstallStarted = 'Install_started', + InstallCompleted = 'Install_completed', + InstallFailed = 'Install_failed', +} + +export enum InstallTypes { + Auto = 'auto', + Manual = 'manual', +} + +export enum InstallLocationTypes { + PROG_FILES = 'PROG_FILES', + REMOTE = 'REMOTE', + LOCAL = 'LOCAL', + CUSTOM = 'CUSTOM', +} + +export enum SDAEndReasonTypes { + Reboot = 'Reboot', + Closed = 'Closed', + Crashed = 'Crashed', +} + +export enum AnalyticsActions { + ENABLED = 'ON', + DISABLED = 'OFF', +} + +export enum AnalyticsElements { + MENU = 'Menu', + SCREEN_CAPTURE_ANNOTATE = 'screen_capture_annotate', + TOAST_NOTIFICATION = 'toast_notification', + SDA_CRASH = 'sda_crash', + SDA_SESSION = 'sda_session', + SDA_INSTALL = 'sda_install', +} + +export interface IAnalyticsData { + element: AnalyticsElements; + action_type?: + | MenuActionTypes + | ScreenSnippetActionTypes + | ToastNotificationActionTypes + | SDAUserSessionActionTypes + | InstallActionTypes; + action_result?: AnalyticsActions; + extra_data?: object; +} + +export interface ISessionData extends IAnalyticsData { + extra_data?: { + sessionStartDatetime?: string; + machineStartDatetime?: string; + machineId?: string; + InstallVariant?: string; + osName?: string; + osVersion?: string; + osLanguage?: string; + osTimeZone?: string; + cpuNumberOfCores?: number; + cpuMaxFrequency?: number; + cpuUsagePercent?: number; + maxCPUUsagePercent?: number; + memoryTotal?: number; + memoryUsedPercent?: number; + maxMemoryUsedPercent?: number; + sdaUsedMemory?: number; + memoryAvailable?: number; + vdi?: boolean; + endReason?: string; + crashProcess?: string; + }; +} diff --git a/src/app/config-handler.ts b/src/app/config-handler.ts index d874b139..6abd1af0 100644 --- a/src/app/config-handler.ts +++ b/src/app/config-handler.ts @@ -7,14 +7,14 @@ import { buildNumber } from '../../package.json'; import { isDevEnv, isElectronQA, isLinux, isMac } from '../common/env'; import { logger } from '../common/logger'; import { arrayEquals, filterOutSelectedValues, pick } from '../common/utils'; +import { analytics } from './bi/analytics-handler'; +import { sendAutoUpdateAnalytics } from './bi/auto-update-analytics'; import { - analytics, InstallActionTypes, InstallTypes, SDAEndReasonTypes, SDAUserSessionActionTypes, -} from './bi/analytics-handler'; -import { sendAutoUpdateAnalytics } from './bi/auto-update-analytics'; +} from './bi/interface'; import { appStats } from './stats'; const writeFile = util.promisify(fs.writeFile); diff --git a/src/app/crash-handler.ts b/src/app/crash-handler.ts index 8e8d7592..e78b3727 100644 --- a/src/app/crash-handler.ts +++ b/src/app/crash-handler.ts @@ -8,12 +8,8 @@ import { } from 'electron'; import { i18n } from '../common/i18n'; import { logger } from '../common/logger'; -import { - analytics, - AnalyticsElements, - ICrashData, - SDACrashProcess, -} from './bi/analytics-handler'; +import { analytics } from './bi/analytics-handler'; +import { AnalyticsElements, ICrashData, SDACrashProcess } from './bi/interface'; import { ICustomBrowserWindow } from './window-handler'; import { windowExists } from './window-utils'; diff --git a/src/app/main-api-handler.ts b/src/app/main-api-handler.ts index 4072d23d..807a4c96 100644 --- a/src/app/main-api-handler.ts +++ b/src/app/main-api-handler.ts @@ -21,7 +21,7 @@ import { logger } from '../common/logger'; import { whitelistHandler } from '../common/whitelist-handler'; import { activityDetection } from './activity-detection'; import appStateHandler from './app-state-handler'; -import { analytics, SDAUserSessionActionTypes } from './bi/analytics-handler'; +import { analytics } from './bi/analytics-handler'; import { closeC9Pipe, connectC9Pipe, writeC9Pipe } from './c9-pipe-handler'; import { loadC9Shell, terminateC9Shell } from './c9-shell-handler'; import { getCitrixMediaRedirectionStatus } from './citrix-handler'; @@ -53,6 +53,7 @@ import { import { getCommandLineArgs } from '../common/utils'; import callNotificationHelper from '../renderer/call-notification-helper'; import { autoUpdate, AutoUpdateTrigger } from './auto-update-handler'; +import { SDAUserSessionActionTypes } from './bi/interface'; import { presenceStatus } from './presence-status-handler'; import { appStats } from './stats'; import { presenceStatusStore } from './stores/index'; diff --git a/src/app/memory-monitor.ts b/src/app/memory-monitor.ts index 30a25476..45d1064f 100644 --- a/src/app/memory-monitor.ts +++ b/src/app/memory-monitor.ts @@ -2,7 +2,7 @@ import * as electron from 'electron'; import { isMac } from '../common/env'; import { logger } from '../common/logger'; -import { SDAUserSessionActionTypes } from './bi/analytics-handler'; +import { SDAUserSessionActionTypes } from './bi/interface'; import { CloudConfigDataTypes, config } from './config-handler'; import { appStats } from './stats'; import { windowHandler } from './window-handler'; diff --git a/src/app/screen-snippet-handler.ts b/src/app/screen-snippet-handler.ts index 5289b9db..009e9591 100644 --- a/src/app/screen-snippet-handler.ts +++ b/src/app/screen-snippet-handler.ts @@ -25,11 +25,8 @@ import { import { i18n } from '../common/i18n'; import { ScreenShotAnnotation } from '../common/ipcEvent'; import { logger } from '../common/logger'; -import { - analytics, - AnalyticsElements, - ScreenSnippetActionTypes, -} from './bi/analytics-handler'; +import { analytics } from './bi/analytics-handler'; +import { AnalyticsElements, ScreenSnippetActionTypes } from './bi/interface'; import { winStore } from './stores'; import { IWindowState } from './stores/window-store'; import { updateAlwaysOnTop } from './window-actions'; diff --git a/src/app/stats.ts b/src/app/stats.ts index 77e1e765..c9b0a0e4 100644 --- a/src/app/stats.ts +++ b/src/app/stats.ts @@ -4,13 +4,13 @@ import * as si from 'systeminformation'; import { buildNumber, version } from '../../package.json'; import { logger } from '../common/logger'; +import { analytics } from './bi/analytics-handler'; import { - analytics, AnalyticsElements, ISessionData, SDAEndReasonTypes, SDAUserSessionActionTypes, -} from './bi/analytics-handler'; +} from './bi/interface'; const MAX_USAGE_CHECK_INTERVAL = 15 * 60 * 1000; // every 15min diff --git a/src/app/window-handler.ts b/src/app/window-handler.ts index ea7cd997..7d81a3ed 100644 --- a/src/app/window-handler.ts +++ b/src/app/window-handler.ts @@ -40,11 +40,8 @@ import { import { notification } from '../renderer/notification'; import { cleanAppCacheOnCrash } from './app-cache-handler'; import { AppMenu } from './app-menu'; -import { - analytics, - SDAEndReasonTypes, - SDAUserSessionActionTypes, -} from './bi/analytics-handler'; +import { analytics } from './bi/analytics-handler'; +import { SDAEndReasonTypes, SDAUserSessionActionTypes } from './bi/interface'; import { closeC9Pipe } from './c9-pipe-handler'; import { handleChildWindow } from './child-window-handler'; import { diff --git a/src/renderer/app-bridge.ts b/src/renderer/app-bridge.ts index 224ff302..51147690 100644 --- a/src/renderer/app-bridge.ts +++ b/src/renderer/app-bridge.ts @@ -1,5 +1,5 @@ import { ipcRenderer } from 'electron'; -import { IAnalyticsData } from '../app/bi/analytics-handler'; +import { IAnalyticsData } from '../app/bi/interface'; import { apiCmds, apiName, diff --git a/src/renderer/components/annotate-area.tsx b/src/renderer/components/annotate-area.tsx index dba2e431..30549d33 100644 --- a/src/renderer/components/annotate-area.tsx +++ b/src/renderer/components/annotate-area.tsx @@ -3,7 +3,7 @@ import * as React from 'react'; import { AnalyticsElements, ScreenSnippetActionTypes, -} from '../../app/bi/analytics-handler'; +} from '../../app/bi/interface'; import { IDimensions, IPath, diff --git a/src/renderer/components/snipping-tool.tsx b/src/renderer/components/snipping-tool.tsx index 874afcae..58b5039d 100644 --- a/src/renderer/components/snipping-tool.tsx +++ b/src/renderer/components/snipping-tool.tsx @@ -4,7 +4,7 @@ import { svgAsPngUri } from 'save-svg-as-png'; import { AnalyticsElements, ScreenSnippetActionTypes, -} from '../../app/bi/analytics-handler'; +} from '../../app/bi/interface'; import { i18n } from '../../common/i18n-preload'; import { ScreenShotAnnotation } from '../../common/ipcEvent'; import * as PenIcon from '../../renderer/assets/snip-draw.svg'; diff --git a/src/renderer/notification.ts b/src/renderer/notification.ts index 653b951a..f2197d60 100644 --- a/src/renderer/notification.ts +++ b/src/renderer/notification.ts @@ -1,10 +1,10 @@ import { app, BrowserWindow, ipcMain } from 'electron'; +import { analytics } from '../app/bi/analytics-handler'; import { - analytics, AnalyticsElements, ToastNotificationActionTypes, -} from '../app/bi/analytics-handler'; +} from '../app/bi/interface'; import { config } from '../app/config-handler'; import { AUX_CLICK,