LokiContext: Add feature tracking (#62344)

* add feature tracking to LokiContextUi

* only depend on `row.uid`

Co-authored-by: Gábor Farkas <gabor.farkas@gmail.com>

---------

Co-authored-by: Gábor Farkas <gabor.farkas@gmail.com>
This commit is contained in:
Sven Grossmann 2023-01-30 11:30:39 +01:00 committed by GitHub
parent 38d7168921
commit d7026900bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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) {