Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const createProps = () => ({
lastModifiedTime: 0,
isDropdownVisible: true,
dataMask: {},
logEvent: jest.fn(),
});
const editModeOnProps = {
...createProps(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import getDashboardUrl from 'src/dashboard/util/getDashboardUrl';
import { getActiveFilters } from 'src/dashboard/util/activeDashboardFilters';
import { getUrlParam } from 'src/utils/urlUtils';
import { FILTER_BOX_MIGRATION_STATES } from 'src/explore/constants';
import { LOG_ACTIONS_DASHBOARD_DOWNLOAD_AS_IMAGE } from 'src/logger/LogUtils';

const propTypes = {
addSuccessToast: PropTypes.func.isRequired,
Expand Down Expand Up @@ -65,6 +66,7 @@ const propTypes = {
onSave: PropTypes.func.isRequired,
showPropertiesModal: PropTypes.func.isRequired,
manageEmbedded: PropTypes.func.isRequired,
logEvent: PropTypes.func,
refreshLimit: PropTypes.number,
refreshWarning: PropTypes.string,
lastModifiedTime: PropTypes.number.isRequired,
Expand Down Expand Up @@ -182,6 +184,7 @@ class HeaderActionsDropdown extends React.PureComponent {
)(domEvent).then(() => {
menu.style.visibility = 'visible';
});
this.props.logEvent?.(LOG_ACTIONS_DASHBOARD_DOWNLOAD_AS_IMAGE);
break;
}
case MENU_KEYS.TOGGLE_FULLSCREEN: {
Expand Down
2 changes: 2 additions & 0 deletions superset-frontend/src/dashboard/components/Header/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ class Header extends React.PureComponent {
setRefreshFrequency,
lastModifiedTime,
filterboxMigrationState,
logEvent,
} = this.props;

const userCanEdit =
Expand Down Expand Up @@ -679,6 +680,7 @@ class Header extends React.PureComponent {
filterboxMigrationState={filterboxMigrationState}
isDropdownVisible={this.state.isDropdownVisible}
setIsDropdownVisible={this.setIsDropdownVisible}
logEvent={logEvent}
/>
}
showFaveStar={user?.userId && dashboardInfo?.id}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ const createProps = (overrides: any = {}) => ({
toggleExpandSlice: jest.fn(),
forceRefresh: jest.fn(),
logExploreChart: jest.fn(),
logEvent: jest.fn(),
exportCSV: jest.fn(),
formData: { slice_id: 1, datasource: '58__table' },
width: 100,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ const SliceHeader: FC<SliceHeaderProps> = ({
updateSliceName = () => ({}),
toggleExpandSlice = () => ({}),
logExploreChart = () => ({}),
logEvent,
exportCSV = () => ({}),
editMode = false,
annotationQuery = {},
Expand Down Expand Up @@ -271,6 +272,7 @@ const SliceHeader: FC<SliceHeaderProps> = ({
toggleExpandSlice={toggleExpandSlice}
forceRefresh={forceRefresh}
logExploreChart={logExploreChart}
logEvent={logEvent}
exportCSV={exportCSV}
exportFullCSV={exportFullCSV}
supersetCanExplore={supersetCanExplore}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const createProps = (viz_type = 'sunburst') =>
forceRefresh: jest.fn(),
handleToggleFullSize: jest.fn(),
toggleExpandSlice: jest.fn(),
logEvent: jest.fn(),
slice: {
slice_id: 371,
slice_url: '/explore/?form_data=%7B%22slice_id%22%3A%20371%7D',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import ViewQueryModal from 'src/explore/components/controls/ViewQueryModal';
import { ResultsPaneOnDashboard } from 'src/explore/components/DataTablesPane';
import Modal from 'src/components/Modal';
import { DrillDetailMenuItems } from 'src/components/Chart/DrillDetail';
import { LOG_ACTIONS_CHART_DOWNLOAD_AS_IMAGE } from 'src/logger/LogUtils';

const MENU_KEYS = {
CROSS_FILTER_SCOPING: 'cross_filter_scoping',
Expand Down Expand Up @@ -137,6 +138,7 @@ export interface SliceHeaderControlsProps {

forceRefresh: (sliceId: number, dashboardId: number) => void;
logExploreChart?: (sliceId: number) => void;
logEvent?: (eventName: string, eventData?: object) => void;
toggleExpandSlice?: (sliceId: number) => void;
exportCSV?: (sliceId: number) => void;
exportFullCSV?: (sliceId: number) => void;
Expand Down Expand Up @@ -321,6 +323,9 @@ class SliceHeaderControls extends React.PureComponent<
)(domEvent).then(() => {
menu.style.visibility = 'visible';
});
this.props.logEvent?.(LOG_ACTIONS_CHART_DOWNLOAD_AS_IMAGE, {
chartId: this.props.slice.slice_id,
});
break;
}
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ class Chart extends React.Component {
postTransformProps,
datasetsStatus,
isInView,
logEvent,
} = this.props;

const { width } = this.state;
Expand Down Expand Up @@ -457,6 +458,7 @@ class Chart extends React.Component {
editMode={editMode}
annotationQuery={chart.annotationQuery}
logExploreChart={this.logExploreChart}
logEvent={logEvent}
onExploreChart={this.onExploreChart}
exportCSV={this.exportCSV}
exportFullCSV={this.exportFullCSV}
Expand Down
5 changes: 5 additions & 0 deletions superset-frontend/src/logger/LogUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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_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 --------------------------------------------------------------
export const LOG_EVENT_TYPE_TIMING = new Set([
Expand All @@ -67,6 +70,8 @@ export const LOG_EVENT_TYPE_USER = new Set([
LOG_ACTIONS_PERIODIC_RENDER_DASHBOARD,
LOG_ACTIONS_MOUNT_EXPLORER,
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 = [
Expand Down