Skip to content

Commit 6186e34

Browse files
committed
chore: pro upsell dialog on promotion complete
1 parent 219a2d7 commit 6186e34

13 files changed

+133
-33
lines changed

src/brackets.config.dist.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
"buildtype" : "production",
1010
"bugsnagEnv" : "production",
1111
"app_notification_url" : "https://updates.phcode.io/appNotifications/prod/",
12-
"app_update_url" : "https://updates.phcode.io/tauri/update-latest-stable-prod.json"
12+
"app_update_url" : "https://updates.phcode.io/tauri/update-latest-stable-prod.json",
13+
"promotions_url" : "https://promotions.phcode.dev/prod/"
1314
}

src/brackets.config.staging.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
"buildtype" : "staging",
1010
"bugsnagEnv" : "staging",
1111
"app_notification_url" : "https://updates.phcode.io/appNotifications/staging/",
12-
"app_update_url" : "https://updates.phcode.io/tauri/update-latest-pre-release.json"
12+
"app_update_url" : "https://updates.phcode.io/tauri/update-latest-pre-release.json",
13+
"promotions_url" : "https://promotions.phcode.dev/dev/"
1314
}

src/config.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
"app_name_about": "Phoenix Code",
55
"about_icon": "styles/images/phoenix-icon.svg",
66
"account_url": "https://account.phcode.dev/",
7+
"promotions_url": "https://promotions.phcode.dev/dev/",
8+
"purchase_url": "https://phcode.io/pricing",
79
"how_to_use_url": "https://github.com/adobe/brackets/wiki/How-to-Use-Brackets",
810
"docs_url": "https://docs.phcode.dev/",
911
"support_url": "https://account.phcode.dev/?returnUrl=https%3A%2F%2Faccount.phcode.dev%2F%23support",

src/nls/root/strings.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1675,5 +1675,7 @@ define({
16751675
"PROMO_CARD_3_MESSAGE": "Duplicate and delete elements with a single click.",
16761676
"PROMO_CARD_4": "Editing Text In Preview",
16771677
"PROMO_CARD_4_MESSAGE": "Edit headings, buttons, and copy directly in the preview.",
1678-
"PROMO_LEARN_MORE": "Learn More\u2026"
1678+
"PROMO_LEARN_MORE": "Learn More\u2026",
1679+
"PROMO_GET_APP_UPSELL_BUTTON": "Get {0}",
1680+
"PROMO_PRO_ENDED_TITLE": "Your {0} upgrade has ended"
16791681
});

src/services/html/pro-upgrade.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="browser-login-waiting-dialog modal">
1+
<div class="pro-upgrade-dialog modal">
22
<div class="modal-header">
33
<h1 class="dialog-title">{{{title}}}</h1>
44
</div>

src/services/html/promo-ended.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<div class="pro-ended-dialog modal">
2+
<div class="modal-header">
3+
<h1 class="dialog-title">{{{title}}}</h1>
4+
</div>
5+
6+
<div class="modal-body">
7+
<div class="promo-iframe-wrap">
8+
<iframe
9+
class="promo-iframe"
10+
src="{{promoURL}}"
11+
title="{{title}}"
12+
loading="lazy"
13+
referrerpolicy="no-referrer">
14+
</iframe>
15+
</div>
16+
</div>
17+
18+
<div class="modal-footer">
19+
<button class="dialog-button btn" data-button-id="cancel">{{Strings.CANCEL}}</button>
20+
<button class="dialog-button btn primary" data-button-id="get_pro">{{{buttonGetPro}}}</button>
21+
</div>
22+
</div>

