Tracks: Add dashboard events
This commit is contained in:
parent
d52a32692c
commit
b19e1dd261
|
@ -21,6 +21,7 @@ import './style.scss';
|
||||||
import defaultSections from './default-sections';
|
import defaultSections from './default-sections';
|
||||||
import Section from './section';
|
import Section from './section';
|
||||||
import withSelect from 'wc-api/with-select';
|
import withSelect from 'wc-api/with-select';
|
||||||
|
import { recordEvent } from 'lib/tracks';
|
||||||
|
|
||||||
class CustomizableDashboard extends Component {
|
class CustomizableDashboard extends Component {
|
||||||
constructor( props ) {
|
constructor( props ) {
|
||||||
|
@ -102,6 +103,10 @@ class CustomizableDashboard extends Component {
|
||||||
toggledSection.isVisible = ! toggledSection.isVisible;
|
toggledSection.isVisible = ! toggledSection.isVisible;
|
||||||
sections.push( toggledSection );
|
sections.push( toggledSection );
|
||||||
|
|
||||||
|
if ( ! toggledSection.isVisible ) {
|
||||||
|
recordEvent( 'dash_section_remove', { key: toggledSection.key } );
|
||||||
|
}
|
||||||
|
|
||||||
this.updateSections( sections );
|
this.updateSections( sections );
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import { getAllowedIntervalsForQuery } from '@woocommerce/date';
|
||||||
import ChartBlock from './block';
|
import ChartBlock from './block';
|
||||||
import { uniqCharts } from './config';
|
import { uniqCharts } from './config';
|
||||||
import withSelect from 'wc-api/with-select';
|
import withSelect from 'wc-api/with-select';
|
||||||
|
import { recordEvent } from 'lib/tracks';
|
||||||
import './style.scss';
|
import './style.scss';
|
||||||
|
|
||||||
class DashboardCharts extends Component {
|
class DashboardCharts extends Component {
|
||||||
|
@ -66,13 +67,21 @@ class DashboardCharts extends Component {
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<MenuTitle>{ __( 'Charts', 'woocommerce-admin' ) }</MenuTitle>
|
<MenuTitle>{ __( 'Charts', 'woocommerce-admin' ) }</MenuTitle>
|
||||||
{ uniqCharts.map( chart => {
|
{ uniqCharts.map( chart => {
|
||||||
|
const key = chart.endpoint + '_' + chart.key;
|
||||||
|
const checked = ! hiddenBlocks.includes( key );
|
||||||
return (
|
return (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
checked={ ! hiddenBlocks.includes( chart.endpoint + '_' + chart.key ) }
|
checked={ checked }
|
||||||
isCheckbox
|
isCheckbox
|
||||||
isClickable
|
isClickable
|
||||||
key={ chart.endpoint + '_' + chart.key }
|
key={ chart.endpoint + '_' + chart.key }
|
||||||
onInvoke={ () => onToggleHiddenBlock( chart.endpoint + '_' + chart.key )() }
|
onInvoke={ () => {
|
||||||
|
onToggleHiddenBlock( key )();
|
||||||
|
recordEvent( 'dash_charts_chart_toggle', {
|
||||||
|
status: checked ? 'off' : 'on',
|
||||||
|
key,
|
||||||
|
} );
|
||||||
|
} }
|
||||||
>
|
>
|
||||||
{ __( `${ chart.label }`, 'woocommerce-admin' ) }
|
{ __( `${ chart.label }`, 'woocommerce-admin' ) }
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
|
|
@ -19,6 +19,7 @@ import { EllipsisMenu, MenuItem, MenuTitle, SectionHeader } from '@woocommerce/c
|
||||||
*/
|
*/
|
||||||
import Leaderboard from 'analytics/components/leaderboard';
|
import Leaderboard from 'analytics/components/leaderboard';
|
||||||
import withSelect from 'wc-api/with-select';
|
import withSelect from 'wc-api/with-select';
|
||||||
|
import { recordEvent } from 'lib/tracks';
|
||||||
import './style.scss';
|
import './style.scss';
|
||||||
|
|
||||||
class Leaderboards extends Component {
|
class Leaderboards extends Component {
|
||||||
|
@ -64,13 +65,20 @@ class Leaderboards extends Component {
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<MenuTitle>{ __( 'Leaderboards', 'woocommerce-admin' ) }</MenuTitle>
|
<MenuTitle>{ __( 'Leaderboards', 'woocommerce-admin' ) }</MenuTitle>
|
||||||
{ allLeaderboards.map( leaderboard => {
|
{ allLeaderboards.map( leaderboard => {
|
||||||
|
const checked = ! hiddenBlocks.includes( leaderboard.id );
|
||||||
return (
|
return (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
checked={ ! hiddenBlocks.includes( leaderboard.id ) }
|
checked={ checked }
|
||||||
isCheckbox
|
isCheckbox
|
||||||
isClickable
|
isClickable
|
||||||
key={ leaderboard.id }
|
key={ leaderboard.id }
|
||||||
onInvoke={ () => onToggleHiddenBlock( leaderboard.id )() }
|
onInvoke={ () => {
|
||||||
|
onToggleHiddenBlock( leaderboard.id )();
|
||||||
|
recordEvent( 'dash_leaderboards_toggle', {
|
||||||
|
status: checked ? 'off' : 'on',
|
||||||
|
key: leaderboard.id,
|
||||||
|
} );
|
||||||
|
} }
|
||||||
>
|
>
|
||||||
{ leaderboard.label }
|
{ leaderboard.label }
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
|
|
@ -31,6 +31,7 @@ import {
|
||||||
} from '@woocommerce/components';
|
} from '@woocommerce/components';
|
||||||
import withSelect from 'wc-api/with-select';
|
import withSelect from 'wc-api/with-select';
|
||||||
import './style.scss';
|
import './style.scss';
|
||||||
|
import { recordEvent } from 'lib/tracks';
|
||||||
|
|
||||||
class StorePerformance extends Component {
|
class StorePerformance extends Component {
|
||||||
renderMenu() {
|
renderMenu() {
|
||||||
|
@ -65,7 +66,13 @@ class StorePerformance extends Component {
|
||||||
isCheckbox
|
isCheckbox
|
||||||
isClickable
|
isClickable
|
||||||
key={ i }
|
key={ i }
|
||||||
onInvoke={ () => onToggleHiddenBlock( indicator.stat )() }
|
onInvoke={ () => {
|
||||||
|
onToggleHiddenBlock( indicator.stat )();
|
||||||
|
recordEvent( 'dash_indicators_toggle', {
|
||||||
|
status: checked ? 'off' : 'on',
|
||||||
|
key: indicator.stat,
|
||||||
|
} );
|
||||||
|
} }
|
||||||
>
|
>
|
||||||
{ sprintf( __( 'Show %s', 'woocommerce-admin' ), indicator.label ) }
|
{ sprintf( __( 'Show %s', 'woocommerce-admin' ), indicator.label ) }
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
@ -152,6 +159,9 @@ class StorePerformance extends Component {
|
||||||
prevLabel={ prevLabel }
|
prevLabel={ prevLabel }
|
||||||
prevValue={ secondaryValue }
|
prevValue={ secondaryValue }
|
||||||
delta={ delta }
|
delta={ delta }
|
||||||
|
onLinkClickCallback={ () => {
|
||||||
|
recordEvent( 'dash_indicators_click', { key: indicator.stat } );
|
||||||
|
} }
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} )
|
} )
|
||||||
|
|
Loading…
Reference in New Issue