diff --git a/bedrock/base/templates/macros.html b/bedrock/base/templates/macros.html index d1b98e02eb3..af05855e50d 100644 --- a/bedrock/base/templates/macros.html +++ b/bedrock/base/templates/macros.html @@ -66,6 +66,13 @@ {%- endmacro %} +{% macro ms_store_button(class_name='', extra_data_attributes={}, extra_img_attributes={}, href=settings.MICROSOFT_WINDOWS_STORE_FIREFOX_LINK, id='', product='Firefox', campaign='', target='') -%} +{% set optional_img_attributes = {'width': '152', 'height': '55'} %} + + {{ ftl('download-button-get-it-from-microsoft') }} + +{%- endmacro %} + {# Docs: https://bedrock.readthedocs.io/en/latest/firefox-accounts.html#signup-form #} {% macro fxa_email_form(entrypoint, entrypoint_experiment, entrypoint_variation, context=None, utm_campaign=None, utm_content=None, utm_term=None, style=None, class_name='fxa-email-form', form_title=None, intro_text=none, button_text=None, button_class='mzp-c-button mzp-t-product') -%}
diff --git a/bedrock/mozorg/templatetags/misc.py b/bedrock/mozorg/templatetags/misc.py index d4582ff4661..967c71a58b8 100644 --- a/bedrock/mozorg/templatetags/misc.py +++ b/bedrock/mozorg/templatetags/misc.py @@ -22,7 +22,7 @@ from markupsafe import Markup from product_details import product_details -from bedrock.base.templatetags.helpers import static +from bedrock.base.templatetags.helpers import static, urlparams ALL_FX_PLATFORMS = ("windows", "linux", "mac", "android", "ios") @@ -628,6 +628,19 @@ def play_store_url(ctx, product, campaign=None): return base_url +@library.global_function +@jinja2.pass_context +def ms_store_url(ctx, product, mode="direct", campaign=None): + """Returns a Microsoft Windows Store URL for a given product""" + base_url = getattr(settings, f"MICROSOFT_WINDOWS_STORE_{product.upper()}_LINK") + params = { + "mode": mode, + "cid": campaign, + } + + return urlparams(base_url, **params) + + @library.global_function @jinja2.pass_context def lang_short(ctx): diff --git a/bedrock/mozorg/tests/test_helper_misc.py b/bedrock/mozorg/tests/test_helper_misc.py index 6798e4b1ed1..08ed6e1ae93 100644 --- a/bedrock/mozorg/tests/test_helper_misc.py +++ b/bedrock/mozorg/tests/test_helper_misc.py @@ -863,6 +863,38 @@ def test_pocket_play_store_url_localized_campaign(self): ) +class TestMSStoreURL(TestCase): + rf = RequestFactory() + + def _render(self, product, mode="direct", campaign=None): + req = self.rf.get("/") + campaign_param = f"'{campaign}'" if campaign is not None else campaign + return render( + f"{{{{ ms_store_url('{product}', '{mode}', {campaign_param}) }}}}", + {"request": req}, + ) + + def test_firefox_release_ms_store_url(self): + """should return a MS Store URL for Firefox release channel""" + assert self._render(product="firefox") == "https://apps.microsoft.com/detail/9nzvdkpmr9rd?mode=direct" + + def test_firefox_beta_ms_store_url(self): + """should return a MS Store URL for Firefox Beta channel""" + assert self._render(product="firefox_beta") == "https://apps.microsoft.com/detail/9nzw26frndln?mode=direct" + + def test_firefox_ms_store_url_launch_mode(self): + """should return a MS Store URL including different launch mode parameters""" + assert self._render(product="firefox", mode="full") == "https://apps.microsoft.com/detail/9nzvdkpmr9rd?mode=full" + assert self._render(product="firefox", mode="mini") == "https://apps.microsoft.com/detail/9nzvdkpmr9rd?mode=mini" + + def test_firefox_ms_store_url_campaign(self): + """should return a MS Store URL including campaign parameters""" + assert ( + self._render(product="firefox", campaign="mozorg-firefox-home") + == "https://apps.microsoft.com/detail/9nzvdkpmr9rd?mode=direct&cid=mozorg-firefox-home" + ) + + class TestLangShort(TestCase): rf = RequestFactory() diff --git a/bedrock/settings/appstores.py b/bedrock/settings/appstores.py index d324a7dac5a..dc8a6d26fe8 100644 --- a/bedrock/settings/appstores.py +++ b/bedrock/settings/appstores.py @@ -105,3 +105,9 @@ # Link to Firefox Send on the Google Play Store. GOOGLE_PLAY_FIREFOX_SEND_LINK = "https://play.google.com/store/apps/details?id=org.mozilla.firefoxsend" + +# Link to Firefox on the Microsoft Windows Store. +MICROSOFT_WINDOWS_STORE_FIREFOX_LINK = "https://apps.microsoft.com/detail/9nzvdkpmr9rd" + +# Link to Firefox Beta on the Microsoft Windows Store. +MICROSOFT_WINDOWS_STORE_FIREFOX_BETA_LINK = "https://apps.microsoft.com/detail/9nzw26frndln" diff --git a/bedrock/settings/base.py b/bedrock/settings/base.py index 32eeafb2f1f..1c798a7cb0b 100644 --- a/bedrock/settings/base.py +++ b/bedrock/settings/base.py @@ -1030,6 +1030,8 @@ def _is_bedrock_custom_app(app_name): GOOGLE_PLAY_FOCUS_LINK, GOOGLE_PLAY_KLAR_LINK, GOOGLE_PLAY_POCKET_LINK, + MICROSOFT_WINDOWS_STORE_FIREFOX_BETA_LINK, + MICROSOFT_WINDOWS_STORE_FIREFOX_LINK, ) # Locales that should display the 'Send to Device' widget diff --git a/l10n/en/download_button.ftl b/l10n/en/download_button.ftl index 67a428ae968..41ffcd11c54 100644 --- a/l10n/en/download_button.ftl +++ b/l10n/en/download_button.ftl @@ -71,3 +71,6 @@ download-button-linux-64-v2 = Download for Linux 64-bit # $attrs (attrs) - link to https://support.mozilla.org/kb/install-firefox-linux#w_install-firefox-deb-package-for-debian-based-distributions # Note: Debian and Ubuntu are brand names and shouldn't be translated download-button-using-debian = Using Debian, Ubuntu or any Debian-based distribution?
You can set up our APT repository instead. + +# Microsoft Windows Store badge +download-button-get-it-from-microsoft = Get it from Microsoft diff --git a/media/img/l10n/ar/firefox/windows/ms-store-badge.svg b/media/img/l10n/ar/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..94721c752d9 --- /dev/null +++ b/media/img/l10n/ar/firefox/windows/ms-store-badge.svg @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/media/img/l10n/be/firefox/windows/ms-store-badge.svg b/media/img/l10n/be/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..a72b434fe08 --- /dev/null +++ b/media/img/l10n/be/firefox/windows/ms-store-badge.svg @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Атрымайце гэта ад + + diff --git a/media/img/l10n/bg/firefox/windows/ms-store-badge.svg b/media/img/l10n/bg/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..96d1324951c --- /dev/null +++ b/media/img/l10n/bg/firefox/windows/ms-store-badge.svg @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Вземете от + + + diff --git a/media/img/l10n/bn/firefox/windows/ms-store-badge.svg b/media/img/l10n/bn/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..14e0c32a34b --- /dev/null +++ b/media/img/l10n/bn/firefox/windows/ms-store-badge.svg @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/media/img/l10n/bs/firefox/windows/ms-store-badge.svg b/media/img/l10n/bs/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..2925b7a8d1b --- /dev/null +++ b/media/img/l10n/bs/firefox/windows/ms-store-badge.svg @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Preuzmite od + + diff --git a/media/img/l10n/cs/firefox/windows/ms-store-badge.svg b/media/img/l10n/cs/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..f4b21ca60f4 --- /dev/null +++ b/media/img/l10n/cs/firefox/windows/ms-store-badge.svg @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/media/img/l10n/da/firefox/windows/ms-store-badge.svg b/media/img/l10n/da/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..3027515c723 --- /dev/null +++ b/media/img/l10n/da/firefox/windows/ms-store-badge.svg @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +Få det hos + diff --git a/media/img/l10n/de/firefox/windows/ms-store-badge.svg b/media/img/l10n/de/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..38f5e862495 --- /dev/null +++ b/media/img/l10n/de/firefox/windows/ms-store-badge.svg @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/media/img/l10n/el/firefox/windows/ms-store-badge.svg b/media/img/l10n/el/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..871cdf5fffe --- /dev/null +++ b/media/img/l10n/el/firefox/windows/ms-store-badge.svg @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + Αποκτήστε το από τη + + + + + + + + + + diff --git a/media/img/l10n/en-US/firefox/windows/ms-store-badge.svg b/media/img/l10n/en-US/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..dac987778ad --- /dev/null +++ b/media/img/l10n/en-US/firefox/windows/ms-store-badge.svg @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/media/img/l10n/es-ES/firefox/windows/ms-store-badge.svg b/media/img/l10n/es-ES/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..de25161705c --- /dev/null +++ b/media/img/l10n/es-ES/firefox/windows/ms-store-badge.svg @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Consíguelo de + + + diff --git a/media/img/l10n/et/firefox/windows/ms-store-badge.svg b/media/img/l10n/et/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..360d668148f --- /dev/null +++ b/media/img/l10n/et/firefox/windows/ms-store-badge.svg @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + +Hangi see + + + + + + + + + diff --git a/media/img/l10n/fi/firefox/windows/ms-store-badge.svg b/media/img/l10n/fi/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..0ddc5d7e7fc --- /dev/null +++ b/media/img/l10n/fi/firefox/windows/ms-store-badge.svg @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/media/img/l10n/fr/firefox/windows/ms-store-badge.svg b/media/img/l10n/fr/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..8a980be1751 --- /dev/null +++ b/media/img/l10n/fr/firefox/windows/ms-store-badge.svg @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Obtenir sur + + diff --git a/media/img/l10n/he/firefox/windows/ms-store-badge.svg b/media/img/l10n/he/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..861b6f8a1a6 --- /dev/null +++ b/media/img/l10n/he/firefox/windows/ms-store-badge.svg @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/media/img/l10n/hi-IN/firefox/windows/ms-store-badge.svg b/media/img/l10n/hi-IN/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..a408386780e --- /dev/null +++ b/media/img/l10n/hi-IN/firefox/windows/ms-store-badge.svg @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/media/img/l10n/hr/firefox/windows/ms-store-badge.svg b/media/img/l10n/hr/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..d9c6e3175c2 --- /dev/null +++ b/media/img/l10n/hr/firefox/windows/ms-store-badge.svg @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Preuzmite od tvrtke + + diff --git a/media/img/l10n/hu/firefox/windows/ms-store-badge.svg b/media/img/l10n/hu/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..cdd3a2e7ef5 --- /dev/null +++ b/media/img/l10n/hu/firefox/windows/ms-store-badge.svg @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/media/img/l10n/id/firefox/windows/ms-store-badge.svg b/media/img/l10n/id/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..aac5bab7547 --- /dev/null +++ b/media/img/l10n/id/firefox/windows/ms-store-badge.svg @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Dapatkan dari + + diff --git a/media/img/l10n/it/firefox/windows/ms-store-badge.svg b/media/img/l10n/it/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..8bdc91aa890 --- /dev/null +++ b/media/img/l10n/it/firefox/windows/ms-store-badge.svg @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Scaricalo da + + + diff --git a/media/img/l10n/ja/firefox/windows/ms-store-badge.svg b/media/img/l10n/ja/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..33b2dc4a5f9 --- /dev/null +++ b/media/img/l10n/ja/firefox/windows/ms-store-badge.svg @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + から入手 + + + + + + + + + + diff --git a/media/img/l10n/ko/firefox/windows/ms-store-badge.svg b/media/img/l10n/ko/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..b4943a887b7 --- /dev/null +++ b/media/img/l10n/ko/firefox/windows/ms-store-badge.svg @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/media/img/l10n/lt/firefox/windows/ms-store-badge.svg b/media/img/l10n/lt/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..fba793c4505 --- /dev/null +++ b/media/img/l10n/lt/firefox/windows/ms-store-badge.svg @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + Gauti iš + + + + + diff --git a/media/img/l10n/lv/firefox/windows/ms-store-badge.svg b/media/img/l10n/lv/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..a9fdfe7ef89 --- /dev/null +++ b/media/img/l10n/lv/firefox/windows/ms-store-badge.svg @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Iegūt no korporācijas + + + + diff --git a/media/img/l10n/ms/firefox/windows/ms-store-badge.svg b/media/img/l10n/ms/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..9a9f828058b --- /dev/null +++ b/media/img/l10n/ms/firefox/windows/ms-store-badge.svg @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + Dapatkan daripada + + + + diff --git a/media/img/l10n/nb-NO/firefox/windows/ms-store-badge.svg b/media/img/l10n/nb-NO/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..ab78aede12f --- /dev/null +++ b/media/img/l10n/nb-NO/firefox/windows/ms-store-badge.svg @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + Få det fra + + + + diff --git a/media/img/l10n/nl/firefox/windows/ms-store-badge.svg b/media/img/l10n/nl/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..70366f9264c --- /dev/null +++ b/media/img/l10n/nl/firefox/windows/ms-store-badge.svg @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/media/img/l10n/pl/firefox/windows/ms-store-badge.svg b/media/img/l10n/pl/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..173a1c66463 --- /dev/null +++ b/media/img/l10n/pl/firefox/windows/ms-store-badge.svg @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Pobierz z witryny + + diff --git a/media/img/l10n/pt-BR/firefox/windows/ms-store-badge.svg b/media/img/l10n/pt-BR/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..9d464d6453c --- /dev/null +++ b/media/img/l10n/pt-BR/firefox/windows/ms-store-badge.svg @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Baixe da + + diff --git a/media/img/l10n/pt-PT/firefox/windows/ms-store-badge.svg b/media/img/l10n/pt-PT/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..3d3d2ac8acd --- /dev/null +++ b/media/img/l10n/pt-PT/firefox/windows/ms-store-badge.svg @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/media/img/l10n/ro/firefox/windows/ms-store-badge.svg b/media/img/l10n/ro/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..0c1df8c1b3d --- /dev/null +++ b/media/img/l10n/ro/firefox/windows/ms-store-badge.svg @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + Descărcați de la + + + + diff --git a/media/img/l10n/ru/firefox/windows/ms-store-badge.svg b/media/img/l10n/ru/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..c501691a4c1 --- /dev/null +++ b/media/img/l10n/ru/firefox/windows/ms-store-badge.svg @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/media/img/l10n/sk/firefox/windows/ms-store-badge.svg b/media/img/l10n/sk/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..068fc01ea51 --- /dev/null +++ b/media/img/l10n/sk/firefox/windows/ms-store-badge.svg @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/media/img/l10n/sl/firefox/windows/ms-store-badge.svg b/media/img/l10n/sl/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..ebca22d43d8 --- /dev/null +++ b/media/img/l10n/sl/firefox/windows/ms-store-badge.svg @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/media/img/l10n/sr/firefox/windows/ms-store-badge.svg b/media/img/l10n/sr/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..b6af25dd489 --- /dev/null +++ b/media/img/l10n/sr/firefox/windows/ms-store-badge.svg @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Preuzmite od korporacije + + + diff --git a/media/img/l10n/sv-SE/firefox/windows/ms-store-badge.svg b/media/img/l10n/sv-SE/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..516165bd8ca --- /dev/null +++ b/media/img/l10n/sv-SE/firefox/windows/ms-store-badge.svg @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Skaffa det från + + + diff --git a/media/img/l10n/th/firefox/windows/ms-store-badge.svg b/media/img/l10n/th/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..e7e391cdda5 --- /dev/null +++ b/media/img/l10n/th/firefox/windows/ms-store-badge.svg @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + รับได้ที่ + + diff --git a/media/img/l10n/tr/firefox/windows/ms-store-badge.svg b/media/img/l10n/tr/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..1fa86435c6c --- /dev/null +++ b/media/img/l10n/tr/firefox/windows/ms-store-badge.svg @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/media/img/l10n/uk/firefox/windows/ms-store-badge.svg b/media/img/l10n/uk/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..0cdd2554e1c --- /dev/null +++ b/media/img/l10n/uk/firefox/windows/ms-store-badge.svg @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Пропозиція від + + diff --git a/media/img/l10n/vi/firefox/windows/ms-store-badge.svg b/media/img/l10n/vi/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..c1ec7e9e769 --- /dev/null +++ b/media/img/l10n/vi/firefox/windows/ms-store-badge.svg @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/media/img/l10n/zh-CN/firefox/windows/ms-store-badge.svg b/media/img/l10n/zh-CN/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..a946cd9350c --- /dev/null +++ b/media/img/l10n/zh-CN/firefox/windows/ms-store-badge.svg @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 获取 + + diff --git a/media/img/l10n/zh-TW/firefox/windows/ms-store-badge.svg b/media/img/l10n/zh-TW/firefox/windows/ms-store-badge.svg new file mode 100644 index 00000000000..6888b5b4562 --- /dev/null +++ b/media/img/l10n/zh-TW/firefox/windows/ms-store-badge.svg @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/media/js/base/datalayer-productdownload.es6.js b/media/js/base/datalayer-productdownload.es6.js index 054a5cfb7d0..771eb549fa2 100644 --- a/media/js/base/datalayer-productdownload.es6.js +++ b/media/js/base/datalayer-productdownload.es6.js @@ -12,6 +12,7 @@ const iTunesURL = /^https:\/\/itunes.apple.com/; const appStoreURL = /^https:\/\/apps.apple.com/; const playStoreURL = /^https:\/\/play.google.com/; const marketURL = /^market:\/\/play.google.com/; +const msStoreUrl = /^https:\/\/apps.microsoft.com/; if (typeof window.dataLayer === 'undefined') { window.dataLayer = []; @@ -31,7 +32,8 @@ TrackProductDownload.isValidDownloadURL = (downloadURL) => { iTunesURL.test(downloadURL) || appStoreURL.test(downloadURL) || playStoreURL.test(downloadURL) || - marketURL.test(downloadURL) + marketURL.test(downloadURL) || + msStoreUrl.test(downloadURL) ) { return true; } else { @@ -46,7 +48,7 @@ TrackProductDownload.isValidDownloadURL = (downloadURL) => { * Create the product_download event object * @param {string} product * @param {string} platform - * @param {string} method - site, store, or adjust + * @param {string} method - site or store * @param {string} release_channel - optional, we don't get it for ios downloads * @param {string} download_language - optional, we don't get it for mobile downloads * @returns {Object} @@ -182,6 +184,21 @@ TrackProductDownload.getEventFromUrl = (downloadURL) => { 'store', 'release' ); + } else if (msStoreUrl.test(downloadURL)) { + let channel = 'unrecognized'; + if (downloadURL.indexOf('/9nzvdkpmr9rd') !== -1) { + channel = 'release'; + } else if (downloadURL.indexOf('/9nzw26frndln') !== -1) { + channel = 'beta'; + } + + // MS Store + eventObject = TrackProductDownload.getEventObject( + 'firefox', + 'win', + 'store', + channel + ); } return eventObject; @@ -222,6 +239,37 @@ TrackProductDownload.sendEventFromURL = (downloadURL) => { } }; +/** + * Send product_download event to glean.js + * @param {Object} - product details formatted into a product_download event + */ +TrackProductDownload.sendGleanEvent = (eventObject) => { + if (typeof window.Mozilla.Glean !== 'undefined') { + /** + * Glean is more limited when it comes to the number of + * default click event fields, so we need to combine + * some meta data into the label. + */ + let label = eventObject.method; + + // release_channel is optional + if (eventObject.release_channel) { + label += `,${eventObject.release_channel}`; + } + + // download_language is optional + if (eventObject.download_language) { + label += `,${eventObject.download_language}`; + } + + window.Mozilla.Glean.clickEvent({ + id: eventObject.event, + type: `${eventObject.platform}`, + label: label + }); + } +}; + /** * Sends an event to the data layer * @param {Object} - product details formatted into a product_download event @@ -233,13 +281,7 @@ TrackProductDownload.sendEvent = (eventObject) => { TrackProductDownload.sendOldEvent(eventObject); // track event in glean.js - if (typeof window.Mozilla.Glean !== 'undefined') { - window.Mozilla.Glean.clickEvent({ - id: eventObject.event, - type: eventObject.platform, - label: eventObject.release_channel - }); - } + TrackProductDownload.sendGleanEvent(eventObject); }; /** diff --git a/tests/unit/spec/base/datalayer-productdownload.js b/tests/unit/spec/base/datalayer-productdownload.js index b2ab505bde4..ecc00a1880d 100644 --- a/tests/unit/spec/base/datalayer-productdownload.js +++ b/tests/unit/spec/base/datalayer-productdownload.js @@ -294,6 +294,24 @@ describe('TrackProductDownload.getEventFromUrl', function () { ); expect(testEvent['download_language']).toBeFalsy(); }); + it('should identify Firefox in the MS Store', function () { + const testEvent = TrackProductDownload.getEventFromUrl( + 'https://apps.microsoft.com/detail/9nzvdkpmr9rd?mode=direct&cid=firefox-home' + ); + expect(testEvent['product']).toBe('firefox'); + expect(testEvent['platform']).toBe('win'); + expect(testEvent['method']).toBe('store'); + expect(testEvent['release_channel']).toBe('release'); + }); + it('should identify Firefox Beta in the MS Store', function () { + const testEvent = TrackProductDownload.getEventFromUrl( + 'https://apps.microsoft.com/detail/9nzw26frndln?mode=direct&cid=firefox-all' + ); + expect(testEvent['product']).toBe('firefox'); + expect(testEvent['platform']).toBe('win'); + expect(testEvent['method']).toBe('store'); + expect(testEvent['release_channel']).toBe('beta'); + }); }); describe('TrackProductDownload.handleLink', function () { @@ -345,3 +363,43 @@ describe('TrackProductDownload.handleLink', function () { }); }); }); + +describe('TrackProductDownload.sendGleanEvent', function () { + beforeEach(function () { + window.Mozilla.Glean = sinon.stub(); + window.Mozilla.Glean.clickEvent = sinon.stub(); + spyOn(window.Mozilla.Glean, 'clickEvent'); + }); + + it('should call Glean.clickEvent with required parameters', function () { + TrackProductDownload.sendGleanEvent({ + event: 'firefox_download', + product: 'firefox', + platform: 'macos', + method: 'site' + }); + + expect(window.Mozilla.Glean.clickEvent).toHaveBeenCalledWith({ + id: 'firefox_download', + type: 'macos', + label: 'site' + }); + }); + + it('should call Glean.clickEvent with additional optional parameters', function () { + TrackProductDownload.sendGleanEvent({ + event: 'firefox_download', + product: 'firefox', + platform: 'win64', + method: 'site', + release_channel: 'release', + download_language: 'en-CA' + }); + + expect(window.Mozilla.Glean.clickEvent).toHaveBeenCalledWith({ + id: 'firefox_download', + type: 'win64', + label: 'site,release,en-CA' + }); + }); +});