Public Dashboards: adding telemetry for Sharing Modal options and Public Dashboards events (#50834)

* Public Dashboards: adding telemetry for Sharing Modal options and Public Dashboards events
pull/51456/head
Ezequiel Victorero 3 years ago committed by GitHub
parent 120c92b950
commit 99f921cf32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 82
      .betterer.results
  2. 3
      public/app/features/dashboard/components/ShareModal/ShareEmbed.test.tsx
  3. 2
      public/app/features/dashboard/components/ShareModal/ShareEmbed.tsx
  4. 6
      public/app/features/dashboard/components/ShareModal/ShareExport.tsx
  5. 7
      public/app/features/dashboard/components/ShareModal/ShareLibraryPanel.tsx
  6. 6
      public/app/features/dashboard/components/ShareModal/ShareLink.test.tsx
  7. 2
      public/app/features/dashboard/components/ShareModal/ShareLink.tsx
  8. 8
      public/app/features/dashboard/components/ShareModal/ShareModal.tsx
  9. 5
      public/app/features/dashboard/components/ShareModal/SharePublicDashboard.test.tsx
  10. 15
      public/app/features/dashboard/components/ShareModal/SharePublicDashboard.tsx
  11. 1
      public/app/features/dashboard/components/ShareModal/ShareSnapshot.tsx

@ -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"],

@ -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/';

@ -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<Props, State> {
}
componentDidMount() {
reportInteraction('grafana_dashboards_embed_share_viewed');
this.buildIframeHtml();
}

@ -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<Props, State> {
this.exporter = new DashboardExporter();
}
componentDidMount() {
reportInteraction('grafana_dashboards_export_share_viewed');
}
onShareExternallyChange = () => {
this.setState({
shareExternally: !this.state.shareExternally,

@ -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;
}

@ -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);
});

@ -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<Props, State> {
}
componentDidMount() {
reportInteraction('grafana_dashboards_link_share_viewed');
this.buildUrl();
}

@ -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<Props, State> {
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 });

@ -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/';

@ -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) => {
<Switch
disabled={dashboardHasTemplateVariables(dashboardVariables)}
value={publicDashboard?.isEnabled}
onChange={() =>
onChange={() => {
reportInteraction('grafana_dashboards_public_enable_clicked', {
action: publicDashboard?.isEnabled ? 'disable' : 'enable',
});
setPublicDashboardConfig({
...publicDashboard,
isEnabled: !publicDashboard.isEnabled,
})
}
});
}}
/>
</Field>
{publicDashboardPersisted(publicDashboard) && publicDashboard.isEnabled && (

@ -56,6 +56,7 @@ export class ShareSnapshot extends PureComponent<Props, State> {
}
componentDidMount() {
reportInteraction('grafana_dashboards_snapshot_share_viewed');
this.getSnaphotShareOptions();
}

Loading…
Cancel
Save