Track user actions in the SIEM app (#36675) (#36760)

* Track user actions in the SIEM app

For now, we're tracking:

* Top navigation changes (`tab_X`)
* Opening a timeline (`open_timeline`)

* added type

* This seems to solve the 'yarn run build' issue

* Addressed comments

* Use the APP_ID from the top level
This commit is contained in:
Tudor Golubenco 2019-05-21 15:19:43 +02:00 committed by GitHub
parent 3bc571e22a
commit e7ec433db3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 2 deletions

View file

@ -10,7 +10,7 @@ import { Server } from 'hapi';
import { getConfigSchema, initServerWithKibana } from './server/kibana.index';
const APP_ID = 'siem';
export const APP_ID = 'siem';
export const APP_NAME = 'SIEM';
// eslint-disable-next-line @typescript-eslint/no-explicit-any

View file

@ -19,6 +19,7 @@ import { FlyoutButton } from './button';
import { Pane } from './pane';
import { timelineActions } from '../../store/actions';
import { DEFAULT_TIMELINE_WIDTH } from '../timeline/body/helpers';
import { trackUiAction as track } from '../../lib/track_usage';
/** The height in pixels of the flyout header, exported for use in height calculations */
export const flyoutHeaderHeight: number = 48;
@ -100,7 +101,10 @@ export const FlyoutComponent = pure<Props>(
dataProviders={dataProviders!}
show={!show}
timelineId={timelineId}
onOpen={() => showTimeline!({ id: timelineId, show: true })}
onOpen={() => {
track('open_timeline');
showTimeline!({ id: timelineId, show: true });
}}
/>
</>
)

View file

@ -7,6 +7,7 @@ import { EuiTab, EuiTabs } from '@elastic/eui';
import * as React from 'react';
import { getHostsUrl, getNetworkUrl, getOverviewUrl, getTimelinesUrl } from '../../link_to';
import { trackUiAction as track } from '../../../lib/track_usage';
import * as i18n from '../translations';
@ -89,6 +90,7 @@ export class TabNavigation extends React.PureComponent<TabNavigationProps, TabNa
...this.state,
selectedTabId: id,
});
track(`tab_${id}`);
window.location.assign(href);
};

View file

@ -0,0 +1,11 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
// @ts-ignore
import { trackUiMetric } from '../../../../../../src/legacy/core_plugins/ui_metric/public';
import { APP_ID } from '../../..';
export const trackUiAction = (metricType: string) => trackUiMetric(APP_ID, metricType);