Dashboard: Add feature reporting for dashboard import (#46080)

* Add feature reporting for dashboard import

* Update tracking event names
This commit is contained in:
Ashley Harrison 2022-03-02 14:35:52 +00:00 committed by GitHub
parent e738896316
commit 3427ae463d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View File

@ -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<Props> {
}
onFileUpload = (event: FormEvent<HTMLInputElement>) => {
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<Props> {
};
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]) {

View File

@ -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<Props, State> {
};
onSubmit = (form: ImportDashboardDTO) => {
reportInteraction(IMPORT_FINISHED_EVENT_NAME);
this.props.importDashboard(form);
};