Merge branch 'master' into sda-2947

This commit is contained in:
Johan Kwarnmark 2021-02-02 10:52:42 +01:00 committed by GitHub
commit bce80e940c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 1 deletions

View File

@ -1,7 +1,8 @@
export interface IAnalyticsData {
element: AnalyticsElements;
action_type?: MenuActionTypes | ScreenSnippetActionTypes;
action_type?: MenuActionTypes | ScreenSnippetActionTypes | ToastNotificationActionTypes;
action_result?: AnalyticsActions;
extra_data?: object;
}
export interface ICrashData extends IAnalyticsData {
@ -29,6 +30,10 @@ export enum ScreenSnippetActionTypes {
ANNOTATE_ERASED = 'annotate_erased',
}
export enum ToastNotificationActionTypes {
TOAST_CLOSED = 'toast_closed',
}
export enum AnalyticsActions {
ENABLED = 'ON',
DISABLED = 'OFF',
@ -37,6 +42,7 @@ export enum AnalyticsActions {
export enum AnalyticsElements {
MENU = 'Menu',
SCREEN_CAPTURE_ANNOTATE = 'screen_capture_annotate',
TOAST_NOTIFICATION = 'toast_notification',
SDA_CRASH = 'sda_crash',
}

View File

@ -1,5 +1,10 @@
import { app, BrowserWindow, ipcMain } from 'electron';
import {
analytics,
AnalyticsElements,
ToastNotificationActionTypes,
} from '../app/analytics-handler';
import { config } from '../app/config-handler';
import { createComponentWindow, windowExists } from '../app/window-utils';
import { AnimationQueue } from '../common/animation-queue';
@ -73,6 +78,19 @@ class Notification extends NotificationHandler {
constructor(opts) {
super(opts);
ipcMain.on('close-notification', (_event, windowId) => {
const browserWindow = this.getNotificationWindow(windowId);
if (
browserWindow &&
windowExists(browserWindow) &&
browserWindow.notificationData
) {
const notificationData = (browserWindow.notificationData as any).data;
analytics.track({
element: AnalyticsElements.TOAST_NOTIFICATION,
action_type: ToastNotificationActionTypes.TOAST_CLOSED,
extra_data: notificationData || {},
});
}
// removes the event listeners on the client side
this.notificationClosed(windowId);
this.hideNotification(windowId);