Add check for tasklist layout experiment (#32593)
* Add check for tasklist layout experiment * Remove task list setup feature flags * Remove errant config file * Add negative check for experiment 1 in experiment 2
This commit is contained in:
parent
750f1498a3
commit
26a27650a3
|
@ -6,7 +6,9 @@ import { useEffect, useLayoutEffect, useRef } from '@wordpress/element';
|
|||
import classnames from 'classnames';
|
||||
import { decodeEntities } from '@wordpress/html-entities';
|
||||
import { getSetting } from '@woocommerce/settings';
|
||||
import { ONBOARDING_STORE_NAME } from '@woocommerce/data';
|
||||
import { Text, useSlot } from '@woocommerce/experimental';
|
||||
import { useSelect } from '@wordpress/data';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
|
@ -93,12 +95,18 @@ export const Header = ( { sections, isEmbedded = false, query } ) => {
|
|||
}
|
||||
}, [ isEmbedded, sections, siteTitle ] );
|
||||
|
||||
const tasksReminderFeature =
|
||||
window.wcAdminFeatures[ 'tasklist-setup-experiment-1' ];
|
||||
const { hasTasksReminderFeature } = useSelect( ( select ) => {
|
||||
const taskLists = select( ONBOARDING_STORE_NAME ).getTaskLists();
|
||||
return {
|
||||
hasTasksReminderFeature: taskLists.some(
|
||||
( list ) => list.id === 'setup_experiment_1'
|
||||
),
|
||||
};
|
||||
} );
|
||||
|
||||
return (
|
||||
<div className={ className } ref={ headerElement }>
|
||||
{ tasksReminderFeature && (
|
||||
{ hasTasksReminderFeature && (
|
||||
<TasksReminderBar
|
||||
pageTitle={ pageTitle }
|
||||
updateBodyMargin={ updateBodyMargin }
|
||||
|
|
|
@ -20,8 +20,6 @@
|
|||
"store-alerts": true,
|
||||
"transient-notices": true,
|
||||
"wc-pay-promotion": true,
|
||||
"wc-pay-welcome-page": true,
|
||||
"tasklist-setup-experiment-1": false,
|
||||
"tasklist-setup-experiment-2": false
|
||||
"wc-pay-welcome-page": true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,8 +20,6 @@
|
|||
"store-alerts": true,
|
||||
"transient-notices": true,
|
||||
"wc-pay-promotion": true,
|
||||
"wc-pay-welcome-page": true,
|
||||
"tasklist-setup-experiment-1": false,
|
||||
"tasklist-setup-experiment-2": false
|
||||
"wc-pay-welcome-page": true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,6 +73,33 @@ class TaskLists {
|
|||
add_filter( 'woocommerce_admin_shared_settings', array( __CLASS__, 'task_list_preloaded_settings' ), 20 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an experiment is the treatment or control.
|
||||
*
|
||||
* @param string $name Name prefix of experiment.
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_experiment_treatment( $name ) {
|
||||
$anon_id = isset( $_COOKIE['tk_ai'] ) ? sanitize_text_field( wp_unslash( $_COOKIE['tk_ai'] ) ) : '';
|
||||
$allow_tracking = 'yes' === get_option( 'woocommerce_allow_tracking' );
|
||||
$abtest = new \WooCommerce\Admin\Experimental_Abtest(
|
||||
$anon_id,
|
||||
'woocommerce',
|
||||
$allow_tracking
|
||||
);
|
||||
|
||||
$date = new \DateTime();
|
||||
$date->setTimeZone( new \DateTimeZone( 'UTC' ) );
|
||||
|
||||
$experiment_name = sprintf(
|
||||
'%s_%s_%s',
|
||||
$name,
|
||||
$date->format( 'Y' ),
|
||||
$date->format( 'm' )
|
||||
);
|
||||
return $abtest->get_variation( $experiment_name ) === 'treatment';
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize default lists.
|
||||
*/
|
||||
|
@ -93,7 +120,8 @@ class TaskLists {
|
|||
'Appearance',
|
||||
),
|
||||
'event_prefix' => 'tasklist_',
|
||||
'visible' => ! Features::is_enabled( 'tasklist-setup-experiment-1' ) && ! Features::is_enabled( 'tasklist-setup-experiment-2' ),
|
||||
'visible' => ! self::is_experiment_treatment( 'woocommerce_tasklist_setup_experiment_1' )
|
||||
&& ! self::is_experiment_treatment( 'woocommerce_tasklist_setup_experiment_2' ),
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -117,7 +145,7 @@ class TaskLists {
|
|||
'options' => array(
|
||||
'use_completed_title' => true,
|
||||
),
|
||||
'visible' => Features::is_enabled( 'tasklist-setup-experiment-1' ),
|
||||
'visible' => self::is_experiment_treatment( 'woocommerce_tasklist_setup_experiment_1' ),
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -138,7 +166,8 @@ class TaskLists {
|
|||
'Appearance',
|
||||
),
|
||||
'event_prefix' => 'tasklist_',
|
||||
'visible' => Features::is_enabled( 'tasklist-setup-experiment-2' ),
|
||||
'visible' => self::is_experiment_treatment( 'woocommerce_tasklist_setup_experiment_2' )
|
||||
&& ! self::is_experiment_treatment( 'woocommerce_tasklist_setup_experiment_1' ),
|
||||
'options' => array(
|
||||
'use_completed_title' => true,
|
||||
),
|
||||
|
|
Loading…
Reference in New Issue