From bec2878fe4c9c2d9a52fa417f07e0c023a46c9a2 Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Wed, 2 Mar 2022 10:03:42 -0500 Subject: [PATCH] Dashboard: Add feature reporting for dashboard import (#46080) (#46099) * Add feature reporting for dashboard import * Update tracking event names (cherry picked from commit 3427ae463dfd73d2e8e335b4a0772aa74ca8c979) Co-authored-by: Ashley Harrison --- .../manage-dashboards/DashboardImportPage.tsx | 15 +++++++++++++++ .../components/ImportDashboardOverview.tsx | 6 +++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/public/app/features/manage-dashboards/DashboardImportPage.tsx b/public/app/features/manage-dashboards/DashboardImportPage.tsx index a8744ae3291..378b9fe4cc5 100644 --- a/public/app/features/manage-dashboards/DashboardImportPage.tsx +++ b/public/app/features/manage-dashboards/DashboardImportPage.tsx @@ -3,6 +3,7 @@ import { connect, ConnectedProps } from 'react-redux'; import { css } from '@emotion/css'; import { AppEvents, GrafanaTheme2, LoadingState } from '@grafana/data'; import { selectors } from '@grafana/e2e-selectors'; +import { reportInteraction } from '@grafana/runtime'; import { Button, Field, @@ -33,6 +34,8 @@ type DashboardImportPageRouteSearchParams = { type OwnProps = Themeable2 & GrafanaRouteComponentProps<{}, DashboardImportPageRouteSearchParams>; +const IMPORT_STARTED_EVENT_NAME = 'dashboard_import_loaded'; + const mapStateToProps = (state: StoreState) => ({ navModel: getNavModel(state.navIndex, 'import', undefined, true), loadingState: state.importDashboard.state, @@ -63,6 +66,10 @@ class UnthemedDashboardImport extends PureComponent { } onFileUpload = (event: FormEvent) => { + reportInteraction(IMPORT_STARTED_EVENT_NAME, { + import_source: 'json_uploaded', + }); + const { importDashboardJson } = this.props; const file = event.currentTarget.files && event.currentTarget.files.length > 0 && event.currentTarget.files[0]; @@ -89,10 +96,18 @@ class UnthemedDashboardImport extends PureComponent { }; getDashboardFromJson = (formData: { dashboardJson: string }) => { + reportInteraction(IMPORT_STARTED_EVENT_NAME, { + import_source: 'json_pasted', + }); + this.props.importDashboardJson(JSON.parse(formData.dashboardJson)); }; getGcomDashboard = (formData: { gcomDashboard: string }) => { + reportInteraction(IMPORT_STARTED_EVENT_NAME, { + import_source: 'gcom', + }); + let dashboardId; const match = /(^\d+$)|dashboards\/(\d+)/.exec(formData.gcomDashboard); if (match && match[1]) { diff --git a/public/app/features/manage-dashboards/components/ImportDashboardOverview.tsx b/public/app/features/manage-dashboards/components/ImportDashboardOverview.tsx index c94f75c5b5b..275a12d18ac 100644 --- a/public/app/features/manage-dashboards/components/ImportDashboardOverview.tsx +++ b/public/app/features/manage-dashboards/components/ImportDashboardOverview.tsx @@ -6,7 +6,9 @@ import { ImportDashboardForm } from './ImportDashboardForm'; import { clearLoadedDashboard, importDashboard } from '../state/actions'; import { DashboardSource, ImportDashboardDTO } from '../state/reducers'; import { StoreState } from 'app/types'; -import { locationService } from '@grafana/runtime'; +import { locationService, reportInteraction } from '@grafana/runtime'; + +const IMPORT_FINISHED_EVENT_NAME = 'dashboard_import_imported'; const mapStateToProps = (state: StoreState) => { const searchObj = locationService.getSearchObject(); @@ -39,6 +41,8 @@ class ImportDashboardOverviewUnConnected extends PureComponent { }; onSubmit = (form: ImportDashboardDTO) => { + reportInteraction(IMPORT_FINISHED_EVENT_NAME); + this.props.importDashboard(form); };