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

mozilla / fx-private-relay / 8bd4307c-ef7a-4052-8295-6e0c6dfe01fa

11 Apr 2025 09:00PM CUT coverage: 85.214% (+0.01%) from 85.201%
8bd4307c-ef7a-4052-8295-6e0c6dfe01fa

Pull #5500

circleci

groovecoder
MPP-4012 - feat(glean): log API access as Glean server event

Introduce a new `api.accessed` Glean event to capture accesses to Relay API
endpoints. This includes the HTTP method and endpoint path, and logs events
for all `/api/` prefixed routes via a new middleware component.

- Added `record_api_accessed()` to `EventsServerEventLogger`
- Extended `RelayGleanLogger` with `log_api_accessed()` for easier integration
- Registered `GleanApiAccessMiddleware` to log access for all API routes
- Added corresponding unit test for API access logging
- Updated `relay-server-metrics.yaml` to define the `api.accessed` metric
- Updated notification email for several existing metrics to use relay-team@mozilla.com
Pull Request #5500: WIP: MPP-4012 - feat(glean): log API access as Glean server event

2460 of 3595 branches covered (68.43%)

Branch coverage included in aggregate %.

59 of 60 new or added lines in 7 files covered. (98.33%)

1 existing line in 1 file now uncovered.

17250 of 19535 relevant lines covered (88.3%)

9.83 hits per line

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

0.0
/frontend/src/components/waitlist/CountryPicker.tsx
1
import { SelectHTMLAttributes, useEffect, useState } from "react";
×
2
import { getLocale } from "../../functions/getLocale";
×
3
import { useL10n } from "../../hooks/l10n";
×
4

5
type LocaleDisplayNames = Record<string, string>;
6
type Territories = {
7
  main: Record<
8
    string,
9
    {
10
      localeDisplayNames: {
11
        territories: LocaleDisplayNames;
12
      };
13
    }
14
  >;
15
};
16
export type Props = SelectHTMLAttributes<HTMLSelectElement>;
17
export const CountryPicker = (props: Props) => {
×
18
  const l10n = useL10n();
×
19
  const currentLocale = getLocale(l10n);
×
20
  const [localeDisplayNames, setLocaleDisplayNames] =
21
    useState<LocaleDisplayNames>();
×
22

23
  useEffect(() => {
×
24
    importTerritories(currentLocale).then((localeDisplayNames) => {
×
25
      setLocaleDisplayNames(localeDisplayNames);
×
26
    });
27
  }, [currentLocale]);
28

29
  const options = Object.entries(localeDisplayNames ?? {})
×
30
    // cldr-localenames-modern also includes names of continents,
31
    // whose territory codes consist of numbers.
32
    // (See e.g. node_modules/cldr-localenames-modern/main/en/territories.json.)
33
    // Since we're only interested in countries, filter those out:
34
    .filter(
35
      ([code]) =>
36
        !["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"].some((nr) =>
×
37
          code.includes(nr),
×
38
        ),
39
    )
40
    .sort(([_codeA, nameA], [_codeB, nameB]) => nameA.localeCompare(nameB))
×
41
    .map(([code, name]) => (
42
      <option key={code} value={code}>
×
43
        {name}
44
      </option>
45
    ));
46

47
  return <select {...props}>{options}</select>;
48
};
49

50
async function importTerritories(locale: string): Promise<LocaleDisplayNames> {
51
  try {
×
52
    const territories: Territories = await import(
×
53
      `cldr-localenames-modern/main/${locale}/territories.json`
×
54
    );
55
    return territories.main[locale].localeDisplayNames.territories;
×
56
  } catch (_e) {
57
    try {
×
58
      // cldr-localenames-modern doesn't include suffixed locale codes for
59
      // locales in their main territory (i.e. it only has `es`, not `es-ES`, or
60
      // `nl` but not `nl-NL`, or `sv` but not `sv-SE`), so try loading a
61
      // truncated version if the full version was not found:
62
      const truncatedLocale = locale.split("-")[0];
×
63
      const territories: Territories = await import(
×
64
        `cldr-localenames-modern/main/${truncatedLocale}/territories.json`
×
65
      );
66
      return territories.main[truncatedLocale].localeDisplayNames.territories;
×
67
    } catch (_e) {
68
      const territoriesEn = await import(
×
69
        "cldr-localenames-modern/main/en/territories.json"
70
      );
71
      return territoriesEn.main.en.localeDisplayNames.territories;
×
72
    }
73
  }
74
}
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