Skip to content

Commit

Permalink
Add URL redirector for VPN mobile app store links (Fixes mozilla#15286)…
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgibson authored Oct 15, 2024
1 parent c298f95 commit 029f88e
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 4 deletions.
7 changes: 4 additions & 3 deletions bedrock/firefox/redirects.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def firefox_channel(*args, **kwargs):


def mobile_app(request, *args, **kwargs):
qs = request.META.get("QUERY_STRING", "")
campaign = None
product = "firefox"

Expand Down Expand Up @@ -47,12 +46,14 @@ def mobile_app(request, *args, **kwargs):
]

for p in product_options:
if f"product={p}" in qs:
if p == request.GET.get("product"):
product = p
break

for c in campaign_options:
if f"campaign={c}" in qs:
if c == request.GET.get("campaign"):
campaign = c
break

return mobile_app_redirector(request, product, campaign)

Expand Down
28 changes: 27 additions & 1 deletion bedrock/products/redirects.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,32 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.

from bedrock.redirects.util import redirect
from bedrock.redirects.util import mobile_app_redirector, redirect


def mobile_app(request, *args, **kwargs):
campaign = None
product = "vpn"

product_options = ["vpn"]

campaign_options = [
"vpn-landing-page",
"vpn-pricing-page",
]

for p in product_options:
if p == request.GET.get("product"):
product = p
break

for c in campaign_options:
if c == request.GET.get("campaign"):
campaign = c
break

return mobile_app_redirector(request, product, campaign)


redirectpatterns = (
# Issue 10335
Expand All @@ -15,4 +40,5 @@
redirect(r"^vpn/download/windows/?$", "products.vpn.windows-download"),
redirect(r"^vpn/download/mac/?$", "products.vpn.mac-download"),
redirect(r"^products/mozsocial/invite/?$", "products.landing"),
redirect(r"^products/vpn/mobile/app/?$", mobile_app, cache_timeout=0, query=False),
)
6 changes: 6 additions & 0 deletions bedrock/settings/appstores.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,9 @@

# Link to Firefox Beta on the Microsoft Windows Store with custom protocol handler.
MICROSOFT_WINDOWS_STORE_FIREFOX_BETA_DIRECT_LINK = "ms-windows-store://pdp/?productid=9nzw26frndln"

# Link to Mozilla VPN on the Google Play Store.
GOOGLE_PLAY_VPN_LINK = "https://play.google.com/store/apps/details?id=org.mozilla.firefox.vpn"

# Link to Mozilla VPN on the Apple App Store.
APPLE_APPSTORE_VPN_LINK = "https://apps.apple.com/{country}/app/apple-store/id1489407738"
2 changes: 2 additions & 0 deletions bedrock/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,7 @@ def _is_bedrock_custom_app(app_name):
APPLE_APPSTORE_FOCUS_LINK,
APPLE_APPSTORE_KLAR_LINK,
APPLE_APPSTORE_POCKET_LINK,
APPLE_APPSTORE_VPN_LINK,
GOOGLE_PLAY_FIREFOX_BETA_LINK,
GOOGLE_PLAY_FIREFOX_LINK,
GOOGLE_PLAY_FIREFOX_LINK_UTMS,
Expand All @@ -1007,6 +1008,7 @@ def _is_bedrock_custom_app(app_name):
GOOGLE_PLAY_FOCUS_LINK,
GOOGLE_PLAY_KLAR_LINK,
GOOGLE_PLAY_POCKET_LINK,
GOOGLE_PLAY_VPN_LINK,
MICROSOFT_WINDOWS_STORE_FIREFOX_BETA_DIRECT_LINK,
MICROSOFT_WINDOWS_STORE_FIREFOX_BETA_WEB_LINK,
MICROSOFT_WINDOWS_STORE_FIREFOX_DIRECT_LINK,
Expand Down
25 changes: 25 additions & 0 deletions tests/redirects/map_globalconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1302,5 +1302,30 @@
# issue 15075
url_test("/newsletter/knowledge-is-power{,/,/confirm,/confirm/token}", "/newsletter/firefox/"),
url_test("/products/mozsocial/invite/", "/products/"),
# Issue 15262
url_test(
"/products/vpn/mobile/app/?product=vpn",
"https://play.google.com/store/apps/details?id=org.mozilla.firefox.vpn",
req_headers=UA_ANDROID,
resp_headers={"Cache-Control": "max-age=0"},
),
url_test(
"/products/vpn/mobile/app/?product=vpn",
"https://apps.apple.com/app/apple-store/id1489407738",
req_headers=UA_IOS,
resp_headers={"Cache-Control": "max-age=0"},
),
url_test(
"/products/vpn/mobile/app/?product=vpn&campaign=vpn-landing-page",
"https://play.google.com/store/apps/details?id=org.mozilla.firefox.vpn&referrer=utm_source%3Dwww.mozilla.org%26utm_medium%3Dreferral%26utm_campaign%3Dvpn-landing-page",
req_headers=UA_ANDROID,
resp_headers={"Cache-Control": "max-age=0"},
),
url_test(
"/products/vpn/mobile/app/?product=vpn&campaign=vpn-landing-page",
"https://apps.apple.com/app/apple-store/id1489407738?pt=373246&ct=vpn-landing-page&mt=8",
req_headers=UA_IOS,
resp_headers={"Cache-Control": "max-age=0"},
),
)
)

0 comments on commit 029f88e

Please sign in to comment.