mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Datasources: Extend properties for the datasource-test tracking event (#62292)
chore: extend properties for the test datasource tracking event
This commit is contained in:
@@ -72,7 +72,7 @@ const failDataSourceTest = async (error: object) => {
|
||||
};
|
||||
const dispatchedActions = await thunkTester(state)
|
||||
.givenThunk(testDataSource)
|
||||
.whenThunkIsDispatched('Azure Monitor', dependencies);
|
||||
.whenThunkIsDispatched('Azure Monitor', DATASOURCES_ROUTES.Edit, dependencies);
|
||||
|
||||
return dispatchedActions;
|
||||
};
|
||||
@@ -234,7 +234,7 @@ describe('testDataSource', () => {
|
||||
};
|
||||
const dispatchedActions = await thunkTester(state)
|
||||
.givenThunk(testDataSource)
|
||||
.whenThunkIsDispatched('CloudWatch', dependencies);
|
||||
.whenThunkIsDispatched('CloudWatch', DATASOURCES_ROUTES.Edit, dependencies);
|
||||
|
||||
expect(dispatchedActions).toEqual([testDataSourceStarting(), testDataSourceSucceeded(state.testingStatus)]);
|
||||
expect(trackDataSourceTested).toHaveBeenCalledWith({
|
||||
@@ -242,6 +242,7 @@ describe('testDataSource', () => {
|
||||
datasource_uid: 'CW1234',
|
||||
grafana_version: '1.0',
|
||||
success: true,
|
||||
editLink: '/datasources/edit/CloudWatch',
|
||||
});
|
||||
});
|
||||
|
||||
@@ -270,7 +271,7 @@ describe('testDataSource', () => {
|
||||
};
|
||||
const dispatchedActions = await thunkTester(state)
|
||||
.givenThunk(testDataSource)
|
||||
.whenThunkIsDispatched('Azure Monitor', dependencies);
|
||||
.whenThunkIsDispatched('Azure Monitor', DATASOURCES_ROUTES.Edit, dependencies);
|
||||
|
||||
expect(dispatchedActions).toEqual([testDataSourceStarting(), testDataSourceFailed(result)]);
|
||||
expect(trackDataSourceTested).toHaveBeenCalledWith({
|
||||
@@ -278,6 +279,7 @@ describe('testDataSource', () => {
|
||||
datasource_uid: 'azM0nit0R',
|
||||
grafana_version: '1.0',
|
||||
success: false,
|
||||
editLink: '/datasources/edit/Azure Monitor',
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -90,6 +90,7 @@ export const initDataSourceSettings = (
|
||||
|
||||
export const testDataSource = (
|
||||
dataSourceName: string,
|
||||
editRoute = DATASOURCES_ROUTES.Edit,
|
||||
dependencies: TestDataSourceDependencies = {
|
||||
getDatasourceSrv,
|
||||
getBackendSrv,
|
||||
@@ -97,6 +98,7 @@ export const testDataSource = (
|
||||
): ThunkResult<void> => {
|
||||
return async (dispatch: ThunkDispatch, getState) => {
|
||||
const dsApi = await dependencies.getDatasourceSrv().get(dataSourceName);
|
||||
const editLink = editRoute.replace(/:uid/gi, dataSourceName);
|
||||
|
||||
if (!dsApi.testDatasource) {
|
||||
return;
|
||||
@@ -114,6 +116,7 @@ export const testDataSource = (
|
||||
plugin_id: dsApi.type,
|
||||
datasource_uid: dsApi.uid,
|
||||
success: true,
|
||||
editLink,
|
||||
});
|
||||
} catch (err) {
|
||||
let message: string | undefined;
|
||||
@@ -134,6 +137,7 @@ export const testDataSource = (
|
||||
plugin_id: dsApi.type,
|
||||
datasource_uid: dsApi.uid,
|
||||
success: false,
|
||||
editLink,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -43,8 +43,9 @@ export const useInitDataSourceSettings = (uid: string) => {
|
||||
|
||||
export const useTestDataSource = (uid: string) => {
|
||||
const dispatch = useDispatch();
|
||||
const dataSourcesRoutes = useDataSourcesRoutes();
|
||||
|
||||
return () => dispatch(testDataSource(uid));
|
||||
return () => dispatch(testDataSource(uid, dataSourcesRoutes.Edit));
|
||||
};
|
||||
|
||||
export const useLoadDataSources = () => {
|
||||
|
||||
@@ -53,4 +53,6 @@ type DataSourceTestedProps = {
|
||||
plugin_version?: string;
|
||||
/** Whether or not the datasource test succeeded = the datasource was successfully configured */
|
||||
success: boolean;
|
||||
/** The URL that points to the edit page for the datasoruce. We are using this to be able to distinguish between the performance of different datasource edit locations. */
|
||||
editLink?: string;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user