Skip to content

Commit

Permalink
Implement subscription expiring message
Browse files Browse the repository at this point in the history
  • Loading branch information
jps-moz authored and brizental committed Jan 23, 2023
1 parent 12aad36 commit 1c067fb
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
3 changes: 3 additions & 0 deletions addons/message_subscription_expiring/contactSupportLink.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
((api) => {
api.urlOpener.openLink(api.urlOpener.LinkHelpSupport);
});
12 changes: 12 additions & 0 deletions addons/message_subscription_expiring/isExpiring.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(function(api, condition) {
// Show message only if within 1 week of expiring.
let weekBeforeExpireMSecs = api.subscriptionData.expiresOn - 1000 * 60 * 60 * 24;

if (Date.now() < api.subscriptionData.expiresOn &&
Date.now() >= weekBeforeExpireMSecs) {
api.addon.date = weekBeforeExpireMSecs;
condition.enable();
} else {
condition.disable();
}
})
3 changes: 3 additions & 0 deletions addons/message_subscription_expiring/manageAccountLink.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
((api) => {
api.urlOpener.openLink(api.urlOpener.LinkAccount);
});
36 changes: 36 additions & 0 deletions addons/message_subscription_expiring/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"api_version": "0.1",
"id": "message_subscription_expiring",
"name": "Subscription expiring message",
"type": "message",
"conditions": {
"javascript": "isExpiring.js"
},
"message": {
"id": "message_subscription_expiring",
"title": "Your subscription is ending soon",
"subtitle": "Your Mozilla VPN subscription will end in one week. After that, you’ll no longer be able to use Mozilla VPN.",
"badge": "warning",
"blocks": [
{
"id": "c_1",
"type": "text",
"content": "Don’t lose your subscription — please go to your account page to renew your access to Mozilla VPN. If you’re having any issues, please contact support to get help."
},
{
"id": "c_2",
"type": "button",
"style": "primary",
"content": "Manage account",
"javascript": "manageAccountLink.js"
},
{
"id": "c_3",
"type": "button",
"style": "link",
"content": "Contact support",
"javascript": "contactSupportLink.js"
}
]
}
}

0 comments on commit 1c067fb

Please sign in to comment.