diff --git a/client/dashboard/index.js b/client/dashboard/index.js
index d36dbec5f96..f4ad0a1f3e2 100644
--- a/client/dashboard/index.js
+++ b/client/dashboard/index.js
@@ -17,7 +17,7 @@ class Dashboard extends Component {
render() {
const { path, profileItems, query } = this.props;
- if ( window.wcAdminFeatures.onboarding && ! profileItems.skipped && ! profileItems.completed ) {
+ if ( window.wcAdminFeatures.onboarding && ! profileItems.completed ) {
return ;
}
diff --git a/client/dashboard/profile-wizard/steps/start/index.js b/client/dashboard/profile-wizard/steps/start/index.js
index c96ac540e47..0adfdacf7e1 100644
--- a/client/dashboard/profile-wizard/steps/start/index.js
+++ b/client/dashboard/profile-wizard/steps/start/index.js
@@ -41,20 +41,26 @@ class Start extends Component {
}
componentDidMount() {
- const { updateProfileItems } = this.props;
+ const { updateProfileItems, profileItems } = this.props;
if (
this.props.activePlugins.includes( 'jetpack' ) &&
this.props.activePlugins.includes( 'woocommerce-services' )
) {
- updateProfileItems( { wcs_jetpack: 'already-installed' } );
+ // Don't track event again if they revisit the start page.
+ if ( 'already-installed' !== profileItems.plugins ) {
+ recordEvent( 'wcadmin_storeprofiler_already_installed_plugins', {} );
+ }
+
+ updateProfileItems( { plugins: 'already-installed' } );
return updateQueryString( { step: 'store-details' } );
}
}
async skipWizard() {
- const { createNotice, isProfileItemsError, updateProfileItems } = this.props;
+ const { createNotice, isProfileItemsError, updateProfileItems, activePlugins } = this.props;
- await updateProfileItems( { skipped: true, wcs_jetpack: 'skipped' } );
+ const plugins = activePlugins.includes( 'jetpack' ) ? 'skipped-wcs' : 'skipped';
+ await updateProfileItems( { plugins } );
if ( isProfileItemsError ) {
createNotice(
@@ -62,21 +68,31 @@ class Start extends Component {
__( 'There was a problem updating your preferences.', 'woocommerce-admin' )
);
} else {
- recordEvent( 'storeprofiler_welcome_clicked', { get_started: true } );
+ recordEvent( 'storeprofiler_welcome_clicked', { get_started: true, plugins } );
+ return updateQueryString( { step: 'store-details' } );
}
}
async startWizard() {
- const { createNotice, isProfileItemsError, updateProfileItems, updateOptions } = this.props;
+ const {
+ createNotice,
+ isProfileItemsError,
+ updateProfileItems,
+ updateOptions,
+ goToNextStep,
+ activePlugins,
+ } = this.props;
await updateOptions( {
woocommerce_setup_jetpack_opted_in: true,
} );
- await updateProfileItems( { wcs_jetpack: 'wizard' } );
+
+ const plugins = activePlugins.includes( 'jetpack' ) ? 'installed-wcs' : 'installed';
+ await updateProfileItems( { plugins } );
if ( ! isProfileItemsError ) {
- recordEvent( 'storeprofiler_welcome_clicked', { get_started: true } );
- this.props.goToNextStep();
+ recordEvent( 'storeprofiler_welcome_clicked', { get_started: true, plugins } );
+ goToNextStep();
} else {
createNotice(
'error',
@@ -257,7 +273,9 @@ class Start extends Component {
export default compose(
withSelect( select => {
- const { getProfileItemsError, getActivePlugins, getOptions } = select( 'wc-api' );
+ const { getProfileItemsError, getActivePlugins, getOptions, getProfileItems } = select(
+ 'wc-api'
+ );
const isProfileItemsError = Boolean( getProfileItemsError() );
@@ -265,11 +283,13 @@ export default compose(
const allowTracking = 'yes' === get( options, [ 'woocommerce_allow_tracking' ], false );
const activePlugins = getActivePlugins();
+ const profileItems = getProfileItems();
return {
isProfileItemsError,
activePlugins,
allowTracking,
+ profileItems,
};
} ),
withDispatch( dispatch => {
diff --git a/client/dashboard/profile-wizard/steps/store-details.js b/client/dashboard/profile-wizard/steps/store-details.js
index 3dd06f24050..a863258de9e 100644
--- a/client/dashboard/profile-wizard/steps/store-details.js
+++ b/client/dashboard/profile-wizard/steps/store-details.js
@@ -45,7 +45,7 @@ class StoreDetails extends Component {
onSubmit( values ) {
const { profileItems } = this.props;
- if ( 'already-installed' === profileItems.wcs_jetpack ) {
+ if ( 'already-installed' === profileItems.plugins ) {
this.setState( { showUsageModal: true } );
return;
}
diff --git a/src/API/OnboardingProfile.php b/src/API/OnboardingProfile.php
index 10bc2786c8c..8c92a03d45d 100644
--- a/src/API/OnboardingProfile.php
+++ b/src/API/OnboardingProfile.php
@@ -209,14 +209,7 @@ public static function get_profile_properties() {
'readonly' => true,
'validate_callback' => 'rest_validate_request_arg',
),
- 'skipped' => array(
- 'type' => 'boolean',
- 'description' => __( 'Whether or not the profile was skipped.', 'woocommerce-admin' ),
- 'context' => array( 'view' ),
- 'readonly' => true,
- 'validate_callback' => 'rest_validate_request_arg',
- ),
- 'wcs_jetpack' => array(
+ 'plugins' => array(
'type' => 'string',
'description' => __( 'How the Jetpack/WooCommerce Services step was handled.', 'woocommerce-admin' ),
'context' => array( 'view' ),
@@ -224,8 +217,10 @@ public static function get_profile_properties() {
'validate_callback' => 'rest_validate_request_arg',
'enum' => array(
'skipped',
+ 'skipped-wcs',
'already-installed',
- 'wizard',
+ 'installed-wcs',
+ 'installed',
),
),
'account_type' => array(
diff --git a/src/Features/Onboarding.php b/src/Features/Onboarding.php
index 093551a3194..06bed033a49 100644
--- a/src/Features/Onboarding.php
+++ b/src/Features/Onboarding.php
@@ -77,7 +77,7 @@ public function __construct() {
}
/**
- * Returns true if the profiler should be displayed (not completed and not skipped).
+ * Returns true if the profiler should be displayed (not completed).
*
* @return bool
*/
@@ -85,15 +85,14 @@ public function should_show_profiler() {
$onboarding_data = get_option( 'wc_onboarding_profile', array() );
$is_completed = isset( $onboarding_data['completed'] ) && true === $onboarding_data['completed'];
- $is_skipped = isset( $onboarding_data['skipped'] ) && true === $onboarding_data['skipped'];
// @todo When merging to WooCommerce Core, we should set the `completed` flag to true during the upgrade progress.
// https://github.com/woocommerce/woocommerce-admin/pull/2300#discussion_r287237498.
- return $is_completed || $is_skipped ? false : true;
+ return ! $is_completed;
}
/**
- * Returns true if the task list should be displayed (not completed or hidden off the dashboard.
+ * Returns true if the task list should be displayed (not completed or hidden off the dashboard).
*
* @return bool
*/
@@ -530,8 +529,7 @@ public static function update_help_tab() {
$task_list_hidden = get_option( 'woocommerce_task_list_hidden', 'no' );
$onboarding_data = get_option( 'wc_onboarding_profile', array() );
$is_completed = isset( $onboarding_data['completed'] ) && true === $onboarding_data['completed'];
- $is_skipped = isset( $onboarding_data['skipped'] ) && true === $onboarding_data['skipped'];
- $is_enabled = $is_completed || $is_skipped ? false : true;
+ $is_enabled = ! $is_completed;
$help_tab['content'] = '
' . __( 'WooCommerce Onboarding', 'woocommerce-admin' ) . '
';
@@ -642,15 +640,23 @@ public static function reset_profiler() {
return;
}
- $new_value = 1 === absint( $_GET['reset_profiler'] ) ? false : true;
+ $previous = 1 === absint( $_GET['reset_profiler'] );
+ $new_value = ! $previous;
+
+ wc_admin_record_tracks_event(
+ 'wcadmin_storeprofiler_toggled',
+ array(
+ 'previous' => $previous,
+ 'new_value' => $new_value,
+ )
+ );
$request = new \WP_REST_Request( 'POST', '/wc-admin/v1/onboarding/profile' );
$request->set_headers( array( 'content-type' => 'application/json' ) );
$request->set_body(
wp_json_encode(
array(
- 'completed' => false,
- 'skipped' => $new_value,
+ 'completed' => $new_value,
)
)
);
diff --git a/tests/api/onboarding-profile.php b/tests/api/onboarding-profile.php
index 9f50be94991..b9eab200991 100644
--- a/tests/api/onboarding-profile.php
+++ b/tests/api/onboarding-profile.php
@@ -99,9 +99,8 @@ public function test_schema() {
$data = $response->get_data();
$properties = $data['schema']['properties'];
- $this->assertCount( 15, $properties );
+ $this->assertCount( 14, $properties );
$this->assertArrayHasKey( 'completed', $properties );
- $this->assertArrayHasKey( 'skipped', $properties );
$this->assertArrayHasKey( 'account_type', $properties );
$this->assertArrayHasKey( 'industry', $properties );
$this->assertArrayHasKey( 'product_types', $properties );
@@ -113,7 +112,7 @@ public function test_schema() {
$this->assertArrayHasKey( 'theme', $properties );
$this->assertArrayHasKey( 'wccom_connected', $properties );
$this->assertArrayHasKey( 'items_purchased', $properties );
- $this->assertArrayHasKey( 'wcs_jetpack', $properties );
+ $this->assertArrayHasKey( 'plugins', $properties );
$this->assertArrayHasKey( 'setup_client', $properties );
}