Replace addReferralId in JS by MailPoet Url Factory
[MAILPOET-2182]
This commit is contained in:
committed by
M. Shull
parent
72f5a6e02e
commit
0ca0144219
@@ -1,6 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import MailPoet from 'mailpoet';
|
import MailPoet from 'mailpoet';
|
||||||
import addReferralId from 'referral_url_decorator.jsx';
|
|
||||||
|
|
||||||
class FreePlanAnnouncement extends React.Component {
|
class FreePlanAnnouncement extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@@ -33,7 +32,7 @@ class FreePlanAnnouncement extends React.Component {
|
|||||||
<p>{MailPoet.I18n.t('freePlanDescription')}</p>
|
<p>{MailPoet.I18n.t('freePlanDescription')}</p>
|
||||||
<a
|
<a
|
||||||
className="button-primary"
|
className="button-primary"
|
||||||
href={addReferralId('https://www.mailpoet.com/free-plan/')}
|
href={MailPoet.MailPoetUrlFactory.getFreePlanUrl()}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
>
|
>
|
||||||
|
@@ -2,7 +2,6 @@ import React from 'react';
|
|||||||
import MailPoet from 'mailpoet';
|
import MailPoet from 'mailpoet';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import ReactStringReplace from 'react-string-replace';
|
import ReactStringReplace from 'react-string-replace';
|
||||||
import addReferralId from 'referral_url_decorator.jsx';
|
|
||||||
|
|
||||||
const resumeMailerSending = () => {
|
const resumeMailerSending = () => {
|
||||||
MailPoet.Ajax.post({
|
MailPoet.Ajax.post({
|
||||||
@@ -116,7 +115,7 @@ const PHPMailerCheckSettingsNotice = () => (
|
|||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<a
|
<a
|
||||||
href={addReferralId('https://www.mailpoet.com/free-plan/?utm_source=plugin&utm_campaign=sending-error')}
|
href={MailPoet.MailPoetUrlFactory.getFreePlanUrl('sending-error')}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
>
|
>
|
||||||
|
@@ -1,8 +1,10 @@
|
|||||||
import FeaturesController from 'features_controller';
|
import FeaturesController from 'features_controller';
|
||||||
|
import MailPoetUrlFactory from 'mailpoet_url_factory';
|
||||||
|
|
||||||
// A placeholder for MailPoet object
|
// A placeholder for MailPoet object
|
||||||
var MailPoet = {
|
var MailPoet = {
|
||||||
FeaturesController: FeaturesController(window.mailpoet_feature_flags),
|
FeaturesController: FeaturesController(window.mailpoet_feature_flags),
|
||||||
|
MailPoetUrlFactory: MailPoetUrlFactory(window.mailpoet_referral_id),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Expose MailPoet globally
|
// Expose MailPoet globally
|
||||||
|
27
assets/js/src/mailpoet_url_factory.js
Normal file
27
assets/js/src/mailpoet_url_factory.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
const addReferralId = (url, referralId) => {
|
||||||
|
if (!referralId) {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
const refUrl = new URL(url);
|
||||||
|
refUrl.searchParams.set('ref', referralId);
|
||||||
|
return refUrl.toString();
|
||||||
|
};
|
||||||
|
|
||||||
|
const MailPoetUrlFactory = referralId => ({
|
||||||
|
getFreePlanUrl: (utmCampaign = null, utmMedium = null) => {
|
||||||
|
const url = new URL(addReferralId('https://www.mailpoet.com/free-plan/?utm_source=plugin', referralId));
|
||||||
|
if (utmCampaign) {
|
||||||
|
url.searchParams.set('utm_campaign', utmCampaign);
|
||||||
|
}
|
||||||
|
if (utmMedium) {
|
||||||
|
url.searchParams.set('utm_medium', utmMedium);
|
||||||
|
}
|
||||||
|
return url.toString();
|
||||||
|
},
|
||||||
|
|
||||||
|
getPricingPageUrl: subscribersCount => (
|
||||||
|
addReferralId(`https://www.mailpoet.com/pricing/?subscribers=${subscribersCount}`, referralId)
|
||||||
|
),
|
||||||
|
});
|
||||||
|
|
||||||
|
export default MailPoetUrlFactory;
|
@@ -7,7 +7,6 @@ import Marionette from 'backbone.marionette';
|
|||||||
import SuperModel from 'backbone.supermodel';
|
import SuperModel from 'backbone.supermodel';
|
||||||
import _ from 'underscore';
|
import _ from 'underscore';
|
||||||
import jQuery from 'jquery';
|
import jQuery from 'jquery';
|
||||||
import addReferralId from 'referral_url_decorator.jsx';
|
|
||||||
|
|
||||||
var Module = {};
|
var Module = {};
|
||||||
var SidebarView;
|
var SidebarView;
|
||||||
@@ -352,7 +351,7 @@ Module.SidebarPreviewView = Marionette.View.extend({
|
|||||||
<p>${MailPoet.I18n.t('newsletterPreviewErrorUseSendingService')}</p>
|
<p>${MailPoet.I18n.t('newsletterPreviewErrorUseSendingService')}</p>
|
||||||
<p>
|
<p>
|
||||||
<a
|
<a
|
||||||
href=${addReferralId('https://www.mailpoet.com/free-plan/?utm_source=plugin&utm_campaign=sending-error')}
|
href=${MailPoet.MailPoetUrlFactory.getFreePlanUrl('plugin', 'sending-error')}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
>
|
>
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import MailPoet from 'mailpoet';
|
import MailPoet from 'mailpoet';
|
||||||
import addReferralId from 'referral_url_decorator.jsx';
|
|
||||||
|
|
||||||
const PremiumBanner = () => {
|
const PremiumBanner = () => {
|
||||||
if (window.mailpoet_premium_active) {
|
if (window.mailpoet_premium_active) {
|
||||||
@@ -12,7 +11,7 @@ const PremiumBanner = () => {
|
|||||||
ctaButton = (
|
ctaButton = (
|
||||||
<a
|
<a
|
||||||
className="button"
|
className="button"
|
||||||
href={addReferralId('https://www.mailpoet.com/free-plan/')}
|
href={MailPoet.MailPoetUrlFactory.getFreePlanUrl()}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
>
|
>
|
||||||
@@ -23,7 +22,7 @@ const PremiumBanner = () => {
|
|||||||
ctaButton = (
|
ctaButton = (
|
||||||
<a
|
<a
|
||||||
className="button"
|
className="button"
|
||||||
href={addReferralId(`https://www.mailpoet.com/pricing/?subscribers=${window.mailpoet_subscribers_count}`)}
|
href={MailPoet.MailPoetUrlFactory.getPricingPageUrl(window.mailpoet_subscribers_count)}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
>
|
>
|
||||||
|
@@ -1,10 +0,0 @@
|
|||||||
const addReferralId = (url) => {
|
|
||||||
if (!window.mailpoet_referral_id) {
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
const refUrl = new URL(url);
|
|
||||||
refUrl.searchParams.set('ref', window.mailpoet_referral_id);
|
|
||||||
return refUrl.toString();
|
|
||||||
};
|
|
||||||
|
|
||||||
export default addReferralId;
|
|
Reference in New Issue
Block a user