mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Dashboard: Add feature reporting for dashboard import (#46080)
* Add feature reporting for dashboard import * Update tracking event names
This commit is contained in:
@@ -3,6 +3,7 @@ import { connect, ConnectedProps } from 'react-redux';
|
|||||||
import { css } from '@emotion/css';
|
import { css } from '@emotion/css';
|
||||||
import { AppEvents, GrafanaTheme2, LoadingState } from '@grafana/data';
|
import { AppEvents, GrafanaTheme2, LoadingState } from '@grafana/data';
|
||||||
import { selectors } from '@grafana/e2e-selectors';
|
import { selectors } from '@grafana/e2e-selectors';
|
||||||
|
import { reportInteraction } from '@grafana/runtime';
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Field,
|
Field,
|
||||||
@@ -33,6 +34,8 @@ type DashboardImportPageRouteSearchParams = {
|
|||||||
|
|
||||||
type OwnProps = Themeable2 & GrafanaRouteComponentProps<{}, DashboardImportPageRouteSearchParams>;
|
type OwnProps = Themeable2 & GrafanaRouteComponentProps<{}, DashboardImportPageRouteSearchParams>;
|
||||||
|
|
||||||
|
const IMPORT_STARTED_EVENT_NAME = 'dashboard_import_loaded';
|
||||||
|
|
||||||
const mapStateToProps = (state: StoreState) => ({
|
const mapStateToProps = (state: StoreState) => ({
|
||||||
navModel: getNavModel(state.navIndex, 'import', undefined, true),
|
navModel: getNavModel(state.navIndex, 'import', undefined, true),
|
||||||
loadingState: state.importDashboard.state,
|
loadingState: state.importDashboard.state,
|
||||||
@@ -63,6 +66,10 @@ class UnthemedDashboardImport extends PureComponent<Props> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onFileUpload = (event: FormEvent<HTMLInputElement>) => {
|
onFileUpload = (event: FormEvent<HTMLInputElement>) => {
|
||||||
|
reportInteraction(IMPORT_STARTED_EVENT_NAME, {
|
||||||
|
import_source: 'json_uploaded',
|
||||||
|
});
|
||||||
|
|
||||||
const { importDashboardJson } = this.props;
|
const { importDashboardJson } = this.props;
|
||||||
const file = event.currentTarget.files && event.currentTarget.files.length > 0 && event.currentTarget.files[0];
|
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 }) => {
|
getDashboardFromJson = (formData: { dashboardJson: string }) => {
|
||||||
|
reportInteraction(IMPORT_STARTED_EVENT_NAME, {
|
||||||
|
import_source: 'json_pasted',
|
||||||
|
});
|
||||||
|
|
||||||
this.props.importDashboardJson(JSON.parse(formData.dashboardJson));
|
this.props.importDashboardJson(JSON.parse(formData.dashboardJson));
|
||||||
};
|
};
|
||||||
|
|
||||||
getGcomDashboard = (formData: { gcomDashboard: string }) => {
|
getGcomDashboard = (formData: { gcomDashboard: string }) => {
|
||||||
|
reportInteraction(IMPORT_STARTED_EVENT_NAME, {
|
||||||
|
import_source: 'gcom',
|
||||||
|
});
|
||||||
|
|
||||||
let dashboardId;
|
let dashboardId;
|
||||||
const match = /(^\d+$)|dashboards\/(\d+)/.exec(formData.gcomDashboard);
|
const match = /(^\d+$)|dashboards\/(\d+)/.exec(formData.gcomDashboard);
|
||||||
if (match && match[1]) {
|
if (match && match[1]) {
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ import { ImportDashboardForm } from './ImportDashboardForm';
|
|||||||
import { clearLoadedDashboard, importDashboard } from '../state/actions';
|
import { clearLoadedDashboard, importDashboard } from '../state/actions';
|
||||||
import { DashboardSource, ImportDashboardDTO } from '../state/reducers';
|
import { DashboardSource, ImportDashboardDTO } from '../state/reducers';
|
||||||
import { StoreState } from 'app/types';
|
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 mapStateToProps = (state: StoreState) => {
|
||||||
const searchObj = locationService.getSearchObject();
|
const searchObj = locationService.getSearchObject();
|
||||||
@@ -39,6 +41,8 @@ class ImportDashboardOverviewUnConnected extends PureComponent<Props, State> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onSubmit = (form: ImportDashboardDTO) => {
|
onSubmit = (form: ImportDashboardDTO) => {
|
||||||
|
reportInteraction(IMPORT_FINISHED_EVENT_NAME);
|
||||||
|
|
||||||
this.props.importDashboard(form);
|
this.props.importDashboard(form);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user