• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mozilla / fx-private-relay / 74d01625-9661-4180-904e-0bd85eb6c11f

29 May 2025 12:03PM CUT coverage: 85.583% (+0.2%) from 85.353%
74d01625-9661-4180-904e-0bd85eb6c11f

push

circleci

web-flow
Merge pull request #5573 from mozilla/MPP-4155-new-megabundle-banner

MPP-4155 New Megabundle Banner Landing Page

2490 of 3629 branches covered (68.61%)

Branch coverage included in aggregate %.

60 of 62 new or added lines in 8 files covered. (96.77%)

19 existing lines in 6 files now uncovered.

17598 of 19843 relevant lines covered (88.69%)

9.97 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

50.0
/frontend/src/hooks/api/runtimeData.ts
1
import { SWRResponse } from "swr";
2
import { useApiV1 } from "./api";
10✔
3

4
type CountryCode = string;
5
type LanguageCode = string;
6
export type FlagNames =
7
  | "custom_domain_management_redesign"
8
  | "manage_flags"
9
  | "interview_recruitment"
10
  | "tracker_removal"
11
  | "phone_launch_survey"
12
  | "multi_replies"
13
  | "free_user_onboarding"
14
  | "firefox_integration"
15
  | "mailing_list_announcement"
16
  | "premium_promo_banners"
17
  | "mask_redesign"
18
  | "holiday_promo_2023"
19
  | "four_mask_limit_upsell";
20

21
type WaffleFlag = [FlagNames, boolean];
22

23
export type PlanData = {
24
  monthly: { id?: string; price: number; currency: string; url?: string };
25
  yearly: { id?: string; price: number; currency: string; url?: string };
26
};
27

28
export type ProductData<P extends Partial<PlanData> = PlanData> = {
29
  country_code: CountryCode;
30
  countries: CountryCode[];
31
  available_in_country: boolean;
32
  plan_country_lang_mapping: Record<CountryCode, Record<LanguageCode, P>>;
33
};
34

35
export type RuntimeData = {
36
  FXA_ORIGIN: string;
37
  GOOGLE_ANALYTICS_ID: `UA-${number}-${number}`;
38
  GA4_MEASUREMENT_ID: `G-${string}`;
39
  PERIODICAL_PREMIUM_PRODUCT_ID: `prod_${string}`;
40
  PHONE_PRODUCT_ID: `prod_${string}`;
41
  BUNDLE_PRODUCT_ID: `prod_${string}`;
42
  MEGABUNDLE_PRODUCT_ID: `prod_${string}`;
43
  PERIODICAL_PREMIUM_PLANS: ProductData<PlanData>;
44
  PHONE_PLANS: ProductData<PlanData>;
45
  BUNDLE_PLANS: ProductData<Pick<PlanData, "yearly">>;
46
  MEGABUNDLE_PLANS: ProductData<Pick<PlanData, "yearly">>;
47
  BASKET_ORIGIN: string;
48
  WAFFLE_FLAGS: WaffleFlag[];
49
  MAX_MINUTES_TO_VERIFY_REAL_PHONE: number;
50
};
51

52
/**
53
 * Fetch data from the back-end that wasn't known at build time (e.g. the user's country, or environment variables) using [SWR](https://swr.vercel.app).
54
 */
55
export function useRuntimeData() {
9✔
UNCOV
56
  const runtimeData: SWRResponse<RuntimeData, unknown> = useApiV1(
×
57
    "/runtime_data",
58
    {
59
      // Runtime data rarely changes, so we shouldn't need to refetch it
60
      // multiple times during the user's session
61
      // (their main use is allowing for different values on different
62
      // environments, even though those values are static over time):
63
      revalidateIfStale: false,
64
      revalidateOnFocus: false,
65
      revalidateOnReconnect: false,
66
    },
67
  );
UNCOV
68
  return runtimeData;
×
69
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc