Skip to content

Commit

Permalink
add birthday24 promo. AG-32756
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit 2ed1383
Author: Slava Leleka <v.leleka@adguard.com>
Date:   Mon May 20 06:20:38 2024 +0300

    update ko locale

commit 87034cf
Author: Slava Leleka <v.leleka@adguard.com>
Date:   Fri May 17 20:14:00 2024 +0300

    fix fa locale

commit 7c28bd6
Author: Slava Leleka <v.leleka@adguard.com>
Date:   Fri May 17 13:26:31 2024 +0300

    cleanup

commit dfbb779
Merge: 80ed123 3cdea51
Author: Slava Leleka <v.leleka@adguard.com>
Date:   Thu May 16 19:46:03 2024 +0300

    Merge branch 'master' into feature/AG-32756

commit 80ed123
Author: Slava Leleka <v.leleka@adguard.com>
Date:   Thu May 16 19:17:34 2024 +0300

    add birthday24 promo

commit ad3eab1
Author: Slava Leleka <v.leleka@adguard.com>
Date:   Thu May 16 17:24:16 2024 +0300

    update assets
  • Loading branch information
slavaleleka committed May 20, 2024
1 parent 3cdea51 commit 8b6263a
Show file tree
Hide file tree
Showing 18 changed files with 220 additions and 765 deletions.
82 changes: 82 additions & 0 deletions src/assets/images/birthday24.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
256 changes: 0 additions & 256 deletions src/assets/images/easter24.svg

This file was deleted.

Binary file added src/assets/images/icons/birthday24-off-19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/icons/birthday24-off-38.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/icons/birthday24-on-19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/icons/birthday24-on-38.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed src/assets/images/icons/easter24-off-19.png
Binary file not shown.
Binary file removed src/assets/images/icons/easter24-off-38.png
Binary file not shown.
Binary file removed src/assets/images/icons/easter24-on-19.png
Binary file not shown.
Binary file removed src/assets/images/icons/easter24-on-38.png
Binary file not shown.
Binary file removed src/assets/images/icons/spring24-off-19.png
Binary file not shown.
Binary file removed src/assets/images/icons/spring24-off-38.png
Binary file not shown.
Binary file removed src/assets/images/icons/spring24-on-19.png
Binary file not shown.
Binary file removed src/assets/images/icons/spring24-on-38.png
Binary file not shown.
312 changes: 0 additions & 312 deletions src/assets/images/spring24.svg

This file was deleted.

322 changes: 131 additions & 191 deletions src/background/promoNotifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import browser from 'webextension-polyfill';

import { getForwarderUrl } from '../common/helpers';
import { Prefs } from '../common/prefs';
import { isRuLocale, normalizeLanguage } from '../common/utils/promo';
import { normalizeLanguage } from '../common/utils/promo';
import { notifier } from '../common/notifier';

import { getUrl } from './browserApi/runtime';
Expand Down Expand Up @@ -73,259 +73,199 @@ const NOTIFICATION_DELAY_MS = 30 * 1000; // clear notification in 30 seconds
const VIEWED_NOTIFICATIONS = 'viewed-notifications';
const LAST_NOTIFICATION_TIME = 'viewed-notification-time';

const TDS_PROMO_ACTION = 'easter_24_vpn';
const TDS_PROMO_ACTION_RU = 'easter_24_vpn_ru';
const TDS_PROMO_ACTION = 'birthday_24_vpn';

const COMMON_PROMO_URL_QUERY = `action=${TDS_PROMO_ACTION}&from=popup&app=vpn_extension`;
const RU_PROMO_URL_QUERY = `action=${TDS_PROMO_ACTION_RU}&from=popup&app=vpn_extension`;

// possible return values of getUILanguage(): 'ru' or 'ru-RU' which is 'ru_ru' after normalization
const promoUrlQuery = isRuLocale
? RU_PROMO_URL_QUERY
: COMMON_PROMO_URL_QUERY;
const BIRTHDAY_24_ID = 'birthday24';

/**
* List of locales for the Spring promo, not the Easter one. AG-31141.
*/
const SPRING_PROMO_LOCALES = [
'ru',
'uk',
'ar',
'be',
'bg',
'el',
'sr',
'hy',
'fa',
'he',
'ms',
'id',
'tr',
'vi',
'zh_cn',
'zh_tw',
];

const EASTER_24_ID = 'easter24';

