Dynamically set plugin_name when redirecting to Jetpack Auth from core profiler (#51278)

* Dynamically set plugin_name when redirecting to Jetpack Auth from core profiler

* Add changelog

* Update param name
This commit is contained in:
Chi-Hsuan Huang 2024-09-13 08:34:17 +08:00 committed by GitHub
parent 45fc403f6f
commit f89366033d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 1 deletions

View File

@ -300,15 +300,28 @@ const exitToWooHome = fromPromise( async () => {
window.location.href = getNewPath( {}, '/', {} ); window.location.href = getNewPath( {}, '/', {} );
} ); } );
const getPluginNameParam = (
pluginsSelected: CoreProfilerStateMachineContext[ 'pluginsSelected' ]
) => {
if ( pluginsSelected.includes( 'woocommerce-payments' ) ) {
return 'woocommerce-payments';
}
return 'jetpack-ai';
};
const redirectToJetpackAuthPage = ( { const redirectToJetpackAuthPage = ( {
event, event,
context,
}: { }: {
context: CoreProfilerStateMachineContext; context: CoreProfilerStateMachineContext;
event: { output: { url: string } }; event: { output: { url: string } };
} ) => { } ) => {
const url = new URL( event.output.url ); const url = new URL( event.output.url );
url.searchParams.set( 'installed_ext_success', '1' ); url.searchParams.set( 'installed_ext_success', '1' );
url.searchParams.set( 'plugin_name', 'jetpack-ai' ); url.searchParams.set(
'plugin_name',
getPluginNameParam( context.pluginsSelected )
);
window.location.href = url.toString(); window.location.href = url.toString();
}; };

View File

@ -0,0 +1,4 @@
Significance: patch
Type: update
Dynamically set plugin_name when redirecting to Jetpack Auth from core profiler