From bd56b47bb5c9ac1e26726f478d42534d466629b1 Mon Sep 17 00:00:00 2001 From: Sriram <153843+yesoreyeram@users.noreply.github.com> Date: Tue, 19 Nov 2024 08:47:46 +0000 Subject: [PATCH] Datasources: Health check error tracking (#96629) * datasource health check error tracking * type fix --- .../src/utils/DataSourceWithBackend.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/grafana-runtime/src/utils/DataSourceWithBackend.ts b/packages/grafana-runtime/src/utils/DataSourceWithBackend.ts index 04d7293bab8..2ce4b88e85f 100644 --- a/packages/grafana-runtime/src/utils/DataSourceWithBackend.ts +++ b/packages/grafana-runtime/src/utils/DataSourceWithBackend.ts @@ -19,6 +19,7 @@ import { AdHocVariableFilter, } from '@grafana/data'; +import { reportInteraction } from '../analytics/utils'; import { config } from '../config'; import { BackendSrvRequest, @@ -355,8 +356,17 @@ class DataSourceWithBackend< headers: this.getRequestHeaders(), }) ) - .then((v: FetchResponse) => v.data) - .catch((err) => err.data); + .then((v: FetchResponse) => v.data) + .catch((err) => { + let properties: Record = { + plugin_id: this.meta?.id || '', + plugin_version: this.meta?.info?.version || '', + datasource_healthcheck_status: err?.data?.status || 'error', + datasource_healthcheck_message: err?.data?.message || '', + }; + reportInteraction('datasource_health_check_completed', properties); + return err.data; + }); } /**