only report basic usage

This commit is contained in:
Gareth Dawson
2023-09-28 10:04:07 +01:00
parent fd616b6446
commit ac91cb4320

View File

@@ -1,6 +1,15 @@
import { DataQueryRequest } from '@grafana/data'; import { DataQueryRequest } from '@grafana/data';
import { ZabbixMetricsQuery } from './types'; import { ZabbixMetricsQuery } from './types';
import { reportInteraction } from '@grafana/runtime'; import { reportInteraction } from '@grafana/runtime';
import {
MODE_ITEMID,
MODE_ITSERVICE,
MODE_MACROS,
MODE_METRICS,
MODE_PROBLEMS,
MODE_TEXT,
MODE_TRIGGERS,
} from './constants';
export const trackRequest = (request: DataQueryRequest<ZabbixMetricsQuery>): void => { export const trackRequest = (request: DataQueryRequest<ZabbixMetricsQuery>): void => {
request.targets.forEach((target) => { request.targets.forEach((target) => {
@@ -9,54 +18,26 @@ export const trackRequest = (request: DataQueryRequest<ZabbixMetricsQuery>): voi
}; };
switch (target.queryType) { switch (target.queryType) {
case '0': case MODE_METRICS:
case '1': properties.queryType = 'Metrics';
case '3':
if (target.queryType === '0') {
properties.queryType = 'Metrics';
} else if (target.queryType === '1') {
properties.queryType = 'Services';
} else if (target.queryType === '3') {
properties.queryType = 'Item Id';
}
properties.trends = target.options.useTrends;
properties.showDisabledItems = target.options.showDisabledItems;
properties.useZabbixValueMapping = target.options.useZabbixValueMapping;
properties.disableDataAlignment = target.options.disableDataAlignment;
break; break;
case '2': case MODE_ITSERVICE:
properties.queryType = 'Services';
break;
case MODE_TEXT:
properties.queryType = 'Text'; properties.queryType = 'Text';
properties.showDisabledItems = target.options.showDisabledItems;
break; break;
case '4': case MODE_ITEMID:
properties.queryType = 'Item Id';
break;
case MODE_TRIGGERS:
properties.queryType = 'Triggers'; properties.queryType = 'Triggers';
if (target.options.acknowledged === 0) {
properties.acknowledged = 'unacknowledged';
} else if (target.options.acknowledged === 1) {
properties.acknowledged = 'acknowledged';
} else if (target.options.acknowledged === 2) {
properties.acknowledged = 'all triggers';
}
properties.useTimeRange = target.options.useTimeRange ?? false;
break; break;
case '5': case MODE_PROBLEMS:
properties.queryType = 'Problems'; properties.queryType = 'Problems';
break;
if (target.options.acknowledged === 0) { case MODE_MACROS:
properties.acknowledged = 'unacknowledged'; properties.queryType = 'Macros';
} else if (target.options.acknowledged === 1) {
properties.acknowledged = 'acknowledged';
} else if (target.options.acknowledged === 2) {
properties.acknowledged = 'all triggers';
}
properties.sortProblems = target.options.sortProblems;
properties.useTimeRange = target.options.useTimeRange;
properties.hostsInMaintenance = target.options.hostsInMaintenance;
properties.hostProxy = target.options.hostProxy;
properties.limit = target.options.limit;
break; break;
} }