refactor: replace change in queryAnalytics.ts

This commit is contained in:
Laura Benz
2023-01-10 12:03:41 +01:00
parent fc05dd9b6c
commit a45b83fae3
4 changed files with 8 additions and 7 deletions
+1
View File
@@ -16,6 +16,7 @@ export enum CoreApp {
Unknown = 'unknown',
PanelEditor = 'panel-editor',
PanelViewer = 'panel-viewer',
Correlations = 'correlations',
}
export interface AppRootProps<T extends KeyValue = KeyValue> {
@@ -35,12 +35,12 @@ const renderWithContext = (
};
const initiateDsApi = () => {
const dsApi = new MockDataSourceApi('something');
const dsApi = new MockDataSourceApi('dsApiMock');
dsApi.components = {
QueryEditor: () => <>query editor</>,
};
renderWithContext(<QueryEditorField name="query" dsUid="something" />, async () => {
renderWithContext(<QueryEditorField name="query" dsUid="randomDsUid" />, async () => {
return dsApi;
});
@@ -62,7 +62,7 @@ export const QueryEditorField = ({ dsUid, invalid, error, name }: Props) => {
const transaction: QueryTransaction = {
queries,
request: {
app: CoreApp.Unknown,
app: CoreApp.Correlations,
timezone: 'utc',
startTime: Date.now(),
interval,
@@ -32,8 +32,8 @@ export function emitDataRequestEvent(datasource: DataSourceApi) {
duration: data.request.endTime! - data.request.startTime,
};
if (data.request.app === CoreApp.Explore) {
enrichWithExploreInfo(eventData, data);
if (data.request.app === CoreApp.Explore || data.request.app === CoreApp.Correlations) {
enrichWithInfo(eventData, data);
} else {
enrichWithDashboardInfo(eventData, data);
}
@@ -50,7 +50,7 @@ export function emitDataRequestEvent(datasource: DataSourceApi) {
done = true;
};
function enrichWithExploreInfo(eventData: DataRequestEventPayload, data: PanelData) {
function enrichWithInfo(eventData: DataRequestEventPayload, data: PanelData) {
const totalQueries = Object.keys(data.series).length;
eventData.totalQueries = totalQueries;
}
@@ -71,7 +71,7 @@ export function emitDataRequestEvent(datasource: DataSourceApi) {
eventData.totalQueries = totalQueries;
eventData.cachedQueries = cachedQueries;
const dashboard = getDashboardSrv().dashboard;
const dashboard = getDashboardSrv().getCurrent();
if (dashboard) {
eventData.dashboardId = dashboard.id;
eventData.dashboardName = dashboard.title;