Skip to content

Commit

Permalink
Add telemetry to opening the timeline drawer
Browse files Browse the repository at this point in the history
  • Loading branch information
Zacqary committed Sep 18, 2020
1 parent 2582007 commit ddf25a2
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import React, { useCallback, useState } from 'react';
import { i18n } from '@kbn/i18n';
import { EuiFlexGroup, EuiFlexItem, EuiButtonEmpty, EuiSpacer } from '@elastic/eui';

import { euiStyled } from '../../../../../../observability/public';
import { euiStyled, useUiTracker } from '../../../../../../observability/public';
import { InfraFormatter } from '../../../../lib/lib';
import { Timeline } from './timeline/timeline';

Expand All @@ -28,7 +28,12 @@ export const BottomDrawer: React.FC<{
}> = ({ measureRef, interval, formatter, children }) => {
const [isOpen, setIsOpen] = useState(false);

const onClick = useCallback(() => setIsOpen(!isOpen), [isOpen]);
const trackDrawerOpen = useUiTracker({ app: 'infra_metrics' });
const onClick = useCallback(() => {
if (!isOpen) trackDrawerOpen({ metric: 'open_timeline_drawer__inventory' });
setIsOpen(!isOpen);
}, [isOpen, trackDrawerOpen]);

return (
<BottomActionContainer ref={isOpen ? measureRef : null} isOpen={isOpen}>
<BottomActionTopBar ref={isOpen ? null : measureRef}>
Expand Down

0 comments on commit ddf25a2

Please sign in to comment.