mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* improve typing for DashboardLoadedEvent * cleanup * add cloudwatch tracking event * add test * revert test change * fix typo * remove optional * pr feedback * reactor test * revert changes to api and azure * cleanup * refactoring test * pr feedback
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import { DashboardLoadedEvent } from '@grafana/data';
|
|
let handler: (e: DashboardLoadedEvent<CloudWatchQuery>) => {};
|
|
import { reportInteraction } from '@grafana/runtime';
|
|
|
|
import './module';
|
|
import { CloudWatchDashboardLoadedEvent } from './__mocks__/dashboardOnLoadedEvent';
|
|
import { CloudWatchQuery } from './types';
|
|
|
|
jest.mock('@grafana/runtime', () => {
|
|
return {
|
|
...jest.requireActual('@grafana/runtime'),
|
|
reportInteraction: jest.fn(),
|
|
getAppEvents: () => ({
|
|
subscribe: jest.fn((e, h) => {
|
|
handler = h;
|
|
}),
|
|
}),
|
|
};
|
|
});
|
|
|
|
describe('onDashboardLoadedHandler', () => {
|
|
it('should report a `grafana_ds_cloudwatch_dashboard_loaded` interaction ', () => {
|
|
handler(CloudWatchDashboardLoadedEvent);
|
|
expect(reportInteraction).toHaveBeenCalledWith('grafana_ds_cloudwatch_dashboard_loaded', {
|
|
dashboard_id: 'dashboard123',
|
|
grafana_version: 'v9.0.0',
|
|
org_id: 1,
|
|
logs_queries_count: 1,
|
|
metrics_queries_count: 21,
|
|
metrics_query_builder_count: 3,
|
|
metrics_query_code_count: 4,
|
|
metrics_query_count: 7,
|
|
metrics_search_builder_count: 9,
|
|
metrics_search_code_count: 5,
|
|
metrics_search_count: 14,
|
|
metrics_search_match_exact_count: 9,
|
|
});
|
|
});
|
|
});
|