Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

Remove countries-list dependency and update country name retrieval logic in utils.ts

Bill Yang4b52d7349038
diff --git a/client/package-lock.json b/client/package-lock.json
index 4b3d2eb30..e2cb968f6 100644
--- a/client/package-lock.json
+++ b/client/package-lock.json
@@ -45,7 +45,6 @@
"class-variance-authority": "0.7.1",
"clsx": "2.1.1",
"cmdk": "^1.1.1",
- "countries-list": "3.1.1",
"country-flag-icons": "1.5.19",
"d3": "7.9.0",
"date-fns": "^4.1.0",
@@ -7218,12 +7217,6 @@
"node": ">=10"
}
},
- "node_modules/countries-list": {
- "version": "3.1.1",
- "resolved": "https://registry.npmjs.org/countries-list/-/countries-list-3.1.1.tgz",
- "integrity": "sha512-nPklKJ5qtmY5MdBKw1NiBAoyx5Sa7p2yPpljZyQ7gyCN1m+eMFs9I6CT37Mxt8zvR5L3VzD3DJBE4WQzX3WF4A==",
- "license": "MIT"
- },
"node_modules/country-flag-icons": {
"version": "1.5.19",
"resolved": "https://registry.npmjs.org/country-flag-icons/-/country-flag-icons-1.5.19.tgz",
diff --git a/client/package.json b/client/package.json
index 4fa45ba42..b64b31207 100644
--- a/client/package.json
+++ b/client/package.json
@@ -49,7 +49,6 @@
"class-variance-authority": "0.7.1",
"clsx": "2.1.1",
"cmdk": "^1.1.1",
- "countries-list": "3.1.1",
"country-flag-icons": "1.5.19",
"d3": "7.9.0",
"date-fns": "^4.1.0",
diff --git a/client/src/lib/utils.ts b/client/src/lib/utils.ts
index ca8850fa0..d570e37e3 100644
--- a/client/src/lib/utils.ts
+++ b/client/src/lib/utils.ts
@@ -1,5 +1,4 @@
import { clsx, type ClassValue } from "clsx";
-import { countries } from "countries-list";
import { Duration } from "luxon";
import { twMerge } from "tailwind-merge";
import { userLocale } from "./dateTimeUtils";
@@ -30,7 +29,11 @@ export function formatSecondsAsMinutesAndSeconds(value: number) {
export const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
export const getCountryName = (countryCode: string) => {
- return countries[countryCode as keyof typeof countries]?.name;
+ try {
+ return regionNamesInEnglish.of(countryCode.toUpperCase()) || countryCode;
+ } catch (error) {
+ return countryCode;
+ }
};
export function truncateString(str: string, n = 50) {