mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
Updated Portal to always honor outboundLinkTagging setting (#18079)
no issue - Do not set ?ref in recommendations if analytics is disabled - Do not send url_history if analytics is disabled - Expose outboundLinkTagging as a public setting
This commit is contained in:
parent
9477a08a90
commit
d166977ae4
6 changed files with 16 additions and 7 deletions
|
@ -79,7 +79,7 @@ async function signout({api, state}) {
|
||||||
|
|
||||||
async function signin({data, api, state}) {
|
async function signin({data, api, state}) {
|
||||||
try {
|
try {
|
||||||
await api.member.sendMagicLink({...data, emailType: 'signin'});
|
await api.member.sendMagicLink({...data, emailType: 'signin', outboundLinkTagging: state.site.outbound_link_tagging});
|
||||||
return {
|
return {
|
||||||
page: 'magiclink',
|
page: 'magiclink',
|
||||||
lastPage: 'signin'
|
lastPage: 'signin'
|
||||||
|
@ -100,7 +100,7 @@ async function signup({data, state, api}) {
|
||||||
let {plan, tierId, cadence, email, name, newsletters, offerId} = data;
|
let {plan, tierId, cadence, email, name, newsletters, offerId} = data;
|
||||||
|
|
||||||
if (plan.toLowerCase() === 'free') {
|
if (plan.toLowerCase() === 'free') {
|
||||||
await api.member.sendMagicLink({emailType: 'signup', ...data});
|
await api.member.sendMagicLink({emailType: 'signup', ...data, outboundLinkTagging: state.site.outbound_link_tagging});
|
||||||
} else {
|
} else {
|
||||||
if (tierId && cadence) {
|
if (tierId && cadence) {
|
||||||
await api.member.checkoutPlan({plan, tierId, cadence, email, name, newsletters, offerId});
|
await api.member.checkoutPlan({plan, tierId, cadence, email, name, newsletters, offerId});
|
||||||
|
@ -487,6 +487,7 @@ async function oneClickSubscribe({data: {siteUrl}, state}) {
|
||||||
name: member.name,
|
name: member.name,
|
||||||
email: member.email,
|
email: member.email,
|
||||||
autoRedirect: false,
|
autoRedirect: false,
|
||||||
|
outboundLinkTagging: state.site.outbound_link_tagging,
|
||||||
customUrlHistory: [
|
customUrlHistory: [
|
||||||
{
|
{
|
||||||
time: Date.now(),
|
time: Date.now(),
|
||||||
|
|
|
@ -90,13 +90,17 @@ const openTab = (url) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const RecommendationItem = (recommendation) => {
|
const RecommendationItem = (recommendation) => {
|
||||||
const {t, onAction, member} = useContext(AppContext);
|
const {t, onAction, member, site} = useContext(AppContext);
|
||||||
const {title, url, reason, favicon, one_click_subscribe: oneClickSubscribe, featured_image: featuredImage} = recommendation;
|
const {title, url, reason, favicon, one_click_subscribe: oneClickSubscribe, featured_image: featuredImage} = recommendation;
|
||||||
const allowOneClickSubscribe = member && oneClickSubscribe;
|
const allowOneClickSubscribe = member && oneClickSubscribe;
|
||||||
const [subscribed, setSubscribed] = useState(false);
|
const [subscribed, setSubscribed] = useState(false);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
const outboundLinkTagging = site.outbound_link_tagging ?? false;
|
||||||
|
|
||||||
const refUrl = useMemo(() => {
|
const refUrl = useMemo(() => {
|
||||||
|
if (!outboundLinkTagging) {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const ref = new URL(url);
|
const ref = new URL(url);
|
||||||
|
|
||||||
|
@ -109,7 +113,7 @@ const RecommendationItem = (recommendation) => {
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
}, [url]);
|
}, [url, outboundLinkTagging]);
|
||||||
|
|
||||||
const visitHandler = useCallback(() => {
|
const visitHandler = useCallback(() => {
|
||||||
// Open url in a new tab
|
// Open url in a new tab
|
||||||
|
|
|
@ -231,7 +231,7 @@ function setupGhostApi({siteUrl = window.location.origin, apiUrl, apiKey}) {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
async sendMagicLink({email, emailType, labels, name, oldEmail, newsletters, redirect, customUrlHistory, autoRedirect = true}) {
|
async sendMagicLink({email, emailType, labels, name, oldEmail, newsletters, redirect, customUrlHistory, outboundLinkTagging, autoRedirect = true}) {
|
||||||
const url = endpointFor({type: 'members', resource: 'send-magic-link'});
|
const url = endpointFor({type: 'members', resource: 'send-magic-link'});
|
||||||
const body = {
|
const body = {
|
||||||
name,
|
name,
|
||||||
|
@ -245,7 +245,7 @@ function setupGhostApi({siteUrl = window.location.origin, apiUrl, apiKey}) {
|
||||||
autoRedirect
|
autoRedirect
|
||||||
};
|
};
|
||||||
const urlHistory = customUrlHistory ?? getUrlHistory();
|
const urlHistory = customUrlHistory ?? getUrlHistory();
|
||||||
if (urlHistory) {
|
if (urlHistory && outboundLinkTagging) {
|
||||||
body.urlHistory = urlHistory;
|
body.urlHistory = urlHistory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,5 +41,6 @@ module.exports = {
|
||||||
portal_name: 'portal_name',
|
portal_name: 'portal_name',
|
||||||
portal_button: 'portal_button',
|
portal_button: 'portal_button',
|
||||||
comments_enabled: 'comments_enabled',
|
comments_enabled: 'comments_enabled',
|
||||||
recommendations_enabled: 'recommendations_enabled'
|
recommendations_enabled: 'recommendations_enabled',
|
||||||
|
outbound_link_tagging: 'outbound_link_tagging'
|
||||||
};
|
};
|
||||||
|
|
|
@ -47,6 +47,7 @@ Object {
|
||||||
"og_description": null,
|
"og_description": null,
|
||||||
"og_image": null,
|
"og_image": null,
|
||||||
"og_title": null,
|
"og_title": null,
|
||||||
|
"outbound_link_tagging": true,
|
||||||
"paid_members_enabled": true,
|
"paid_members_enabled": true,
|
||||||
"portal_button": true,
|
"portal_button": true,
|
||||||
"portal_button_icon": null,
|
"portal_button_icon": null,
|
||||||
|
|
|
@ -1391,6 +1391,7 @@ Object {
|
||||||
"og_description": null,
|
"og_description": null,
|
||||||
"og_image": null,
|
"og_image": null,
|
||||||
"og_title": null,
|
"og_title": null,
|
||||||
|
"outbound_link_tagging": true,
|
||||||
"paid_members_enabled": true,
|
"paid_members_enabled": true,
|
||||||
"portal_button": true,
|
"portal_button": true,
|
||||||
"portal_button_icon": null,
|
"portal_button_icon": null,
|
||||||
|
@ -1489,6 +1490,7 @@ Object {
|
||||||
"og_description": null,
|
"og_description": null,
|
||||||
"og_image": null,
|
"og_image": null,
|
||||||
"og_title": null,
|
"og_title": null,
|
||||||
|
"outbound_link_tagging": true,
|
||||||
"paid_members_enabled": true,
|
"paid_members_enabled": true,
|
||||||
"portal_button": true,
|
"portal_button": true,
|
||||||
"portal_button_icon": null,
|
"portal_button_icon": null,
|
||||||
|
|
Loading…
Add table
Reference in a new issue