Merge pull request #1688 from grafana/gareth/add-feature-tracking
track executed queries and panel clicks
This commit is contained in:
@@ -26,6 +26,7 @@ import {
|
||||
toDataFrame,
|
||||
} from '@grafana/data';
|
||||
import { AnnotationQueryEditor } from './components/AnnotationQueryEditor';
|
||||
import { trackRequest } from './tracking';
|
||||
|
||||
export class ZabbixDatasource extends DataSourceApi<ZabbixMetricsQuery, ZabbixDSOptions> {
|
||||
name: string;
|
||||
@@ -113,6 +114,8 @@ export class ZabbixDatasource extends DataSourceApi<ZabbixMetricsQuery, ZabbixDS
|
||||
* @return {Object} Grafana metrics object with timeseries data for each target.
|
||||
*/
|
||||
query(request: DataQueryRequest<ZabbixMetricsQuery>) {
|
||||
trackRequest(request);
|
||||
|
||||
// Migrate old targets
|
||||
const requestTargets = request.targets.map((t) => {
|
||||
// Prevent changes of original object
|
||||
|
||||
@@ -15,6 +15,7 @@ jest.mock(
|
||||
getTemplateSrv: () => ({
|
||||
replace: jest.fn().mockImplementation((query) => query),
|
||||
}),
|
||||
reportInteraction: jest.fn(),
|
||||
}),
|
||||
{ virtual: true }
|
||||
);
|
||||
|
||||
46
src/datasource/tracking.ts
Normal file
46
src/datasource/tracking.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { DataQueryRequest } from '@grafana/data';
|
||||
import { ZabbixMetricsQuery } from './types';
|
||||
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 => {
|
||||
request.targets.forEach((target) => {
|
||||
const properties: any = {
|
||||
app: request.app,
|
||||
};
|
||||
|
||||
switch (target.queryType) {
|
||||
case MODE_METRICS:
|
||||
properties.queryType = 'Metrics';
|
||||
break;
|
||||
case MODE_ITSERVICE:
|
||||
properties.queryType = 'Services';
|
||||
break;
|
||||
case MODE_TEXT:
|
||||
properties.queryType = 'Text';
|
||||
break;
|
||||
case MODE_ITEMID:
|
||||
properties.queryType = 'Item Id';
|
||||
break;
|
||||
case MODE_TRIGGERS:
|
||||
properties.queryType = 'Triggers';
|
||||
break;
|
||||
case MODE_PROBLEMS:
|
||||
properties.queryType = 'Problems';
|
||||
break;
|
||||
case MODE_MACROS:
|
||||
properties.queryType = 'Macros';
|
||||
break;
|
||||
}
|
||||
|
||||
reportInteraction('grafana_zabbix_query_executed', properties);
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user