Add tasklist_view_more_product_types_click track event for add product task

This commit is contained in:
Chi-Hsuan Huang 2022-05-16 17:28:30 +08:00
parent c6d198723f
commit 2520781c7e
2 changed files with 14 additions and 2 deletions

View File

@ -12,6 +12,7 @@ import { useMemo, useState } from '@wordpress/element';
import { Button, Spinner } from '@wordpress/components';
import { getAdminLink } from '@woocommerce/settings';
import { Icon, chevronDown, chevronUp } from '@wordpress/icons';
import { recordEvent } from '@woocommerce/tracks';
/**
* Internal dependencies
@ -147,7 +148,14 @@ export const Products = () => {
) }
<ViewControlButton
isExpanded={ isExpanded }
onClick={ () => setIsExpanded( ! isExpanded ) }
onClick={ () => {
if ( ! isExpanded ) {
recordEvent(
'tasklist_view_more_product_types_click'
);
}
setIsExpanded( ! isExpanded );
} }
/>
<Footer />
</div>

View File

@ -128,11 +128,15 @@ describe( 'Products', () => {
expect( recordEvent ).toHaveBeenNthCalledWith(
1,
'tasklist_view_more_product_types_click'
);
expect( recordEvent ).toHaveBeenNthCalledWith(
2,
'tasklist_product_template_selection',
{ is_suggested: false, product_type: 'grouped' }
);
expect( recordEvent ).toHaveBeenNthCalledWith(
2,
3,
'task_completion_time',
{ task_name: 'products', time: '0-2s' }
);