From 3ded0bbee81359d646be2f393b44e4c48322432c Mon Sep 17 00:00:00 2001 From: Simon Backx Date: Thu, 23 Feb 2023 14:37:23 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Added=20outbound=20link=20tagging?= =?UTF-8?q?=20setting=20(#16324)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit no issue Enable or disable outbound link tagging in both web posts and newsletters. --- ghost/admin/app/components/settings/analytics.hbs | 2 -- ghost/admin/app/services/feature.js | 1 - ghost/admin/app/templates/settings/labs.hbs | 13 ------------- .../tests/acceptance/settings/analytics-test.js | 2 -- ghost/core/core/shared/labs.js | 4 ++-- .../admin/__snapshots__/settings.test.js.snap | 2 +- .../canary/utils/serializers/output/mapper.test.js | 9 +++++++-- 7 files changed, 10 insertions(+), 23 deletions(-) diff --git a/ghost/admin/app/components/settings/analytics.hbs b/ghost/admin/app/components/settings/analytics.hbs index c235336d11..4adb1e7b4d 100644 --- a/ghost/admin/app/components/settings/analytics.hbs +++ b/ghost/admin/app/components/settings/analytics.hbs @@ -74,7 +74,6 @@ - {{#if (feature 'outboundLinkTagging')}}
@@ -97,6 +96,5 @@
- {{/if}} diff --git a/ghost/admin/app/services/feature.js b/ghost/admin/app/services/feature.js index 86903fe7cf..c55530ac6a 100644 --- a/ghost/admin/app/services/feature.js +++ b/ghost/admin/app/services/feature.js @@ -69,7 +69,6 @@ export default class FeatureService extends Service { @feature('emailStability') emailStability; @feature('webmentions') webmentions; @feature('webmentionEmails') webmentionEmails; - @feature('outboundLinkTagging') outboundLinkTagging; @feature('emailErrors') emailErrors; @feature('milestoneEmails') milestoneEmails; @feature('websockets') websockets; diff --git a/ghost/admin/app/templates/settings/labs.hbs b/ghost/admin/app/templates/settings/labs.hbs index 42d63e6cae..16b329650a 100644 --- a/ghost/admin/app/templates/settings/labs.hbs +++ b/ghost/admin/app/templates/settings/labs.hbs @@ -226,19 +226,6 @@ -
-
-
-

Outbound Link Tagging

-

- Adds ?ref to external links in web posts and adds a setting to control this for both web and newsletters. -

-
-
- -
-
-
diff --git a/ghost/admin/tests/acceptance/settings/analytics-test.js b/ghost/admin/tests/acceptance/settings/analytics-test.js index 15cc031502..272cb72918 100644 --- a/ghost/admin/tests/acceptance/settings/analytics-test.js +++ b/ghost/admin/tests/acceptance/settings/analytics-test.js @@ -1,6 +1,5 @@ import {authenticateSession} from 'ember-simple-auth/test-support'; import {click, find} from '@ember/test-helpers'; -import {enableLabsFlag} from '../../helpers/labs-flag'; import {expect} from 'chai'; import {setupApplicationTest} from 'ember-mocha'; import {setupMirage} from 'ember-cli-mirage/test-support'; @@ -65,7 +64,6 @@ describe('Acceptance: Settings - Analytics', function () { }); it('can manage outbound link tagging', async function () { - enableLabsFlag(this.server, 'outboundLinkTagging'); this.server.db.settings.update({key: 'outbound_link_tagging'}, {value: 'true'}); await visit('/settings/analytics'); diff --git a/ghost/core/core/shared/labs.js b/ghost/core/core/shared/labs.js index 2c8d0749f9..789f112f7c 100644 --- a/ghost/core/core/shared/labs.js +++ b/ghost/core/core/shared/labs.js @@ -21,7 +21,8 @@ const GA_FEATURES = [ 'audienceFeedback', 'themeErrorsNotification', 'emailStability', - 'emailErrors' + 'emailErrors', + 'outboundLinkTagging' ]; // NOTE: this allowlist is meant to be used to filter out any unexpected @@ -36,7 +37,6 @@ const ALPHA_FEATURES = [ 'urlCache', 'beforeAfterCard', 'lexicalEditor', - 'outboundLinkTagging', 'websockets', 'webmentionEmails' ]; 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 6e7be084f2..e8fd0e3613 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 @@ -654,7 +654,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": "3653", + "content-length": "3682", "content-type": "application/json; charset=utf-8", "content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/, "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/, diff --git a/ghost/core/test/unit/api/canary/utils/serializers/output/mapper.test.js b/ghost/core/test/unit/api/canary/utils/serializers/output/mapper.test.js index f51fcac5d3..acdfa02a32 100644 --- a/ghost/core/test/unit/api/canary/utils/serializers/output/mapper.test.js +++ b/ghost/core/test/unit/api/canary/utils/serializers/output/mapper.test.js @@ -6,6 +6,7 @@ const urlUtil = require('../../../../../../../core/server/api/endpoints/utils/se const cleanUtil = require('../../../../../../../core/server/api/endpoints/utils/serializers/output/utils/clean'); const extraAttrsUtils = require('../../../../../../../core/server/api/endpoints/utils/serializers/output/utils/extra-attrs'); const mappers = require('../../../../../../../core/server/api/endpoints/utils/serializers/output/mappers'); +const memberAttribution = require('../../../../../../../core/server/services/member-attribution'); function createJsonModel(data) { return Object.assign(data, {toJSON: sinon.stub().returns(data)}); @@ -29,9 +30,13 @@ describe('Unit: utils/serializers/output/mappers', function () { sinon.stub(cleanUtil, 'post').returns({}); sinon.stub(cleanUtil, 'tag').returns({}); sinon.stub(cleanUtil, 'author').returns({}); + + memberAttribution.outboundLinkTagger = { + addToHtml: sinon.stub().callsFake(html => Promise.resolve(html)) + }; }); - it('calls mapper on relations', function () { + it('calls mapper on relations', async function () { const frame = { original: { context: {} @@ -57,7 +62,7 @@ describe('Unit: utils/serializers/output/mappers', function () { }] })); - mappers.posts(post, frame); + await mappers.posts(post, frame); dateUtil.forPost.callCount.should.equal(1);