Onboarding: Add task view and product import track events (https://github.com/woocommerce/woocommerce-admin/pull/3115)

This commit is contained in:
Joshua T Flowers 2019-10-29 10:08:39 +08:00 committed by GitHub
parent 1582cb1bf1
commit bfc1721c69
2 changed files with 26 additions and 2 deletions

View File

@ -29,7 +29,8 @@ class TaskDashboard extends Component {
document.body.classList.add( 'woocommerce-onboarding' );
document.body.classList.add( 'woocommerce-task-dashboard__body' );
this.recordEvent();
this.recordTaskView();
this.recordTaskListView();
if ( this.props.inline ) {
this.props.updateOptions( {
@ -38,12 +39,33 @@ class TaskDashboard extends Component {
}
}
componentDidUpdate( prevProps ) {
const { task } = this.props.query;
const { task: prevTask } = prevProps.query;
if ( prevTask !== task ) {
this.recordTaskView();
}
}
componentWillUnmount() {
document.body.classList.remove( 'woocommerce-onboarding' );
document.body.classList.remove( 'woocommerce-task-dashboard__body' );
}
recordEvent() {
recordTaskView() {
const { task } = this.props.query;
if ( ! task ) {
return;
}
recordEvent( 'task_view', {
task_name: task,
} );
}
recordTaskListView() {
if ( this.getCurrentTask() ) {
return;
}

View File

@ -104,6 +104,8 @@ class Appearance extends Component {
const { createNotice } = this.props;
this.setState( { isPending: true } );
recordEvent( 'tasklist_appearance_import_demo', {} );
apiFetch( {
path: `${ WC_ADMIN_NAMESPACE }/onboarding/tasks/import_sample_products`,
method: 'POST',