Homepage: Add tracks events to Stats List period changes (https://github.com/woocommerce/woocommerce-admin/pull/4448)

This commit is contained in:
Paul Sealock 2020-05-29 12:40:51 +12:00 committed by GitHub
parent 04e39480af
commit 54c00eecf9
2 changed files with 28 additions and 0 deletions

View File

@ -102,6 +102,11 @@ export const StatsOverview = ( { userPrefs, updateCurrentUserData } ) => {
> >
<TabPanel <TabPanel
className="woocommerce-stats-overview__tabs" className="woocommerce-stats-overview__tabs"
onSelect={ ( period ) => {
recordEvent( 'statsoverview_date_picker_update', {
period,
} );
} }
tabs={ [ tabs={ [
{ {
title: __( 'Today', 'woocommerce-admin' ), title: __( 'Today', 'woocommerce-admin' ),

View File

@ -50,6 +50,29 @@ describe( 'StatsOverview tracking', () => {
} }
); );
} ); } );
it( 'should record an event when a period is clicked', () => {
render(
<StatsOverview
userPrefs={ {
hiddenStats: null,
} }
updateCurrentUserData={ () => {} }
/>
);
const monthBtn = screen.getByRole( 'tab', {
name: 'Month to date',
} );
fireEvent.click( monthBtn );
expect( recordEvent ).toHaveBeenCalledWith(
'statsoverview_date_picker_update',
{
period: 'month',
}
);
} );
} ); } );
describe( 'StatsOverview toggle and persist stat preference', () => { describe( 'StatsOverview toggle and persist stat preference', () => {