chore(dashboard): Log events for download as image (#22793)

This commit is contained in:
JUST.in DO IT 2023-01-20 07:59:50 -08:00 committed by GitHub
parent b9686fe6fa
commit 83893f8ff2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 22 additions and 0 deletions

View File

@ -68,6 +68,7 @@ const createProps = () => ({
lastModifiedTime: 0, lastModifiedTime: 0,
isDropdownVisible: true, isDropdownVisible: true,
dataMask: {}, dataMask: {},
logEvent: jest.fn(),
}); });
const editModeOnProps = { const editModeOnProps = {
...createProps(), ...createProps(),

View File

@ -36,6 +36,7 @@ import getDashboardUrl from 'src/dashboard/util/getDashboardUrl';
import { getActiveFilters } from 'src/dashboard/util/activeDashboardFilters'; import { getActiveFilters } from 'src/dashboard/util/activeDashboardFilters';
import { getUrlParam } from 'src/utils/urlUtils'; import { getUrlParam } from 'src/utils/urlUtils';
import { FILTER_BOX_MIGRATION_STATES } from 'src/explore/constants'; import { FILTER_BOX_MIGRATION_STATES } from 'src/explore/constants';
import { LOG_ACTIONS_DASHBOARD_DOWNLOAD_AS_IMAGE } from 'src/logger/LogUtils';
const propTypes = { const propTypes = {
addSuccessToast: PropTypes.func.isRequired, addSuccessToast: PropTypes.func.isRequired,
@ -65,6 +66,7 @@ const propTypes = {
onSave: PropTypes.func.isRequired, onSave: PropTypes.func.isRequired,
showPropertiesModal: PropTypes.func.isRequired, showPropertiesModal: PropTypes.func.isRequired,
manageEmbedded: PropTypes.func.isRequired, manageEmbedded: PropTypes.func.isRequired,
logEvent: PropTypes.func,
refreshLimit: PropTypes.number, refreshLimit: PropTypes.number,
refreshWarning: PropTypes.string, refreshWarning: PropTypes.string,
lastModifiedTime: PropTypes.number.isRequired, lastModifiedTime: PropTypes.number.isRequired,
@ -182,6 +184,7 @@ class HeaderActionsDropdown extends React.PureComponent {
)(domEvent).then(() => { )(domEvent).then(() => {
menu.style.visibility = 'visible'; menu.style.visibility = 'visible';
}); });
this.props.logEvent?.(LOG_ACTIONS_DASHBOARD_DOWNLOAD_AS_IMAGE);
break; break;
} }
case MENU_KEYS.TOGGLE_FULLSCREEN: { case MENU_KEYS.TOGGLE_FULLSCREEN: {

View File

@ -464,6 +464,7 @@ class Header extends React.PureComponent {
setRefreshFrequency, setRefreshFrequency,
lastModifiedTime, lastModifiedTime,
filterboxMigrationState, filterboxMigrationState,
logEvent,
} = this.props; } = this.props;
const userCanEdit = const userCanEdit =
@ -679,6 +680,7 @@ class Header extends React.PureComponent {
filterboxMigrationState={filterboxMigrationState} filterboxMigrationState={filterboxMigrationState}
isDropdownVisible={this.state.isDropdownVisible} isDropdownVisible={this.state.isDropdownVisible}
setIsDropdownVisible={this.setIsDropdownVisible} setIsDropdownVisible={this.setIsDropdownVisible}
logEvent={logEvent}
/> />
} }
showFaveStar={user?.userId && dashboardInfo?.id} showFaveStar={user?.userId && dashboardInfo?.id}

View File

@ -156,6 +156,7 @@ const createProps = (overrides: any = {}) => ({
toggleExpandSlice: jest.fn(), toggleExpandSlice: jest.fn(),
forceRefresh: jest.fn(), forceRefresh: jest.fn(),
logExploreChart: jest.fn(), logExploreChart: jest.fn(),
logEvent: jest.fn(),
exportCSV: jest.fn(), exportCSV: jest.fn(),
formData: { slice_id: 1, datasource: '58__table' }, formData: { slice_id: 1, datasource: '58__table' },
width: 100, width: 100,

View File

@ -133,6 +133,7 @@ const SliceHeader: FC<SliceHeaderProps> = ({
updateSliceName = () => ({}), updateSliceName = () => ({}),
toggleExpandSlice = () => ({}), toggleExpandSlice = () => ({}),
logExploreChart = () => ({}), logExploreChart = () => ({}),
logEvent,
exportCSV = () => ({}), exportCSV = () => ({}),
editMode = false, editMode = false,
annotationQuery = {}, annotationQuery = {},
@ -271,6 +272,7 @@ const SliceHeader: FC<SliceHeaderProps> = ({
toggleExpandSlice={toggleExpandSlice} toggleExpandSlice={toggleExpandSlice}
forceRefresh={forceRefresh} forceRefresh={forceRefresh}
logExploreChart={logExploreChart} logExploreChart={logExploreChart}
logEvent={logEvent}
exportCSV={exportCSV} exportCSV={exportCSV}
exportFullCSV={exportFullCSV} exportFullCSV={exportFullCSV}
supersetCanExplore={supersetCanExplore} supersetCanExplore={supersetCanExplore}

View File

@ -47,6 +47,7 @@ const createProps = (viz_type = 'sunburst') =>
forceRefresh: jest.fn(), forceRefresh: jest.fn(),
handleToggleFullSize: jest.fn(), handleToggleFullSize: jest.fn(),
toggleExpandSlice: jest.fn(), toggleExpandSlice: jest.fn(),
logEvent: jest.fn(),
slice: { slice: {
slice_id: 371, slice_id: 371,
slice_url: '/explore/?form_data=%7B%22slice_id%22%3A%20371%7D', slice_url: '/explore/?form_data=%7B%22slice_id%22%3A%20371%7D',

View File

@ -54,6 +54,7 @@ import ViewQueryModal from 'src/explore/components/controls/ViewQueryModal';
import { ResultsPaneOnDashboard } from 'src/explore/components/DataTablesPane'; import { ResultsPaneOnDashboard } from 'src/explore/components/DataTablesPane';
import Modal from 'src/components/Modal'; import Modal from 'src/components/Modal';
import { DrillDetailMenuItems } from 'src/components/Chart/DrillDetail'; import { DrillDetailMenuItems } from 'src/components/Chart/DrillDetail';
import { LOG_ACTIONS_CHART_DOWNLOAD_AS_IMAGE } from 'src/logger/LogUtils';
const MENU_KEYS = { const MENU_KEYS = {
CROSS_FILTER_SCOPING: 'cross_filter_scoping', CROSS_FILTER_SCOPING: 'cross_filter_scoping',
@ -137,6 +138,7 @@ export interface SliceHeaderControlsProps {
forceRefresh: (sliceId: number, dashboardId: number) => void; forceRefresh: (sliceId: number, dashboardId: number) => void;
logExploreChart?: (sliceId: number) => void; logExploreChart?: (sliceId: number) => void;
logEvent?: (eventName: string, eventData?: object) => void;
toggleExpandSlice?: (sliceId: number) => void; toggleExpandSlice?: (sliceId: number) => void;
exportCSV?: (sliceId: number) => void; exportCSV?: (sliceId: number) => void;
exportFullCSV?: (sliceId: number) => void; exportFullCSV?: (sliceId: number) => void;
@ -321,6 +323,9 @@ class SliceHeaderControls extends React.PureComponent<
)(domEvent).then(() => { )(domEvent).then(() => {
menu.style.visibility = 'visible'; menu.style.visibility = 'visible';
}); });
this.props.logEvent?.(LOG_ACTIONS_CHART_DOWNLOAD_AS_IMAGE, {
chartId: this.props.slice.slice_id,
});
break; break;
} }
default: default:

View File

@ -408,6 +408,7 @@ class Chart extends React.Component {
postTransformProps, postTransformProps,
datasetsStatus, datasetsStatus,
isInView, isInView,
logEvent,
} = this.props; } = this.props;
const { width } = this.state; const { width } = this.state;
@ -457,6 +458,7 @@ class Chart extends React.Component {
editMode={editMode} editMode={editMode}
annotationQuery={chart.annotationQuery} annotationQuery={chart.annotationQuery}
logExploreChart={this.logExploreChart} logExploreChart={this.logExploreChart}
logEvent={logEvent}
onExploreChart={this.onExploreChart} onExploreChart={this.onExploreChart}
exportCSV={this.exportCSV} exportCSV={this.exportCSV}
exportFullCSV={this.exportFullCSV} exportFullCSV={this.exportFullCSV}

View File

@ -47,6 +47,9 @@ export const LOG_ACTIONS_DATASET_CREATION_SUCCESS = 'dataset_creation_success';
export const LOG_ACTIONS_SPA_NAVIGATION = 'spa_navigation'; export const LOG_ACTIONS_SPA_NAVIGATION = 'spa_navigation';
export const LOG_ACTIONS_CONFIRM_OVERWRITE_DASHBOARD_METADATA = export const LOG_ACTIONS_CONFIRM_OVERWRITE_DASHBOARD_METADATA =
'confirm_overwrite_dashboard_metadata'; 'confirm_overwrite_dashboard_metadata';
export const LOG_ACTIONS_DASHBOARD_DOWNLOAD_AS_IMAGE =
'dashboard_download_as_image';
export const LOG_ACTIONS_CHART_DOWNLOAD_AS_IMAGE = 'chart_download_as_image';
// Log event types -------------------------------------------------------------- // Log event types --------------------------------------------------------------
export const LOG_EVENT_TYPE_TIMING = new Set([ export const LOG_EVENT_TYPE_TIMING = new Set([
@ -67,6 +70,8 @@ export const LOG_EVENT_TYPE_USER = new Set([
LOG_ACTIONS_PERIODIC_RENDER_DASHBOARD, LOG_ACTIONS_PERIODIC_RENDER_DASHBOARD,
LOG_ACTIONS_MOUNT_EXPLORER, LOG_ACTIONS_MOUNT_EXPLORER,
LOG_ACTIONS_CONFIRM_OVERWRITE_DASHBOARD_METADATA, LOG_ACTIONS_CONFIRM_OVERWRITE_DASHBOARD_METADATA,
LOG_ACTIONS_DASHBOARD_DOWNLOAD_AS_IMAGE,
LOG_ACTIONS_CHART_DOWNLOAD_AS_IMAGE,
]); ]);
export const LOG_EVENT_DATASET_TYPE_DATASET_CREATION = [ export const LOG_EVENT_DATASET_TYPE_DATASET_CREATION = [