let easter24Notification: PromoNotificationData = {
id: EASTER_24_ID,
const birthday24Notification: PromoNotificationData = {
id: BIRTHDAY_24_ID,
locales: {
en: {
title: 'Easter promo',
btn: 'Get 80% off',
},
// there is no promo for Japanese
// ja: {},
ko: {
title: '부활절 세일',
btn: '80% 할인',
title: 'Would you fit in AdGuard?',
btn: 'Find out',
},
fr: {
title: 'Promo de Pâques',
btn: '80% de remise ici',
title: 'Qui seriez-vous chez AdGuard ?',
btn: 'Découvrez-le',
},
it: {
title: 'Offerta di Pascua',
btn: '80% di sconto qui',
title: 'Chi sarai ad AdGuard ?',
btn: 'Scoprirlo',
},
de: {
title: 'Oster-Sale',
btn: '80% Rabatt',
title: 'Wer wären Sie bei AdGuard?',
btn: 'Herausfinden',
},
ru: {
title: 'Кем бы вы были в AdGuard?',
btn: 'Узнать',
},
es: {
title: 'Promo de Pascua',
btn: 'Obtén un 80% OFF',
title: '¿Quién eres en AdGuard?',
btn: 'Descubrirlo',
},
pt_br: {
title: 'Promo de Páscoa',
btn: 'Obtenha 80% OFF',
es_419: {
title: '¿Quién eres en AdGuard?',
btn: 'Descubrirlo',
},
pt_pt: {
title: 'Promo de Páscoa',
btn: 'Obtenha 80% OFF',
title: 'Quem seria no AdGuard?',
btn: 'Descobrir',
},
ca: {
title: 'Promoció de Pasqua',
btn: '80% de descompte',
},
cs: {
title: 'Velikonoční promo akce',
btn: '80% sleva',
pt_br: {
title: 'Quem é você no AdGuard?',
btn: 'Descobrir',
},
da: {
title: 'Påske kampagne',
btn: '80% rabat',
zh_cn: {
title: '如果你在 AdGuard 工作',
btn: '你的岗位会是...',
},
es_419: {
title: 'Promoción de pascua',
btn: '80% de descuento',
zh_tw: {
title: '如果您在 AdGuard 工作',
btn: '您的崗位會是...',
},
fi: {
title: 'Pääsiäispromo',
btn: '80 % alennus',
ja: {
title: 'あなたが AdGuard メンバーだったら?',
btn: 'おもしろアンケート',
},
hr: {
title: 'Uskršnja promocija',
btn: '80% popusta',
ko: {
title: '여러분이 AdGuard 직원이라면?',
btn: '테스트 시작',
},
hu: {
title: 'Húsvéti promóció',
btn: '80% kedvezmény',
uk: {
title: 'Ким би ви були в AdGuard?',
btn: 'Дізнатися',
},
lt: {
title: 'Velykų akcija',
btn: '80% nuolaida',
ar: {
title: '؟AdGuard من كنت ستكون في ',
btn: 'اكتشاف',
},
nb: {
title: 'Påskekampanje',
btn: '80% rabatt',
be: {
title: 'Кім бы вы былі ў AdGuard?',
btn: 'Даведацца',
},
nl: {
title: 'Pasen promo',
btn: '80% korting',
id: {
title: 'Siapa yang akan Anda jadi di AdGuard?',
btn: 'Mengetahui',
},
pl: {
title: 'Promocja wielkanocna',
btn: '80% zniżki',
},
ro: {
title: 'Promoție de primăvară',
btn: '80% reducere',
title: 'Kim byłbyś w AdGuard?',
btn: 'Dowiedzieć się',
},
sk: {
title: 'Veľkonočné promo',
btn: '80% zľava',
},
sl: {
title: 'Velikonočni promo',
btn: '80% popust',
},
sv: {
title: 'Påsk kampanj',
btn: '80 % rabatt',
tr: {
title: "AdGuard'da kim olurdunuz?",
btn: 'Öğrenmek',
},
},
// will be selected for locale, see usage of getNotificationText
text: null,
urlQuery: promoUrlQuery,
from: '28 March 2024 12:00:00',
to: '3 April 2024 23:59:00',
type: 'animated',
// TODO: use lazyGet() if promo should not be different for different locales,
// otherwise it will not work on variable re-assignment
bgImage: getUrl('assets/images/easter24.svg'),
icons: {
ENABLED: {
19: getUrl('assets/images/icons/easter24-on-19.png'),
38: getUrl('assets/images/icons/easter24-on-38.png'),
vi: {
title: 'Bạn sẽ là ai trong AdGuard?',
btn: 'Tìm hiểu',
},
DISABLED: {
19: getUrl('assets/images/icons/easter24-off-19.png'),
38: getUrl('assets/images/icons/easter24-off-38.png'),
bg: {
title: 'Кой бихте били в AdGuard?',
btn: 'Разбера',
},
},
};

/**
* Diff data for the Spring promo.
*/
const spring24NotificationUpdateDiff = {
locales: {
ar: {
title: 'ترويج الربيع',
btn: '٪80 خصم',
ca: {
title: 'Qui seríeu a AdGuard?',
btn: 'Esbrinar',
},
be: {
title: 'Вясновая акцыя',
btn: 'Зніжка 80%',
cs: {
title: 'Kým byste byli v AdGuard?',
btn: 'Zjistit',
},
bg: {
title: 'Пролетна промоция',
btn: '80% отстъпка',
da: {
title: 'Hvem ville du være i AdGuard?',
btn: 'Finde ud af',
},
el: {
title: 'Ανοιξιάτικη προώθηση',
btn: '80% έκπτωση',
title: 'Ποιος θα ήσασταν στο AdGuard;',
btn: 'Μάθω',
},
fa: {
title: 'تبلیغات بهار',
btn: '80 درصد تخفیف',
title: 'چه نقشی داشته‌اید؟ AdGuard شما در ',
btn: 'فهمیدن',
},
fi: {
title: 'Kuka olisit AdGuardissa?',
btn: 'Selvittää',
},
he: {
title: 'קידום אביב',
btn: '80% הנחה',
title: '?AdGuardמי היית ב',
btn: 'לגלות',
},
hr: {
title: 'Tko bi bio u AdGuardu?',
btn: 'Saznati',
},
hu: {
title: 'Ki lennél az AdGuardban?',
btn: 'Megtudni',
},
hy: {
title: 'Գարնանային ակցիա',
btn: '80% զեղչ',
title: 'Ով կլինեիք AdGuard-ում՞',
btn: 'Պարզել',
},
id: {
title: 'Promosi musim semi',
btn: 'Diskon 80%',
lt: {
title: 'Kuo būtumėte AdGuard?',
btn: 'Sužinoti',
},
ms: {
title: 'Promosi musim bunga',
btn: '80% diskaun',
title: 'Siapa anda akan jadi di AdGuard?',
btn: 'Ketahui',
},
ru: {
title: 'Весенняя акция',
btn: 'Скидка 75%',
no: {
title: 'Hvem ville du vært i AdGuard?',
btn: 'Finne ut',
},
'sr-Latn': {
title: 'Prolećna promocija',
btn: 'Popust 80%',
nl: {
title: 'Wie zou je zijn bij AdGuard?',
btn: 'Uitvinden',
},
tr: {
title: 'Bahar promosyonu',
btn: '%80 indirim',
ro: {
title: 'Cine ai fi în AdGuard?',
btn: 'Afla',
},
uk: {
title: 'Весняна акція',
btn: 'Знижка 80%',
sk: {
title: 'Kým by ste boli v AdGuard?',
btn: 'Zistiť',
},
vi: {
title: 'Khuyến mãi mùa xuân',
btn: 'Giảm giá 80%',
sl: {
title: 'Kdo bi bil v AdGuard?',
btn: 'Izvedeti',
},
zh_cn: {
title: '暖春特惠',
btn: '享2折',
'sr-Latn': {
title: 'Ko bi ste bili u AdGuard?',
btn: 'Saznati',
},
zh_tw: {
title: '暖春優惠',
btn: '享2折',
sv: {
title: 'Vem skulle du vara i AdGuard?',
btn: 'Ta reda på',
},
},
bgImage: getUrl('assets/images/spring24.svg'),
// will be selected for locale, see usage of getNotificationText
text: null,
urlQuery: COMMON_PROMO_URL_QUERY,
from: '30 May 2024 12:00:00',
to: '5 June 2024 23:59:00',
type: 'animated',
// TODO: use lazyGet() if promo should not be different for different locales,
// otherwise it will not work on variable re-assignment
bgImage: getUrl('assets/images/birthday24.svg'),
icons: {
ENABLED: {
19: getUrl('assets/images/icons/spring24-on-19.png'),
38: getUrl('assets/images/icons/spring24-on-38.png'),
19: getUrl('assets/images/icons/birthday24-on-19.png'),
38: getUrl('assets/images/icons/birthday24-on-38.png'),
},
DISABLED: {
19: getUrl('assets/images/icons/spring24-off-19.png'),
38: getUrl('assets/images/icons/spring24-off-38.png'),
19: getUrl('assets/images/icons/birthday24-off-19.png'),
38: getUrl('assets/images/icons/birthday24-off-38.png'),
},
},
};

// possible values of browser lang: 'zh-TW' which is 'zh_tw' after normalization
const currentLocale = normalizeLanguage(browser.i18n.getUILanguage());

const shouldShowSpring24Promo = currentLocale
&& SPRING_PROMO_LOCALES.some((locale) => currentLocale.startsWith(locale));

if (shouldShowSpring24Promo) {
easter24Notification = {
...easter24Notification,
// update the notification data with the Spring promo data
...spring24NotificationUpdateDiff,
};
}

const notifications: { [key: string]: PromoNotificationData } = {
[EASTER_24_ID]: easter24Notification,
[BIRTHDAY_24_ID]: birthday24Notification,
};

/**
Expand Down
Loading

0 comments on commit 8b6263a

Please sign in to comment.