From c0f5183330b5a731e1202637bab3d4abc7567251 Mon Sep 17 00:00:00 2001 From: Gareth Dawson Date: Wed, 19 Oct 2022 10:02:26 +0100 Subject: [PATCH] Logs: Add feature tracking to the load more button in log row context (#57079) * add feature tracking for the load more button in log row context * fix test by mocking reportInteraction * track the new log row limit --- .../logs/components/LogRowContextProvider.test.tsx | 5 +++++ .../logs/components/LogRowContextProvider.tsx | 12 +++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/public/app/features/logs/components/LogRowContextProvider.test.tsx b/public/app/features/logs/components/LogRowContextProvider.test.tsx index afdc4a49eb4..27f38f02087 100644 --- a/public/app/features/logs/components/LogRowContextProvider.test.tsx +++ b/public/app/features/logs/components/LogRowContextProvider.test.tsx @@ -8,6 +8,11 @@ import { createLogRow } from './__mocks__/logRow'; const row = createLogRow({ entry: '4', timeEpochMs: 4 }); +jest.mock('@grafana/runtime', () => ({ + ...jest.requireActual('@grafana/runtime'), + reportInteraction: jest.fn(), +})); + describe('getRowContexts', () => { describe('when called with a DataFrame and results are returned', () => { it('then the result should be in correct format and filtered', async () => { diff --git a/public/app/features/logs/components/LogRowContextProvider.tsx b/public/app/features/logs/components/LogRowContextProvider.tsx index 93dd3b705eb..89a37b9ce46 100644 --- a/public/app/features/logs/components/LogRowContextProvider.tsx +++ b/public/app/features/logs/components/LogRowContextProvider.tsx @@ -10,6 +10,7 @@ import { LogsSortOrder, toDataFrame, } from '@grafana/data'; +import { reportInteraction } from '@grafana/runtime'; export interface RowContextOptions { direction?: 'BACKWARD' | 'FORWARD'; @@ -210,7 +211,16 @@ export const LogRowContextProvider: React.FunctionComponent setLimit(limit + 10), + updateLimit: () => { + setLimit(limit + 10); + + const { datasourceType, uid: logRowUid } = row; + reportInteraction('grafana_explore_logs_log_context_load_more_clicked', { + datasourceType, + logRowUid, + newLimit: limit + 10, + }); + }, limit, logsSortOrder, });