Openstatus www.openstatus.dev
at 4c0f4c00a38753a5d0dfd7e7b7b7706dec6f1503 99 lines 2.4 kB view raw
1import { formatMilliseconds } from "@/lib/formatter"; 2import type { PrivateLocation } from "@openstatus/db/src/schema"; 3import { getRegionInfo } from "@openstatus/regions"; 4import { 5 CircleAlert, 6 CircleCheck, 7 CircleMinus, 8 Send, 9 Siren, 10} from "lucide-react"; 11 12export const config = { 13 "incident.created": { 14 icon: Siren, 15 color: "text-destructive", 16 title: "Incident Created", 17 }, 18 "incident.resolved": { 19 icon: CircleCheck, 20 color: "text-success", 21 title: "Incident Resolved", 22 }, 23 "monitor.failed": { 24 icon: CircleMinus, 25 color: "text-destructive", 26 title: "Monitor Failed", 27 }, 28 "notification.sent": { 29 icon: Send, 30 color: "text-info", 31 title: "Notification Sent", 32 }, 33 "monitor.recovered": { 34 icon: CircleCheck, 35 color: "text-success", 36 title: "Monitor Recovered", 37 }, 38 "monitor.degraded": { 39 icon: CircleAlert, 40 color: "text-warning", 41 title: "Monitor Degraded", 42 }, 43} as const; 44 45export const getMetadata = (privateLocations?: PrivateLocation[]) => { 46 return { 47 region: { 48 label: "Region", 49 key: "region", 50 unit: undefined, 51 visible: () => true, 52 format: (value) => { 53 const regionInfo = getRegionInfo(`${value}`, { 54 location: privateLocations?.find( 55 (location) => String(location.id) === String(value), 56 )?.name, 57 }); 58 return `${regionInfo.location} (${regionInfo.provider})`; 59 }, 60 }, 61 cronTimestamp: { 62 label: "Timestamp", 63 key: "timestamp", 64 unit: undefined, 65 visible: () => false, 66 format: (value) => String(value), 67 }, 68 statusCode: { 69 label: "Status Code", 70 key: "status", 71 unit: undefined, 72 visible: (_value) => typeof _value === "number" && _value !== -1, 73 format: (value) => String(value), 74 }, 75 latency: { 76 label: "Latency", 77 key: "latency", 78 unit: "ms", 79 visible: () => true, 80 format: (value) => formatMilliseconds(Number(value)), 81 }, 82 provider: { 83 label: "Provider", 84 key: "provider", 85 unit: undefined, 86 visible: () => true, 87 format: (value) => String(value), 88 }, 89 } as const satisfies Record< 90 string, 91 { 92 label: string; 93 key: string; 94 unit?: string | undefined; 95 visible: (value: string | number) => boolean; 96 format: (value: string | number) => string; 97 } 98 >; 99};