Send tracks event when report table columns are toggled.

This commit is contained in:
Jeff Stieler 2019-07-09 13:55:51 -06:00
parent 849d556770
commit f7c48e6738
2 changed files with 14 additions and 4 deletions

View File

@ -41,8 +41,8 @@ class ReportTable extends Component {
this.scrollPointRef = createRef();
}
onColumnsChange( shownColumns ) {
const { columnPrefsKey, getHeadersContent, updateCurrentUserData } = this.props;
onColumnsChange( shownColumns, toggledColumn ) {
const { columnPrefsKey, endpoint, getHeadersContent, updateCurrentUserData } = this.props;
const columns = getHeadersContent().map( header => header.key );
const hiddenColumns = columns.filter( column => ! shownColumns.includes( column ) );
@ -52,6 +52,16 @@ class ReportTable extends Component {
};
updateCurrentUserData( userDataFields );
}
if ( toggledColumn ) {
const eventProps = {
report: endpoint,
column: toggledColumn,
status: shownColumns.includes( toggledColumn ) ? 'on' : 'off',
};
recordEvent( 'analytics_table_header_toggle', eventProps );
}
}
onPageChange() {

View File

@ -128,12 +128,12 @@ class TableCard extends Component {
}
const showCols = without( prevState.showCols, key );
onColumnsChange( showCols );
onColumnsChange( showCols, key );
return { showCols };
}
const showCols = [ ...prevState.showCols, key ];
onColumnsChange( showCols );
onColumnsChange( showCols, key );
return { showCols };
} );
};