From 23e3de4e2c6e17fc6f9ff2e2d1593b01e5e0d1aa Mon Sep 17 00:00:00 2001
From: Ian Ramos <5714212+IanRamosC@users.noreply.github.com>
Date: Thu, 24 Oct 2024 22:35:01 -0300
Subject: [PATCH 01/10] Chore: post-ab test cleanup
---
.../packages/my-jetpack/_inc/components/welcome-flow/index.tsx | 3 +++
1 file changed, 3 insertions(+)
diff --git a/projects/packages/my-jetpack/_inc/components/welcome-flow/index.tsx b/projects/packages/my-jetpack/_inc/components/welcome-flow/index.tsx
index 430c426c9514d..46a17b82e4430 100644
--- a/projects/packages/my-jetpack/_inc/components/welcome-flow/index.tsx
+++ b/projects/packages/my-jetpack/_inc/components/welcome-flow/index.tsx
@@ -56,6 +56,9 @@ const WelcomeFlow: FC< Props > = ( {
return null;
}
+ if ( ! recommendedModules && isJetpackUserNew() ) {
+ return 'evaluation-processing';
+ }
// Otherwise, it means user is either new or just repeats the recommendation
return 'evaluation';
}
From a804365fd16eab0fef7ae77b8eb24559cd516a0d Mon Sep 17 00:00:00 2001
From: Ian Ramos <5714212+IanRamosC@users.noreply.github.com>
Date: Tue, 29 Oct 2024 10:30:14 -0300
Subject: [PATCH 02/10] Remove condition for experiment
---
.../packages/my-jetpack/_inc/components/welcome-flow/index.tsx | 3 ---
1 file changed, 3 deletions(-)
diff --git a/projects/packages/my-jetpack/_inc/components/welcome-flow/index.tsx b/projects/packages/my-jetpack/_inc/components/welcome-flow/index.tsx
index 46a17b82e4430..430c426c9514d 100644
--- a/projects/packages/my-jetpack/_inc/components/welcome-flow/index.tsx
+++ b/projects/packages/my-jetpack/_inc/components/welcome-flow/index.tsx
@@ -56,9 +56,6 @@ const WelcomeFlow: FC< Props > = ( {
return null;
}
- if ( ! recommendedModules && isJetpackUserNew() ) {
- return 'evaluation-processing';
- }
// Otherwise, it means user is either new or just repeats the recommendation
return 'evaluation';
}
From 497718593437dc0c23374d0c66c577854c65d2dc Mon Sep 17 00:00:00 2001
From: Ian Ramos <5714212+IanRamosC@users.noreply.github.com>
Date: Fri, 25 Oct 2024 00:04:30 -0300
Subject: [PATCH 03/10] My Jetpack: add post-activation experiment
---
.../welcome-flow/ConnectionStep.tsx | 39 ++++++--------
.../_inc/components/welcome-flow/index.tsx | 9 +---
projects/packages/my-jetpack/global.d.ts | 1 +
.../my-jetpack/src/class-initializer.php | 54 +++++++++++++++++++
4 files changed, 74 insertions(+), 29 deletions(-)
diff --git a/projects/packages/my-jetpack/_inc/components/welcome-flow/ConnectionStep.tsx b/projects/packages/my-jetpack/_inc/components/welcome-flow/ConnectionStep.tsx
index fe41b8d1f136e..d62acd4a7a27d 100644
--- a/projects/packages/my-jetpack/_inc/components/welcome-flow/ConnectionStep.tsx
+++ b/projects/packages/my-jetpack/_inc/components/welcome-flow/ConnectionStep.tsx
@@ -1,45 +1,43 @@
-import { Col, Button, Text, TermsOfService } from '@automattic/jetpack-components';
+import { Col, Button, Text, TermsOfService, getRedirectUrl } from '@automattic/jetpack-components';
import { initializeExPlat, loadExperimentAssignment } from '@automattic/jetpack-explat';
import { __ } from '@wordpress/i18n';
import { useCallback, useContext } from 'react';
import { NoticeContext } from '../../context/notices/noticeContext';
import { NOTICE_SITE_CONNECTED } from '../../context/notices/noticeTemplates';
import useProductsByOwnership from '../../data/products/use-products-by-ownership';
+import { getMyJetpackWindowInitialState } from '../../data/utils/get-my-jetpack-window-state';
import useAnalytics from '../../hooks/use-analytics';
import sideloadTracks from '../../utils/side-load-tracks';
import styles from './style.module.scss';
-import type { WelcomeFlowExperiment } from '.';
-import type { Dispatch, SetStateAction } from 'react';
type ConnectionStepProps = {
onActivateSite: ( e?: Event ) => Promise< void >;
- onUpdateWelcomeFlowExperiment: Dispatch< SetStateAction< WelcomeFlowExperiment > >;
isActivating: boolean;
};
/**
* Component that renders the Welcome banner on My Jetpack.
*
- * @param {object} props - ConnectioStepProps
- * @param {Function} props.onActivateSite - Alias for handleRegisterSite
- * @param {Function} props.onUpdateWelcomeFlowExperiment - Updating the welcomeFlowExperiment state
- * @param {boolean} props.isActivating - Alias for siteIsRegistering
+ * @param {object} props - ConnectioStepProps
+ * @param {Function} props.onActivateSite - Alias for handleRegisterSite
+ * @param {boolean} props.isActivating - Alias for siteIsRegistering
* @return {object} The ConnectionStep component.
*/
-const ConnectionStep = ( {
- onActivateSite,
- onUpdateWelcomeFlowExperiment,
- isActivating,
-}: ConnectionStepProps ) => {
+const ConnectionStep = ( { onActivateSite, isActivating }: ConnectionStepProps ) => {
const { recordEvent } = useAnalytics();
const { setNotice, resetNotice } = useContext( NoticeContext );
+ const { purchaseToken, siteUrl, adminUrl } = getMyJetpackWindowInitialState();
+ const redirectUri = `?redirect_uri=${ encodeURIComponent( window.location.href ) }`;
+ const connectAfterCheckoutUrl = `&connect_after_checkout=true&from_site_slug=${ siteUrl }&admin_url=${ adminUrl }`;
+ const query = `${ redirectUri }${ purchaseToken }${ connectAfterCheckoutUrl }`;
+ const jetpackPlansPath = getRedirectUrl( 'jetpack-plans', { query } );
+
const activationButtonLabel = __( 'Activate Jetpack in one click', 'jetpack-my-jetpack' );
const { refetch: refetchOwnershipData } = useProductsByOwnership();
const onConnectSiteClick = useCallback( async () => {
recordEvent( 'jetpack_myjetpack_welcome_banner_connect_site_click' );
- onUpdateWelcomeFlowExperiment( state => ( { ...state, isLoading: true } ) );
await onActivateSite();
recordEvent( 'jetpack_myjetpack_welcome_banner_connect_site_success' );
@@ -50,23 +48,20 @@ const ConnectionStep = ( {
initializeExPlat();
const { variationName } = await loadExperimentAssignment(
- 'jetpack_my_jetpack_welcome_flow_display_default_recommendations_upfront_202410'
+ 'jetpack_my_jetpack_recommendations_pricing_page_202411'
);
- onUpdateWelcomeFlowExperiment( state => ( {
- ...state,
- variation: ( variationName ?? 'control' ) as WelcomeFlowExperiment[ 'variation' ], // casting to 'control' or 'treatment'
- } ) );
+ if ( variationName === 'treatment' ) {
+ window.location.href = jetpackPlansPath;
+ }
} finally {
resetNotice();
setNotice( NOTICE_SITE_CONNECTED, resetNotice );
refetchOwnershipData();
-
- onUpdateWelcomeFlowExperiment( state => ( { ...state, isLoading: false } ) );
}
}, [
+ jetpackPlansPath,
onActivateSite,
- onUpdateWelcomeFlowExperiment,
recordEvent,
refetchOwnershipData,
resetNotice,
diff --git a/projects/packages/my-jetpack/_inc/components/welcome-flow/index.tsx b/projects/packages/my-jetpack/_inc/components/welcome-flow/index.tsx
index 430c426c9514d..9fc11bfa3f401 100644
--- a/projects/packages/my-jetpack/_inc/components/welcome-flow/index.tsx
+++ b/projects/packages/my-jetpack/_inc/components/welcome-flow/index.tsx
@@ -25,11 +25,7 @@ interface Props extends PropsWithChildren {
setWelcomeFlowExperiment: React.Dispatch< React.SetStateAction< WelcomeFlowExperiment > >;
}
-const WelcomeFlow: FC< Props > = ( {
- welcomeFlowExperiment,
- setWelcomeFlowExperiment,
- children,
-} ) => {
+const WelcomeFlow: FC< Props > = ( { children } ) => {
const { recordEvent } = useAnalytics();
const { dismissWelcomeBanner } = useWelcomeBanner();
const { recommendedModules, submitEvaluation, saveEvaluationResult } =
@@ -131,8 +127,7 @@ const WelcomeFlow: FC< Props > = ( {
{ 'connection' === currentStep && (
) }
{ 'evaluation' === currentStep && (
diff --git a/projects/packages/my-jetpack/global.d.ts b/projects/packages/my-jetpack/global.d.ts
index f302d8567e765..49d4563fabc82 100644
--- a/projects/packages/my-jetpack/global.d.ts
+++ b/projects/packages/my-jetpack/global.d.ts
@@ -99,6 +99,7 @@ interface Window {
showFullJetpackStatsCard: boolean;
videoPressStats: boolean;
};
+ purchaseToken: string;
lifecycleStats: {
historicallyActiveModules: JetpackModule[];
brokenModules: {
diff --git a/projects/packages/my-jetpack/src/class-initializer.php b/projects/packages/my-jetpack/src/class-initializer.php
index 61a490fa4f0ba..9a062833d13c7 100644
--- a/projects/packages/my-jetpack/src/class-initializer.php
+++ b/projects/packages/my-jetpack/src/class-initializer.php
@@ -201,6 +201,28 @@ public static function can_use_analytics() {
return $tracking->should_enable_tracking( new Terms_Of_Service(), $status );
}
+
+ /**
+ * Gets a purchase token that is used for Jetpack logged out visitor checkout.
+ * The purchase token should be appended to all CTA url's that lead to checkout.
+ *
+ * @return string|boolean
+ */
+ protected static function get_purchase_token() {
+ if ( ! self::current_user_can_purchase() ) {
+ return false;
+ }
+
+ $purchase_token = \Jetpack_Options::get_option( 'purchase_token', false );
+
+ if ( $purchase_token ) {
+ return $purchase_token;
+ }
+ // If the purchase token is not saved in the options table yet, then add it.
+ \Jetpack_Options::update_option( 'purchase_token', self::generate_purchase_token(), true );
+ return \Jetpack_Options::get_option( 'purchase_token', false );
+ }
+
/**
* Enqueue admin page assets.
*
@@ -265,6 +287,7 @@ public static function enqueue_scripts() {
'loadAddLicenseScreen' => self::is_licensing_ui_enabled(),
'adminUrl' => esc_url( admin_url() ),
'IDCContainerID' => static::get_idc_container_id(),
+ 'purchaseToken' => self::get_purchase_token(),
'userIsAdmin' => current_user_can( 'manage_options' ),
'userIsNewToJetpack' => self::is_jetpack_user_new(),
'lifecycleStats' => array(
@@ -967,4 +990,35 @@ public static function alert_if_missing_connection( array $red_bubble_slugs ) {
return $red_bubble_slugs;
}
+
+ /**
+ * Generates a purchase token that is used for Jetpack logged out visitor checkout.
+ *
+ * @return string
+ */
+ protected static function generate_purchase_token() {
+ return wp_generate_password( 12, false );
+ }
+
+ /**
+ * Determine if the current user is allowed to make Jetpack purchases without
+ * a WordPress.com account
+ *
+ * @return boolean True if the user can make purchases, false if not
+ */
+ public static function current_user_can_purchase() {
+ // The site must be site-connected to Jetpack (no users connected).
+ $connection_manager = new Connection_Manager();
+
+ if ( ! $connection_manager->is_site_connection() ) {
+ return false;
+ }
+
+ // Make sure only administrators can make purchases.
+ if ( ! current_user_can( 'manage_options' ) ) {
+ return false;
+ }
+
+ return true;
+ }
}
From e16c46b3dba7e4919d023b40ebd8383dc28fad2b Mon Sep 17 00:00:00 2001
From: Ian Ramos <5714212+IanRamosC@users.noreply.github.com>
Date: Tue, 29 Oct 2024 17:28:33 -0300
Subject: [PATCH 04/10] changelog
---
.../changelog/add-my-jetpack-pricing-page-experiment | 4 ++++
1 file changed, 4 insertions(+)
create mode 100644 projects/packages/my-jetpack/changelog/add-my-jetpack-pricing-page-experiment
diff --git a/projects/packages/my-jetpack/changelog/add-my-jetpack-pricing-page-experiment b/projects/packages/my-jetpack/changelog/add-my-jetpack-pricing-page-experiment
new file mode 100644
index 0000000000000..2f9bc654e9fd1
--- /dev/null
+++ b/projects/packages/my-jetpack/changelog/add-my-jetpack-pricing-page-experiment
@@ -0,0 +1,4 @@
+Significance: minor
+Type: changed
+
+My Jetpack: add experiment to the post-connection flow in My Jetpack.
From 8cba9c8685fa624ec4cd14ec6be07deeec0de129 Mon Sep 17 00:00:00 2001
From: Ian Ramos <5714212+IanRamosC@users.noreply.github.com>
Date: Thu, 31 Oct 2024 12:07:13 -0300
Subject: [PATCH 05/10] Keep the loading state while fetching assignment
---
.../welcome-flow/ConnectionStep.tsx | 23 +++++++++++++++----
.../_inc/components/welcome-flow/index.tsx | 20 +++++++++++++---
2 files changed, 36 insertions(+), 7 deletions(-)
diff --git a/projects/packages/my-jetpack/_inc/components/welcome-flow/ConnectionStep.tsx b/projects/packages/my-jetpack/_inc/components/welcome-flow/ConnectionStep.tsx
index d62acd4a7a27d..eea2e5d28bbee 100644
--- a/projects/packages/my-jetpack/_inc/components/welcome-flow/ConnectionStep.tsx
+++ b/projects/packages/my-jetpack/_inc/components/welcome-flow/ConnectionStep.tsx
@@ -9,21 +9,29 @@ import { getMyJetpackWindowInitialState } from '../../data/utils/get-my-jetpack-
import useAnalytics from '../../hooks/use-analytics';
import sideloadTracks from '../../utils/side-load-tracks';
import styles from './style.module.scss';
+import { WelcomeFlowExperiment } from '.';
+import type { Dispatch, SetStateAction } from 'react';
type ConnectionStepProps = {
onActivateSite: ( e?: Event ) => Promise< void >;
+ onUpdateWelcomeFlowExperiment: Dispatch< SetStateAction< WelcomeFlowExperiment > >;
isActivating: boolean;
};
/**
* Component that renders the Welcome banner on My Jetpack.
*
- * @param {object} props - ConnectioStepProps
- * @param {Function} props.onActivateSite - Alias for handleRegisterSite
- * @param {boolean} props.isActivating - Alias for siteIsRegistering
+ * @param {object} props - ConnectioStepProps
+ * @param {Function} props.onActivateSite - Alias for handleRegisterSite
+ * @param {boolean} props.isActivating - Alias for siteIsRegistering
+ * @param {Function} props.onUpdateWelcomeFlowExperiment - Function to update the welcomeFlowExperiment state
* @return {object} The ConnectionStep component.
*/
-const ConnectionStep = ( { onActivateSite, isActivating }: ConnectionStepProps ) => {
+const ConnectionStep = ( {
+ onActivateSite,
+ onUpdateWelcomeFlowExperiment,
+ isActivating,
+}: ConnectionStepProps ) => {
const { recordEvent } = useAnalytics();
const { setNotice, resetNotice } = useContext( NoticeContext );
@@ -38,6 +46,7 @@ const ConnectionStep = ( { onActivateSite, isActivating }: ConnectionStepProps )
const onConnectSiteClick = useCallback( async () => {
recordEvent( 'jetpack_myjetpack_welcome_banner_connect_site_click' );
+ onUpdateWelcomeFlowExperiment( state => ( { ...state, isLoading: true } ) );
await onActivateSite();
recordEvent( 'jetpack_myjetpack_welcome_banner_connect_site_success' );
@@ -51,6 +60,11 @@ const ConnectionStep = ( { onActivateSite, isActivating }: ConnectionStepProps )
'jetpack_my_jetpack_recommendations_pricing_page_202411'
);
+ onUpdateWelcomeFlowExperiment( state => ( {
+ ...state,
+ variation: ( variationName ?? 'control' ) as WelcomeFlowExperiment[ 'variation' ], // casting to 'control' or 'treatment'
+ } ) );
+
if ( variationName === 'treatment' ) {
window.location.href = jetpackPlansPath;
}
@@ -62,6 +76,7 @@ const ConnectionStep = ( { onActivateSite, isActivating }: ConnectionStepProps )
}, [
jetpackPlansPath,
onActivateSite,
+ onUpdateWelcomeFlowExperiment,
recordEvent,
refetchOwnershipData,
resetNotice,
diff --git a/projects/packages/my-jetpack/_inc/components/welcome-flow/index.tsx b/projects/packages/my-jetpack/_inc/components/welcome-flow/index.tsx
index 9fc11bfa3f401..a781e37da7ebb 100644
--- a/projects/packages/my-jetpack/_inc/components/welcome-flow/index.tsx
+++ b/projects/packages/my-jetpack/_inc/components/welcome-flow/index.tsx
@@ -25,7 +25,11 @@ interface Props extends PropsWithChildren {
setWelcomeFlowExperiment: React.Dispatch< React.SetStateAction< WelcomeFlowExperiment > >;
}
-const WelcomeFlow: FC< Props > = ( { children } ) => {
+const WelcomeFlow: FC< Props > = ( {
+ welcomeFlowExperiment,
+ setWelcomeFlowExperiment,
+ children,
+} ) => {
const { recordEvent } = useAnalytics();
const { dismissWelcomeBanner } = useWelcomeBanner();
const { recommendedModules, submitEvaluation, saveEvaluationResult } =
@@ -52,12 +56,21 @@ const WelcomeFlow: FC< Props > = ( { children } ) => {
return null;
}
+ if ( welcomeFlowExperiment.isLoading ) {
+ return 'evaluation-processing';
+ }
+
// Otherwise, it means user is either new or just repeats the recommendation
return 'evaluation';
}
return 'evaluation-processing';
- }, [ isProcessingEvaluation, recommendedModules, siteIsRegistered ] );
+ }, [
+ isProcessingEvaluation,
+ recommendedModules,
+ siteIsRegistered,
+ welcomeFlowExperiment.isLoading,
+ ] );
useEffect( () => {
if ( prevStep !== currentStep ) {
@@ -127,7 +140,8 @@ const WelcomeFlow: FC< Props > = ( { children } ) => {
{ 'connection' === currentStep && (
) }
{ 'evaluation' === currentStep && (
From 25866ca7f767d7cefbf4df0f7e3602a77bf8cebf Mon Sep 17 00:00:00 2001
From: Ian Ramos <5714212+IanRamosC@users.noreply.github.com>
Date: Thu, 31 Oct 2024 21:28:38 -0300
Subject: [PATCH 06/10] Decide when to set the purchase token
---
.../_inc/components/welcome-flow/ConnectionStep.tsx | 2 +-
projects/packages/my-jetpack/src/class-initializer.php | 10 +---------
2 files changed, 2 insertions(+), 10 deletions(-)
diff --git a/projects/packages/my-jetpack/_inc/components/welcome-flow/ConnectionStep.tsx b/projects/packages/my-jetpack/_inc/components/welcome-flow/ConnectionStep.tsx
index eea2e5d28bbee..b10387af84780 100644
--- a/projects/packages/my-jetpack/_inc/components/welcome-flow/ConnectionStep.tsx
+++ b/projects/packages/my-jetpack/_inc/components/welcome-flow/ConnectionStep.tsx
@@ -39,7 +39,7 @@ const ConnectionStep = ( {
const redirectUri = `?redirect_uri=${ encodeURIComponent( window.location.href ) }`;
const connectAfterCheckoutUrl = `&connect_after_checkout=true&from_site_slug=${ siteUrl }&admin_url=${ adminUrl }`;
const query = `${ redirectUri }${ purchaseToken }${ connectAfterCheckoutUrl }`;
- const jetpackPlansPath = getRedirectUrl( 'jetpack-plans', { query } );
+ const jetpackPlansPath = getRedirectUrl( 'jetpack-nav-plans-no-site', { query } );
const activationButtonLabel = __( 'Activate Jetpack in one click', 'jetpack-my-jetpack' );
const { refetch: refetchOwnershipData } = useProductsByOwnership();
diff --git a/projects/packages/my-jetpack/src/class-initializer.php b/projects/packages/my-jetpack/src/class-initializer.php
index 9a062833d13c7..adac96c4aa236 100644
--- a/projects/packages/my-jetpack/src/class-initializer.php
+++ b/projects/packages/my-jetpack/src/class-initializer.php
@@ -1001,19 +1001,11 @@ protected static function generate_purchase_token() {
}
/**
- * Determine if the current user is allowed to make Jetpack purchases without
- * a WordPress.com account
+ * Determine if the current user is allowed to make Jetpack purchases.
*
* @return boolean True if the user can make purchases, false if not
*/
public static function current_user_can_purchase() {
- // The site must be site-connected to Jetpack (no users connected).
- $connection_manager = new Connection_Manager();
-
- if ( ! $connection_manager->is_site_connection() ) {
- return false;
- }
-
// Make sure only administrators can make purchases.
if ( ! current_user_can( 'manage_options' ) ) {
return false;
From bca6d64419e4ed9866204f43503839006013949b Mon Sep 17 00:00:00 2001
From: Ian Ramos <5714212+IanRamosC@users.noreply.github.com>
Date: Thu, 31 Oct 2024 22:14:32 -0300
Subject: [PATCH 07/10] Remove purchase token for siteless purchases
---
.../welcome-flow/ConnectionStep.tsx | 4 +-
.../my-jetpack/src/class-initializer.php | 45 -------------------
2 files changed, 2 insertions(+), 47 deletions(-)
diff --git a/projects/packages/my-jetpack/_inc/components/welcome-flow/ConnectionStep.tsx b/projects/packages/my-jetpack/_inc/components/welcome-flow/ConnectionStep.tsx
index b10387af84780..990ae4421be49 100644
--- a/projects/packages/my-jetpack/_inc/components/welcome-flow/ConnectionStep.tsx
+++ b/projects/packages/my-jetpack/_inc/components/welcome-flow/ConnectionStep.tsx
@@ -35,10 +35,10 @@ const ConnectionStep = ( {
const { recordEvent } = useAnalytics();
const { setNotice, resetNotice } = useContext( NoticeContext );
- const { purchaseToken, siteUrl, adminUrl } = getMyJetpackWindowInitialState();
+ const { siteUrl, adminUrl } = getMyJetpackWindowInitialState();
const redirectUri = `?redirect_uri=${ encodeURIComponent( window.location.href ) }`;
const connectAfterCheckoutUrl = `&connect_after_checkout=true&from_site_slug=${ siteUrl }&admin_url=${ adminUrl }`;
- const query = `${ redirectUri }${ purchaseToken }${ connectAfterCheckoutUrl }`;
+ const query = `${ redirectUri }${ connectAfterCheckoutUrl }`;
const jetpackPlansPath = getRedirectUrl( 'jetpack-nav-plans-no-site', { query } );
const activationButtonLabel = __( 'Activate Jetpack in one click', 'jetpack-my-jetpack' );
diff --git a/projects/packages/my-jetpack/src/class-initializer.php b/projects/packages/my-jetpack/src/class-initializer.php
index adac96c4aa236..49c481e250905 100644
--- a/projects/packages/my-jetpack/src/class-initializer.php
+++ b/projects/packages/my-jetpack/src/class-initializer.php
@@ -202,27 +202,6 @@ public static function can_use_analytics() {
return $tracking->should_enable_tracking( new Terms_Of_Service(), $status );
}
- /**
- * Gets a purchase token that is used for Jetpack logged out visitor checkout.
- * The purchase token should be appended to all CTA url's that lead to checkout.
- *
- * @return string|boolean
- */
- protected static function get_purchase_token() {
- if ( ! self::current_user_can_purchase() ) {
- return false;
- }
-
- $purchase_token = \Jetpack_Options::get_option( 'purchase_token', false );
-
- if ( $purchase_token ) {
- return $purchase_token;
- }
- // If the purchase token is not saved in the options table yet, then add it.
- \Jetpack_Options::update_option( 'purchase_token', self::generate_purchase_token(), true );
- return \Jetpack_Options::get_option( 'purchase_token', false );
- }
-
/**
* Enqueue admin page assets.
*
@@ -287,7 +266,6 @@ public static function enqueue_scripts() {
'loadAddLicenseScreen' => self::is_licensing_ui_enabled(),
'adminUrl' => esc_url( admin_url() ),
'IDCContainerID' => static::get_idc_container_id(),
- 'purchaseToken' => self::get_purchase_token(),
'userIsAdmin' => current_user_can( 'manage_options' ),
'userIsNewToJetpack' => self::is_jetpack_user_new(),
'lifecycleStats' => array(
@@ -990,27 +968,4 @@ public static function alert_if_missing_connection( array $red_bubble_slugs ) {
return $red_bubble_slugs;
}
-
- /**
- * Generates a purchase token that is used for Jetpack logged out visitor checkout.
- *
- * @return string
- */
- protected static function generate_purchase_token() {
- return wp_generate_password( 12, false );
- }
-
- /**
- * Determine if the current user is allowed to make Jetpack purchases.
- *
- * @return boolean True if the user can make purchases, false if not
- */
- public static function current_user_can_purchase() {
- // Make sure only administrators can make purchases.
- if ( ! current_user_can( 'manage_options' ) ) {
- return false;
- }
-
- return true;
- }
}
From 94065619c67f259979816478f7a5613011748f39 Mon Sep 17 00:00:00 2001
From: Ian Ramos <5714212+IanRamosC@users.noreply.github.com>
Date: Thu, 31 Oct 2024 23:50:23 -0300
Subject: [PATCH 08/10] My Jetpack: point to right redirect
---
.../_inc/components/welcome-flow/ConnectionStep.tsx | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/projects/packages/my-jetpack/_inc/components/welcome-flow/ConnectionStep.tsx b/projects/packages/my-jetpack/_inc/components/welcome-flow/ConnectionStep.tsx
index 990ae4421be49..508ae01d923d2 100644
--- a/projects/packages/my-jetpack/_inc/components/welcome-flow/ConnectionStep.tsx
+++ b/projects/packages/my-jetpack/_inc/components/welcome-flow/ConnectionStep.tsx
@@ -35,11 +35,14 @@ const ConnectionStep = ( {
const { recordEvent } = useAnalytics();
const { setNotice, resetNotice } = useContext( NoticeContext );
- const { siteUrl, adminUrl } = getMyJetpackWindowInitialState();
+ const { siteSuffix, siteUrl, adminUrl } = getMyJetpackWindowInitialState();
const redirectUri = `?redirect_uri=${ encodeURIComponent( window.location.href ) }`;
const connectAfterCheckoutUrl = `&connect_after_checkout=true&from_site_slug=${ siteUrl }&admin_url=${ adminUrl }`;
const query = `${ redirectUri }${ connectAfterCheckoutUrl }`;
- const jetpackPlansPath = getRedirectUrl( 'jetpack-nav-plans-no-site', { query } );
+ const jetpackPlansPath = getRedirectUrl( 'jetpack-my-jetpack-site-only-plans', {
+ site: siteSuffix,
+ query,
+ } );
const activationButtonLabel = __( 'Activate Jetpack in one click', 'jetpack-my-jetpack' );
const { refetch: refetchOwnershipData } = useProductsByOwnership();
From ded2a7fa30cc506951e5ff653214d9079ae3a43a Mon Sep 17 00:00:00 2001
From: Ian Ramos <5714212+IanRamosC@users.noreply.github.com>
Date: Fri, 1 Nov 2024 00:21:57 -0300
Subject: [PATCH 09/10] My Jetpack: fix step while assignment is loading
---
.../my-jetpack/_inc/components/welcome-flow/index.tsx | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/projects/packages/my-jetpack/_inc/components/welcome-flow/index.tsx b/projects/packages/my-jetpack/_inc/components/welcome-flow/index.tsx
index a781e37da7ebb..754612efc01ff 100644
--- a/projects/packages/my-jetpack/_inc/components/welcome-flow/index.tsx
+++ b/projects/packages/my-jetpack/_inc/components/welcome-flow/index.tsx
@@ -47,7 +47,7 @@ const WelcomeFlow: FC< Props > = ( {
const [ prevStep, setPrevStep ] = useState( '' );
const currentStep = useMemo( () => {
- if ( ! siteIsRegistered ) {
+ if ( ! siteIsRegistered || welcomeFlowExperiment.isLoading ) {
return 'connection';
} else if ( ! isProcessingEvaluation ) {
if ( ! recommendedModules && ! isJetpackUserNew() ) {
@@ -56,10 +56,6 @@ const WelcomeFlow: FC< Props > = ( {
return null;
}
- if ( welcomeFlowExperiment.isLoading ) {
- return 'evaluation-processing';
- }
-
// Otherwise, it means user is either new or just repeats the recommendation
return 'evaluation';
}
From 4a0f70ce6213acba6722d08c157705c38224b3c9 Mon Sep 17 00:00:00 2001
From: Ian Ramos <5714212+IanRamosC@users.noreply.github.com>
Date: Fri, 1 Nov 2024 10:03:44 -0300
Subject: [PATCH 10/10] My Jetpack: fix redirect URL after connection
---
.../components/welcome-flow/ConnectionStep.tsx | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/projects/packages/my-jetpack/_inc/components/welcome-flow/ConnectionStep.tsx b/projects/packages/my-jetpack/_inc/components/welcome-flow/ConnectionStep.tsx
index 508ae01d923d2..aa30d0d15853c 100644
--- a/projects/packages/my-jetpack/_inc/components/welcome-flow/ConnectionStep.tsx
+++ b/projects/packages/my-jetpack/_inc/components/welcome-flow/ConnectionStep.tsx
@@ -35,14 +35,13 @@ const ConnectionStep = ( {
const { recordEvent } = useAnalytics();
const { setNotice, resetNotice } = useContext( NoticeContext );
- const { siteSuffix, siteUrl, adminUrl } = getMyJetpackWindowInitialState();
- const redirectUri = `?redirect_uri=${ encodeURIComponent( window.location.href ) }`;
- const connectAfterCheckoutUrl = `&connect_after_checkout=true&from_site_slug=${ siteUrl }&admin_url=${ adminUrl }`;
- const query = `${ redirectUri }${ connectAfterCheckoutUrl }`;
- const jetpackPlansPath = getRedirectUrl( 'jetpack-my-jetpack-site-only-plans', {
- site: siteSuffix,
- query,
- } );
+ const { siteSuffix, adminUrl } = getMyJetpackWindowInitialState();
+ const connectAfterCheckoutUrl = `?connect_after_checkout=true&admin_url=${ encodeURIComponent(
+ adminUrl
+ ) }&from_site_slug=${ siteSuffix }&source=my-jetpack`;
+ const redirectUri = `&redirect_to=${ encodeURIComponent( window.location.href ) }`;
+ const query = `${ connectAfterCheckoutUrl }${ redirectUri }&unlinked=1`;
+ const jetpackPlansPath = getRedirectUrl( 'jetpack-my-jetpack-site-only-plans', { query } );
const activationButtonLabel = __( 'Activate Jetpack in one click', 'jetpack-my-jetpack' );
const { refetch: refetchOwnershipData } = useProductsByOwnership();
@@ -75,6 +74,8 @@ const ConnectionStep = ( {
resetNotice();
setNotice( NOTICE_SITE_CONNECTED, resetNotice );
refetchOwnershipData();
+
+ onUpdateWelcomeFlowExperiment( state => ( { ...state, isLoading: false } ) );
}
}, [
jetpackPlansPath,