Plugins: Added hook to make it easier to track interactions in plugins (#56126)

* first stab at context away plugin tracking.

* adding a plugin context and a hook to get hold of a tracker that always appends the plugin context information.

* wip

* improved the code a bit.

* wip

* Fixed type errors.

* added datasource_uid to data sources.

* fixed error message when trying to use hook outside of context.

* small refactoring according to feedback.

* using the correct provider for data source context.

* check not needed.

* enforcing the interaction name to start with grafana_plugin_

* exposing guards for the other context type.

* added structure for writing reporter hook tests.

* added some more tests.

* added tests.

* reverted back to inheritance between context types.

* adding mock for getDataSourceSrv
This commit is contained in:
Marcus Andersson
2022-11-02 16:57:57 +01:00
committed by GitHub
parent 932429a545
commit b804b2f073
27 changed files with 591 additions and 104 deletions

View File

@@ -13,7 +13,7 @@ import {
} from './types';
import { filterMetricsQuery } from './utils/utils';
interface CloudWatchOnDashboardLoadedTrackingEvent {
type CloudWatchOnDashboardLoadedTrackingEvent = {
grafana_version?: string;
dashboard_id?: string;
org_id?: number;
@@ -52,7 +52,7 @@ interface CloudWatchOnDashboardLoadedTrackingEvent {
/* The number of "Insights" queries that are using the code mode.
Should be measured in relation to metrics_query_count, e.g metrics_query_builder_count + metrics_query_code_count = metrics_query_count */
metrics_query_code_count: number;
}
};
export const onDashboardLoadedHandler = ({
payload: { dashboardId, orgId, grafanaVersion, queries },