Datasource Plugins: Allow tracking for configuration usage (#72650)

Datasource Plugins: Allow tracking for configuration usage
This commit is contained in:
Sarah Zinger
2023-08-07 08:31:13 -04:00
committed by GitHub
parent 867162b64a
commit 6ac3348021
5 changed files with 139 additions and 41 deletions

View File

@@ -1,15 +1,22 @@
import { DataSourcePluginMeta, DataSourceSettings, locationUtil, TestDataSourceResponse } from '@grafana/data';
import {
DataSourcePluginMeta,
DataSourceSettings,
locationUtil,
TestDataSourceResponse,
DataSourceTestSucceeded,
DataSourceTestFailed,
} from '@grafana/data';
import {
config,
DataSourceSrv,
DataSourceWithBackend,
getDataSourceSrv,
HealthCheckError,
HealthCheckResultDetails,
isFetchError,
locationService,
} from '@grafana/runtime';
import { updateNavIndex } from 'app/core/actions';
import { contextSrv } from 'app/core/core';
import { appEvents, contextSrv } from 'app/core/core';
import { getBackendSrv } from 'app/core/services/backend_srv';
import { ROUTES as CONNECTIONS_ROUTES } from 'app/features/connections/constants';
import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
@@ -53,7 +60,7 @@ export interface InitDataSourceSettingDependencies {
}
export interface TestDataSourceDependencies {
getDatasourceSrv: typeof getDataSourceSrv;
getDatasourceSrv: () => Pick<DataSourceSrv, 'get'>;
getBackendSrv: typeof getBackendSrv;
}
@@ -150,6 +157,7 @@ export const testDataSource = (
success: true,
path: editLink,
});
appEvents.publish(new DataSourceTestSucceeded());
} catch (err) {
const formattedError = parseHealthCheckError(err);
@@ -161,6 +169,7 @@ export const testDataSource = (
success: false,
path: editLink,
});
appEvents.publish(new DataSourceTestFailed());
}
});
};