Skip to content

Commit 05995bc

Browse files
authored
Merge pull request #7790 from Automattic/fix/sensei-pro-upgrade-url
Sensei Upsell: Update upgrade URL based on hosting provider
2 parents 26fa9f2 + 7eeeb4b commit 05995bc

23 files changed

+259
-41
lines changed

assets/admin/editor-wizard/steps/course-upgrade-step.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { useSelect } from '@wordpress/data';
1111
import { EXTENSIONS_STORE } from '../../../extensions/store';
1212
import senseiProUpsellImage from '../../../images/sensei-pro-upsell.png';
1313
import CheckIcon from '../../../icons/checked.svg';
14+
import { getSenseiProUpsellUrl } from '../../helpers';
1415

1516
/**
1617
* Upgrade step during course creation wizard.
@@ -100,12 +101,13 @@ const FeatureItem = ( { children } ) => (
100101
CourseUpgradeStep.Actions = ( { goToNextStep } ) => {
101102
const upgrade = () => {
102103
window.open(
103-
'https://senseilms.com/sensei-pro/?utm_source=plugin_sensei&utm_medium=upsell&utm_campaign=course_editor_wizard',
104+
getSenseiProUpsellUrl( 'course_editor_wizard' ),
104105
'sensei-pricing',
105106
'noreferrer'
106107
);
107108
goToNextStep();
108109
};
110+
109111
return (
110112
<>
111113
<Button

assets/admin/editor-wizard/steps/lesson-patterns-step.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { Fragment } from '@wordpress/element';
99
*/
1010
import PatternsStep from './patterns-step';
1111
import LogoTreeIcon from '../../../icons/logo-tree.svg';
12+
import { getSenseiProUpsellUrl } from '../../helpers';
1213
import { useHideEditorWizardUpsell } from '../helpers';
1314

1415
/**
@@ -63,7 +64,9 @@ const UpsellBlock = () => (
6364
) }{ ' ' }
6465
<a
6566
className="sensei-editor-wizard-patterns-upsell__link"
66-
href="https://senseilms.com/sensei-pro/?utm_source=plugin_sensei&utm_medium=upsell&utm_campaign=lesson_patterns_editor_wizard"
67+
href={ getSenseiProUpsellUrl(
68+
'lesson_patterns_editor_wizard'
69+
) }
6770
rel="noreferrer external"
6871
target="blank"
6972
>

assets/admin/helpers.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* Get the Sensei Pro upgrade URL.
3+
*
4+
* @param {string} campaign The campaign name.
5+
*
6+
* @return {string} The upgrade URL.
7+
*/
8+
export const getSenseiProUpsellUrl = ( campaign = '' ) => {
9+
const { upsellUrl } = window.sensei_admin;
10+
11+
const senseiParams = new URLSearchParams( {
12+
utm_source: 'plugin_sensei',
13+
utm_medium: 'upsell',
14+
utm_campaign: campaign,
15+
} );
16+
17+
return `${ upsellUrl }?${ senseiParams.toString() }`;
18+
};
19+
20+
/**
21+
* Get the Sensei Pro checkout URL.
22+
*
23+
* @param {string} campaign The campaign name.
24+
*
25+
* @return {string} The checkout URL.
26+
*/
27+
export const getSenseiProCheckoutUrl = ( campaign = '' ) => {
28+
const { checkoutUrl } = window.sensei_admin;
29+
30+
const senseiParams = new URLSearchParams( {
31+
utm_source: 'plugin_sensei',
32+
utm_medium: 'checkout',
33+
utm_campaign: campaign,
34+
} );
35+
36+
return `${ checkoutUrl }?${ senseiParams.toString() }`;
37+
};

assets/blocks/course-outline/outline-block/outline-edit.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ import ExistingLessonsModal from './existing-lessons-modal';
2727
import OutlinePlaceholder from './outline-placeholder';
2828
import useSenseiProSettings from './use-sensei-pro-settings';
2929
import { applyFilters } from '@wordpress/hooks';
30-
31-
const SENSEI_PRO_LINK = 'https://senseilms.com/sensei-pro/';
30+
import { getSenseiProUpsellUrl } from '../../../admin/helpers';
3231

3332
const ALLOWED_BLOCKS = [
3433
'sensei-lms/course-outline-module',
@@ -106,7 +105,7 @@ const OutlineEdit = ( props ) => {
106105
if ( removeCourseOutlineGeneratorUpsell ) {
107106
window.location.hash = 'generate-course-outline-using-ai';
108107
} else {
109-
window.location.href = SENSEI_PRO_LINK;
108+
window.location.href = getSenseiProUpsellUrl( 'outline_edit' );
110109
}
111110
}, [ removeCourseOutlineGeneratorUpsell ] );
112111

assets/blocks/quiz/ordering-promo/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ import { __ } from '@wordpress/i18n';
55
import { addFilter } from '@wordpress/hooks';
66
import { ExternalLink } from '@wordpress/components';
77

8-
const PROMO_LINK =
9-
'https://senseilms.com/sensei-pro/?utm_source=plugin_sensei&utm_medium=upsell&utm_campaign=quiz_ordering_question_type';
8+
/**
9+
* Internal dependencies
10+
*/
11+
import { getSenseiProUpsellUrl } from '../../../admin/helpers';
1012

