diff --git a/projects/packages/my-jetpack/_inc/state/reducers.js b/projects/packages/my-jetpack/_inc/state/reducers.js index 5757c7beeaeb4..d899d6dc2faad 100644 --- a/projects/packages/my-jetpack/_inc/state/reducers.js +++ b/projects/packages/my-jetpack/_inc/state/reducers.js @@ -274,6 +274,13 @@ const welcomeBanner = ( state = {}, action ) => { } }; +const lifecycleStats = ( state = {}, action ) => { + switch ( action.type ) { + default: + return state; + } +}; + const reducers = combineReducers( { products, backupRewindableEvents, @@ -286,6 +293,7 @@ const reducers = combineReducers( { stats, statsCounts, welcomeBanner, + lifecycleStats, } ); export default reducers; diff --git a/projects/packages/my-jetpack/_inc/state/selectors.js b/projects/packages/my-jetpack/_inc/state/selectors.js index 7270f56cbabfd..3696db7f9f0dd 100644 --- a/projects/packages/my-jetpack/_inc/state/selectors.js +++ b/projects/packages/my-jetpack/_inc/state/selectors.js @@ -138,6 +138,37 @@ const getStatsCounts = state => { return state.statsCounts?.data; }; +const getLifecycleStats = state => { + return state.lifecycleStats; +}; + +const getGuessedSiteLifecycleStatus = state => { + const { modules, purchases, plugins, isSiteConnected, isUserConnected } = + getLifecycleStats( state ); + + // 'new' = no purchases + less than 3 modules + if ( purchases.length === 0 && modules.length < 3 ) { + // 'brand-new' = 'new' + (no user or site connection + no modules + only one plugin) + if ( + ( ! isUserConnected || ! isSiteConnected ) && + modules.length === 0 && + plugins.length === 1 + ) { + return 'brand-new'; + } + + return 'new'; + } + + // 'settling-in' = 1 purchase and less than 10 modules + if ( purchases.length === 1 && modules.length < 10 ) { + return 'settling-in'; + } + + // 'established' = 2 or more purchases or 10 or more modules + return 'established'; +}; + const isFetchingStatsCounts = state => { return state.statsCounts?.isFetching || false; }; @@ -163,6 +194,7 @@ const selectors = { ...countBackupItemsSelectors, ...statsCountsSelectors, getWelcomeBannerHasBeenDismissed, + getGuessedSiteLifecycleStatus, }; export default selectors; diff --git a/projects/packages/my-jetpack/changelog/add-my-jetpack-user-type-check b/projects/packages/my-jetpack/changelog/add-my-jetpack-user-type-check new file mode 100644 index 0000000000000..42db3fa20ea47 --- /dev/null +++ b/projects/packages/my-jetpack/changelog/add-my-jetpack-user-type-check @@ -0,0 +1,4 @@ +Significance: minor +Type: added + +Add site lifecycle status guess to My Jetpack diff --git a/projects/packages/my-jetpack/composer.json b/projects/packages/my-jetpack/composer.json index a46e4afd5951c..5c001c5c8cdb1 100644 --- a/projects/packages/my-jetpack/composer.json +++ b/projects/packages/my-jetpack/composer.json @@ -77,7 +77,7 @@ "link-template": "https://github.com/Automattic/jetpack-my-jetpack/compare/${old}...${new}" }, "branch-alias": { - "dev-trunk": "4.12.x-dev" + "dev-trunk": "4.13.x-dev" }, "version-constants": { "::PACKAGE_VERSION": "src/class-initializer.php" diff --git a/projects/packages/my-jetpack/package.json b/projects/packages/my-jetpack/package.json index 97f3265450179..b35c9319a9ac7 100644 --- a/projects/packages/my-jetpack/package.json +++ b/projects/packages/my-jetpack/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@automattic/jetpack-my-jetpack", - "version": "4.12.1-alpha", + "version": "4.13.0-alpha", "description": "WP Admin page with information and configuration shared among all Jetpack stand-alone plugins", "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/my-jetpack/#readme", "bugs": { diff --git a/projects/packages/my-jetpack/src/class-initializer.php b/projects/packages/my-jetpack/src/class-initializer.php index 109b3f047f0d7..e7a66dc6b270e 100644 --- a/projects/packages/my-jetpack/src/class-initializer.php +++ b/projects/packages/my-jetpack/src/class-initializer.php @@ -35,7 +35,7 @@ class Initializer { * * @var string */ - const PACKAGE_VERSION = '4.12.1-alpha'; + const PACKAGE_VERSION = '4.13.0-alpha'; /** * HTML container ID for the IDC screen on My Jetpack page. @@ -189,6 +189,7 @@ public static function enqueue_scripts() { ) ); $modules = new Modules(); + $connection = new Connection_Manager(); $speed_score_history = new Speed_Score_History( wp_parse_url( get_site_url(), PHP_URL_HOST ) ); wp_localize_script( 'my_jetpack_main_app', @@ -214,6 +215,13 @@ public static function enqueue_scripts() { 'IDCContainerID' => static::get_idc_container_id(), 'userIsAdmin' => current_user_can( 'manage_options' ), 'userIsNewToJetpack' => self::is_jetpack_user_new(), + 'lifecycleStats' => array( + 'jetpackPlugins' => self::get_installed_jetpack_plugins(), + 'isSiteConnected' => $connection->is_connected(), + 'isUserConnected' => $connection->is_user_connected(), + 'purchases' => self::get_purchases(), + 'modules' => self::get_active_modules(), + ), 'isStatsModuleActive' => $modules->is_active( 'stats' ), 'isUserFromKnownHost' => self::is_user_from_known_host(), 'isCommercial' => self::is_commercial_site(), @@ -246,6 +254,63 @@ public static function enqueue_scripts() { } } + /** + * Get product slugs of the active purchases + * + * @return array + */ + public static function get_purchases() { + $purchases = Wpcom_Products::get_site_current_purchases(); + if ( is_wp_error( $purchases ) ) { + return array(); + } + + return array_map( + function ( $purchase ) { + return $purchase->product_slug; + }, + $purchases + ); + } + + /** + * Get installed Jetpack plugins + * + * @return array + */ + public static function get_installed_jetpack_plugins() { + $plugin_slugs = array_keys( Plugins_Installer::get_plugins() ); + $plugin_slugs = array_map( + static function ( $slug ) { + $parts = explode( '/', $slug ); + if ( empty( $parts ) ) { + return ''; + } + // Return the last segment of the filepath without the PHP extension + return str_replace( '.php', '', $parts[ count( $parts ) - 1 ] ); + }, + $plugin_slugs + ); + + return array_values( array_intersect( self::JETPACK_PLUGIN_SLUGS, $plugin_slugs ) ); + } + + /** + * Get active modules (except ones enabled by default) + * + * @return array + */ + public static function get_active_modules() { + $modules = new Modules(); + $active_modules = $modules->get_active(); + + // if the Jetpack plugin is active, filter out the modules that are active by default + if ( class_exists( 'Jetpack' ) && ! empty( $active_modules ) ) { + $active_modules = array_diff( $active_modules, Jetpack::get_default_modules() ); + } + return $active_modules; + } + /** * Determine if the current user is "new" to Jetpack * This is used to vary some messaging in My Jetpack diff --git a/projects/plugins/backup/changelog/add-my-jetpack-user-type-check b/projects/plugins/backup/changelog/add-my-jetpack-user-type-check new file mode 100644 index 0000000000000..9aa70e3ec1f75 --- /dev/null +++ b/projects/plugins/backup/changelog/add-my-jetpack-user-type-check @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Updated composer.lock. + + diff --git a/projects/plugins/backup/composer.lock b/projects/plugins/backup/composer.lock index 28b099ca15546..cedc3c71336d5 100644 --- a/projects/plugins/backup/composer.lock +++ b/projects/plugins/backup/composer.lock @@ -1122,7 +1122,7 @@ "dist": { "type": "path", "url": "../../packages/my-jetpack", - "reference": "cd2abb7246ef3cbccfdfe5ca4b68a4581f0c8586" + "reference": "2475331cc29709ee844d2f99340199e6e3fa0f00" }, "require": { "automattic/jetpack-admin-ui": "@dev", @@ -1155,7 +1155,7 @@ "link-template": "https://github.com/Automattic/jetpack-my-jetpack/compare/${old}...${new}" }, "branch-alias": { - "dev-trunk": "4.12.x-dev" + "dev-trunk": "4.13.x-dev" }, "version-constants": { "::PACKAGE_VERSION": "src/class-initializer.php" diff --git a/projects/plugins/boost/changelog/add-my-jetpack-user-type-check b/projects/plugins/boost/changelog/add-my-jetpack-user-type-check new file mode 100644 index 0000000000000..9aa70e3ec1f75 --- /dev/null +++ b/projects/plugins/boost/changelog/add-my-jetpack-user-type-check @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Updated composer.lock. + + diff --git a/projects/plugins/boost/composer.lock b/projects/plugins/boost/composer.lock index cf7ff2c63520b..bffbca3f740d7 100644 --- a/projects/plugins/boost/composer.lock +++ b/projects/plugins/boost/composer.lock @@ -1047,7 +1047,7 @@ "dist": { "type": "path", "url": "../../packages/my-jetpack", - "reference": "cd2abb7246ef3cbccfdfe5ca4b68a4581f0c8586" + "reference": "2475331cc29709ee844d2f99340199e6e3fa0f00" }, "require": { "automattic/jetpack-admin-ui": "@dev", @@ -1080,7 +1080,7 @@ "link-template": "https://github.com/Automattic/jetpack-my-jetpack/compare/${old}...${new}" }, "branch-alias": { - "dev-trunk": "4.12.x-dev" + "dev-trunk": "4.13.x-dev" }, "version-constants": { "::PACKAGE_VERSION": "src/class-initializer.php" diff --git a/projects/plugins/jetpack/changelog/add-my-jetpack-user-type-check b/projects/plugins/jetpack/changelog/add-my-jetpack-user-type-check new file mode 100644 index 0000000000000..a1c1831fa1ef7 --- /dev/null +++ b/projects/plugins/jetpack/changelog/add-my-jetpack-user-type-check @@ -0,0 +1,5 @@ +Significance: patch +Type: other +Comment: Updated composer.lock. + + diff --git a/projects/plugins/jetpack/composer.lock b/projects/plugins/jetpack/composer.lock index 98c60278cbe34..0d13caf1f43f3 100644 --- a/projects/plugins/jetpack/composer.lock +++ b/projects/plugins/jetpack/composer.lock @@ -1681,7 +1681,7 @@ "dist": { "type": "path", "url": "../../packages/my-jetpack", - "reference": "cd2abb7246ef3cbccfdfe5ca4b68a4581f0c8586" + "reference": "2475331cc29709ee844d2f99340199e6e3fa0f00" }, "require": { "automattic/jetpack-admin-ui": "@dev", @@ -1714,7 +1714,7 @@ "link-template": "https://github.com/Automattic/jetpack-my-jetpack/compare/${old}...${new}" }, "branch-alias": { - "dev-trunk": "4.12.x-dev" + "dev-trunk": "4.13.x-dev" }, "version-constants": { "::PACKAGE_VERSION": "src/class-initializer.php" diff --git a/projects/plugins/migration/changelog/add-my-jetpack-user-type-check b/projects/plugins/migration/changelog/add-my-jetpack-user-type-check new file mode 100644 index 0000000000000..9aa70e3ec1f75 --- /dev/null +++ b/projects/plugins/migration/changelog/add-my-jetpack-user-type-check @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Updated composer.lock. + + diff --git a/projects/plugins/migration/composer.lock b/projects/plugins/migration/composer.lock index 7f07f0ba00f90..ab518f6dbd4f4 100644 --- a/projects/plugins/migration/composer.lock +++ b/projects/plugins/migration/composer.lock @@ -1122,7 +1122,7 @@ "dist": { "type": "path", "url": "../../packages/my-jetpack", - "reference": "cd2abb7246ef3cbccfdfe5ca4b68a4581f0c8586" + "reference": "2475331cc29709ee844d2f99340199e6e3fa0f00" }, "require": { "automattic/jetpack-admin-ui": "@dev", @@ -1155,7 +1155,7 @@ "link-template": "https://github.com/Automattic/jetpack-my-jetpack/compare/${old}...${new}" }, "branch-alias": { - "dev-trunk": "4.12.x-dev" + "dev-trunk": "4.13.x-dev" }, "version-constants": { "::PACKAGE_VERSION": "src/class-initializer.php" diff --git a/projects/plugins/protect/changelog/add-my-jetpack-user-type-check b/projects/plugins/protect/changelog/add-my-jetpack-user-type-check new file mode 100644 index 0000000000000..9aa70e3ec1f75 --- /dev/null +++ b/projects/plugins/protect/changelog/add-my-jetpack-user-type-check @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Updated composer.lock. + + diff --git a/projects/plugins/protect/composer.lock b/projects/plugins/protect/composer.lock index e240039c597cf..d2fa6f98db150 100644 --- a/projects/plugins/protect/composer.lock +++ b/projects/plugins/protect/composer.lock @@ -1035,7 +1035,7 @@ "dist": { "type": "path", "url": "../../packages/my-jetpack", - "reference": "cd2abb7246ef3cbccfdfe5ca4b68a4581f0c8586" + "reference": "2475331cc29709ee844d2f99340199e6e3fa0f00" }, "require": { "automattic/jetpack-admin-ui": "@dev", @@ -1068,7 +1068,7 @@ "link-template": "https://github.com/Automattic/jetpack-my-jetpack/compare/${old}...${new}" }, "branch-alias": { - "dev-trunk": "4.12.x-dev" + "dev-trunk": "4.13.x-dev" }, "version-constants": { "::PACKAGE_VERSION": "src/class-initializer.php" diff --git a/projects/plugins/search/changelog/add-my-jetpack-user-type-check b/projects/plugins/search/changelog/add-my-jetpack-user-type-check new file mode 100644 index 0000000000000..9aa70e3ec1f75 --- /dev/null +++ b/projects/plugins/search/changelog/add-my-jetpack-user-type-check @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Updated composer.lock. + + diff --git a/projects/plugins/search/composer.lock b/projects/plugins/search/composer.lock index f76cdd54ac3e2..ea34f9c7b725a 100644 --- a/projects/plugins/search/composer.lock +++ b/projects/plugins/search/composer.lock @@ -978,7 +978,7 @@ "dist": { "type": "path", "url": "../../packages/my-jetpack", - "reference": "cd2abb7246ef3cbccfdfe5ca4b68a4581f0c8586" + "reference": "2475331cc29709ee844d2f99340199e6e3fa0f00" }, "require": { "automattic/jetpack-admin-ui": "@dev", @@ -1011,7 +1011,7 @@ "link-template": "https://github.com/Automattic/jetpack-my-jetpack/compare/${old}...${new}" }, "branch-alias": { - "dev-trunk": "4.12.x-dev" + "dev-trunk": "4.13.x-dev" }, "version-constants": { "::PACKAGE_VERSION": "src/class-initializer.php" diff --git a/projects/plugins/social/changelog/add-my-jetpack-user-type-check b/projects/plugins/social/changelog/add-my-jetpack-user-type-check new file mode 100644 index 0000000000000..9aa70e3ec1f75 --- /dev/null +++ b/projects/plugins/social/changelog/add-my-jetpack-user-type-check @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Updated composer.lock. + + diff --git a/projects/plugins/social/composer.lock b/projects/plugins/social/composer.lock index b8e379d730928..e4a27092e697f 100644 --- a/projects/plugins/social/composer.lock +++ b/projects/plugins/social/composer.lock @@ -978,7 +978,7 @@ "dist": { "type": "path", "url": "../../packages/my-jetpack", - "reference": "cd2abb7246ef3cbccfdfe5ca4b68a4581f0c8586" + "reference": "2475331cc29709ee844d2f99340199e6e3fa0f00" }, "require": { "automattic/jetpack-admin-ui": "@dev", @@ -1011,7 +1011,7 @@ "link-template": "https://github.com/Automattic/jetpack-my-jetpack/compare/${old}...${new}" }, "branch-alias": { - "dev-trunk": "4.12.x-dev" + "dev-trunk": "4.13.x-dev" }, "version-constants": { "::PACKAGE_VERSION": "src/class-initializer.php" diff --git a/projects/plugins/starter-plugin/changelog/add-my-jetpack-user-type-check b/projects/plugins/starter-plugin/changelog/add-my-jetpack-user-type-check new file mode 100644 index 0000000000000..9aa70e3ec1f75 --- /dev/null +++ b/projects/plugins/starter-plugin/changelog/add-my-jetpack-user-type-check @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Updated composer.lock. + + diff --git a/projects/plugins/starter-plugin/composer.lock b/projects/plugins/starter-plugin/composer.lock index 50da833f0615c..357f3fd75c82c 100644 --- a/projects/plugins/starter-plugin/composer.lock +++ b/projects/plugins/starter-plugin/composer.lock @@ -978,7 +978,7 @@ "dist": { "type": "path", "url": "../../packages/my-jetpack", - "reference": "cd2abb7246ef3cbccfdfe5ca4b68a4581f0c8586" + "reference": "2475331cc29709ee844d2f99340199e6e3fa0f00" }, "require": { "automattic/jetpack-admin-ui": "@dev", @@ -1011,7 +1011,7 @@ "link-template": "https://github.com/Automattic/jetpack-my-jetpack/compare/${old}...${new}" }, "branch-alias": { - "dev-trunk": "4.12.x-dev" + "dev-trunk": "4.13.x-dev" }, "version-constants": { "::PACKAGE_VERSION": "src/class-initializer.php" diff --git a/projects/plugins/videopress/changelog/add-my-jetpack-user-type-check b/projects/plugins/videopress/changelog/add-my-jetpack-user-type-check new file mode 100644 index 0000000000000..9aa70e3ec1f75 --- /dev/null +++ b/projects/plugins/videopress/changelog/add-my-jetpack-user-type-check @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Updated composer.lock. + + diff --git a/projects/plugins/videopress/composer.lock b/projects/plugins/videopress/composer.lock index 81cd1b39dd1a3..009ca3a79ebc2 100644 --- a/projects/plugins/videopress/composer.lock +++ b/projects/plugins/videopress/composer.lock @@ -978,7 +978,7 @@ "dist": { "type": "path", "url": "../../packages/my-jetpack", - "reference": "cd2abb7246ef3cbccfdfe5ca4b68a4581f0c8586" + "reference": "2475331cc29709ee844d2f99340199e6e3fa0f00" }, "require": { "automattic/jetpack-admin-ui": "@dev", @@ -1011,7 +1011,7 @@ "link-template": "https://github.com/Automattic/jetpack-my-jetpack/compare/${old}...${new}" }, "branch-alias": { - "dev-trunk": "4.12.x-dev" + "dev-trunk": "4.13.x-dev" }, "version-constants": { "::PACKAGE_VERSION": "src/class-initializer.php"