Skip to content

Commit

Permalink
Cleanup product task experiment (#35950)
Browse files Browse the repository at this point in the history
* Cleanup product task experiment

* Rename experimental-products -> products

* Add changelog

* Clean up product task experiment in woo/onboarding

Remove product variant

* Rename experimental-import-products -> import-products

* Clean up OnboardingTasks.php

* Add changelog

* Remove experimental-products-task feature flag
  • Loading branch information
chihsuan committed Dec 28, 2022
1 parent b133ad9 commit 9f0d718
Show file tree
Hide file tree
Showing 39 changed files with 79 additions and 835 deletions.
@@ -0,0 +1,4 @@
Significance: patch
Type: dev

Cleanup product task experiment
Expand Up @@ -34,7 +34,6 @@ export const trackView = async ( taskId: string, variant?: string ) => {
} );
};

let experimentalVariant: string | undefined;
type WooOnboardingTaskProps = {
id: string;
variant?: string;
Expand All @@ -56,37 +55,15 @@ type WooOnboardingTaskSlotProps = Slot.Props & {
*/
const WooOnboardingTask: React.FC< WooOnboardingTaskProps > & {
Slot: React.VFC< WooOnboardingTaskSlotProps >;
} = ( { id, variant, ...props } ) => {
useEffect( () => {
if ( id === 'products' ) {
experimentalVariant = variant;
}
}, [ id, variant ] );

} = ( { id, ...props } ) => {
return <Fill name={ 'woocommerce_onboarding_task_' + id } { ...props } />;
};

// We need this here just in case the experiment assignment takes awhile to load, so that we don't fire trackView with a blank experimentalVariant
// Remove all of the code in this file related to experiments and variants when the product task experiment concludes and never speak of the existence of this code to anyone
const pollForExperimentalVariant = ( id: string, count: number ) => {
if ( count > 20 ) {
trackView( id, 'experiment_timed_out' ); // if we can't fetch experiment after 4 seconds, give up
} else if ( experimentalVariant ) {
trackView( id, experimentalVariant );
} else {
setTimeout( () => pollForExperimentalVariant( id, count + 1 ), 200 );
}
};

WooOnboardingTask.Slot = ( { id, fillProps } ) => {
// The Slot is a React component and this hook works as expected.
// eslint-disable-next-line react-hooks/rules-of-hooks
useEffect( () => {
if ( id === 'products' ) {
pollForExperimentalVariant( id, 0 );
} else {
trackView( id );
}
trackView( id );
}, [ id ] );

return (
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Expand Up @@ -13,12 +13,12 @@ import { recordEvent } from '@woocommerce/tracks';
/**
* Internal dependencies
*/
import Stacks from '../experimental-products/stack';
import Stacks from '../products/stack';
import CardList from './CardList';
import { importTypes } from './importTypes';
import './style.scss';
import useProductTypeListItems from '../experimental-products/use-product-types-list-items';
import { getProductTypes } from '../experimental-products/utils';
import useProductTypeListItems from '../products/use-product-types-list-items';
import { getProductTypes } from '../products/utils';
import LoadSampleProductModal from '../components/load-sample-product-modal';
import useLoadSampleProducts from '../components/use-load-sample-products';
import LoadSampleProductConfirmModal from '../components/load-sample-product-confirm-modal';
Expand Down Expand Up @@ -114,7 +114,7 @@ registerPlugin( 'wc-admin-onboarding-task-products', {
// @ts-expect-error 'scope' does exist. @types/wordpress__plugins is outdated.
scope: 'woocommerce-tasks',
render: () => (
<WooOnboardingTask id="products" variant="import">
<WooOnboardingTask id="products">
<Products />
</WooOnboardingTask>
),
Expand Down
Expand Up @@ -7,7 +7,7 @@ import userEvent from '@testing-library/user-event';
/**
* Internal dependencies
*/
import { Products } from '../';
import { Products } from '..';

jest.mock( '@woocommerce/tracks', () => ( { recordEvent: jest.fn() } ) );

Expand Down
24 changes: 5 additions & 19 deletions plugins/woocommerce-admin/client/tasks/fills/index.js
@@ -1,8 +1,7 @@
/**
* Internal dependencies
*/
import { isProductTaskExperimentTreatment } from './experimental-products/use-product-layout-experiment';
import { isImportProductExperiment } from './product-task-experiment';
import { isImportProduct } from './utils';
import './PaymentGatewaySuggestions';
import './shipping';
import './Marketing';
Expand All @@ -12,28 +11,15 @@ import './tax';
import './woocommerce-payments';
import './purchase';

const possiblyImportProductTaskExperiment = async () => {
const isExperiment = await isProductTaskExperimentTreatment();
if ( isExperiment ) {
if ( isImportProductExperiment() ) {
import( './experimental-import-products' );
} else {
import( './experimental-products' );
}
const possiblyImportProductTask = async () => {
if ( isImportProduct() ) {
import( './import-products' );
} else {
import( './products' );
}
};

if (
window.wcAdminFeatures &&
( window.wcAdminFeatures[ 'experimental-import-products-task' ] ||
window.wcAdminFeatures[ 'experimental-products-task' ] )
) {
possiblyImportProductTaskExperiment();
} else {
import( './products' );
}
possiblyImportProductTask();

if (
window.wcAdminFeatures &&
Expand Down

This file was deleted.

0 comments on commit 9f0d718

Please sign in to comment.