1113
function addOrderingPromoOption( options ) {
1214
options.push( {
@@ -39,7 +41,9 @@ function addPromoLink( children, option ) {
3941
<div className="sensei-lms-question-block__type-selector__option__description sensei-lms-question-block__type-selector__option__description--disabled">
4042
{ option.description }
4143
</div>
42-
<ExternalLink href={ PROMO_LINK }>
44+
<ExternalLink
45+
href={ getSenseiProUpsellUrl( 'quiz_ordering_question_type' ) }
46+
>
4347
{ __( 'Upgrade to Sensei Pro', 'sensei-lms' ) }
4448
</ExternalLink>
4549
</div>

assets/blocks/quiz/quiz-block/quiz-settings.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ jest.mock( '@wordpress/block-editor', () => ( {
3939
jest.mock( '@wordpress/data' );
4040

4141
describe( '<QuizSettings />', () => {
42+
afterEach( () => {
43+
delete window.sensei_admin;
44+
} );
4245
beforeEach( () => {
46+
window.sensei_admin = {
47+
upsellUrl: 'https://senseilms.com/sensei-pro',
48+
};
4349
useSelect.mockImplementation( () => [
4450
{
4551
attributes: {

assets/blocks/quiz/quiz-block/quiz-timer-promo.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
import { ToggleControl, ExternalLink } from '@wordpress/components';
55
import { __ } from '@wordpress/i18n';
66

7+
/**
8+
* Internal dependencies
9+
*/
10+
import { getSenseiProUpsellUrl } from '../../../admin/helpers';
11+
712
/**
813
* Quiz block inserter for adding new or existing questions.
914
*/
@@ -20,7 +25,7 @@ const QuizTimerPromo = () => {
2025
/>
2126

2227
<p>
23-
<ExternalLink href="https://senseilms.com/sensei-pro/?utm_source=plugin_sensei&utm_medium=upsell&utm_campaign=quiz_timer">
28+
<ExternalLink href={ getSenseiProUpsellUrl( 'quiz_timer' ) }>
2429
{ __( 'Upgrade to Sensei Pro', 'sensei-lms' ) }
2530
</ExternalLink>
2631
</p>

assets/home/sections/sensei-pro-ad.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ import { EXTENSIONS_STORE } from '../../extensions/store';
1111
import { Col } from '../grid';
1212
import senseiProAdImageUrl from '../../images/sensei-pro-ad-image.png';
1313
import senseiProAdStarsUrl from '../../images/sensei-pro-ad-stars.png';
14-
import { addUtms } from '../utils';
14+
import {
15+
getSenseiProUpsellUrl,
16+
getSenseiProCheckoutUrl,
17+
} from '../../admin/helpers';
1518

1619
/**
1720
* Sensei Pro Ad to be shown on Sensei Home.
@@ -109,9 +112,7 @@ const SenseiProAd = ( { show } ) => {
109112
</ul>
110113

111114
<a
112-
href={ addUtms(
113-
'https://senseilms.com/checkout/?add-to-cart=7009'
114-
) }
115+
href={ getSenseiProCheckoutUrl( 'home' ) }
115116
target="_blank"
116117
rel="noreferrer external"
117118
className="sensei-home__sensei-pro-ad__button is-primary is-large components-button"
@@ -120,9 +121,7 @@ const SenseiProAd = ( { show } ) => {
120121
</a>
121122

122123
<a
123-
href={ addUtms(
124-
'https://senseilms.com/sensei-pro/'
125-
) }
124+
href={ getSenseiProUpsellUrl( 'home' ) }
126125
target="_blank"
127126
rel="noreferrer external"
128127
className="sensei-home__sensei-pro-ad__button is-secondary is-large components-button"

assets/js/admin/course-access-period-promo-sidebar.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
import { ExternalLink, SelectControl, PanelBody } from '@wordpress/components';
55
import { __ } from '@wordpress/i18n';
66

7+
/**
8+
* Internal dependencies
9+
*/
10+
import { getSenseiProUpsellUrl } from '../../admin/helpers';
11+
712
/**
813
* Course access period promo sidebar component.
914
*/
@@ -15,7 +20,9 @@ const CourseAccessPeriodPromoSidebar = () => {
1520
>
1621
<div className="sensei-course-access-period-promo">
1722
<p>
18-
<ExternalLink href="https://senseilms.com/sensei-pro/?utm_source=plugin_sensei&utm_medium=upsell&utm_campaign=course_access_period">
23+
<ExternalLink
24+
href={ getSenseiProUpsellUrl( 'course_access_period' ) }
25+
>
1926
{ __( 'Upgrade to Sensei Pro', 'sensei-lms' ) }
2027
</ExternalLink>
2128
</p>

assets/js/admin/course-general-sidebar.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { applyFilters } from '@wordpress/hooks';
1818
/**
1919
* Internal dependencies
2020
*/
21+
import { getSenseiProUpsellUrl } from '../../admin/helpers';
2122
import editorLifecycle from '../../shared/helpers/editor-lifecycle';
2223
import {
2324
extractStructure,
@@ -140,7 +141,9 @@ const CourseGeneralSidebar = () => {
140141
{ ! hideCoteachersUpgrade && (
141142
<div className="sensei-course-coteachers-wrapper">
142143
{ __( 'Multiple teachers?', 'sensei-lms' ) }{ ' ' }
143-
<ExternalLink href="https://senseilms.com/sensei-pro/?utm_source=plugin_sensei&utm_medium=upsell&utm_campaign=co-teachers">
144+
<ExternalLink
145+
href={ getSenseiProUpsellUrl( 'co-teachers' ) }
146+
>
144147
{ __( 'Upgrade to Sensei Pro', 'sensei-lms' ) }
145148
</ExternalLink>
146149
</div>

0 commit comments

Comments
 (0)