Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
feat: improve og images (#602)
Maximilian Kaske138dc16e37bb
diff --git a/apps/web/package.json b/apps/web/package.jsonindex 8a50b56c6..ae9071519 100644--- a/apps/web/package.json+++ b/apps/web/package.json@@ -34,7 +34,7 @@"@t3-oss/env-nextjs": "0.7.0","@tailwindcss/typography": "0.5.10","@tanstack/react-table": "8.10.3",- "@tremor/react": "3.8.2",+ "@tremor/react": "3.13.3","@trpc/client": "10.38.5","@trpc/next": "10.38.5","@trpc/react-query": "10.38.5",diff --git a/apps/web/public/assets/og/dashboard.png b/apps/web/public/assets/og/dashboard.pngnew file mode 100644index 000000000..6d1b80fe1Binary files /dev/null and b/apps/web/public/assets/og/dashboard.png differdiff --git a/apps/web/src/app/api/og/_components/background.tsx b/apps/web/src/app/api/og/_components/background.tsxnew file mode 100644index 000000000..01cee3cbe--- /dev/null+++ b/apps/web/src/app/api/og/_components/background.tsx@@ -0,0 +1,36 @@+import { cn } from "@/lib/utils";++export function Background({+ children,+ tw,+}: {+ children: React.ReactNode;+ tw?: string;+}) {+ return (+ <div+ tw={cn(+ "relative flex flex-col bg-white items-center justify-center w-full h-full",+ tw,+ )}+ >+ <div+ tw="flex w-full h-full absolute inset-0"+ // not every css variable is supported+ style={{+ backgroundImage: "radial-gradient(#cbd5e1 10%, transparent 10%)",+ backgroundSize: "16px 16px",+ }}+ />+ <div+ tw="flex w-full h-full absolute inset-0 opacity-70"+ style={{+ backgroundColor: "white",+ backgroundImage:+ "radial-gradient(farthest-corner at 100px 100px, #cbd5e1, white 80%)", // tbd: switch color position+ }}+ />+ {children}+ </div>+ );+}diff --git a/apps/web/src/app/api/og/_components/basic-layout.tsx b/apps/web/src/app/api/og/_components/basic-layout.tsxnew file mode 100644index 000000000..788d7d6ac--- /dev/null+++ b/apps/web/src/app/api/og/_components/basic-layout.tsx@@ -0,0 +1,37 @@+import { cn } from "@/lib/utils";+import { Background } from "./background";++export function BasicLayout({+ title,+ description,+ children,+ tw,+}: {+ title: string;+ description?: string;+ children?: React.ReactNode;+ tw?: string;+}) {+ return (+ <Background>+ <div tw="flex flex-col h-full w-full px-24">+ <div tw="flex flex-col flex-1 justify-end">+ <div tw="flex flex-col px-12">+ <h1 style={{ fontFamily: "Cal" }} tw="text-6xl">+ {title}+ </h1>+ <p tw="text-slate-600 text-3xl">{description}</p>+ </div>+ </div>+ <div+ tw={cn(+ "flex flex-col justify-center shadow-2xl mt-1 bg-white rounded-t-lg border-t-2 border-r-2 border-l-2 border-slate-200 px-12",+ tw,+ )}+ >+ {children}+ </div>+ </div>+ </Background>+ );+}diff --git a/apps/web/src/app/api/og/_components/status-check.tsx b/apps/web/src/app/api/og/_components/status-check.tsxnew file mode 100644index 000000000..628c3b211--- /dev/null+++ b/apps/web/src/app/api/og/_components/status-check.tsx@@ -0,0 +1,104 @@+import type { StatusVariant } from "@/lib/tracker";+import { cn } from "@/lib/utils";++export function StatusCheck({+ variant,+}: {+ variant: StatusVariant | "incident";+}) {+ function getVariant() {+ switch (variant) {+ case "down":+ return {+ color: "bg-red-500",+ label: "Major Outage",+ icon: Minus,+ };+ case "degraded":+ return {+ color: "bg-yellow-500",+ label: "Systems Degraded",+ icon: Minus,+ };+ case "incident":+ return {+ color: "bg-yellow-500",+ label: "Incident Ongoing",+ icon: Alert,+ };+ default:+ return {+ color: "bg-green-500",+ label: "All Systems Operational",+ icon: Check,+ };+ }+ }++ const { icon, color, label } = getVariant();++ return (+ <div tw="flex flex-col justify-center items-center gap-2 w-full">+ <div tw={cn("flex text-white rounded-full p-3", color)}>{icon()}</div>+ <p style={{ fontFamily: "Cal" }} tw="text-4xl">+ {label}+ </p>+ </div>+ );+}++function Check() {+ return (+ <svg+ xmlns="http://www.w3.org/2000/svg"+ width="40"+ height="40"+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ stroke-width="2"+ stroke-linecap="round"+ stroke-linejoin="round"+ >+ <path d="M20 6 9 17l-5-5" />+ </svg>+ );+}++function Minus() {+ return (+ <svg+ xmlns="http://www.w3.org/2000/svg"+ width="40"+ height="40"+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ stroke-width="2"+ stroke-linecap="round"+ stroke-linejoin="round"+ >+ <path d="M5 12h14" />+ </svg>+ );+}++function Alert() {+ return (+ <svg+ xmlns="http://www.w3.org/2000/svg"+ width="40"+ height="40"+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ stroke-width="2"+ stroke-linecap="round"+ stroke-linejoin="round"+ >+ <path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z" />+ <path d="M12 9v4" />+ <path d="M12 17h.01" />+ </svg>+ );+}diff --git a/apps/web/src/app/api/og/_components/tracker.tsx b/apps/web/src/app/api/og/_components/tracker.tsxnew file mode 100644index 000000000..ef163e8ac--- /dev/null+++ b/apps/web/src/app/api/og/_components/tracker.tsx@@ -0,0 +1,55 @@+import type { Monitor } from "@openstatus/tinybird";++import {+ addBlackListInfo,+ getStatus,+ getTotalUptimeString,+} from "@/lib/tracker";+import { cn, formatDate } from "@/lib/utils";++export function Tracker({ data }: { data: Monitor[] }) {+ const _data = addBlackListInfo(data);+ const uptime = getTotalUptimeString(data);++ return (+ <div tw="flex flex-col w-full my-12">+ <div tw="flex flex-col mx-auto">+ <div tw="flex flex-row items-center justify-between -mb-1 text-black font-light">+ <p></p>+ <p tw="font-medium">{uptime}</p>+ </div>+ {/* Empty State */}+ <div tw="flex flex-row relative">+ {new Array(data.length).fill(null).map((_, i) => {+ return <div key={i} tw="h-16 w-3 rounded-full mr-1 bg-black/20" />;+ })}+ <div tw="flex flex-row-reverse absolute left-0">+ {_data.map((item, i) => {+ const { variant } = getStatus(item.ok / item.count);+ const isBlackListed = Boolean(item.blacklist);+ if (isBlackListed) {+ return (+ <div key={i} tw="h-16 w-3 rounded-full mr-1 bg-green-400" />+ );+ }+ return (+ <div+ key={i}+ tw={cn("h-16 w-3 rounded-full mr-1", {+ "bg-green-500": variant === "up",+ "bg-red-500": variant === "down",+ "bg-yellow-500": variant === "degraded",+ })}+ />+ );+ })}+ </div>+ </div>+ <div tw="flex flex-row items-center justify-between -mt-3 text-slate-500 text-sm">+ <p tw="">{data.length} days ago</p>+ <p tw="mr-1">{formatDate(new Date())}</p>+ </div>+ </div>+ </div>+ );+}diff --git a/apps/web/src/app/api/og/checker/route.tsx b/apps/web/src/app/api/og/checker/route.tsxnew file mode 100644index 000000000..10b201324--- /dev/null+++ b/apps/web/src/app/api/og/checker/route.tsx@@ -0,0 +1,173 @@+import { ImageResponse } from "next/server";++import {+ getCheckerDataById,+ regionFormatter,+ timestampFormatter,+} from "@/app/play/checker/[id]/utils";+import { cn } from "@/lib/utils";+import { BasicLayout } from "../_components/basic-layout";+import {+ calSemiBold,+ interLight,+ interMedium,+ interRegular,+ SIZE,+} from "../utils";++export const runtime = "edge";++export async function GET(req: Request) {+ const interMediumData = await interMedium;+ const interRegularData = await interRegular;+ const interLightData = await interLight;+ const calSemiBoldData = await calSemiBold;++ const { searchParams } = new URL(req.url);++ const id = searchParams.has("id") ? searchParams.get("id") : undefined;++ const data = id ? await getCheckerDataById(id) : undefined;++ function getMinMax() {+ if (!data?.checks?.length) return;+ let min = data.checks[0];+ let max = data.checks[0];+ for (const check of data.checks) {+ if (check.latency < min.latency) min = check;+ if (check.latency > max.latency) max = check;+ }+ return { min, max };+ }++ const { min, max } = getMinMax() || {};++ function getStatusColor(statusCode: number) {+ const green = String(statusCode).startsWith("2");+ if (green) return "border-green-300 bg-green-50 text-green-700";+ const blue = String(statusCode).startsWith("3");+ if (blue) return "border-blue-300 bg-blue-50 text-blue-700";+ const red =+ String(statusCode).startsWith("4") || String(statusCode).startsWith("5");+ if (red) return "border-red-300 bg-red-50 text-red-700";+ return "border-gray-300 bg-gray-50 text-gray-700";+ }++ return new ImageResponse(+ (+ <BasicLayout+ title="Speed Checker"+ description="Experience the performance of your application from around the different continents."+ tw="pt-4 pb-8"+ >+ <h2+ style={{+ width: (SIZE.width * 3) / 4,+ lineClamp: 2,+ textOverflow: "ellipsis",+ overflow: "hidden",+ whiteSpace: "nowrap",+ }}+ tw="text-3xl text-left font-medium mb-0"+ >+ {data?.url}+ </h2>+ <p tw="text-slate-500 text-right">{timestampFormatter(data!.time)}</p>+ <div tw="flex">+ <div tw="flex flex-col flex-1">+ <p tw="text-slate-600 mb-1">Min. Request</p>+ </div>+ <div tw="flex flex-col flex-1">+ <p tw="text-slate-600 mb-1">Max. Request</p>+ </div>+ </div>+ <div tw="flex w-full h-px bg-slate-200" />+ <div tw="flex">+ <div tw="flex flex-col flex-1">+ <div tw="flex items-center">+ <p tw="text-slate-600 font-medium text-lg mr-2 w-24 mb-2">+ Status+ </p>+ <p+ tw={cn(+ "text-lg border rounded-full px-3 mb-2",+ getStatusColor(min!.status),+ )}+ >+ {min?.status}+ </p>+ </div>+ <div tw="flex items-center">+ <p tw="text-slate-600 font-medium text-lg mr-2 w-24 mb-2">+ Region+ </p>+ <p tw="text-black text-xl mb-2">{regionFormatter(min!.region)}</p>+ </div>+ <div tw="flex items-center">+ <p tw="text-slate-600 font-medium text-lg mr-2 w-24 mb-2">+ Latency+ </p>+ <p tw="text-black text-xl font-mono mb-2">{min?.latency}ms</p>+ </div>+ </div>+ <div tw="flex flex-col flex-1">+ <div tw="flex items-center">+ <p tw="text-slate-600 font-medium text-lg mr-2 w-24 mb-2">+ Status+ </p>+ <p+ tw={cn(+ "text-lg border rounded-full px-3 mb-2",+ getStatusColor(max!.status),+ )}+ >+ {max?.status}+ </p>+ </div>+ <div tw="flex items-center">+ <p tw="text-slate-600 font-medium text-lg mr-2 w-24 mb-2">+ Region+ </p>+ <p tw="text-black text-xl mb-2">{regionFormatter(max!.region)}</p>+ </div>+ <div tw="flex items-center">+ <p tw="text-slate-600 font-medium text-lg mr-2 w-24 mb-2">+ Latency+ </p>+ <p tw="text-black text-xl font-mono mb-2">{max?.latency}ms</p>+ </div>+ </div>+ </div>+ </BasicLayout>+ ),+ {+ ...SIZE,+ fonts: [+ {+ name: "Inter",+ data: interMediumData,+ style: "normal",+ weight: 500,+ },+ {+ name: "Inter",+ data: interRegularData,+ style: "normal",+ weight: 400,+ },+ {+ name: "Inter",+ data: interLightData,+ style: "normal",+ weight: 300,+ },+ {+ name: "Cal",+ data: calSemiBoldData,+ style: "normal",+ weight: 600,+ },+ ],+ },+ );+}diff --git a/apps/web/src/app/api/og/monitor/route.tsx b/apps/web/src/app/api/og/monitor/route.tsxnew file mode 100644index 000000000..37b141163--- /dev/null+++ b/apps/web/src/app/api/og/monitor/route.tsx@@ -0,0 +1,73 @@+import { ImageResponse } from "next/server";++import { DESCRIPTION, TITLE } from "@/app/shared-metadata";+import { getMonitorListData } from "@/lib/tb";+import { convertTimezoneToGMT } from "@/lib/timezone";+import { BasicLayout } from "../_components/basic-layout";+import { Tracker } from "../_components/tracker";+import { calSemiBold, interLight, interRegular, SIZE } from "../utils";++export const runtime = "edge";++export async function GET(req: Request) {+ const interRegularData = await interRegular;+ const interLightData = await interLight;+ const calSemiBoldData = await calSemiBold;++ const { searchParams } = new URL(req.url);++ const title =+ (searchParams.has("title") && searchParams.get("title")) || TITLE;++ const description =+ (searchParams.has("description") && searchParams.get("description")) ||+ DESCRIPTION;++ const monitorId =+ (searchParams.has("id") && searchParams.get("id")) || undefined;++ const timezone = convertTimezoneToGMT();++ const data =+ (monitorId &&+ (await getMonitorListData({+ monitorId,+ timezone,+ }))) ||+ [];++ return new ImageResponse(+ (+ <BasicLayout+ title={title}+ description={description}+ tw={data.length === 0 ? "mt-32" : undefined}+ >+ {Boolean(data.length) ? <Tracker data={data} /> : null}+ </BasicLayout>+ ),+ {+ ...SIZE,+ fonts: [+ {+ name: "Inter",+ data: interRegularData,+ style: "normal",+ weight: 400,+ },+ {+ name: "Inter",+ data: interLightData,+ style: "normal",+ weight: 300,+ },+ {+ name: "Cal",+ data: calSemiBoldData,+ style: "normal",+ weight: 600,+ },+ ],+ },+ );+}diff --git a/apps/web/src/app/api/og/page/route.tsx b/apps/web/src/app/api/og/page/route.tsxnew file mode 100644index 000000000..de22961e3--- /dev/null+++ b/apps/web/src/app/api/og/page/route.tsx@@ -0,0 +1,75 @@+import { ImageResponse } from "next/server";++import { DESCRIPTION, TITLE } from "@/app/shared-metadata";+import { getResponseListData } from "@/lib/tb";+import { calcStatus } from "@/lib/tracker";+import { notEmpty } from "@/lib/utils";+import { api } from "@/trpc/server";+import { BasicLayout } from "../_components/basic-layout";+import { StatusCheck } from "../_components/status-check";+import { calSemiBold, interLight, interRegular, SIZE } from "../utils";++export const runtime = "edge";++export async function GET(req: Request) {+ const interRegularData = await interRegular;+ const interLightData = await interLight;+ const calSemiBoldData = await calSemiBold;++ const { searchParams } = new URL(req.url);++ const slug = searchParams.has("slug") ? searchParams.get("slug") : undefined;++ const page = await api.page.getPageBySlug.query({ slug: slug || "" });++ const title = page ? page.title : TITLE;+ const description = page ? "" : DESCRIPTION;++ const isIncident = page?.statusReports.some(+ (incident) => !["monitoring", "resolved"].includes(incident.status),+ );++ const monitorsData = (+ await Promise.all(+ page?.monitors.map((monitor) => {+ return getResponseListData({+ monitorId: String(monitor.id),+ limit: 10,+ });+ }) || [],+ )+ ).filter(notEmpty);++ const status = calcStatus(monitorsData);++ return new ImageResponse(+ (+ <BasicLayout title={title} description={description} tw="py-24 px-24">+ <StatusCheck variant={isIncident ? "incident" : status.variant} />+ </BasicLayout>+ ),+ {+ ...SIZE,+ fonts: [+ {+ name: "Inter",+ data: interRegularData,+ style: "normal",+ weight: 400,+ },+ {+ name: "Inter",+ data: interLightData,+ style: "normal",+ weight: 300,+ },+ {+ name: "Cal",+ data: calSemiBoldData,+ style: "normal",+ weight: 600,+ },+ ],+ },+ );+}diff --git a/apps/web/src/app/api/og/post/route.tsx b/apps/web/src/app/api/og/post/route.tsxindex edaf0cd95..9a570f42b 100644--- a/apps/web/src/app/api/og/post/route.tsx+++ b/apps/web/src/app/api/og/post/route.tsx@@ -2,33 +2,17 @@import { ImageResponse } from "next/server";import { DESCRIPTION, TITLE } from "@/app/shared-metadata";+import { BasicLayout } from "../_components/basic-layout";+import {+ calSemiBold,+ DEFAULT_URL,+ interLight,+ interRegular,+ SIZE,+} from "../utils";export const runtime = "edge";-const DEFAULT_URL = process.env.VERCEL_URL- ? `https://${process.env.VERCEL_URL}`- : "http://localhost:3000";--const size = {- width: 1200,- height: 630,-};--const interRegular = fetch(- new URL("../../../../public/fonts/Inter-Regular.ttf", import.meta.url),-).then((res) => res.arrayBuffer());--const interLight = fetch(- new URL("../../../../public/fonts/Inter-Light.ttf", import.meta.url),-).then((res) => res.arrayBuffer());--const calSemiBold = fetch(- new URL("../../../../public/fonts/CalSans-SemiBold.ttf", import.meta.url),-).then((res) => res.arrayBuffer());--// TODO: add publishedAt date-// Think of instead having the image, preferably display author...-export async function GET(req: Request) {const interRegularData = await interRegular;const interLightData = await interLight;@@ -36,60 +20,30 @@ export async function GET(req: Request) {const { searchParams } = new URL(req.url);- const title = searchParams.has("title") ? searchParams.get("title") : TITLE;- const description = searchParams.has("description")- ? searchParams.get("description")- : DESCRIPTION;+ const title =+ (searchParams.has("title") && searchParams.get("title")) || TITLE;+ const description =+ (searchParams.has("description") && searchParams.get("description")) ||+ DESCRIPTION;const image = searchParams.has("image")? searchParams.get("image"): undefined;return new ImageResponse((- <div tw="relative flex flex-col bg-white items-center justify-center w-full h-full">- <div- tw="flex w-full h-full absolute inset-0"- // not every css variable is supported- style={{- backgroundImage: "radial-gradient(#cbd5e1 10%, transparent 10%)",- backgroundSize: "24px 24px",- }}- />- <div- tw="flex w-full h-full absolute inset-0 opacity-70"- style={{- backgroundColor: "white",- backgroundImage:- "radial-gradient(farthest-corner at 100px 100px, #cbd5e1, white 80%)", // tbd: switch color position- }}- />- <div tw="flex flex-col h-full justify-between px-24">- <div tw="flex flex-col flex-1 justify-end">- <div tw="flex flex-col px-12">- {/* lineClamp not working... */}- <h1 style={{ fontFamily: "Cal", lineClamp: "2" }} tw="text-6xl">- {title}- </h1>- <p style={{ lineClamp: "2" }} tw="text-slate-600 text-3xl">- {description}- </p>- </div>- </div>- {image ? (- <div tw="flex justify-center shadow-2xl mt-1">- <img- alt=""- style={{ objectFit: "cover", height: 350 }} // h-80 = 320px- tw="flex w-full border-2 rounded-xl"- src={new URL(image, DEFAULT_URL).toString()}- />- </div>- ) : null}- </div>- </div>+ <BasicLayout title={title} description={description}>+ {image ? (+ <img+ alt=""+ style={{ objectFit: "cover", height: 350 }} // h-80 = 320px+ tw="flex w-full"+ src={new URL(image, DEFAULT_URL).toString()}+ />+ ) : null}+ </BasicLayout>),{- ...size,+ ...SIZE,fonts: [{name: "Inter",diff --git a/apps/web/src/app/api/og/route.tsx b/apps/web/src/app/api/og/route.tsxindex b0c45fd55..ccd66447c 100644--- a/apps/web/src/app/api/og/route.tsx+++ b/apps/web/src/app/api/og/route.tsx@@ -1,137 +1,98 @@+/* eslint-disable @next/next/no-img-element */import { ImageResponse } from "next/server";import { DESCRIPTION, TITLE } from "@/app/shared-metadata";-import { getMonitorListData } from "@/lib/tb";-import { convertTimezoneToGMT } from "@/lib/timezone";+import { Background } from "./_components/background";import {- addBlackListInfo,- getStatus,- getTotalUptimeString,-} from "@/lib/tracker";-import { cn, formatDate } from "@/lib/utils";+ calSemiBold,+ DEFAULT_URL,+ interLight,+ interMedium,+ interRegular,+ SIZE,+} from "./utils";export const runtime = "edge";-const size = {- width: 1200,- height: 630,-};--const interRegular = fetch(- new URL("../../../public/fonts/Inter-Regular.ttf", import.meta.url),-).then((res) => res.arrayBuffer());--const interLight = fetch(- new URL("../../../public/fonts/Inter-Light.ttf", import.meta.url),-).then((res) => res.arrayBuffer());--const calSemiBold = fetch(- new URL("../../../public/fonts/CalSans-SemiBold.ttf", import.meta.url),-).then((res) => res.arrayBuffer());+// const TITLE = "A better way to monitor your services.";+// const DESCRIPTION = "Reduce alert fatigue by triggering only relevant alerts when your services experience downtime.";+const IMAGE = "assets/og/dashboard.png";+const FOOTER = "openstatus.dev";export async function GET(req: Request) {+ const interMediumData = await interMedium;const interRegularData = await interRegular;const interLightData = await interLight;const calSemiBoldData = await calSemiBold;const { searchParams } = new URL(req.url);- const title = searchParams.has("title") ? searchParams.get("title") : TITLE;- const description = searchParams.has("description")- ? searchParams.get("description")- : DESCRIPTION;- const monitorId = searchParams.has("monitorId")- ? searchParams.get("monitorId")- : undefined;+ const title =+ (searchParams.has("title") && searchParams.get("title")) || TITLE;- const timezone = convertTimezoneToGMT();+ const description =+ (searchParams.has("description") && searchParams.get("description")) ||+ DESCRIPTION;- // currently, we only show the tracker for a single(!) monitor- const data =- (monitorId &&- (await getMonitorListData({- monitorId,- timezone,- }))) ||- [];+ const image =+ (searchParams.has("image") && searchParams.get("image")) || IMAGE;- const _data = addBlackListInfo(data);- const uptime = getTotalUptimeString(data);+ const footer =+ (searchParams.has("footer") && searchParams.get("footer")) || FOOTER;return new ImageResponse((- <div tw="relative flex flex-col bg-white items-center justify-center w-full h-full">+ <Background tw="justify-start items-start"><div- tw="flex w-full h-full absolute inset-0"- // not every css variable is supported- style={{- backgroundImage: "radial-gradient(#cbd5e1 10%, transparent 10%)",- backgroundSize: "24px 24px",- }}- />+ style={{ clipPath: "polygon(90% 0%, 200% 0%, 200% 200%, -30% 200%)" }}+ tw="flex absolute h-full w-full bg-slate-200"+ >+ <img+ alt=""+ style={{ objectFit: "cover" }}+ tw="flex w-full h-full"+ src={new URL(image, DEFAULT_URL).toString()}+ />+ </div>+ {/* adds a border to the mask element */}<div- tw="flex w-full h-full absolute inset-0 opacity-70"style={{- backgroundColor: "white",+ clipPath: "polygon(90% 0%, 170% 0%, -30% 200%, -29% 200%)",+ // from-slate-100 to-slate-300backgroundImage:- "radial-gradient(farthest-corner at 100px 100px, #cbd5e1, white 80%)", // tbd: switch color position+ "linear-gradient(to bottom left, #f1f5f9, #cbd5e1)",}}+ tw="flex absolute h-full w-full" // bg-slate-200/>- <div tw="max-w-4xl relative flex flex-col">- <h1 style={{ fontFamily: "Cal" }} tw="text-6xl">- {title}- </h1>- <p tw="text-slate-600 text-3xl">{description}</p>- {Boolean(data.length) && Boolean(_data.length) ? (- <div tw="flex flex-col w-full mt-6">- <div tw="flex flex-row items-center justify-between -mb-1 text-black font-light">- <p tw="">{formatDate(new Date())}</p>- <p tw="mr-1">{uptime}</p>- </div>- <div tw="flex flex-row relative">- {/* Empty State */}- {new Array(data.length).fill(null).map((_, i) => {- return (- <div key={i} tw="h-16 w-3 rounded-full mr-1 bg-black/20" />- );- })}- <div tw="flex flex-row-reverse absolute right-0">- {_data.map((item, i) => {- const { variant } = getStatus(item.ok / item.count);- const isBlackListed = Boolean(item.blacklist);- if (isBlackListed) {- return (- <div- key={i}- tw="h-16 w-3 rounded-full mr-1 bg-green-400"- />- );- }- return (- <div- key={i}- tw={cn("h-16 w-3 rounded-full mr-1", {- "bg-green-500": variant === "up",- "bg-red-500": variant === "down",- "bg-yellow-500": variant === "degraded",- })}- />- );- })}- </div>- </div>- <div tw="flex flex-row items-center justify-between -mt-3 text-slate-500 text-sm">- <p tw="">{data.length} days ago</p>- <p tw="mr-1">today</p>- </div>- </div>- ) : null}+ <div tw="flex flex-col justify-between h-full flex-1 py-24 px-24">+ <div tw="flex flex-col h-full flex-1 justify-center">+ <h1+ style={{ fontFamily: "Cal", width: 700 }}+ tw="text-6xl text-black"+ >+ {title}+ </h1>+ <p style={{ width: 580 }} tw="text-4xl text-slate-700">+ {description}+ </p>+ </div>+ <div tw="flex w-full">+ <p style={{ width: 450 }} tw="font-medium text-xl">+ {footer}+ </p>+ </div></div>- </div>+ </Background>),{- ...size,+ ...SIZE,fonts: [+ {+ name: "Inter",+ data: interMediumData,+ style: "normal",+ weight: 500,+ },{name: "Inter",data: interRegularData,diff --git a/apps/web/src/app/api/og/utils.ts b/apps/web/src/app/api/og/utils.tsnew file mode 100644index 000000000..74914ad72--- /dev/null+++ b/apps/web/src/app/api/og/utils.ts@@ -0,0 +1,24 @@+export const SIZE = {+ width: 1200,+ height: 630,+};++export const DEFAULT_URL = process.env.VERCEL_URL+ ? `https://${process.env.VERCEL_URL}`+ : "http://localhost:3000";++export const interMedium = fetch(+ new URL("../../../public/fonts/Inter-Medium.ttf", import.meta.url),+).then((res) => res.arrayBuffer());++export const interRegular = fetch(+ new URL("../../../public/fonts/Inter-Regular.ttf", import.meta.url),+).then((res) => res.arrayBuffer());++export const interLight = fetch(+ new URL("../../../public/fonts/Inter-Light.ttf", import.meta.url),+).then((res) => res.arrayBuffer());++export const calSemiBold = fetch(+ new URL("../../../public/fonts/CalSans-SemiBold.ttf", import.meta.url),+).then((res) => res.arrayBuffer());diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/overview/_components/chart.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/overview/_components/chart.tsxindex 2b7280982..dd0bb1a99 100644--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/overview/_components/chart.tsx+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/overview/_components/chart.tsx@@ -1,5 +1,6 @@"use client";+import type { CustomTooltipProps } from "@tremor/react";import { Card, LineChart, Title } from "@tremor/react";const dataFormatter = (number: number) =>@@ -40,8 +41,36 @@ export function Chart({ data, regions }: ChartProps) {]}onValueChange={(v) => void 0} // that prop makes the chart interactivevalueFormatter={dataFormatter}- curveType="natural"+ curveType="monotone"+ intervalType="equidistantPreserveStart"+ // customTooltip={customTooltip}/></Card>);}++// TBD: add custom tooltip+const customTooltip = ({ payload, active }: CustomTooltipProps) => {+ if (!active || !payload) return null;+ return (+ <div className="rounded-tremor-default text-tremor-default bg-tremor-background shadow-tremor-dropdown border-tremor-border w-36 border p-2">+ <div className="flex flex-col gap-3">+ {payload+ .filter((category) => category.type !== undefined) // tremor adds additional data to the payload, we don't want that+ .map((category, idx) => (+ <div key={idx} className="flex flex-1 gap-2">+ <div+ className={`flex w-1 flex-col bg-${category.color}-500 rounded`}+ />+ <div className="flex gap-1">+ <p className="text-tremor-content">{category.dataKey}</p>+ <p className="text-tremor-content-emphasis font-mono font-medium">+ {dataFormatter(category.value as number)}+ </p>+ </div>+ </div>+ ))}+ </div>+ </div>+ );+};diff --git a/apps/web/src/app/play/checker/[id]/page.tsx b/apps/web/src/app/play/checker/[id]/page.tsxindex 6644f5178..7e00bfb86 100644--- a/apps/web/src/app/play/checker/[id]/page.tsx+++ b/apps/web/src/app/play/checker/[id]/page.tsx@@ -1,3 +1,4 @@+import type { Metadata } from "next";import Link from "next/link";import { redirect } from "next/navigation";import * as z from "zod";@@ -5,6 +6,11 @@ import * as z from "zod";import { monitorFlyRegionSchema } from "@openstatus/db/src/schema";import { Separator } from "@openstatus/ui";+import {+ defaultMetadata,+ ogMetadata,+ twitterMetadata,+} from "@/app/shared-metadata";import { Shell } from "@/components/dashboard/shell";import { BackButton } from "@/components/layout/back-button";import { CopyLinkButton } from "./_components/copy-link-button";@@ -22,13 +28,12 @@ const searchParamsSchema = z.object({region: monitorFlyRegionSchema.optional(),});-export default async function CheckPage({- params,- searchParams,-}: {+interface Props {params: { id: string };searchParams: { [key: string]: string | string[] | undefined };-}) {+}++export default async function CheckPage({ params, searchParams }: Props) {const search = searchParamsSchema.safeParse(searchParams);const selectedRegion = search.success ? search.data.region : undefined;@@ -90,3 +95,26 @@ export default async function CheckPage({</>);}++export async function generateMetadata({ params }: Props): Promise<Metadata> {+ const title = "Speed Checker";+ const description =+ "Get speed insights for your api, website from multiple regions.";+ return {+ ...defaultMetadata,+ title,+ description,+ twitter: {+ ...twitterMetadata,+ title,+ description,+ images: [`/api/og/checker?id=${params?.id}`],+ },+ openGraph: {+ ...ogMetadata,+ title,+ description,+ images: [`/api/og/checker?id=${params?.id}`],+ },+ };+}diff --git a/apps/web/src/app/shared-metadata.ts b/apps/web/src/app/shared-metadata.tsindex adcd56010..9d1c1ebc0 100644--- a/apps/web/src/app/shared-metadata.ts+++ b/apps/web/src/app/shared-metadata.ts@@ -2,7 +2,7 @@ import type { Metadata } from "next";export const TITLE = "OpenStatus";export const DESCRIPTION =- "A better way to monitor your services. Don't let your down time ruin your day.";+ "A better way to monitor your services. Don't let your downtime ruin your day.";export const defaultMetadata: Metadata = {title: {diff --git a/apps/web/src/app/status-page/[domain]/layout.tsx b/apps/web/src/app/status-page/[domain]/layout.tsxindex a8f4d1458..3142e158f 100644--- a/apps/web/src/app/status-page/[domain]/layout.tsx+++ b/apps/web/src/app/status-page/[domain]/layout.tsx@@ -93,7 +93,6 @@ export default async function StatusPageLayout({ children, params }: Props) {export async function generateMetadata({ params }: Props): Promise<Metadata> {const page = await api.page.getPageBySlug.query({ slug: params.domain });- const firstMonitor = page?.monitors?.[0]; // temporary solutionreturn {...defaultMetadata,@@ -102,21 +101,13 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {icons: page?.icon,twitter: {...twitterMetadata,- images: [- `/api/og?monitorId=${firstMonitor?.id}&title=${page?.title}&description=${- page?.description || `The ${page?.title} status page`- }`,- ],+ images: [`/api/og/page?slug=${page?.slug}`],title: page?.title,description: page?.description,},openGraph: {...ogMetadata,- images: [- `/api/og?monitorId=${firstMonitor?.id}&title=${page?.title}&description=${- page?.description || `The ${page?.title} status page`- }`,- ],+ images: [`/api/og/page?slug=${page?.slug}`],title: page?.title,description: page?.description,},diff --git a/apps/web/src/components/status-page/status-check.tsx b/apps/web/src/components/status-page/status-check.tsxindex c32095532..b317bb8ff 100644--- a/apps/web/src/components/status-page/status-check.tsx+++ b/apps/web/src/components/status-page/status-check.tsx@@ -8,7 +8,7 @@ import type {import { getResponseListData } from "@/lib/tb";import type { StatusVariant } from "@/lib/tracker";-import { getStatus } from "@/lib/tracker";+import { calcStatus } from "@/lib/tracker";import { cn, notEmpty } from "@/lib/utils";import { Icons } from "../icons";@@ -49,21 +49,8 @@ export async function StatusCheck({)).filter(notEmpty);- function calcStatus() {- const { count, ok } = monitorsData.flat(1).reduce(- (prev, curr) => {- if (!curr.statusCode) return prev; // TODO: handle this better- const isOk = curr.statusCode <= 299 && curr.statusCode >= 200;- return { count: prev.count + 1, ok: prev.ok + (isOk ? 1 : 0) };- },- { count: 0, ok: 0 },- );- const ratio = ok / count;- if (isNaN(ratio)) return getStatus(1); // outsmart caching issue- return getStatus(ratio);- }+ const status = calcStatus(monitorsData);- const status = calcStatus();const incident = {label: "Incident",variant: "incident",diff --git a/apps/web/src/components/workspace/select-workspace.tsx b/apps/web/src/components/workspace/select-workspace.tsxindex efd6a42b6..a0647b29e 100644--- a/apps/web/src/components/workspace/select-workspace.tsx+++ b/apps/web/src/components/workspace/select-workspace.tsx@@ -50,7 +50,9 @@ export function SelectWorkspace() {<ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" /></Button></DropdownMenuTrigger>- <DropdownMenuContent className="w-[var(--radix-dropdown-menu-trigger-width)]">+ <DropdownMenuContent+ style={{ width: "var(--radix-dropdown-menu-trigger-width)" }}+ ><DropdownMenuLabel>Workspaces</DropdownMenuLabel><DropdownMenuSeparator />{workspaces.map((workspace) => (diff --git a/apps/web/src/lib/tracker.ts b/apps/web/src/lib/tracker.tsindex 13a71b099..4653c14d1 100644--- a/apps/web/src/lib/tracker.ts+++ b/apps/web/src/lib/tracker.ts@@ -1,4 +1,4 @@-import type { Monitor } from "@openstatus/tinybird";+import type { Monitor, Ping } from "@openstatus/tinybird";export type StatusVariant = "up" | "degraded" | "down" | "empty";@@ -90,6 +90,23 @@ export function isInBlacklist(timestamp: number) {return el ? blacklistDates[el] : undefined;}+/**+ * Calculate the overall status of a page based on all the monitor data+ */+export function calcStatus(data: Ping[][]) {+ const { count, ok } = data.flat(1).reduce(+ (prev, curr) => {+ if (!curr.statusCode) return prev; // TODO: handle this better+ const isOk = curr.statusCode <= 299 && curr.statusCode >= 200;+ return { count: prev.count + 1, ok: prev.ok + (isOk ? 1 : 0) };+ },+ { count: 0, ok: 0 },+ );+ const ratio = ok / count;+ if (isNaN(ratio)) return getStatus(1); // outsmart caching issue+ return getStatus(ratio);+}+/*** Blacklist dates where we had issues with data collection*/diff --git a/apps/web/src/public/fonts/Inter-Medium.ttf b/apps/web/src/public/fonts/Inter-Medium.ttfnew file mode 100644index 000000000..a01f3777aBinary files /dev/null and b/apps/web/src/public/fonts/Inter-Medium.ttf differdiff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex e9a890c72..2cbdf37da 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -177,8 +177,8 @@ importers:specifier: 8.10.3version: 8.10.3([email protected])([email protected])'@tremor/react':- specifier: 3.8.2+ specifier: 3.13.3'@trpc/client':specifier: 10.38.5version: 10.38.5(@trpc/[email protected])@@ -2238,8 +2238,21 @@ packages:react-dom: 18.2.0([email protected])dev: false- /@headlessui/[email protected]([email protected]):- resolution: {integrity: sha512-3aMdDyYZx9A15euRehpppSyQnb2gIw2s/Uccn2ELIoLQ9oDy0+9oRygNWNjXCD5Dt+w1pxo7C+XoiYvGcqA4Kg==}+ resolution: {integrity: sha512-4i5DOrzwN4qSgNsL4Si61VMkUcWbcSKueUV7sFhpHzQcSShdlHENE5+QBntMSRvHt8NyoFO2AGG8si9lq+w4zQ==}+ engines: {node: '>=10'}+ peerDependencies:+ react: ^16 || ^17 || ^18+ react-dom: ^16 || ^17 || ^18+ dependencies:+ '@tanstack/react-virtual': 3.0.2([email protected])([email protected])+ client-only: 0.0.1+ react: 18.2.0+ react-dom: 18.2.0([email protected])+ dev: false++ /@headlessui/[email protected]([email protected]):+ resolution: {integrity: sha512-fpL830Fln1SykOCboExsWr3JIVeQKieLJ3XytLe/tt1A0XzqUthOftDmjcCYLW62w7mQI7wXcoPXr3tZ9QfGxw==}engines: {node: '>=10'}peerDependencies:tailwindcss: ^3.0@@ -4869,11 +4882,26 @@ packages:react-dom: 18.2.0([email protected])dev: false+ resolution: {integrity: sha512-9XbRLPKgnhMwwmuQMnJMv+5a9sitGNCSEtf/AZXzmJdesYk7XsjYHaEDny+IrJzvPNwZliIIDwCRiaUqR3zzCA==}+ peerDependencies:+ react: ^16.8.0 || ^17.0.0 || ^18.0.0+ react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0+ dependencies:+ '@tanstack/virtual-core': 3.0.0+ react: 18.2.0+ react-dom: 18.2.0([email protected])+ dev: false+/@tanstack/[email protected]:resolution: {integrity: sha512-hJ55YfJlWbfzRROfcyA/kC1aZr/shsLA8XNAwN8jXylhYWGLnPmiJJISrUfj4dMMWRiFi0xBlnlC7MLH+zSrcw==}engines: {node: '>=12'}dev: false+ /@tanstack/[email protected]:+ resolution: {integrity: sha512-SYXOBTjJb05rXa2vl55TTwO40A6wKu0R5i1qQwhJYNDIqaIGF7D0HsLw+pJAyi2OvntlEIVusx3xtbbgSUi6zg==}+ dev: false+/@tootallnate/[email protected]:resolution: {integrity: sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==}engines: {node: '>= 10'}@@ -4883,21 +4911,21 @@ packages:resolution: {integrity: sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==}dev: true- /@tremor/[email protected]([email protected])([email protected])([email protected])([email protected]):- resolution: {integrity: sha512-gZ6GTBIiL915U2Tikreooh8nllWEgKd1wnZ3ru0Cm9qmq6TbW+jHikCpHy1KQ2PQkpdKrXi5R2s6f8N4Fj5Imw==}+ /@tremor/[email protected]([email protected])([email protected])([email protected])([email protected]):+ resolution: {integrity: sha512-v0JTAhZr1VTj67nmrb5WF/vI5Mq3Fj7LigPYwqFZcYwrF1UXkUwv5mEt8V5GR5QVMmprmYx7A6m8baImt99IQQ==}peerDependencies:react: ^18.0.0react-dom: '>=16.6.0'dependencies:'@floating-ui/react': 0.19.2([email protected])([email protected])- '@headlessui/react': 1.7.17([email protected])([email protected])- '@headlessui/tailwindcss': 0.1.3([email protected])+ '@headlessui/react': 1.7.18([email protected])([email protected])+ '@headlessui/tailwindcss': 0.2.0([email protected])date-fns: 2.30.0react: 18.2.0- react-day-picker: 8.8.2([email protected])([email protected])+ react-day-picker: 8.10.0([email protected])([email protected])react-dom: 18.2.0([email protected])- react-transition-group: 4.4.5([email protected])([email protected])+ react-transition-state: 2.1.1([email protected])([email protected])tailwind-merge: 1.14.0transitivePeerDependencies:- prop-types@@ -6172,10 +6200,6 @@ packages:clsx: 2.0.0dev: false- resolution: {integrity: sha512-CSbhY4cFEJRe6/GQzIk5qXZ4Jeg5pcsP7b5peFSDpffpe1cqjASH/n9UTjBwOp6XpMSTwQ8Za2K5V02ueA7Tmw==}- dev: false-resolution: {integrity: sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==}engines: {node: '>=6'}@@ -6776,13 +6800,6 @@ packages:'@babel/runtime': 7.23.2dev: false- resolution: {integrity: sha512-nRCa7CK3VTrM2NmGkIy4cbK7IZlgBE/PYMn55rrXefr5xXDP0LdtfPnblFDoVdcAfslJ7or6iqAUnx0CCGIWQA==}- dependencies:- '@babel/runtime': 7.23.2- csstype: 3.1.2- dev: false-resolution: {integrity: sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==}dependencies:@@ -11136,6 +11153,16 @@ packages:minimist: 1.2.8strip-json-comments: 2.0.1+ resolution: {integrity: sha512-mz+qeyrOM7++1NCb1ARXmkjMkzWVh2GL9YiPbRjKe0zHccvekk4HE+0MPOZOrosn8r8zTHIIeOUXTmXRqmkRmg==}+ peerDependencies:+ date-fns: ^2.28.0 || ^3.0.0+ react: ^16.8.0 || ^17.0.0 || ^18.0.0+ dependencies:+ date-fns: 2.30.0+ react: 18.2.0+ dev: false+resolution: {integrity: sha512-sK5M5PNZaLiszmACUKUpVu1eX3eFDVV+WLdWQ3BxTPbEC9jhuawmlgpbSXX5dIIQQwJpZ4wwP5+vsMVOwa1IRw==}peerDependencies:@@ -11259,17 +11286,6 @@ packages:use-sidecar: 1.1.2(@types/[email protected])([email protected])dev: false- resolution: {integrity: sha512-S7szxlaIuiy5UqLhLL1KY3aoyGHbZzsTpYal9eYMwCyKqoqoVLCmIgAgNyIM1FhnP2KyBygASJxdhejrzjMb+w==}- peerDependencies:- react: ^16.0.0 || ^17.0.0 || ^18.0.0- react-dom: ^16.0.0 || ^17.0.0 || ^18.0.0- dependencies:- lodash: 4.17.21- react: 18.2.0- react-dom: 18.2.0([email protected])- dev: false-resolution: {integrity: sha512-BMP2Ad42tD60h0JW6BFaib+RJuV5dsXJK9Baxiv/HlNFjvRLqA9xrNKxVWnUIZPQfzUwGXIlU/dSYLU+54YGQA==}peerDependencies:@@ -11323,16 +11339,12 @@ packages:react-lifecycles-compat: 3.0.4dev: false- resolution: {integrity: sha512-pZcd1MCJoiKiBR2NRxeCRg13uCXbydPnmB4EOeRrY7480qNWO8IIgQG6zlDkm6uRMsURXPuKq0GWtiM59a5Q6g==}+ resolution: {integrity: sha512-kQx5g1FVu9knoz1T1WkapjUgFz08qQ/g1OmuWGi3/AoEFfS0kStxrPlZx81urjCXdz2d+1DqLpU6TyLW/Ro04Q==}peerDependencies:- react: '>=16.6.0'- react-dom: '>=16.6.0'+ react: '>=16.8.0'+ react-dom: '>=16.8.0'dependencies:- '@babel/runtime': 7.23.2- dom-helpers: 5.2.1- loose-envify: 1.4.0- prop-types: 15.8.1react: 18.2.0react-dom: 18.2.0([email protected])dev: false@@ -11415,22 +11427,21 @@ packages:decimal.js-light: 2.5.1dev: false- resolution: {integrity: sha512-cVgiAU3W5UrA8nRRV/N0JrudgZzY/vjkzrlShbH+EFo1vs4nMlXgshZWLI0DfDLmn4/p4pF7Lq7F5PU+K94Ipg==}- engines: {node: '>=12'}+ resolution: {integrity: sha512-5s+u1m5Hwxb2nh0LABkE3TS/lFqFHyWl7FnPbQhHobbQQia4ih1t3o3+ikPYr31Ns+kYe4FASIthKeKi/YYvMg==}+ engines: {node: '>=14'}peerDependencies:prop-types: ^15.6.0react: ^16.0.0 || ^17.0.0 || ^18.0.0react-dom: ^16.0.0 || ^17.0.0 || ^18.0.0dependencies:- classnames: 2.3.2+ clsx: 2.0.0eventemitter3: 4.0.7lodash: 4.17.21prop-types: 15.8.1react: 18.2.0react-dom: 18.2.0([email protected])react-is: 16.13.1- react-resize-detector: 8.1.0([email protected])([email protected])recharts-scale: 0.4.5tiny-invariant: 1.3.1