Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
fix: region code formatter (#1425)
Maximilian Kaske6c74a62c0ff5
diff --git a/apps/dashboard/src/components/controls-search/command-region.tsx b/apps/dashboard/src/components/controls-search/command-region.tsxindex a0cafcb72..ff327dec3 100644--- a/apps/dashboard/src/components/controls-search/command-region.tsx+++ b/apps/dashboard/src/components/controls-search/command-region.tsx@@ -25,7 +25,7 @@ import {import { REGIONS } from "@/data/metrics.client";import { useTRPC } from "@/lib/trpc/client";import { cn } from "@/lib/utils";-import { groupByContinent } from "@openstatus/utils";+import { formatRegionCode, groupByContinent } from "@openstatus/utils";import { useQuery } from "@tanstack/react-query";import { Check, Lock } from "lucide-react";import { parseAsArrayOf, parseAsStringLiteral, useQueryState } from "nuqs";@@ -129,7 +129,7 @@ export function CommandRegion({className="size-3"/><span className="font-mono">- {region.code.replace(/(koyeb_|railway_|fly_)/g, "")}+ {formatRegionCode(region.code)}</span><span className="truncate text-muted-foreground text-xs">{region.location}diff --git a/apps/dashboard/src/components/data-table/response-logs/regions/columns.tsx b/apps/dashboard/src/components/data-table/response-logs/regions/columns.tsxindex f0d1af9e7..e293011ea 100644--- a/apps/dashboard/src/components/data-table/response-logs/regions/columns.tsx+++ b/apps/dashboard/src/components/data-table/response-logs/regions/columns.tsx@@ -12,7 +12,7 @@ import {} from "@/components/ui/tooltip";import type { RegionMetric } from "@/data/region-metrics";import { getActions } from "@/data/region-metrics.client";-import { regionDict } from "@openstatus/utils";+import { formatRegionCode, regionDict } from "@openstatus/utils";import type { ColumnDef } from "@tanstack/react-table";// import { toast } from "sonner";import { useRouter } from "next/navigation";@@ -33,8 +33,7 @@ export const columns: ColumnDef<RegionMetric>[] = [<TooltipProvider><Tooltip><TooltipTrigger className="flex h-[50px] items-center gap-1">- {region.flag}{" "}- {region.code.replace(/(koyeb_|railway_|fly_)/g, "")}+ {region.flag} {formatRegionCode(region.code)}</TooltipTrigger><TooltipContent side="left">{region.location} ({region.provider})diff --git a/apps/dashboard/src/components/forms/monitor/form-scheduling-regions.tsx b/apps/dashboard/src/components/forms/monitor/form-scheduling-regions.tsxindex 78ab05a9e..ad0578616 100644--- a/apps/dashboard/src/components/forms/monitor/form-scheduling-regions.tsx+++ b/apps/dashboard/src/components/forms/monitor/form-scheduling-regions.tsx@@ -37,7 +37,7 @@ import { IconCloudProviderTooltip } from "@/components/common/icon-cloud-provideimport { Note, NoteButton } from "@/components/common/note";import { UpgradeDialog } from "@/components/dialogs/upgrade";import { useTRPC } from "@/lib/trpc/client";-import { groupByContinent } from "@openstatus/utils";+import { formatRegionCode, groupByContinent } from "@openstatus/utils";import { useQuery } from "@tanstack/react-query";import { isTRPCClientError } from "@trpc/client";import { CircleX, Info } from "lucide-react";@@ -298,10 +298,7 @@ export function FormSchedulingRegions({className="w-full truncate font-mono font-normal text-sm"><span className="text-nowrap">- {region.code.replace(- /(koyeb_|railway_|fly_)/g,- "",- )}{" "}+ {formatRegionCode(region.code)}{" "}{region.flag}</span><span className="truncate font-normal text-muted-foreground text-xs leading-[inherit]">diff --git a/apps/web/src/app/(pages)/(content)/play/checker/api/mock.ts b/apps/web/src/app/(pages)/(content)/play/checker/api/mock.tsindex 7ab430f6b..13859d408 100644--- a/apps/web/src/app/(pages)/(content)/play/checker/api/mock.ts+++ b/apps/web/src/app/(pages)/(content)/play/checker/api/mock.ts@@ -1619,5 +1619,161 @@ export const data = {},region: "koyeb_was",},+ {+ type: "http",+ state: "success",+ status: 200,+ latency: 1100,+ headers: {+ Age: "0",+ "Cache-Control":+ "private, no-cache, no-store, max-age=0, must-revalidate",+ "Content-Type": "text/html; charset=utf-8",+ Date: "Fri, 23 Aug 2024 12:17:58 GMT",+ Link: '</_next/static/media/162bf645eb375add-s.p.ttf>; rel=preload; as="font"; crossorigin=""; type="font/ttf", </_next/static/media/a34f9d1faa5f3315-s.p.woff2>; rel=preload; as="font"; crossorigin=""; type="font/woff2"',+ Server: "Railway",+ "Set-Cookie":+ "__Host-authjs.csrf-token=e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7b8c%7C0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a; Path=/; HttpOnly; Secure; SameSite=Lax",+ "Strict-Transport-Security": "max-age=63072000",+ Vary: "RSC, Next-Router-State-Tree, Next-Router-Prefetch",+ "X-Matched-Path": "/",+ "X-Powered-By": "Next.js",+ "X-Railway-Cache": "MISS",+ "X-Railway-Execution-Region": "us-west2",+ "X-Railway-Id":+ "railway-us-west2::us-west2::klm345-1724415477600-nop67890",+ },+ timestamp: 1724415477600,+ timing: {+ dnsStart: 1724415477700,+ dnsDone: 1724415477702,+ connectStart: 1724415477702,+ connectDone: 1724415477703,+ tlsHandshakeStart: 1724415477703,+ tlsHandshakeDone: 1724415477720,+ firstByteStart: 1724415477720,+ firstByteDone: 1724415478720,+ transferStart: 1724415478720,+ transferDone: 1724415478720,+ },+ region: "railway_us-west2",+ },+ {+ type: "http",+ state: "success",+ status: 200,+ latency: 1201,+ headers: {+ Age: "0",+ "Cache-Control":+ "private, no-cache, no-store, max-age=0, must-revalidate",+ "Content-Type": "text/html; charset=utf-8",+ Date: "Fri, 23 Aug 2024 12:17:58 GMT",+ Link: '</_next/static/media/162bf645eb375add-s.p.ttf>; rel=preload; as="font"; crossorigin=""; type="font/ttf", </_next/static/media/a34f9d1faa5f3315-s.p.woff2>; rel=preload; as="font"; crossorigin=""; type="font/woff2"',+ Server: "Railway",+ "Set-Cookie":+ "__Host-authjs.csrf-token=e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7b8c%7C0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a; Path=/; HttpOnly; Secure; SameSite=Lax",+ "Strict-Transport-Security": "max-age=63072000",+ Vary: "RSC, Next-Router-State-Tree, Next-Router-Prefetch",+ "X-Matched-Path": "/",+ "X-Powered-By": "Next.js",+ "X-Railway-Cache": "MISS",+ "X-Railway-Execution-Region": "us-west2",+ "X-Railway-Id":+ "railway-us-west2::us-west2::klm345-1724415477600-nop67890",+ },+ timestamp: 1724415477700,+ timing: {+ dnsStart: 1724415477800,+ dnsDone: 1724415477802,+ connectStart: 1724415477802,+ connectDone: 1724415477803,+ tlsHandshakeStart: 1724415477803,+ tlsHandshakeDone: 1724415477820,+ firstByteStart: 1724415477820,+ firstByteDone: 1724415478820,+ transferStart: 1724415478820,+ transferDone: 1724415478820,+ },+ region: "railway_us-east4-eqdc4a",+ },+ {+ type: "http",+ state: "success",+ status: 200,+ latency: 612,+ headers: {+ Age: "0",+ "Cache-Control":+ "private, no-cache, no-store, max-age=0, must-revalidate",+ "Content-Type": "text/html; charset=utf-8",+ Date: "Fri, 23 Aug 2024 12:17:58 GMT",+ Link: '</_next/static/media/162bf645eb375add-s.p.ttf>; rel=preload; as="font"; crossorigin=""; type="font/ttf", </_next/static/media/a34f9d1faa5f3315-s.p.woff2>; rel=preload; as="font"; crossorigin=""; type="font/woff2"',+ Server: "Railway",+ "Set-Cookie":+ "__Host-authjs.csrf-token=e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7b8c%7C0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a; Path=/; HttpOnly; Secure; SameSite=Lax",+ "Strict-Transport-Security": "max-age=63072000",+ Vary: "RSC, Next-Router-State-Tree, Next-Router-Prefetch",+ "X-Matched-Path": "/",+ "X-Powered-By": "Next.js",+ "X-Railway-Cache": "MISS",+ "X-Railway-Execution-Region": "us-west2",+ "X-Railway-Id":+ "railway-us-west2::us-west2::klm345-1724415477600-nop67890",+ },+ timestamp: 1724415477800,+ timing: {+ dnsStart: 1724415477900,+ dnsDone: 1724415477902,+ connectStart: 1724415477902,+ connectDone: 1724415477903,+ tlsHandshakeStart: 1724415477903,+ tlsHandshakeDone: 1724415477920,+ firstByteStart: 1724415477920,+ firstByteDone: 1724415478920,+ transferStart: 1724415478920,+ transferDone: 1724415478920,+ },+ region: "railway_europe-west4-drams3a",+ },+ {+ type: "http",+ state: "success",+ status: 200,+ latency: 705,+ headers: {+ Age: "0",+ "Cache-Control":+ "private, no-cache, no-store, max-age=0, must-revalidate",+ "Content-Type": "text/html; charset=utf-8",+ Date: "Fri, 23 Aug 2024 12:17:58 GMT",+ Link: '</_next/static/media/162bf645eb375add-s.p.ttf>; rel=preload; as="font"; crossorigin=""; type="font/ttf", </_next/static/media/a34f9d1faa5f3315-s.p.woff2>; rel=preload; as="font"; crossorigin=""; type="font/woff2"',+ Server: "Railway",+ "Set-Cookie":+ "__Host-authjs.csrf-token=e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7b8c%7C0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a; Path=/; HttpOnly; Secure; SameSite=Lax",+ "Strict-Transport-Security": "max-age=63072000",+ Vary: "RSC, Next-Router-State-Tree, Next-Router-Prefetch",+ "X-Matched-Path": "/",+ "X-Powered-By": "Next.js",+ "X-Railway-Cache": "MISS",+ "X-Railway-Execution-Region": "us-west2",+ "X-Railway-Id":+ "railway-us-west2::us-west2::klm345-1724415477600-nop67890",+ },+ timestamp: 1724415477900,+ timing: {+ dnsStart: 1724415478000,+ dnsDone: 1724415478002,+ connectStart: 1724415478002,+ connectDone: 1724415478003,+ tlsHandshakeStart: 1724415478003,+ tlsHandshakeDone: 1724415478020,+ firstByteStart: 1724415478020,+ firstByteDone: 1724415479020,+ transferStart: 1724415479020,+ transferDone: 1724415479020,+ },+ region: "railway_asia-southeast1-eqsg3a",+ },],};diff --git a/apps/web/src/components/forms/monitor/select-region.tsx b/apps/web/src/components/forms/monitor/select-region.tsxindex 04df1fb25..197d5a8d1 100644--- a/apps/web/src/components/forms/monitor/select-region.tsx+++ b/apps/web/src/components/forms/monitor/select-region.tsx@@ -17,7 +17,12 @@ import {PopoverContent,PopoverTrigger,} from "@openstatus/ui/src/components/popover";-import { type Continent, type RegionInfo, regionDict } from "@openstatus/utils";+import {+ type Continent,+ type RegionInfo,+ formatRegionCode,+ regionDict,+} from "@openstatus/utils";import { cn } from "@/lib/utils";import {@@ -118,7 +123,7 @@ export function SelectRegion({</div><div className="flex w-full justify-between"><span>- {code.replace(/(koyeb_|railway_|fly_)/g, "")}{" "}+ {formatRegionCode(code)}{" "}<span className="truncate text-muted-foreground">{location}</span>diff --git a/apps/web/src/components/monitor-dashboard/region-preset.tsx b/apps/web/src/components/monitor-dashboard/region-preset.tsxindex 1f45da2ee..5bab8f011 100644--- a/apps/web/src/components/monitor-dashboard/region-preset.tsx+++ b/apps/web/src/components/monitor-dashboard/region-preset.tsx@@ -17,7 +17,12 @@ import {PopoverContent,PopoverTrigger,} from "@openstatus/ui/src/components/popover";-import { type Continent, type RegionInfo, regionDict } from "@openstatus/utils";+import {+ type Continent,+ type RegionInfo,+ formatRegionCode,+ regionDict,+} from "@openstatus/utils";import { IconCloudProvider } from "@/components/icon-cloud-provider";import { cn } from "@/lib/utils";@@ -142,7 +147,7 @@ export function RegionsPreset({<IconCloudProvider provider={region.provider} /></span><span>- {code.replace(/(koyeb_|railway_|fly_)/g, "")}{" "}+ {formatRegionCode(code)}{" "}<span className="truncate text-muted-foreground">{location}</span>diff --git a/apps/web/src/components/ping-response-analysis/columns.tsx b/apps/web/src/components/ping-response-analysis/columns.tsxindex 688df8d8e..17d9ab3f8 100644--- a/apps/web/src/components/ping-response-analysis/columns.tsx+++ b/apps/web/src/components/ping-response-analysis/columns.tsx@@ -12,7 +12,7 @@ import {HoverCardPortal,HoverCardTrigger,} from "@openstatus/ui";-import { regionDict } from "@openstatus/utils";+import { formatRegionCode, regionDict } from "@openstatus/utils";export const columns: ColumnDef<RegionChecker>[] = [{@@ -21,13 +21,12 @@ export const columns: ColumnDef<RegionChecker>[] = [header: "Region",cell: ({ row }) => {const region = regionDict[row.original.region];+ const code = formatRegionCode(row.original.region);return (<div className="flex items-center gap-1.5"><IconCloudProviderTooltip provider={region.provider} />- <div>- <span className="font-mono">- {row.original.region.replace(/(koyeb_|railway_|fly_)/g, "")}- </span>{" "}+ <div className="truncate">+ <span className="font-mono">{code}</span>{" "}<span className="text-muted-foreground">{regionFormatter(row.original.region, "long")}</span>diff --git a/apps/web/src/components/ping-response-analysis/multi-region-chart.tsx b/apps/web/src/components/ping-response-analysis/multi-region-chart.tsxindex fea8d17db..79a483da7 100644--- a/apps/web/src/components/ping-response-analysis/multi-region-chart.tsx+++ b/apps/web/src/components/ping-response-analysis/multi-region-chart.tsx@@ -14,7 +14,7 @@ import {ChartTooltip,ChartTooltipContent,} from "@openstatus/ui/src/components/chart";-import { regionDict } from "@openstatus/utils";+import { formatRegionCode, regionDict } from "@openstatus/utils";const chartConfig = {dns: {@@ -79,7 +79,7 @@ export function MultiRegionChart({ regions }: { regions: RegionChecker[] }) {transform="rotate(-35)"className="font-mono">- {payload.value.replace(/(koyeb_|railway_|fly_)/g, "")}+ {formatRegionCode(payload.value)}</text></g>);diff --git a/apps/web/src/components/ping-response-analysis/multi-region-tabs.tsx b/apps/web/src/components/ping-response-analysis/multi-region-tabs.tsxindex 7e6769bdd..fe3a19b65 100644--- a/apps/web/src/components/ping-response-analysis/multi-region-tabs.tsx+++ b/apps/web/src/components/ping-response-analysis/multi-region-tabs.tsx@@ -46,6 +46,7 @@ export function MultiRegionTabs({columns={columns}getRowCanExpand={() => true}renderSubComponent={renderSubComponent}+ defaultColumnVisibility={{ transfer: false }}/></TabsContent></Tabs>diff --git a/packages/utils/index.ts b/packages/utils/index.tsindex c42794717..8079d227a 100644--- a/packages/utils/index.ts+++ b/packages/utils/index.ts@@ -1,133 +1,9 @@-/**- * AWS data center informations from 18 regions, supported by vercel.- * https://vercel.com/docs/concepts/edge-network/regions#region-list- */-import type { Region } from "@openstatus/db/src/schema/constants";import { base } from "@openstatus/assertions";import { monitorMethods, monitorStatus } from "@openstatus/db/src/schema";import { z } from "zod";-// export const vercelRegionsDict = {-// /**-// * A random location will be chosen-// */-// auto: {-// code: "auto",-// name: "random",-// location: "Random",-// flag: "๐",-// },-// arn1: {-// code: "arn1",-// name: "eu-north-1",-// location: "Stockholm, Sweden",-// flag: "๐ธ๐ช",-// },-// bom1: {-// code: "bom1",-// name: "ap-south-1",-// location: "Mumbai, India",-// flag: "๐ฎ๐ณ",-// },-// cdg1: {-// code: "cdg1",-// name: "eu-west-3",-// location: "Paris, France",-// flag: "๐ซ๐ท",-// },-// cle1: {-// code: "cle1",-// name: "us-east-2",-// location: "Cleveland, USA",-// flag: "๐บ๐ธ",-// },-// cpt1: {-// code: "cpt1",-// name: "af-south-1",-// location: "Cape Town, South Africa",-// flag: "๐ฟ๐ฆ",-// },-// dub1: {-// code: "dub1",-// name: "eu-west-1",-// location: "Dublin, Ireland",-// flag: "๐ฎ๐ช",-// },-// fra1: {-// code: "fra1",-// name: "eu-central-1",-// location: "Frankfurt, Germany",-// flag: "๐ฉ๐ช",-// },-// gru1: {-// code: "gru1",-// name: "sa-east-1",-// location: "Sรฃo Paulo, Brazil",-// flag: "๐ง๐ท",-// },-// hkg1: {-// code: "hkg1",-// name: "ap-east-1",-// location: "Hong Kong",-// flag: "๐ญ๐ฐ",-// },-// hnd1: {-// code: "hnd1",-// name: "ap-northeast-1",-// location: "Tokyo, Japan",-// flag: "๐ฏ๐ต",-// },-// iad1: {-// code: "iad1",-// name: "us-east-1",-// location: "Washington, D.C., USA",-// flag: "๐บ๐ธ",-// },-// icn1: {-// code: "icn1",-// name: "ap-northeast-2",-// location: "Seoul, South Korea",-// flag: "๐ฐ๐ท",-// },-// kix1: {-// code: "kix1",-// name: "ap-northeast-3",-// location: "Osaka, Japan",-// flag: "๐ฏ๐ต",-// },-// lhr1: {-// code: "lhr1",-// name: "eu-west-2",-// location: "London, United Kingdom",-// flag: "๐ฌ๐ง",-// },-// pdx1: {-// code: "pdx1",-// name: "us-west-2",-// location: "Portland, USA",-// flag: "๐บ๐ธ",-// },-// sfo1: {-// code: "sfo1",-// name: "us-west-1",-// location: "San Francisco, USA",-// flag: "๐บ๐ธ",-// },-// sin1: {-// code: "sin1",-// name: "ap-southeast-1",-// location: "Singapore",-// flag: "๐ธ๐ฌ",-// },-// syd1: {-// code: "syd1",-// name: "ap-southeast-2",-// location: "Sydney, Australia",-// flag: "๐ฆ๐บ",-// },-// } as const;export type Continent =| "Europe"@@ -474,7 +350,16 @@ export const regionDict: Record<Region, RegionInfo> = {},} as const;-// const r = t.flatMap((u) => u[1].continent);+export function formatRegionCode(region: RegionInfo | Region) {+ const r = typeof region === "string" ? regionDict[region] : region;+ const suffix = r.code.replace(/(koyeb_|railway_|fly_)/g, "");++ if (r.provider === "railway") {+ return suffix.replace(/(-eqdc4a|-eqsg3a|-drams3a)/g, "");+ }++ return suffix;+}export const groupByContinent = Object.entries(regionDict).reduce<Record<Continent, RegionInfo[]>