Skip to content

Commit

Permalink
SDA-4291 - Move interfaces into a dedicate file
Browse files Browse the repository at this point in the history
  • Loading branch information
KiranNiranjan authored and Kiran Niranjan committed Oct 11, 2023
1 parent ae41c6c commit 55bc303
Show file tree
Hide file tree
Showing 17 changed files with 166 additions and 168 deletions.
4 changes: 2 additions & 2 deletions spec/snippingTool.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
jest.mock('save-svg-as-png', function () {
return {
svgAsPngUri: async function (svg) {
async svgAsPngUri(svg) {
return Promise.resolve(svg);
},
};
});

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';
Expand Down
12 changes: 6 additions & 6 deletions src/app/app-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion src/app/auto-update-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
137 changes: 8 additions & 129 deletions src/app/bi/analytics-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 2 additions & 2 deletions src/app/bi/auto-update-analytics.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
128 changes: 128 additions & 0 deletions src/app/bi/interface.ts
Original file line number Diff line number Diff line change
@@ -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;
};
}
6 changes: 3 additions & 3 deletions src/app/config-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 2 additions & 6 deletions src/app/crash-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
3 changes: 2 additions & 1 deletion src/app/main-api-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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';
Expand Down
Loading

0 comments on commit 55bc303

Please sign in to comment.