diff --git a/public/app/plugins/datasource/loki/components/LokiContextUi.tsx b/public/app/plugins/datasource/loki/components/LokiContextUi.tsx index 33396254e24..0df61348beb 100644 --- a/public/app/plugins/datasource/loki/components/LokiContextUi.tsx +++ b/public/app/plugins/datasource/loki/components/LokiContextUi.tsx @@ -4,6 +4,7 @@ import React, { useEffect, useState } from 'react'; import { useAsync } from 'react-use'; import { GrafanaTheme2, LogRowModel, SelectableValue } from '@grafana/data'; +import { reportInteraction } from '@grafana/runtime'; import { MultiSelect, Tag, Tooltip, useStyles2 } from '@grafana/ui'; import LokiLanguageProvider from '../LanguageProvider'; @@ -102,6 +103,20 @@ export function LokiContextUi(props: LokiContextUiProps) { setInitialized(true); }); + useEffect(() => { + reportInteraction('grafana_explore_logs_loki_log_context_loaded', { + logRowUid: row.uid, + type: 'load', + }); + + return () => { + reportInteraction('grafana_explore_logs_loki_log_context_loaded', { + logRowUid: row.uid, + type: 'unload', + }); + }; + }, [row.uid]); + const realLabels = contextFilters.filter(({ fromParser }) => !fromParser); const realLabelsEnabled = realLabels.filter(({ enabled }) => enabled); @@ -141,7 +156,21 @@ export function LokiContextUi(props: LokiContextUiProps) { maxMenuHeight={200} menuShouldPortal={false} noOptionsMessage="No further labels available" - onChange={(keys) => { + onChange={(keys, actionMeta) => { + if (actionMeta.action === 'select-option') { + reportInteraction('grafana_explore_logs_loki_log_context_filtered', { + logRowUid: row.uid, + type: 'label', + action: 'select', + }); + } + if (actionMeta.action === 'remove-value') { + reportInteraction('grafana_explore_logs_loki_log_context_filtered', { + logRowUid: row.uid, + type: 'label', + action: 'remove', + }); + } return setContextFilters( contextFilters.map((filter) => { if (filter.fromParser) { @@ -167,7 +196,21 @@ export function LokiContextUi(props: LokiContextUiProps) { maxMenuHeight={200} noOptionsMessage="No further labels available" isClearable={true} - onChange={(keys) => { + onChange={(keys, actionMeta) => { + if (actionMeta.action === 'select-option') { + reportInteraction('grafana_explore_logs_loki_log_context_filtered', { + logRowUid: row.uid, + type: 'parsed_label', + action: 'select', + }); + } + if (actionMeta.action === 'remove-value') { + reportInteraction('grafana_explore_logs_loki_log_context_filtered', { + logRowUid: row.uid, + type: 'parsed_label', + action: 'remove', + }); + } setContextFilters( contextFilters.map((filter) => { if (!filter.fromParser) {