Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
feat: add flags to chart and regions dictionary (#477)
Maximilian Kaske3173cce9dbe7
diff --git a/apps/web/src/app/app/(dashboard)/[workspaceSlug]/monitors/[id]/data/_components/chart-wrapper.tsx b/apps/web/src/app/app/(dashboard)/[workspaceSlug]/monitors/[id]/data/_components/chart-wrapper.tsxindex f194a70ad..84b9689a4 100644--- a/apps/web/src/app/app/(dashboard)/[workspaceSlug]/monitors/[id]/data/_components/chart-wrapper.tsx+++ b/apps/web/src/app/app/(dashboard)/[workspaceSlug]/monitors/[id]/data/_components/chart-wrapper.tsx@@ -1,6 +1,7 @@"use client";import type { Ping, Region } from "@openstatus/tinybird";+import { regionsDict } from "@openstatus/utils";import type { Period } from "../utils";import { Chart } from "./chart";@@ -23,18 +24,20 @@ export function ChartWrapper({*/function groupDataByTimestamp(data: Ping[], period: Period) {let currentTimestamp = 0;- const regions: Partial<Record<Region, null>> = {};+ const regions: Record<string, null> = {};const _data = data.reduce((acc, curr) => {const { cronTimestamp, latency, region } = curr;- regions[region] = null; // to get the region keys+ const { flag, code } = regionsDict[region];+ const fullNameRegion = `${flag} ${code}`;+ regions[fullNameRegion] = null; // to get the region keysif (cronTimestamp === currentTimestamp) {// overwrite last object in accconst last = acc.pop();if (last) {acc.push({...last,- [region]: latency,+ [fullNameRegion]: latency,});}} else if (cronTimestamp) {@@ -42,14 +45,15 @@ function groupDataByTimestamp(data: Ping[], period: Period) {// create new object in accacc.push({timestamp: renderTimestamp(cronTimestamp, period),- [region]: latency,+ [fullNameRegion]: latency,});}return acc;},[] as (Partial<Record<Region, string>> & { timestamp: string })[],);- return { regions: Object.keys(regions) as Region[], data: _data.reverse() };++ return { regions: Object.keys(regions), data: _data.reverse() };}/**diff --git a/apps/web/src/app/app/(dashboard)/[workspaceSlug]/monitors/[id]/data/_components/chart.tsx b/apps/web/src/app/app/(dashboard)/[workspaceSlug]/monitors/[id]/data/_components/chart.tsxindex f7e3a0182..c33d71918 100644--- a/apps/web/src/app/app/(dashboard)/[workspaceSlug]/monitors/[id]/data/_components/chart.tsx+++ b/apps/web/src/app/app/(dashboard)/[workspaceSlug]/monitors/[id]/data/_components/chart.tsx@@ -2,14 +2,12 @@import { Card, LineChart, Title } from "@tremor/react";-import type { Region } from "@openstatus/tinybird";-const dataFormatter = (number: number) =>`${Intl.NumberFormat("us").format(number).toString()}ms`;interface ChartProps {- data: (Partial<Record<Region, string>> & { timestamp: string })[];- regions: Region[];+ data: { timestamp: string; [key: string]: string }[];+ regions: string[];}export function Chart({ data, regions }: ChartProps) {diff --git a/packages/utils/index.ts b/packages/utils/index.tsindex 5c12d4694..e52c112fd 100644--- a/packages/utils/index.ts+++ b/packages/utils/index.ts@@ -10,130 +10,154 @@ export const vercelRegionsDict = {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 const flyRegionsDict = {ams: {code: "ams",- name: "ap-southeast-2",+ name: "",location: "Amsterdam, Netherlands",+ flag: "๐ณ๐ฑ",},iad: {code: "iad",name: "us-east-1",location: "Ashburn, Virginia, USA",+ flag: "๐บ๐ธ",},jnb: {code: "jnb",name: "",location: "Johannesburg, South Africa",+ flag: "๐ฟ๐ฆ",},hkg: {code: "hkg",name: "",location: "Hong Kong, Hong Kong",+ flag: "๐ญ๐ฐ",},gru: {code: "gru",name: "",location: "Sao Paulo, Brazil",+ flag: "๐ง๐ท",},-syd: {code: "syd",- name: "ap-southeast-2",+ name: "",location: "Sydney, Australia",+ flag: "๐ฆ๐บ",},} as const;