mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-25 00:20:09 -06:00
SDA-4359 & SDA-4291 (Refactor BI & send in memory session analytic events) (#1969)
* SDA-4359 - Refactor BI & send in memory session analytic events * SDA-4359 - Rename function name
This commit is contained in:
parent
244468a37a
commit
3189c54310
2
package-lock.json
generated
2
package-lock.json
generated
@ -25,7 +25,7 @@
|
||||
"rimraf": "^3.0.2",
|
||||
"save-svg-as-png": "^1.4.17",
|
||||
"shell-path": "^3.0.0",
|
||||
"systeminformation": "^5.21.7",
|
||||
"systeminformation": "5.21.7",
|
||||
"win32-api": "^20.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -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/analytics-handler';
|
||||
import { ScreenSnippetActionTypes } from '../src/app/bi/analytics-handler';
|
||||
import { ScreenShotAnnotation } from '../src/common/ipcEvent';
|
||||
import SnippingTool from '../src/renderer/components/snipping-tool';
|
||||
import { ipcRenderer } from './__mocks__/electron';
|
||||
|
@ -15,7 +15,7 @@ import {
|
||||
AnalyticsActions,
|
||||
AnalyticsElements,
|
||||
MenuActionTypes,
|
||||
} from './analytics-handler';
|
||||
} from './bi/analytics-handler';
|
||||
import { CloudConfigDataTypes, config, IConfig } from './config-handler';
|
||||
import { restartDialog, titleBarChangeDialog } from './dialog-handler';
|
||||
import { exportCrashDumps, exportLogs } from './reports-handler';
|
||||
|
@ -2,19 +2,12 @@ import { GenericServerOptions } from 'builder-util-runtime';
|
||||
import electronLog from 'electron-log';
|
||||
import { MacUpdater, NsisUpdater } from 'electron-updater';
|
||||
|
||||
import { app } from 'electron';
|
||||
import { isMac, isWindowsOS } from '../common/env';
|
||||
import { logger } from '../common/logger';
|
||||
import { isUrl } from '../common/utils';
|
||||
import { whitelistHandler } from '../common/whitelist-handler';
|
||||
import {
|
||||
analytics,
|
||||
AnalyticsElements,
|
||||
IInstallData,
|
||||
InstallActionTypes,
|
||||
InstallLocationTypes,
|
||||
InstallTypes,
|
||||
} from './analytics-handler';
|
||||
import { InstallActionTypes, InstallTypes } from './bi/analytics-handler';
|
||||
import { sendAutoUpdateAnalytics } from './bi/auto-update-analytics';
|
||||
import { config } from './config-handler';
|
||||
import { retrieveWindowsRegistry } from './registry-handler';
|
||||
import { EChannelRegistry, RegistryStore } from './stores/registry-store';
|
||||
@ -106,7 +99,10 @@ export class AutoUpdate {
|
||||
if (!this.isUpdateAvailable) {
|
||||
return;
|
||||
}
|
||||
this.sendAnalytics(InstallActionTypes.InstallStarted, InstallTypes.Auto);
|
||||
sendAutoUpdateAnalytics(
|
||||
InstallActionTypes.InstallStarted,
|
||||
InstallTypes.Auto,
|
||||
);
|
||||
// Handle update and restart for macOS
|
||||
if (isMac) {
|
||||
windowHandler.setIsAutoUpdating(true);
|
||||
@ -179,24 +175,7 @@ export class AutoUpdate {
|
||||
|
||||
return updateUrl;
|
||||
};
|
||||
/**
|
||||
* Sends install analytics
|
||||
*/
|
||||
public sendAnalytics = (
|
||||
action: InstallActionTypes,
|
||||
installType: InstallTypes,
|
||||
) => {
|
||||
const installLocation = this.getInstallLocation();
|
||||
const event: IInstallData = {
|
||||
element: AnalyticsElements.SDA_INSTALL,
|
||||
action_type: action,
|
||||
extra_data: {
|
||||
installLocation,
|
||||
installType,
|
||||
},
|
||||
};
|
||||
analytics.track(event);
|
||||
};
|
||||
|
||||
private updateEventHandler = async (info, eventType: string) => {
|
||||
const mainWebContents = windowHandler.mainWebContents;
|
||||
if (mainWebContents && !mainWebContents.isDestroyed()) {
|
||||
@ -282,30 +261,6 @@ export class AutoUpdate {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Identifies and returns the installation location
|
||||
*/
|
||||
private getInstallLocation = () => {
|
||||
const appPath = app.getPath('exe');
|
||||
if (isWindowsOS) {
|
||||
if (appPath.includes('AppData\\Local\\Programs')) {
|
||||
return InstallLocationTypes.LOCAL;
|
||||
}
|
||||
if (appPath.includes('Program Files')) {
|
||||
return InstallLocationTypes.PROG_FILES;
|
||||
}
|
||||
return InstallLocationTypes.CUSTOM;
|
||||
}
|
||||
if (isMac) {
|
||||
if (appPath.includes('/Applications')) {
|
||||
return InstallLocationTypes.PROG_FILES;
|
||||
}
|
||||
return InstallLocationTypes.LOCAL;
|
||||
}
|
||||
|
||||
return InstallLocationTypes.PROG_FILES;
|
||||
};
|
||||
}
|
||||
|
||||
const autoUpdate = new AutoUpdate();
|
||||
|
55
src/app/bi/auto-update-analytics.ts
Normal file
55
src/app/bi/auto-update-analytics.ts
Normal file
@ -0,0 +1,55 @@
|
||||
import { app } from 'electron';
|
||||
import { isMac, isWindowsOS } from '../../common/env';
|
||||
import {
|
||||
analytics,
|
||||
AnalyticsElements,
|
||||
IInstallData,
|
||||
InstallActionTypes,
|
||||
InstallLocationTypes,
|
||||
InstallTypes,
|
||||
} from './analytics-handler';
|
||||
|
||||
/**
|
||||
* Sends auto update analytics event
|
||||
* @param action
|
||||
* @param installType
|
||||
*/
|
||||
export const sendAutoUpdateAnalytics = (
|
||||
action: InstallActionTypes,
|
||||
installType: InstallTypes,
|
||||
) => {
|
||||
const installLocation = getInstallLocation();
|
||||
const event: IInstallData = {
|
||||
element: AnalyticsElements.SDA_INSTALL,
|
||||
action_type: action,
|
||||
extra_data: {
|
||||
installLocation,
|
||||
installType,
|
||||
},
|
||||
};
|
||||
analytics.track(event);
|
||||
};
|
||||
|
||||
/**
|
||||
* Identifies and returns the installation location
|
||||
*/
|
||||
const getInstallLocation = () => {
|
||||
const appPath = app.getPath('exe');
|
||||
if (isWindowsOS) {
|
||||
if (appPath.includes('AppData\\Local\\Programs')) {
|
||||
return InstallLocationTypes.LOCAL;
|
||||
}
|
||||
if (appPath.includes('Program Files')) {
|
||||
return InstallLocationTypes.PROG_FILES;
|
||||
}
|
||||
return InstallLocationTypes.CUSTOM;
|
||||
}
|
||||
if (isMac) {
|
||||
if (appPath.includes('/Applications')) {
|
||||
return InstallLocationTypes.PROG_FILES;
|
||||
}
|
||||
return InstallLocationTypes.LOCAL;
|
||||
}
|
||||
|
||||
return InstallLocationTypes.PROG_FILES;
|
||||
};
|
@ -12,8 +12,8 @@ import {
|
||||
InstallTypes,
|
||||
SDAEndReasonTypes,
|
||||
SDAUserSessionActionTypes,
|
||||
} from './analytics-handler';
|
||||
import { autoUpdate } from './auto-update-handler';
|
||||
} from './bi/analytics-handler';
|
||||
import { sendAutoUpdateAnalytics } from './bi/auto-update-analytics';
|
||||
import { appStats } from './stats';
|
||||
|
||||
const writeFile = util.promisify(fs.writeFile);
|
||||
@ -638,7 +638,7 @@ class Config {
|
||||
);
|
||||
this.isFirstTime = true;
|
||||
this.bootCount = 0;
|
||||
autoUpdate.sendAnalytics(
|
||||
sendAutoUpdateAnalytics(
|
||||
InstallActionTypes.InstallCompleted,
|
||||
InstallTypes.Manual,
|
||||
);
|
||||
@ -653,7 +653,7 @@ class Config {
|
||||
await this.setUpFirstTimeLaunch();
|
||||
// Skip welcome screen
|
||||
this.isFirstTime = false;
|
||||
autoUpdate.sendAnalytics(
|
||||
sendAutoUpdateAnalytics(
|
||||
InstallActionTypes.InstallCompleted,
|
||||
InstallTypes.Auto,
|
||||
);
|
||||
@ -670,7 +670,7 @@ class Config {
|
||||
);
|
||||
this.isFirstTime = true;
|
||||
this.bootCount = 0;
|
||||
autoUpdate.sendAnalytics(
|
||||
sendAutoUpdateAnalytics(
|
||||
InstallActionTypes.InstallCompleted,
|
||||
InstallTypes.Manual,
|
||||
);
|
||||
|
@ -13,7 +13,7 @@ import {
|
||||
AnalyticsElements,
|
||||
ICrashData,
|
||||
SDACrashProcess,
|
||||
} from './analytics-handler';
|
||||
} from './bi/analytics-handler';
|
||||
import { ICustomBrowserWindow } from './window-handler';
|
||||
import { windowExists } from './window-utils';
|
||||
|
||||
|
@ -20,8 +20,8 @@ import { i18n, LocaleType } from '../common/i18n';
|
||||
import { logger } from '../common/logger';
|
||||
import { whitelistHandler } from '../common/whitelist-handler';
|
||||
import { activityDetection } from './activity-detection';
|
||||
import { analytics, SDAUserSessionActionTypes } from './analytics-handler';
|
||||
import appStateHandler from './app-state-handler';
|
||||
import { analytics, SDAUserSessionActionTypes } from './bi/analytics-handler';
|
||||
import { closeC9Pipe, connectC9Pipe, writeC9Pipe } from './c9-pipe-handler';
|
||||
import { loadC9Shell, terminateC9Shell } from './c9-shell-handler';
|
||||
import { getCitrixMediaRedirectionStatus } from './citrix-handler';
|
||||
|
@ -2,7 +2,7 @@ import * as electron from 'electron';
|
||||
|
||||
import { isMac } from '../common/env';
|
||||
import { logger } from '../common/logger';
|
||||
import { SDAUserSessionActionTypes } from './analytics-handler';
|
||||
import { SDAUserSessionActionTypes } from './bi/analytics-handler';
|
||||
import { CloudConfigDataTypes, config } from './config-handler';
|
||||
import { appStats } from './stats';
|
||||
import { windowHandler } from './window-handler';
|
||||
|
@ -29,7 +29,7 @@ import {
|
||||
analytics,
|
||||
AnalyticsElements,
|
||||
ScreenSnippetActionTypes,
|
||||
} from './analytics-handler';
|
||||
} from './bi/analytics-handler';
|
||||
import { winStore } from './stores';
|
||||
import { IWindowState } from './stores/window-store';
|
||||
import { updateAlwaysOnTop } from './window-actions';
|
||||
|
@ -13,7 +13,7 @@ import {
|
||||
ISessionData,
|
||||
SDAEndReasonTypes,
|
||||
SDAUserSessionActionTypes,
|
||||
} from './analytics-handler';
|
||||
} from './bi/analytics-handler';
|
||||
|
||||
const MAX_USAGE_CHECK_INTERVAL = 15 * 60 * 1000; // every 15min
|
||||
|
||||
@ -150,6 +150,12 @@ export class AppStats {
|
||||
logger.error(`stats: parsing stats JSON file failed due to error ${e}`);
|
||||
}
|
||||
}
|
||||
if (this.stats.length > 0) {
|
||||
this.stats.forEach((event) => {
|
||||
analytics.track(event);
|
||||
});
|
||||
this.stats = [];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -38,12 +38,12 @@ import {
|
||||
throttle,
|
||||
} from '../common/utils';
|
||||
import { notification } from '../renderer/notification';
|
||||
import { cleanAppCacheOnCrash } from './app-cache-handler';
|
||||
import { AppMenu } from './app-menu';
|
||||
import {
|
||||
SDAEndReasonTypes,
|
||||
SDAUserSessionActionTypes,
|
||||
} from './analytics-handler';
|
||||
import { cleanAppCacheOnCrash } from './app-cache-handler';
|
||||
import { AppMenu } from './app-menu';
|
||||
} from './bi/analytics-handler';
|
||||
import { closeC9Pipe } from './c9-pipe-handler';
|
||||
import { handleChildWindow } from './child-window-handler';
|
||||
import {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { ipcRenderer } from 'electron';
|
||||
import { IAnalyticsData } from '../app/analytics-handler';
|
||||
import { IAnalyticsData } from '../app/bi/analytics-handler';
|
||||
import {
|
||||
apiCmds,
|
||||
apiName,
|
||||
|
@ -3,7 +3,7 @@ import * as React from 'react';
|
||||
import {
|
||||
AnalyticsElements,
|
||||
ScreenSnippetActionTypes,
|
||||
} from './../../app/analytics-handler';
|
||||
} from '../../app/bi/analytics-handler';
|
||||
import {
|
||||
IDimensions,
|
||||
IPath,
|
||||
|
@ -1,15 +1,15 @@
|
||||
import { ipcRenderer } from 'electron';
|
||||
import * as React from 'react';
|
||||
import { svgAsPngUri } from 'save-svg-as-png';
|
||||
import {
|
||||
AnalyticsElements,
|
||||
ScreenSnippetActionTypes,
|
||||
} from '../../app/bi/analytics-handler';
|
||||
import { i18n } from '../../common/i18n-preload';
|
||||
import { ScreenShotAnnotation } from '../../common/ipcEvent';
|
||||
import * as PenIcon from '../../renderer/assets/snip-draw.svg';
|
||||
import * as EraseIcon from '../../renderer/assets/snip-erase.svg';
|
||||
import * as HighlightIcon from '../../renderer/assets/snip-highlight.svg';
|
||||
import {
|
||||
AnalyticsElements,
|
||||
ScreenSnippetActionTypes,
|
||||
} from './../../app/analytics-handler';
|
||||
import AnnotateArea from './annotate-area';
|
||||
import ColorPickerPill, { IColor } from './color-picker-pill';
|
||||
import MenuButton from './menu-button';
|
||||
|
@ -4,7 +4,7 @@ import {
|
||||
analytics,
|
||||
AnalyticsElements,
|
||||
ToastNotificationActionTypes,
|
||||
} from '../app/analytics-handler';
|
||||
} from '../app/bi/analytics-handler';
|
||||
import { config } from '../app/config-handler';
|
||||
import {
|
||||
AUX_CLICK,
|
||||
|
Loading…
Reference in New Issue
Block a user