From f8966e26c85f1faef677a9d60ed04c60e36aa5a7 Mon Sep 17 00:00:00 2001 From: Sag Date: Wed, 10 Jul 2024 14:24:27 +0200 Subject: [PATCH] Cleaned up "Recommendations" GA feature flag (#20580) no issue - "Recommendations" feature was released in Ghost [v5.71.0](https://github.com/TryGhost/Ghost/releases/tag/v5.71.0) (commit: 1b82efe5d21eca044efe749ca3094b21d170bf84) - [Project details](https://www.notion.so/ghost/Recommentions-5be89ec0d02a4c9b9310a964f9b22901?pvs=4) --- .../admin-x-settings/src/components/Sidebar.tsx | 3 +-- .../general/users/EmailNotifications.tsx | 5 ++--- .../settings/growth/GrowthSettings.tsx | 3 +-- .../membership/recommendations.test.ts | 6 +----- ghost/admin/app/services/feature.js | 1 - .../RecommendationServiceWrapper.js | 17 ++++++----------- ghost/core/core/shared/labs.js | 1 - .../admin/__snapshots__/settings.test.js.snap | 2 +- 8 files changed, 12 insertions(+), 26 deletions(-) diff --git a/apps/admin-x-settings/src/components/Sidebar.tsx b/apps/admin-x-settings/src/components/Sidebar.tsx index e25abef801..1105c9c630 100644 --- a/apps/admin-x-settings/src/components/Sidebar.tsx +++ b/apps/admin-x-settings/src/components/Sidebar.tsx @@ -111,7 +111,6 @@ const Sidebar: React.FC = () => { }; const hasTipsAndDonations = useFeatureFlag('tipsAndDonations'); - const hasRecommendations = useFeatureFlag('recommendations'); const updateSearch = (e: React.ChangeEvent) => { setFilter(e.target.value); @@ -184,7 +183,7 @@ const Sidebar: React.FC = () => { - {hasRecommendations && } + {hasStripeEnabled && } {hasTipsAndDonations && } diff --git a/apps/admin-x-settings/src/components/settings/general/users/EmailNotifications.tsx b/apps/admin-x-settings/src/components/settings/general/users/EmailNotifications.tsx index 68326ab9ba..00f7369d4e 100644 --- a/apps/admin-x-settings/src/components/settings/general/users/EmailNotifications.tsx +++ b/apps/admin-x-settings/src/components/settings/general/users/EmailNotifications.tsx @@ -5,7 +5,6 @@ import {User, hasAdminAccess} from '@tryghost/admin-x-framework/api/users'; const EmailNotificationsInputs: React.FC<{ user: User; setUserData: (user: User) => void; }> = ({user, setUserData}) => { const hasWebmentions = useFeatureFlag('webmentions'); - const hasRecommendations = useFeatureFlag('recommendations'); return ( @@ -28,7 +27,7 @@ const EmailNotificationsInputs: React.FC<{ user: User; setUserData: (user: User) setUserData?.({...user, mention_notifications: e.target.checked}); }} />} - {hasRecommendations && { setUserData?.({...user, recommendation_notifications: e.target.checked}); }} - />} + /> { const hasTipsAndDonations = useFeatureFlag('tipsAndDonations'); - const hasRecommendations = useFeatureFlag('recommendations'); const {config, settings} = useGlobalData(); const hasStripeEnabled = checkStripeEnabled(settings || [], config || {}); return ( - {hasRecommendations && } + {hasStripeEnabled && } {hasTipsAndDonations && } diff --git a/apps/admin-x-settings/test/acceptance/membership/recommendations.test.ts b/apps/admin-x-settings/test/acceptance/membership/recommendations.test.ts index 9d2de9f7fa..35971f8648 100644 --- a/apps/admin-x-settings/test/acceptance/membership/recommendations.test.ts +++ b/apps/admin-x-settings/test/acceptance/membership/recommendations.test.ts @@ -1,12 +1,8 @@ import {expect, test} from '@playwright/test'; import {globalDataRequests} from '../../utils/acceptance'; -import {mockApi, responseFixtures, toggleLabsFlag} from '@tryghost/admin-x-framework/test/acceptance'; +import {mockApi, responseFixtures} from '@tryghost/admin-x-framework/test/acceptance'; test.describe('Recommendations', async () => { - test.beforeEach(async () => { - toggleLabsFlag('recommendations', true); - }); - test('can view recommendations', async ({page}) => { await mockApi({page, requests: { ...globalDataRequests, diff --git a/ghost/admin/app/services/feature.js b/ghost/admin/app/services/feature.js index 9e3fbcf0b4..2af398c3b0 100644 --- a/ghost/admin/app/services/feature.js +++ b/ghost/admin/app/services/feature.js @@ -73,7 +73,6 @@ export default class FeatureService extends Service { @feature('collectionsCard') collectionsCard; @feature('importMemberTier') importMemberTier; @feature('tipsAndDonations') tipsAndDonations; - @feature('recommendations') recommendations; @feature('lexicalIndicators') lexicalIndicators; @feature('adminXDemo') adminXDemo; @feature('ActivityPub') ActivityPub; diff --git a/ghost/core/core/server/services/recommendations/RecommendationServiceWrapper.js b/ghost/core/core/server/services/recommendations/RecommendationServiceWrapper.js index dd9bf714a6..56372c495a 100644 --- a/ghost/core/core/server/services/recommendations/RecommendationServiceWrapper.js +++ b/ghost/core/core/server/services/recommendations/RecommendationServiceWrapper.js @@ -43,7 +43,6 @@ class RecommendationServiceWrapper { return; } - const labs = require('../../../shared/labs'); const config = require('../../../shared/config'); const urlUtils = require('../../../shared/url-utils'); const models = require('../../models'); @@ -146,10 +145,8 @@ class RecommendationServiceWrapper { service: this.incomingRecommendationService }); - if (labs.isSet('recommendations')) { - this.service.init().catch(logging.error); - this.incomingRecommendationService.init().catch(logging.error); - } + this.service.init().catch(logging.error); + this.incomingRecommendationService.init().catch(logging.error); const PATH_SUFFIX = '/.well-known/recommendations.json'; @@ -169,12 +166,10 @@ class RecommendationServiceWrapper { // Listen for incoming webmentions DomainEvents.subscribe(MentionCreatedEvent, async (event) => { - if (labs.isSet('recommendations')) { - // Check if this is a recommendation - if (event.data.mention.verified && isRecommendationUrl(event.data.mention.source)) { - logging.info('[INCOMING RECOMMENDATION] Received recommendation from ' + event.data.mention.source); - await this.incomingRecommendationService.sendRecommendationEmail(event.data.mention); - } + // Check if this is a recommendation + if (event.data.mention.verified && isRecommendationUrl(event.data.mention.source)) { + logging.info('[INCOMING RECOMMENDATION] Received recommendation from ' + event.data.mention.source); + await this.incomingRecommendationService.sendRecommendationEmail(event.data.mention); } }); } diff --git a/ghost/core/core/shared/labs.js b/ghost/core/core/shared/labs.js index 765ab1826f..e8b68426b1 100644 --- a/ghost/core/core/shared/labs.js +++ b/ghost/core/core/shared/labs.js @@ -19,7 +19,6 @@ const GA_FEATURES = [ 'themeErrorsNotification', 'outboundLinkTagging', 'announcementBar', - 'recommendations', 'newEmailAddresses', 'internalLinking' ]; diff --git a/ghost/core/test/e2e-api/admin/__snapshots__/settings.test.js.snap b/ghost/core/test/e2e-api/admin/__snapshots__/settings.test.js.snap index 96e3bc3d5c..75c28d354b 100644 --- a/ghost/core/test/e2e-api/admin/__snapshots__/settings.test.js.snap +++ b/ghost/core/test/e2e-api/admin/__snapshots__/settings.test.js.snap @@ -1155,7 +1155,7 @@ exports[`Settings API Edit Can edit a setting 2: [headers] 1`] = ` Object { "access-control-allow-origin": "http://127.0.0.1:2369", "cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0", - "content-length": "4479", + "content-length": "4454", "content-type": "application/json; charset=utf-8", "content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/, "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,