mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-11-25 02:10:32 -06:00
SDA API calls logging (#1295)
* API calls logging improvement * Electron update
This commit is contained in:
parent
fb2c866483
commit
a1ac758e9b
16
package-lock.json
generated
16
package-lock.json
generated
@ -5936,9 +5936,9 @@
|
||||
}
|
||||
},
|
||||
"electron": {
|
||||
"version": "14.1.1",
|
||||
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/electron/-/electron-14.1.1.tgz",
|
||||
"integrity": "sha1-ZDcm/h/UrXf7s6dbIRAF7QE1dIU=",
|
||||
"version": "14.2.1",
|
||||
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/electron/-/electron-14.2.1.tgz",
|
||||
"integrity": "sha1-7ouc+owErU2UVtqlu6xWLCwlF6E=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@electron/get": "^1.0.1",
|
||||
@ -5947,9 +5947,9 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/node": {
|
||||
"version": "14.17.19",
|
||||
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/@types/node/-/node-14.17.19.tgz",
|
||||
"integrity": "sha1-c0HprBtddI16PdwEM27VNqb5HDE=",
|
||||
"version": "14.17.33",
|
||||
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/@types/node/-/node-14.17.33.tgz",
|
||||
"integrity": "sha1-AR7ijjjceu4b4DLOrfYzKgqxWxI=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
@ -15158,8 +15158,8 @@
|
||||
}
|
||||
},
|
||||
"screen-snippet": {
|
||||
"version": "git+ssh://git@github.com/symphonyoss/ScreenSnippet2.git#889aedbd3ecf16320a387967aaee0e7ca992d717",
|
||||
"from": "screen-snippet@git+https://github.com/symphonyoss/ScreenSnippet2.git#v2.4.0",
|
||||
"version": "git+https://github.com/symphonyoss/ScreenSnippet2.git#63071f24d6539598cef436daadf659c6d3fa3661",
|
||||
"from": "git+https://github.com/symphonyoss/ScreenSnippet2.git#9.2.2",
|
||||
"optional": true
|
||||
},
|
||||
"semver": {
|
||||
|
@ -19,7 +19,7 @@
|
||||
"compile:project": "gulp build",
|
||||
"compile:spec": "tsc -p tsconfig.spec.json",
|
||||
"compile:robot": "npm rebuild --build-from-source robotjs",
|
||||
"dev": "npm run prebuild && cross-env ELECTRON_DEV=true electron .",
|
||||
"dev": "gulp build && npm run browserify && cross-env ELECTRON_DEV=true electron .",
|
||||
"demo": "run-os",
|
||||
"demo:win32": "npm run prebuild && cross-env ELECTRON_DEV=true electron . --url=file:///src/demo/index.html",
|
||||
"demo:darwin": "npm run prebuild && cross-env ELECTRON_DEV=true electron . --url=file://$(pwd)/src/demo/index.html",
|
||||
@ -126,7 +126,7 @@
|
||||
"browserify": "16.5.1",
|
||||
"cross-env": "5.2.0",
|
||||
"del": "3.0.0",
|
||||
"electron": "14.1.1",
|
||||
"electron": "14.2.1",
|
||||
"electron-builder": "22.7.0",
|
||||
"electron-builder-squirrel-windows": "20.38.3",
|
||||
"electron-icon-maker": "0.0.4",
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { app, powerMonitor } from 'electron';
|
||||
import { app, powerMonitor, WebContents } from 'electron';
|
||||
import Timer = NodeJS.Timer;
|
||||
|
||||
import { logger } from '../common/logger';
|
||||
@ -6,7 +6,7 @@ import { windowHandler } from './window-handler';
|
||||
|
||||
class ActivityDetection {
|
||||
private idleThreshold: number;
|
||||
private window: Electron.WebContents | null;
|
||||
private window: WebContents | null;
|
||||
private timer: Timer | undefined;
|
||||
private queryInterval: NodeJS.Timer | undefined;
|
||||
|
||||
@ -22,7 +22,7 @@ class ActivityDetection {
|
||||
* @param idleThreshold {number}
|
||||
*/
|
||||
public setWindowAndThreshold(
|
||||
window: Electron.WebContents,
|
||||
window: WebContents,
|
||||
idleThreshold: number,
|
||||
): void {
|
||||
this.window = window;
|
||||
|
@ -1,6 +1,11 @@
|
||||
import { WebContents } from 'electron';
|
||||
|
||||
export interface IAnalyticsData {
|
||||
element: AnalyticsElements;
|
||||
action_type?: MenuActionTypes | ScreenSnippetActionTypes | ToastNotificationActionTypes;
|
||||
action_type?:
|
||||
| MenuActionTypes
|
||||
| ScreenSnippetActionTypes
|
||||
| ToastNotificationActionTypes;
|
||||
action_result?: AnalyticsActions;
|
||||
extra_data?: object;
|
||||
}
|
||||
@ -56,15 +61,15 @@ const MAX_EVENT_QUEUE_LENGTH = 50;
|
||||
const analyticsCallback = 'analytics-callback';
|
||||
|
||||
class Analytics {
|
||||
private preloadWindow: Electron.webContents | undefined;
|
||||
private preloadWindow: WebContents | undefined;
|
||||
private analyticsEventQueue: IAnalyticsData[] = [];
|
||||
|
||||
/**
|
||||
* Stores the reference to the preload window
|
||||
*
|
||||
* @param webContents {Electron.webContents}
|
||||
* @param webContents {WeContents}
|
||||
*/
|
||||
public registerPreloadWindow(webContents: Electron.webContents): void {
|
||||
public registerPreloadWindow(webContents: WebContents): void {
|
||||
this.preloadWindow = webContents;
|
||||
|
||||
if (!(this.preloadWindow && !this.preloadWindow.isDestroyed())) {
|
||||
|
@ -110,6 +110,7 @@ class CrashHandler {
|
||||
`crash-handler: Renderer process crash event processed with data ${JSON.stringify(
|
||||
eventData,
|
||||
)}`,
|
||||
details,
|
||||
);
|
||||
break;
|
||||
default:
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { BrowserWindow, dialog, shell } from 'electron';
|
||||
import { BrowserWindow, dialog, shell, WebContents } from 'electron';
|
||||
import * as fs from 'fs';
|
||||
import { i18n } from '../common/i18n';
|
||||
import { logger } from '../common/logger';
|
||||
@ -35,14 +35,14 @@ class DownloadHandler {
|
||||
});
|
||||
}
|
||||
|
||||
private window!: Electron.WebContents | null;
|
||||
private window!: WebContents | null;
|
||||
private items: IDownloadItem[] = [];
|
||||
|
||||
/**
|
||||
* Sets the window for the download handler
|
||||
* @param window Window object
|
||||
*/
|
||||
public setWindow(window: Electron.WebContents): void {
|
||||
public setWindow(window: WebContents): void {
|
||||
this.window = window;
|
||||
logger.info(`download-handler: Initialized download handler`);
|
||||
}
|
||||
|
@ -83,10 +83,7 @@ ipcMain.on(
|
||||
);
|
||||
return;
|
||||
}
|
||||
logger.info(
|
||||
`main-api-handler: API call received - ${arg.cmd} - Properties:`,
|
||||
arg,
|
||||
);
|
||||
logApiCallParams(arg);
|
||||
switch (arg.cmd) {
|
||||
case apiCmds.isOnline:
|
||||
if (typeof arg.isOnline === 'boolean') {
|
||||
@ -440,3 +437,82 @@ ipcMain.handle(
|
||||
return;
|
||||
},
|
||||
);
|
||||
|
||||
/**
|
||||
* Log API call parameters.
|
||||
*/
|
||||
const logApiCallParams = (arg: any) => {
|
||||
const apiCmd = arg.cmd;
|
||||
switch (apiCmd) {
|
||||
case apiCmds.showNotification:
|
||||
const title = 'hidden';
|
||||
const body = 'hidden';
|
||||
const notificationDetails: INotificationData = {
|
||||
...arg.notificationOpts,
|
||||
title,
|
||||
body,
|
||||
};
|
||||
logger.info(
|
||||
`main-api-handler: - ${apiCmd} - Properties: ${JSON.stringify(
|
||||
notificationDetails,
|
||||
null,
|
||||
2,
|
||||
)}`,
|
||||
);
|
||||
break;
|
||||
case apiCmds.badgeDataUrl:
|
||||
const dataUrl = 'hidden';
|
||||
const badgeDataUrlDetails = {
|
||||
...arg,
|
||||
dataUrl,
|
||||
};
|
||||
logger.info(
|
||||
`main-api-handler: - ${apiCmd} - Properties: ${JSON.stringify(
|
||||
badgeDataUrlDetails,
|
||||
null,
|
||||
2,
|
||||
)}`,
|
||||
);
|
||||
break;
|
||||
case apiCmds.openScreenPickerWindow:
|
||||
const sources = arg.sources.map((source: any) => {
|
||||
return {
|
||||
name: source.name,
|
||||
id: source.id,
|
||||
thumbnail: 'hidden',
|
||||
display_id: source.display_id,
|
||||
appIcon: source.appIcon,
|
||||
};
|
||||
});
|
||||
const openScreenPickerDetails = {
|
||||
...arg,
|
||||
sources,
|
||||
};
|
||||
logger.info(
|
||||
`main-api-handler: - ${apiCmd} - Properties: ${JSON.stringify(
|
||||
openScreenPickerDetails,
|
||||
null,
|
||||
2,
|
||||
)}`,
|
||||
);
|
||||
break;
|
||||
case apiCmds.isMisspelled:
|
||||
logger.verbose(
|
||||
`main-api-handler: - ${apiCmd} - Properties: ${JSON.stringify(
|
||||
arg,
|
||||
null,
|
||||
2,
|
||||
)}`,
|
||||
);
|
||||
break;
|
||||
default:
|
||||
logger.info(
|
||||
`main-api-handler: - ${apiCmd} - Properties: ${JSON.stringify(
|
||||
arg,
|
||||
null,
|
||||
2,
|
||||
)}`,
|
||||
);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
@ -3,7 +3,7 @@ import { WebContents } from 'electron';
|
||||
export class MainProcessEvents {
|
||||
private registeredWebContents: Map<string, Set<WebContents>> = new Map<
|
||||
string,
|
||||
Set<Electron.WebContents>
|
||||
Set<WebContents>
|
||||
>();
|
||||
|
||||
/**
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { WebContents } from 'electron';
|
||||
import { apiName } from '../common/api-interface';
|
||||
import { isMac } from '../common/env';
|
||||
import { logger } from '../common/logger';
|
||||
@ -12,7 +13,7 @@ class ProtocolHandler {
|
||||
private static isValidProtocolUri = (uri: string): boolean =>
|
||||
!!(uri && uri.startsWith(protocol.SymphonyProtocol));
|
||||
|
||||
private preloadWebContents: Electron.WebContents | null = null;
|
||||
private preloadWebContents: WebContents | null = null;
|
||||
private protocolUri: string | null = null;
|
||||
|
||||
constructor() {
|
||||
@ -22,9 +23,9 @@ class ProtocolHandler {
|
||||
/**
|
||||
* Stores the web contents of the preload
|
||||
*
|
||||
* @param webContents {Electron.WebContents}
|
||||
* @param webContents {WeContents}
|
||||
*/
|
||||
public setPreloadWebContents(webContents: Electron.WebContents): void {
|
||||
public setPreloadWebContents(webContents: WebContents): void {
|
||||
this.preloadWebContents = webContents;
|
||||
logger.info(
|
||||
`protocol handler: SFE is active and we have a valid protocol window with web contents!`,
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as archiver from 'archiver';
|
||||
import { app, BrowserWindow, dialog, shell } from 'electron';
|
||||
import { app, BrowserWindow, dialog, shell, WebContents } from 'electron';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
@ -83,12 +83,12 @@ const generateArchiveForDirectory = (
|
||||
});
|
||||
};
|
||||
|
||||
let logWebContents: Electron.WebContents;
|
||||
let logWebContents: WebContents;
|
||||
const logTypes: string[] = [];
|
||||
const receivedLogs: ILogs[] = [];
|
||||
|
||||
export const registerLogRetriever = (
|
||||
sender: Electron.WebContents,
|
||||
sender: WebContents,
|
||||
logName: string,
|
||||
): void => {
|
||||
logWebContents = sender;
|
||||
|
@ -1,4 +1,10 @@
|
||||
import { app, BrowserWindow, ipcMain, nativeImage } from 'electron';
|
||||
import {
|
||||
app,
|
||||
BrowserWindow,
|
||||
ipcMain,
|
||||
nativeImage,
|
||||
WebContents,
|
||||
} from 'electron';
|
||||
import * as fs from 'fs';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
@ -69,9 +75,9 @@ class ScreenSnippet {
|
||||
* Captures a user selected portion of the monitor and returns jpeg image
|
||||
* encoded in base64 format.
|
||||
*
|
||||
* @param webContents {Electron.webContents}
|
||||
* @param webContents {WeContents}
|
||||
*/
|
||||
public async capture(webContents: Electron.webContents) {
|
||||
public async capture(webContents: WebContents) {
|
||||
const mainWindow = windowHandler.getMainWindow();
|
||||
if (mainWindow && windowExists(mainWindow) && isWindowsOS) {
|
||||
this.shouldUpdateAlwaysOnTop = mainWindow.isAlwaysOnTop();
|
||||
@ -308,7 +314,7 @@ class ScreenSnippet {
|
||||
* Uploads a screen snippet
|
||||
* @param webContents A browser window's web contents object
|
||||
*/
|
||||
private uploadSnippet(webContents: Electron.webContents) {
|
||||
private uploadSnippet(webContents: WebContents) {
|
||||
ipcMain.once(
|
||||
'upload-snippet',
|
||||
async (
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { app, MenuItem } from 'electron';
|
||||
import { app, MenuItem, WebContents } from 'electron';
|
||||
import * as path from 'path';
|
||||
|
||||
import {
|
||||
@ -47,9 +47,9 @@ export class SpellChecker {
|
||||
/**
|
||||
* Attaches context-menu event for every webContents
|
||||
*
|
||||
* @param webContents {Electron.WebContents}
|
||||
* @param webContents {WeContents}
|
||||
*/
|
||||
public attachToWebContents(webContents: Electron.WebContents): void {
|
||||
public attachToWebContents(webContents: WebContents): void {
|
||||
const contextMenuBuilder = new ContextMenuBuilder(
|
||||
this.spellCheckHandler,
|
||||
webContents,
|
||||
|
@ -3,6 +3,7 @@ import {
|
||||
dialog,
|
||||
PermissionRequestHandlerHandlerDetails,
|
||||
systemPreferences,
|
||||
WebContents,
|
||||
} from 'electron';
|
||||
|
||||
import { apiName, IBoundsChange, KeyCodes } from '../common/api-interface';
|
||||
@ -447,11 +448,9 @@ const handleMediaPermissions = async (
|
||||
/**
|
||||
* Sets permission requests for the window
|
||||
*
|
||||
* @param webContents {Electron.webContents}
|
||||
* @param webContents {WeContents}
|
||||
*/
|
||||
export const handlePermissionRequests = (
|
||||
webContents: Electron.webContents,
|
||||
): void => {
|
||||
export const handlePermissionRequests = (webContents: WebContents): void => {
|
||||
if (!webContents || !webContents.session) {
|
||||
return;
|
||||
}
|
||||
|
@ -962,9 +962,9 @@ export class WindowHandler {
|
||||
/**
|
||||
* Checks if the window and a key has a window
|
||||
*
|
||||
* @param webContents {Electron.webContents}
|
||||
* @param webContents {WeContents}
|
||||
*/
|
||||
public hasView(webContents: Electron.webContents): boolean {
|
||||
public hasView(webContents: WebContents): boolean {
|
||||
return (
|
||||
webContents === this.mainView?.webContents ||
|
||||
webContents === this.titleBarView?.webContents
|
||||
@ -1370,7 +1370,7 @@ export class WindowHandler {
|
||||
* @param id
|
||||
*/
|
||||
public createScreenPickerWindow(
|
||||
window: Electron.WebContents,
|
||||
window: WebContents,
|
||||
sources: DesktopCapturerSource[],
|
||||
id: number,
|
||||
): void {
|
||||
@ -1612,13 +1612,13 @@ export class WindowHandler {
|
||||
* Creates a screen sharing indicator whenever uses start
|
||||
* sharing the screen
|
||||
*
|
||||
* @param screenSharingWebContents {Electron.webContents}
|
||||
* @param screenSharingWebContents {WeContents}
|
||||
* @param displayId {string} - current display id
|
||||
* @param id {number} - postMessage request id
|
||||
* @param streamId {string} - MediaStream id
|
||||
*/
|
||||
public createScreenSharingIndicatorWindow(
|
||||
screenSharingWebContents: Electron.webContents,
|
||||
screenSharingWebContents: WebContents,
|
||||
displayId: string,
|
||||
id: number,
|
||||
streamId: string,
|
||||
|
@ -322,7 +322,7 @@ export const isValidWindow = (
|
||||
* @return {Boolean} returns true if exists otherwise false
|
||||
* @param webContents
|
||||
*/
|
||||
export const isValidView = (webContents: Electron.webContents): boolean => {
|
||||
export const isValidView = (webContents: WebContents): boolean => {
|
||||
if (!checkValidWindow) {
|
||||
return true;
|
||||
}
|
||||
@ -526,12 +526,12 @@ export const downloadManagerAction = async (type, filePath): Promise<void> => {
|
||||
*
|
||||
* @param _event
|
||||
* @param item {Electron.DownloadItem}
|
||||
* @param webContents {Electron.WebContents}
|
||||
* @param webContents {WeContents}
|
||||
*/
|
||||
export const handleDownloadManager = (
|
||||
_event,
|
||||
item: Electron.DownloadItem,
|
||||
webContents: Electron.WebContents,
|
||||
webContents: WebContents,
|
||||
) => {
|
||||
// Send file path when download is complete
|
||||
item.once('done', (_e, state) => {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { app } from 'electron';
|
||||
import { app, WebContents } from 'electron';
|
||||
import electronLog, { LogLevel, transports } from 'electron-log';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
@ -37,7 +37,7 @@ class Logger {
|
||||
private readonly desiredLogLevel?: LogLevel;
|
||||
private readonly logQueue: ILogMsg[];
|
||||
private readonly logPath: string;
|
||||
private loggerWindow: Electron.WebContents | null;
|
||||
private loggerWindow: WebContents | null;
|
||||
|
||||
constructor() {
|
||||
this.loggerWindow = null;
|
||||
@ -158,7 +158,7 @@ class Logger {
|
||||
*
|
||||
* @param window {WebContents} - renderer window
|
||||
*/
|
||||
public setLoggerWindow(window: Electron.WebContents): void {
|
||||
public setLoggerWindow(window: WebContents): void {
|
||||
this.loggerWindow = window;
|
||||
|
||||
if (this.loggerWindow) {
|
||||
|
@ -7,10 +7,7 @@
|
||||
"jsx": "react",
|
||||
"outDir": "lib",
|
||||
"rootDir": ".",
|
||||
"lib": [
|
||||
"es2016",
|
||||
"dom"
|
||||
],
|
||||
"lib": ["es2016", "dom"],
|
||||
"moduleResolution": "node",
|
||||
"strict": true,
|
||||
"removeComments": false,
|
||||
@ -24,14 +21,8 @@
|
||||
"noUnusedLocals": true,
|
||||
"noImplicitThis": true,
|
||||
"noUnusedParameters": true,
|
||||
"typeRoots": [
|
||||
"node_modules/@types"
|
||||
]
|
||||
"typeRoots": ["node_modules/@types"]
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"lib",
|
||||
"tests",
|
||||
"spec"
|
||||
]
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "lib", "tests", "spec"]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user