src/services/login-service.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ define(function (require, exports, module) {
5858

5959
try {
6060
const accountBaseURL = LoginService.getAccountBaseURL();
61-
const language = Phoenix.app && Phoenix.app.language ? Phoenix.app.language : 'en';
61+
const language = brackets.getLocale();
6262
let url = `${accountBaseURL}/getAppEntitlements?lang=${language}`;
6363
let fetchOptions = {
6464
method: 'GET',

src/services/pro-dialogs.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,17 @@ define(function (require, exports, module) {
2929
const proTitle = `<span class="phoenix-pro-title">
3030
<span class="pro-plan-name">Phoenix Pro</span>
3131
<i class="fa-solid fa-feather orange-gold" style="margin-left: 3px;"></i>
32-
</span>`;
32+
</span>`,
33+
proTitlePlain = `<span class="pro-plan-name">Phoenix Pro</span>
34+
<i class="fa-solid fa-feather" style="margin-left: 2px;"></i>`;
3335
require("./setup-login-service"); // this adds loginService to KernalModeTrust
3436
const Dialogs = require("widgets/Dialogs"),
3537
Mustache = require("thirdparty/mustache/mustache"),
3638
Strings = require("strings"),
3739
StringUtils = require("utils/StringUtils"),
38-
proUpgradeHTML = require("text!./html/pro-upgrade.html");
40+
ThemeManager = require("view/ThemeManager"),
41+
proUpgradeHTML = require("text!./html/pro-upgrade.html"),
42+
proEndedHTML = require("text!./html/promo-ended.html");
3943

4044
function showProUpgradeDialog(trialDays) {
4145
const title = StringUtils.format(Strings.PROMO_UPGRADE_TITLE, proTitle);
@@ -44,10 +48,29 @@ define(function (require, exports, module) {
4448
Dialogs.showModalDialogUsingTemplate($template).done(function (id) {
4549
console.log("Dialog closed with id: " + id);
4650
if(id === 'learn_more') {
47-
Phoenix.app.openURLInDefaultBrowser(brackets.config.homepage_url);
51+
// todo add metrics
52+
Phoenix.app.openURLInDefaultBrowser(brackets.config.purchase_url);
53+
}
54+
});
55+
}
56+
57+
function showProEndedDialog(currentVersion) {
58+
currentVersion = currentVersion || window.AppConfig.apiVersion;
59+
const buttonGetPro = StringUtils.format(Strings.PROMO_GET_APP_UPSELL_BUTTON, proTitlePlain);
60+
const title = StringUtils.format(Strings.PROMO_PRO_ENDED_TITLE, proTitle);
61+
const currentTheme = ThemeManager.getCurrentTheme();
62+
const theme = currentTheme && currentTheme.dark ? "dark" : "light";
63+
const promoURL = `${brackets.config.promotions_url}app/upsell_after_trial.html?lang=${brackets.getLocale()}&theme=${theme}&version=${currentVersion}`;
64+
const $template = $(Mustache.render(proEndedHTML, {Strings, title, buttonGetPro, promoURL}));
65+
Dialogs.showModalDialogUsingTemplate($template).done(function (id) {
66+
console.log("Dialog closed with id: " + id);
67+
if(id === 'get_pro') {
68+
// todo add metrics
69+
Phoenix.app.openURLInDefaultBrowser(brackets.config.purchase_url);
4870
}
4971
});
5072
}
5173

5274
exports.showProUpgradeDialog = showProUpgradeDialog;
75+
exports.showProEndedDialog = showProEndedDialog;
5376
});

src/services/profile-menu.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,6 @@ define(function (require, exports, module) {
525525
title: Strings.CMD_USER_PROFILE
526526
})
527527
.appendTo($("#main-toolbar .bottom-buttons"));
528-
// _updateProfileIcon("CA", "blue");
529528
$icon.on('click', ()=>{
530529
togglePopup();
531530
});

src/services/promotions.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,20 @@ define(function (require, exports, module) {
203203

204204
// Check if we should grant any trial
205205
if (remainingDays <= 0 && !isNewerVersion) {
206-
console.log("Existing trial expired, same/older version - no new trial");
206+
// Check if promo ended dialog was already shown for this version
207+
if (existingTrialData.upgradeDialogShownVersion !== currentVersion) {
208+
// todo we should not show this to logged in pro subscribers, but at startup time,
209+
// we do not know if login is done yet.
210+
console.log("Existing trial expired, showing promo ended dialog");
211+
ProDialogs.showProEndedDialog(currentVersion);
212+
// Store that dialog was shown for this version
213+
await _setTrialData({
214+
...existingTrialData,
215+
upgradeDialogShownVersion: currentVersion
216+
});
217+
} else {
218+
console.log("Existing trial expired, upgrade dialog already shown for this version");
219+
}
207220
return;
208221
}
209222

0 commit comments

Comments
 (0)