From a0c4e8b4f412cc37e4af45b057a5e04cfb6d46e2 Mon Sep 17 00:00:00 2001 From: Nathan Marrs Date: Fri, 12 Dec 2025 04:16:55 -0800 Subject: [PATCH] Suggested Dashboards: Add missing loaded event tracking for v1 of feature (#115195) ## Summary Fixes a regression where the `loaded` analytics event was not being tracked for the `BasicProvisionedDashboardsEmptyPage` component, which is the component shown in production when the `suggestedDashboards` feature toggle is disabled (i.e. community dashboards disabled but v1 of feature enabled) ## Problem Regression introduced by https://github.com/grafana/grafana/pull/112808/changes#diff-3a19d2e887a3344cb0bcd2449b570bd50a7d78d1d473f4a3cf623f9fe40f35fc adding community dashboard support to `SuggestedDashboards`, the `BasicProvisionedDashboardsEmptyPage` component was missing the `loaded` event tracking. Component is mounted here: https://github.com/grafana/grafana/pull/112808/changes#diff-fba79ed6f8bfb5f712bdd529155158977a3e081d1d6a5932a5fa90fb57a243e6R82. This caused analytics discrepancies where in the past 7 days (note: issue has been present for last several weeks but here is sample of data from previous week): - 106 provisioned dashboard items were clicked - Only 1 `loaded` event was received (from `SuggestedDashboards` when the feature toggle is enabled) - The `loaded` events are missing for the production v1 flow (when `suggestedDashboards` feature toggle is off) ## Root Cause The `BasicProvisionedDashboardsEmptyPage` component (used in v1 flow in production) was never updated with the `loaded` event tracking that was added to `SuggestedDashboards` in PR #113417. Since the `suggestedDashboards` feature toggle is not enabled in production, users were seeing `BasicProvisionedDashboardsEmptyPage` which had no tracking, resulting in missing analytics events. ## Solution Added the `loaded` event tracking to `BasicProvisionedDashboardsEmptyPage` using the same approach that was previously used (tracking inside the async callback when dashboards are loaded). This ensures consistency with the existing pattern and restores analytics tracking for the production flow. ## Changes - Added `DashboardLibraryInteractions.loaded()` call in `BasicProvisionedDashboardsEmptyPage` when dashboards are successfully loaded - Uses the same tracking pattern as the original implementation (tracking inside async callback) - Matches the event structure used in `SuggestedDashboards` for consistency ## Testing - Verified that `loaded` events are now tracked when `BasicProvisionedDashboardsEmptyPage` loads dashboards - Confirmed the event includes correct `contentKinds`, `datasourceTypes`, and `eventLocation` values - No duplicate events are sent (tracking only occurs once per load) ## Related - Original analytics implementation: #113417 - Related PR: #112808 - Component: [`BasicProvisionedDashboardsEmptyPage.tsx`](https://github.com/grafana/grafana/blob/main/public/app/features/dashboard/dashgrid/DashboardLibrary/BasicProvisionedDashboardsEmptyPage.tsx) --- .../BasicProvisionedDashboardsEmptyPage.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/public/app/features/dashboard/dashgrid/DashboardLibrary/BasicProvisionedDashboardsEmptyPage.tsx b/public/app/features/dashboard/dashgrid/DashboardLibrary/BasicProvisionedDashboardsEmptyPage.tsx index 91ed79019fe..bcfb61ef823 100644 --- a/public/app/features/dashboard/dashgrid/DashboardLibrary/BasicProvisionedDashboardsEmptyPage.tsx +++ b/public/app/features/dashboard/dashgrid/DashboardLibrary/BasicProvisionedDashboardsEmptyPage.tsx @@ -39,6 +39,17 @@ export const BasicProvisionedDashboardsEmptyPage = ({ datasourceUid }: Props) => } const dashboards = await fetchProvisionedDashboards(ds.type); + + if (dashboards.length > 0) { + DashboardLibraryInteractions.loaded({ + numberOfItems: dashboards.length, + contentKinds: [CONTENT_KINDS.DATASOURCE_DASHBOARD], + datasourceTypes: [ds.type], + sourceEntryPoint: SOURCE_ENTRY_POINTS.DATASOURCE_PAGE, + eventLocation: EVENT_LOCATIONS.EMPTY_DASHBOARD, + }); + } + return dashboards; }, [datasourceUid]);