diff --git a/.betterer.results b/.betterer.results index d095beac46d..72c8916db6b 100644 --- a/.betterer.results +++ b/.betterer.results @@ -86,7 +86,7 @@ exports[`no enzyme tests`] = { "public/app/features/alerting/TestRuleResult.test.tsx:2358420489": [ [0, 19, 13, "RegExp match", "2409514259"] ], - "public/app/features/dashboard/components/ShareModal/ShareLink.test.tsx:2357087833": [ + "public/app/features/dashboard/components/ShareModal/ShareLink.test.tsx:3716733755": [ [0, 35, 13, "RegExp match", "2409514259"] ], "public/app/features/dashboard/dashgrid/DashboardGrid.test.tsx:2723773538": [ @@ -4886,48 +4886,46 @@ exports[`better eslint`] = { [16, 40, 3, "Unexpected any. Specify a different type.", "193409811"], [30, 18, 3, "Unexpected any. Specify a different type.", "193409811"] ], - "public/app/features/dashboard/components/ShareModal/ShareEmbed.test.tsx:2703340283": [ - [39, 3, 13, "Do not use any type assertions.", "538937261"], - [39, 13, 3, "Unexpected any. Specify a different type.", "193409811"], - [48, 24, 3, "Unexpected any. Specify a different type.", "193409811"], - [54, 22, 55, "Do not use any type assertions.", "2080143574"], - [58, 9, 3, "Unexpected any. Specify a different type.", "193409811"] - ], - "public/app/features/dashboard/components/ShareModal/ShareExport.tsx:3901008754": [ - [51, 67, 3, "Unexpected any. Specify a different type.", "193409811"], - [55, 25, 3, "Unexpected any. Specify a different type.", "193409811"], - [66, 23, 3, "Unexpected any. Specify a different type.", "193409811"], - [81, 67, 3, "Unexpected any. Specify a different type.", "193409811"], - [85, 25, 3, "Unexpected any. Specify a different type.", "193409811"], - [96, 23, 3, "Unexpected any. Specify a different type.", "193409811"], - [105, 28, 3, "Unexpected any. Specify a different type.", "193409811"] - ], - "public/app/features/dashboard/components/ShareModal/ShareLink.test.tsx:2357087833": [ - [33, 3, 13, "Do not use any type assertions.", "538937261"], - [33, 13, 3, "Unexpected any. Specify a different type.", "193409811"], - [42, 3, 13, "Do not use any type assertions.", "538937261"], - [42, 13, 3, "Unexpected any. Specify a different type.", "193409811"], - [76, 15, 3, "Unexpected any. Specify a different type.", "193409811"], - [77, 18, 3, "Unexpected any. Specify a different type.", "193409811"], - [80, 30, 3, "Unexpected any. Specify a different type.", "193409811"], - [81, 21, 3, "Unexpected any. Specify a different type.", "193409811"], - [111, 24, 63, "Do not use any type assertions.", "3674793430"], - [115, 11, 3, "Unexpected any. Specify a different type.", "193409811"], - [197, 24, 3, "Unexpected any. Specify a different type.", "193409811"], - [203, 22, 55, "Do not use any type assertions.", "2080143574"], - [207, 9, 3, "Unexpected any. Specify a different type.", "193409811"] + "public/app/features/dashboard/components/ShareModal/ShareEmbed.test.tsx:1798881678": [ + [41, 3, 13, "Do not use any type assertions.", "538937261"], + [41, 13, 3, "Unexpected any. Specify a different type.", "193409811"], + [50, 24, 3, "Unexpected any. Specify a different type.", "193409811"], + [57, 22, 55, "Do not use any type assertions.", "2080143574"], + [61, 9, 3, "Unexpected any. Specify a different type.", "193409811"] ], - "public/app/features/dashboard/components/ShareModal/ShareModal.tsx:3869940488": [ + "public/app/features/dashboard/components/ShareModal/ShareExport.tsx:1231464422": [ + [55, 67, 3, "Unexpected any. Specify a different type.", "193409811"], + [59, 25, 3, "Unexpected any. Specify a different type.", "193409811"], + [70, 23, 3, "Unexpected any. Specify a different type.", "193409811"], + [85, 67, 3, "Unexpected any. Specify a different type.", "193409811"], + [89, 25, 3, "Unexpected any. Specify a different type.", "193409811"], + [100, 23, 3, "Unexpected any. Specify a different type.", "193409811"], + [109, 28, 3, "Unexpected any. Specify a different type.", "193409811"] + ], + "public/app/features/dashboard/components/ShareModal/ShareLink.test.tsx:3716733755": [ + [43, 3, 13, "Do not use any type assertions.", "538937261"], + [43, 13, 3, "Unexpected any. Specify a different type.", "193409811"], + [77, 15, 3, "Unexpected any. Specify a different type.", "193409811"], + [78, 18, 3, "Unexpected any. Specify a different type.", "193409811"], + [81, 30, 3, "Unexpected any. Specify a different type.", "193409811"], + [82, 21, 3, "Unexpected any. Specify a different type.", "193409811"], + [113, 24, 63, "Do not use any type assertions.", "3674793430"], + [117, 11, 3, "Unexpected any. Specify a different type.", "193409811"], + [199, 24, 3, "Unexpected any. Specify a different type.", "193409811"], + [205, 22, 55, "Do not use any type assertions.", "2080143574"], + [209, 9, 3, "Unexpected any. Specify a different type.", "193409811"] + ], + "public/app/features/dashboard/components/ShareModal/ShareModal.tsx:2780210084": [ [86, 20, 3, "Unexpected any. Specify a different type.", "193409811"] ], - "public/app/features/dashboard/components/ShareModal/SharePublicDashboard.test.tsx:3005912975": [ - [18, 19, 68, "Do not use any type assertions.", "630749985"], - [18, 19, 54, "Do not use any type assertions.", "4291334336"], - [23, 6, 59, "Do not use any type assertions.", "3685154675"], - [23, 6, 49, "Do not use any type assertions.", "1184085652"], - [44, 24, 3, "Unexpected any. Specify a different type.", "193409811"], - [50, 22, 55, "Do not use any type assertions.", "2080143574"], - [54, 9, 3, "Unexpected any. Specify a different type.", "193409811"] + "public/app/features/dashboard/components/ShareModal/SharePublicDashboard.test.tsx:3176925826": [ + [20, 19, 68, "Do not use any type assertions.", "630749985"], + [20, 19, 54, "Do not use any type assertions.", "4291334336"], + [25, 6, 59, "Do not use any type assertions.", "3685154675"], + [25, 6, 49, "Do not use any type assertions.", "1184085652"], + [46, 24, 3, "Unexpected any. Specify a different type.", "193409811"], + [53, 22, 55, "Do not use any type assertions.", "2080143574"], + [57, 9, 3, "Unexpected any. Specify a different type.", "193409811"] ], "public/app/features/dashboard/components/ShareModal/SharePublicDashboardUtils.test.tsx:3549968113": [ [24, 18, 46, "Do not use any type assertions.", "2293567025"], @@ -4935,8 +4933,8 @@ exports[`better eslint`] = { [36, 18, 30, "Do not use any type assertions.", "387012726"], [38, 14, 21, "Do not use any type assertions.", "3316176532"] ], - "public/app/features/dashboard/components/ShareModal/ShareSnapshot.tsx:305910085": [ - [148, 43, 3, "Unexpected any. Specify a different type.", "193409811"] + "public/app/features/dashboard/components/ShareModal/ShareSnapshot.tsx:2987761063": [ + [149, 43, 3, "Unexpected any. Specify a different type.", "193409811"] ], "public/app/features/dashboard/components/ShareModal/utils.test.ts:3192556439": [ [34, 31, 115, "Do not use any type assertions.", "3780428905"], diff --git a/public/app/features/dashboard/components/ShareModal/ShareEmbed.test.tsx b/public/app/features/dashboard/components/ShareModal/ShareEmbed.test.tsx index ac1293a487c..aa81cc1cb33 100644 --- a/public/app/features/dashboard/components/ShareModal/ShareEmbed.test.tsx +++ b/public/app/features/dashboard/components/ShareModal/ShareEmbed.test.tsx @@ -1,8 +1,10 @@ import { render, screen } from '@testing-library/react'; import React from 'react'; +import { setEchoSrv } from '@grafana/runtime/src'; import config from 'app/core/config'; +import { Echo } from '../../../../core/services/echo/Echo'; import { DashboardModel, PanelModel } from '../../state'; import { ShareEmbed } from './ShareEmbed'; @@ -49,6 +51,7 @@ describe('ShareEmbed', () => { let originalBootData: any; beforeAll(() => { + setEchoSrv(new Echo()); originalBootData = config.bootData; config.appUrl = 'http://dashboards.grafana.com/'; diff --git a/public/app/features/dashboard/components/ShareModal/ShareEmbed.tsx b/public/app/features/dashboard/components/ShareModal/ShareEmbed.tsx index 1262ee2dfde..4183e817a16 100644 --- a/public/app/features/dashboard/components/ShareModal/ShareEmbed.tsx +++ b/public/app/features/dashboard/components/ShareModal/ShareEmbed.tsx @@ -1,6 +1,7 @@ import React, { FormEvent, PureComponent } from 'react'; import { AppEvents, SelectableValue } from '@grafana/data'; +import { reportInteraction } from '@grafana/runtime/src'; import { ClipboardButton, Field, Modal, RadioButtonGroup, Switch, TextArea } from '@grafana/ui'; import { appEvents } from 'app/core/core'; @@ -32,6 +33,7 @@ export class ShareEmbed extends PureComponent { } componentDidMount() { + reportInteraction('grafana_dashboards_embed_share_viewed'); this.buildIframeHtml(); } diff --git a/public/app/features/dashboard/components/ShareModal/ShareExport.tsx b/public/app/features/dashboard/components/ShareModal/ShareExport.tsx index 934b233eda1..08cd2cac449 100644 --- a/public/app/features/dashboard/components/ShareModal/ShareExport.tsx +++ b/public/app/features/dashboard/components/ShareModal/ShareExport.tsx @@ -1,7 +1,7 @@ import { saveAs } from 'file-saver'; import React, { PureComponent } from 'react'; -import { config } from '@grafana/runtime'; +import { config, reportInteraction } from '@grafana/runtime'; import { Button, Field, Modal, Switch } from '@grafana/ui'; import { appEvents } from 'app/core/core'; import { getBackendSrv } from 'app/core/services/backend_srv'; @@ -31,6 +31,10 @@ export class ShareExport extends PureComponent { this.exporter = new DashboardExporter(); } + componentDidMount() { + reportInteraction('grafana_dashboards_export_share_viewed'); + } + onShareExternallyChange = () => { this.setState({ shareExternally: !this.state.shareExternally, diff --git a/public/app/features/dashboard/components/ShareModal/ShareLibraryPanel.tsx b/public/app/features/dashboard/components/ShareModal/ShareLibraryPanel.tsx index db91c703b43..59b073448f6 100644 --- a/public/app/features/dashboard/components/ShareModal/ShareLibraryPanel.tsx +++ b/public/app/features/dashboard/components/ShareModal/ShareLibraryPanel.tsx @@ -1,5 +1,6 @@ -import React from 'react'; +import React, { useEffect } from 'react'; +import { reportInteraction } from '@grafana/runtime/src'; import { AddLibraryPanelContents } from 'app/features/library-panels/components/AddLibraryPanelModal/AddLibraryPanelModal'; import { ShareModalTabProps } from './types'; @@ -9,6 +10,10 @@ interface Props extends ShareModalTabProps { } export const ShareLibraryPanel = ({ panel, initialFolderId, onDismiss }: Props) => { + useEffect(() => { + reportInteraction('grafana_dashboards_library_panel_share_viewed'); + }, []); + if (!panel) { return null; } diff --git a/public/app/features/dashboard/components/ShareModal/ShareLink.test.tsx b/public/app/features/dashboard/components/ShareModal/ShareLink.test.tsx index a8c1ac5ea84..c33313bb5c8 100644 --- a/public/app/features/dashboard/components/ShareModal/ShareLink.test.tsx +++ b/public/app/features/dashboard/components/ShareModal/ShareLink.test.tsx @@ -2,10 +2,11 @@ import { shallow, ShallowWrapper } from 'enzyme'; import React from 'react'; import { getDefaultTimeRange } from '@grafana/data'; -import { setTemplateSrv } from '@grafana/runtime'; +import { setEchoSrv, setTemplateSrv } from '@grafana/runtime'; import config from 'app/core/config'; import { initTemplateSrv } from '../../../../../test/helpers/initTemplateSrv'; +import { Echo } from '../../../../core/services/echo/Echo'; import { variableAdapters } from '../../../variables/adapters'; import { createQueryVariableAdapter } from '../../../variables/query/adapter'; import { DashboardModel, PanelModel } from '../../state'; @@ -31,7 +32,7 @@ function mockLocationHref(href: string) { //@ts-ignore delete window.location; - (window as any).location = { + window.location = { ...location, href, origin: new URL(href).origin, @@ -102,6 +103,7 @@ describe('ShareModal', () => { let templateSrv = initTemplateSrv('key', []); beforeAll(() => { + setEchoSrv(new Echo()); variableAdapters.register(createQueryVariableAdapter()); setTemplateSrv(templateSrv); }); diff --git a/public/app/features/dashboard/components/ShareModal/ShareLink.tsx b/public/app/features/dashboard/components/ShareModal/ShareLink.tsx index 0b937f4cf6b..6faf67dc749 100644 --- a/public/app/features/dashboard/components/ShareModal/ShareLink.tsx +++ b/public/app/features/dashboard/components/ShareModal/ShareLink.tsx @@ -2,6 +2,7 @@ import React, { PureComponent } from 'react'; import { AppEvents, SelectableValue } from '@grafana/data'; import { selectors as e2eSelectors } from '@grafana/e2e-selectors'; +import { reportInteraction } from '@grafana/runtime/src'; import { Alert, ClipboardButton, Field, FieldSet, Icon, Input, RadioButtonGroup, Switch } from '@grafana/ui'; import config from 'app/core/config'; import { appEvents } from 'app/core/core'; @@ -38,6 +39,7 @@ export class ShareLink extends PureComponent { } componentDidMount() { + reportInteraction('grafana_dashboards_link_share_viewed'); this.buildUrl(); } diff --git a/public/app/features/dashboard/components/ShareModal/ShareModal.tsx b/public/app/features/dashboard/components/ShareModal/ShareModal.tsx index 49cf5da65de..680dd001428 100644 --- a/public/app/features/dashboard/components/ShareModal/ShareModal.tsx +++ b/public/app/features/dashboard/components/ShareModal/ShareModal.tsx @@ -1,5 +1,6 @@ import React from 'react'; +import { reportInteraction } from '@grafana/runtime/src'; import { Modal, ModalTabsHeader, TabContent } from '@grafana/ui'; import { config } from 'app/core/config'; import { contextSrv } from 'app/core/core'; @@ -79,10 +80,9 @@ export class ShareModal extends React.Component { this.state = getInitialState(props); } - // onDismiss = () => { - // //this.setState(getInitialState(this.props)); - // this.props.onDismiss(); - // }; + componentDidMount() { + reportInteraction('grafana_dashboards_share_modal_viewed'); + } onSelectTab = (t: any) => { this.setState({ activeTab: t.value }); diff --git a/public/app/features/dashboard/components/ShareModal/SharePublicDashboard.test.tsx b/public/app/features/dashboard/components/ShareModal/SharePublicDashboard.test.tsx index b9bb5a4cc15..2fc2e330276 100644 --- a/public/app/features/dashboard/components/ShareModal/SharePublicDashboard.test.tsx +++ b/public/app/features/dashboard/components/ShareModal/SharePublicDashboard.test.tsx @@ -1,10 +1,12 @@ import { fireEvent, render, screen, waitFor } from '@testing-library/react'; import React from 'react'; -import { BackendSrv } from '@grafana/runtime'; +import { BackendSrv, setEchoSrv } from '@grafana/runtime'; import config from 'app/core/config'; import { DashboardModel, PanelModel } from 'app/features/dashboard/state'; +import { Echo } from '../../../../core/services/echo/Echo'; + import { ShareModal } from './ShareModal'; import { PublicDashboard } from './SharePublicDashboardUtils'; @@ -45,6 +47,7 @@ describe('SharePublic', () => { let originalBootData: any; beforeAll(() => { + setEchoSrv(new Echo()); originalBootData = config.bootData; config.appUrl = 'http://dashboards.grafana.com/'; diff --git a/public/app/features/dashboard/components/ShareModal/SharePublicDashboard.tsx b/public/app/features/dashboard/components/ShareModal/SharePublicDashboard.tsx index b00f433c64f..145e659574a 100644 --- a/public/app/features/dashboard/components/ShareModal/SharePublicDashboard.tsx +++ b/public/app/features/dashboard/components/ShareModal/SharePublicDashboard.tsx @@ -1,6 +1,7 @@ import React, { useCallback, useEffect, useState } from 'react'; import { AppEvents } from '@grafana/data'; +import { reportInteraction } from '@grafana/runtime/src'; import { Alert, Button, Checkbox, ClipboardButton, Field, FieldSet, Icon, Input, Switch } from '@grafana/ui'; import { notifyApp } from 'app/core/actions'; import { createErrorNotification } from 'app/core/copy/appNotification'; @@ -39,10 +40,14 @@ export const SharePublicDashboard = (props: Props) => { }); useEffect(() => { + reportInteraction('grafana_dashboards_public_share_viewed'); + getPublicDashboardConfig(props.dashboard.uid, setPublicDashboardConfig).catch(); }, [props.dashboard.uid]); const onSavePublicConfig = () => { + reportInteraction('grafana_dashboards_public_create_clicked'); + if (dashboardHasTemplateVariables(dashboardVariables)) { dispatch( notifyApp(createErrorNotification('This dashboard cannot be made public because it has template variables')) @@ -154,12 +159,16 @@ export const SharePublicDashboard = (props: Props) => { + onChange={() => { + reportInteraction('grafana_dashboards_public_enable_clicked', { + action: publicDashboard?.isEnabled ? 'disable' : 'enable', + }); + setPublicDashboardConfig({ ...publicDashboard, isEnabled: !publicDashboard.isEnabled, - }) - } + }); + }} /> {publicDashboardPersisted(publicDashboard) && publicDashboard.isEnabled && ( diff --git a/public/app/features/dashboard/components/ShareModal/ShareSnapshot.tsx b/public/app/features/dashboard/components/ShareModal/ShareSnapshot.tsx index 15301f46633..2a52ca0483c 100644 --- a/public/app/features/dashboard/components/ShareModal/ShareSnapshot.tsx +++ b/public/app/features/dashboard/components/ShareModal/ShareSnapshot.tsx @@ -56,6 +56,7 @@ export class ShareSnapshot extends PureComponent { } componentDidMount() { + reportInteraction('grafana_dashboards_snapshot_share_viewed'); this.getSnaphotShareOptions(); }