diff --git a/public/app/plugins/datasource/loki/components/LokiLabelBrowser.tsx b/public/app/plugins/datasource/loki/components/LokiLabelBrowser.tsx index 2fd67e7169a..c89734d7b62 100644 --- a/public/app/plugins/datasource/loki/components/LokiLabelBrowser.tsx +++ b/public/app/plugins/datasource/loki/components/LokiLabelBrowser.tsx @@ -187,7 +187,7 @@ export class UnthemedLokiLabelBrowser extends React.Component { - reportInteraction('grafana_loki_log_browser_closed', { + reportInteraction('grafana_loki_label_browser_closed', { app: this.props.app, closeType: 'showLogsButton', }); @@ -196,7 +196,7 @@ export class UnthemedLokiLabelBrowser extends React.Component { - reportInteraction('grafana_loki_log_browser_closed', { + reportInteraction('grafana_loki_label_browser_closed', { app: this.props.app, closeType: 'showLogsRateButton', }); @@ -206,10 +206,6 @@ export class UnthemedLokiLabelBrowser extends React.Component { - reportInteraction('grafana_loki_log_browser_closed', { - app: this.props.app, - closeType: 'clearButton', - }); this.setState((state) => { const labels: SelectableLabel[] = state.labels.map((label) => ({ ...label, diff --git a/public/app/plugins/datasource/loki/components/LokiQueryEditor.tsx b/public/app/plugins/datasource/loki/components/LokiQueryEditor.tsx index 04ca1cbba03..36ac3174b7f 100644 --- a/public/app/plugins/datasource/loki/components/LokiQueryEditor.tsx +++ b/public/app/plugins/datasource/loki/components/LokiQueryEditor.tsx @@ -73,6 +73,10 @@ export const LokiQueryEditor = React.memo((props) => { }; const onClickLabelBrowserButton = () => { + reportInteraction('grafana_loki_label_browser_opened', { + app: app, + }); + setLabelBrowserVisible((visible) => !visible); }; diff --git a/public/app/plugins/datasource/loki/components/LokiQueryField.tsx b/public/app/plugins/datasource/loki/components/LokiQueryField.tsx index 9ec7354f88d..f1ea5d4a399 100644 --- a/public/app/plugins/datasource/loki/components/LokiQueryField.tsx +++ b/public/app/plugins/datasource/loki/components/LokiQueryField.tsx @@ -4,7 +4,7 @@ import { Plugin, Node } from 'slate'; import { Editor } from 'slate-react'; import { CoreApp, QueryEditorProps } from '@grafana/data'; -import { config, reportInteraction } from '@grafana/runtime'; +import { config } from '@grafana/runtime'; import { SlatePrism, TypeaheadOutput, @@ -135,20 +135,6 @@ export class LokiQueryField extends React.PureComponent { - if (!this.state.labelBrowserVisible) { - reportInteraction('grafana_loki_log_browser_opened', { - app: this.props.app, - }); - } else { - reportInteraction('grafana_loki_log_browser_closed', { - app: this.props.app, - closeType: 'logBrowserButton', - }); - } - this.setState((state) => ({ labelBrowserVisible: !state.labelBrowserVisible })); - }; - onTypeahead = async (typeahead: TypeaheadInput): Promise => { const { datasource } = this.props; diff --git a/public/app/plugins/datasource/loki/querybuilder/components/LabelBrowserModal.tsx b/public/app/plugins/datasource/loki/querybuilder/components/LabelBrowserModal.tsx index 7e86717196d..beba91e8255 100644 --- a/public/app/plugins/datasource/loki/querybuilder/components/LabelBrowserModal.tsx +++ b/public/app/plugins/datasource/loki/querybuilder/components/LabelBrowserModal.tsx @@ -1,6 +1,7 @@ import React, { useState, useEffect } from 'react'; import { CoreApp } from '@grafana/data'; +import { reportInteraction } from '@grafana/runtime'; import { LoadingPlaceholder, Modal } from '@grafana/ui'; import { LocalStorageValueProvider } from 'app/core/components/LocalStorageValueProvider'; @@ -47,8 +48,16 @@ export const LabelBrowserModal = (props: Props) => { onClose(); }; + const reportInteractionAndClose = () => { + reportInteraction('grafana_loki_label_browser_closed', { + app, + closeType: 'modalClose', + }); + onClose(); + }; + return ( - + {!labelsLoaded && } {labelsLoaded && !hasLogLabels &&

No labels found.

} {labelsLoaded && hasLogLabels && (