From 80a9c95c9038baa382840b9615816e243ceab367 Mon Sep 17 00:00:00 2001 From: moon Date: Mon, 30 Sep 2024 14:19:17 -0700 Subject: [PATCH] Use plugin_name to include woocommerce-payments in the woocommerce core profiler --- .../is-woocommerce-core-profiler-flow.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/client/state/selectors/is-woocommerce-core-profiler-flow.ts b/client/state/selectors/is-woocommerce-core-profiler-flow.ts index 01645a4aac853..e556171a64fdc 100644 --- a/client/state/selectors/is-woocommerce-core-profiler-flow.ts +++ b/client/state/selectors/is-woocommerce-core-profiler-flow.ts @@ -11,10 +11,22 @@ import type { AppState } from 'calypso/types'; * @returns {?boolean} Whether the user reached Calypso via the WooCommerce Core Profiler flow */ export const isWooCommerceCoreProfilerFlow = ( state: AppState ): boolean => { - const allowedFrom = [ 'woocommerce-core-profiler' ]; + const isCoreProfiler = + get( getInitialQueryArguments( state ), 'from' ) === 'woocommerce-core-profiler' || + get( getCurrentQueryArguments( state ), 'from' ) === 'woocommerce-core-profiler'; + + const allowedPluginNames = [ 'woocommerce-payment' ]; + const isPluginNameAllowed = + allowedPluginNames.includes( + get( getInitialQueryArguments( state ), 'plugin_name' ) as string + ) || + allowedPluginNames.includes( + get( getCurrentQueryArguments( state ), 'plugin_name' ) as string + ); + return ( - allowedFrom.includes( get( getInitialQueryArguments( state ), 'from' ) as string ) || - allowedFrom.includes( get( getCurrentQueryArguments( state ), 'from' ) as string ) || + isCoreProfiler || + isPluginNameAllowed || ( config.isEnabled( 'woocommerce/core-profiler-passwordless-auth' ) && new URLSearchParams( state.login?.redirectTo?.original ).get( 'from' ) === 'woocommerce-core-profiler' )