Send a tracks event for report table pagination actions.
This commit is contained in:
parent
c820c92fe4
commit
1da8aba8e8
|
@ -66,7 +66,8 @@ class ReportTable extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
onPageChange() {
|
||||
onPageChange( newPage, source ) {
|
||||
const { endpoint } = this.props;
|
||||
this.scrollPointRef.current.scrollIntoView();
|
||||
const tableElement = this.scrollPointRef.current.nextSibling.querySelector(
|
||||
'.woocommerce-table__table'
|
||||
|
@ -76,6 +77,14 @@ class ReportTable extends Component {
|
|||
if ( focusableElements.length ) {
|
||||
focusableElements[ 0 ].focus();
|
||||
}
|
||||
|
||||
if ( source ) {
|
||||
if ( 'goto' === source ) {
|
||||
recordEvent( 'analytics_table_go_to_page', { report: endpoint, page: newPage } );
|
||||
} else {
|
||||
recordEvent( 'analytics_table_page_click', { report: endpoint, direction: source } );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
trackTableSearch() {
|
||||
|
|
|
@ -38,7 +38,7 @@ class Pagination extends Component {
|
|||
if ( page - 1 < 1 ) {
|
||||
return;
|
||||
}
|
||||
onPageChange( page - 1 );
|
||||
onPageChange( page - 1, 'previous' );
|
||||
}
|
||||
|
||||
nextPage( event ) {
|
||||
|
@ -47,7 +47,7 @@ class Pagination extends Component {
|
|||
if ( page + 1 > this.pageCount ) {
|
||||
return;
|
||||
}
|
||||
onPageChange( page + 1 );
|
||||
onPageChange( page + 1, 'next' );
|
||||
}
|
||||
|
||||
perPageChange( perPage ) {
|
||||
|
@ -71,7 +71,7 @@ class Pagination extends Component {
|
|||
const newPage = parseInt( event.target.value, 10 );
|
||||
|
||||
if ( newPage !== page && isFinite( newPage ) && newPage > 0 && this.pageCount && this.pageCount >= newPage ) {
|
||||
onPageChange( newPage );
|
||||
onPageChange( newPage, 'goto' );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue