Skip to content

Open-source status page, incident response and uptime monitoring

chore: stpg improvements (#1370)

Maximilian Kasked3fb165a7156
diff --git a/apps/status-page/src/app/(status-page)/[domain]/(public)/events/(list)/page.tsx b/apps/status-page/src/app/(status-page)/[domain]/(public)/events/(list)/page.tsx
index 8b9ab07f5..0d09eb5d1 100644
--- a/apps/status-page/src/app/(status-page)/[domain]/(public)/events/(list)/page.tsx
+++ b/apps/status-page/src/app/(status-page)/[domain]/(public)/events/(list)/page.tsx
@@ -21,6 +21,7 @@ import {
import { Badge } from "@/components/ui/badge";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { formatDate } from "@/lib/formatter";
+import { CircleCheck } from "lucide-react";
import Link from "next/link";
// TODO: include ?filter=maintenance/reports
@@ -45,7 +46,16 @@ export default function Page() {
<TabsContent value="reports" className="flex flex-col gap-4">
{statusReports.length > 0 ? (
statusReports.map((report) => {
- const startedAt = report.statusReportUpdates[0].date;
+ const updates = report.statusReportUpdates.sort(
+ (a, b) => b.date.getTime() - a.date.getTime(),
+ );
+ const firstUpdate = updates[updates.length - 1];
+ const lastUpdate = updates[0];
+ // NOTE: updates are sorted descending by date
+ const startedAt = firstUpdate.date;
+ // HACKY: LEGACY: only resolved via report and not via report update
+ const isReportResolvedOnly =
+ report.status === "resolved" && lastUpdate.status !== "resolved";
return (
<StatusEvent key={report.id}>
<StatusEventAside>
@@ -58,7 +68,12 @@ export default function Page() {
className="rounded-lg"
>
<StatusEventContent>
- <StatusEventTitle>{report.title}</StatusEventTitle>
+ <StatusEventTitle className="inline-flex gap-1">
+ {report.title}
+ {isReportResolvedOnly ? (
+ <CircleCheck className="size-4 text-success shrink-0 mt-1 ml-1.5" />
+ ) : null}
+ </StatusEventTitle>
{report.monitorsToStatusReports.length > 0 ? (
<StatusEventAffected className="flex flex-wrap gap-1">
{report.monitorsToStatusReports.map((affected) => (
diff --git a/apps/status-page/src/app/(status-page)/[domain]/(public)/page.tsx b/apps/status-page/src/app/(status-page)/[domain]/(public)/page.tsx
index 1ad5e51db..63505cfa1 100644
--- a/apps/status-page/src/app/(status-page)/[domain]/(public)/page.tsx
+++ b/apps/status-page/src/app/(status-page)/[domain]/(public)/page.tsx
@@ -23,6 +23,7 @@ import { StatusMonitor } from "@/components/status-page/status-monitor";
import { Separator } from "@/components/ui/separator";
import { useTRPC } from "@/lib/trpc/client";
import { useQuery } from "@tanstack/react-query";
+import Link from "next/link";
import { useParams } from "next/navigation";
export default function Page() {
@@ -61,15 +62,21 @@ export default function Page() {
);
if (!maintenance) return null;
return (
- <StatusBannerContainer key={e.id} status={e.status}>
- <StatusBannerTitle>{e.name}</StatusBannerTitle>
- <StatusBannerContent>
- <StatusEventTimelineMaintenance
- maintenance={maintenance}
- withDot={false}
- />
- </StatusBannerContent>
- </StatusBannerContainer>
+ <Link
+ href={`./events/maintenance/${e.id}`}
+ key={e.id}
+ className="rounded-lg"
+ >
+ <StatusBannerContainer status={e.status}>
+ <StatusBannerTitle>{e.name}</StatusBannerTitle>
+ <StatusBannerContent>
+ <StatusEventTimelineMaintenance
+ maintenance={maintenance}
+ withDot={false}
+ />
+ </StatusBannerContent>
+ </StatusBannerContainer>
+ </Link>
);
}
if (e.type === "report") {
@@ -78,15 +85,21 @@ export default function Page() {
);
if (!report) return null;
return (
- <StatusBannerContainer key={e.id} status={e.status}>
- <StatusBannerTitle>{e.name}</StatusBannerTitle>
- <StatusBannerContent>
- <StatusEventTimelineReport
- updates={report.statusReportUpdates}
- withDot={false}
- />
- </StatusBannerContent>
- </StatusBannerContainer>
+ <Link
+ href={`./events/report/${e.id}`}
+ key={e.id}
+ className="rounded-lg"
+ >
+ <StatusBannerContainer status={e.status}>
+ <StatusBannerTitle>{e.name}</StatusBannerTitle>
+ <StatusBannerContent>
+ <StatusEventTimelineReport
+ updates={report.statusReportUpdates}
+ withDot={false}
+ />
+ </StatusBannerContent>
+ </StatusBannerContainer>
+ </Link>
);
}
return null;
diff --git a/apps/status-page/src/components/content/timestamp-hover-card.tsx b/apps/status-page/src/components/content/timestamp-hover-card.tsx
index f68b2720d..47548ef52 100644
--- a/apps/status-page/src/components/content/timestamp-hover-card.tsx
+++ b/apps/status-page/src/components/content/timestamp-hover-card.tsx
@@ -4,6 +4,7 @@ import {
HoverCardTrigger,
} from "@/components/ui/hover-card";
import { useCopyToClipboard } from "@/hooks/use-copy-to-clipboard";
+import { useMediaQuery } from "@/hooks/use-media-query";
import { UTCDate } from "@date-fns/utc";
import {
type HoverCardContentProps,
@@ -21,6 +22,7 @@ export function TimestampHoverCard({
alignOffset = -4,
sideOffset,
children,
+ onClick,
...props
}: React.ComponentProps<typeof HoverCardTrigger> & {
date: Date;
@@ -30,6 +32,7 @@ export function TimestampHoverCard({
sideOffset?: HoverCardContentProps["sideOffset"];
}) {
const [open, setOpen] = useState(false);
+ const isTouch = useMediaQuery("(hover: none)");
const [_, setRerender] = useState(0);
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
@@ -51,7 +54,16 @@ export function TimestampHoverCard({
return (
<HoverCard openDelay={0} closeDelay={0} open={open} onOpenChange={setOpen}>
{/* NOTE: the trigger is an `a` tag per default */}
- <HoverCardTrigger {...props}>{children}</HoverCardTrigger>
+ <HoverCardTrigger
+ onClick={(e) => {
+ // NOTE: support touch devices
+ if (isTouch) setOpen((prev) => !prev);
+ onClick?.(e);
+ }}
+ {...props}
+ >
+ {children}
+ </HoverCardTrigger>
<HoverCardPortal>
<HoverCardContent
className="z-10 w-auto p-2"
diff --git a/apps/status-page/src/components/nav/footer.tsx b/apps/status-page/src/components/nav/footer.tsx
index e328e706a..f0b04ea8d 100644
--- a/apps/status-page/src/components/nav/footer.tsx
+++ b/apps/status-page/src/components/nav/footer.tsx
@@ -4,7 +4,6 @@ import { Link } from "@/components/common/link";
import { TimestampHoverCard } from "@/components/content/timestamp-hover-card";
import { ThemeToggle } from "@/components/theme-toggle";
import { useTRPC } from "@/lib/trpc/client";
-import { cn } from "@/lib/utils";
import { useQuery } from "@tanstack/react-query";
import { format } from "date-fns";
import { useParams } from "next/navigation";
@@ -22,12 +21,7 @@ export function Footer(props: React.ComponentProps<"footer">) {
<footer {...props}>
<div className="mx-auto flex max-w-2xl items-center justify-between gap-4 px-3 py-2">
<div className="leading-[0.9]">
- <p
- className={cn(
- "text-muted-foreground text-sm",
- page.workspacePlan === "team" && "sr-only",
- )}
- >
+ <p className="text-muted-foreground text-sm">
Powered by <Link href="#">OpenStatus</Link>
</p>
<TimestampHoverCard date={new Date(dataUpdatedAt)} side="top">
diff --git a/apps/status-page/src/components/nav/header.tsx b/apps/status-page/src/components/nav/header.tsx
index 6ee8fc445..edab17f41 100644
--- a/apps/status-page/src/components/nav/header.tsx
+++ b/apps/status-page/src/components/nav/header.tsx
@@ -69,8 +69,10 @@ export function Header(props: React.ComponentProps<"header">) {
);
const types = (
- page?.workspacePlan === "free" ? ["rss", "atom"] : ["email", "rss", "atom"]
- ) satisfies ("email" | "rss" | "atom")[];
+ page?.workspacePlan === "free"
+ ? ["rss", "atom", "ssh"]
+ : ["email", "rss", "atom", "ssh"]
+ ) satisfies ("email" | "rss" | "atom" | "ssh")[];
return (
<header {...props}>
@@ -78,7 +80,7 @@ export function Header(props: React.ComponentProps<"header">) {
{/* NOTE: same width as the `StatusUpdates` button */}
<div className="w-[150px] shrink-0">
<Link
- href={page?.homepageUrl ?? "/"}
+ href={page?.homepageUrl || "/"}
target={page?.homepageUrl ? "_blank" : undefined}
rel={page?.homepageUrl ? "noreferrer" : undefined}
className="rounded-full"
@@ -212,6 +214,7 @@ function GetInTouch({
size="icon"
type="button"
className={cn("size-8", className)}
+ asChild
{...props}
>
<a href={link} target="_blank" rel="noreferrer">
diff --git a/apps/status-page/src/components/status-page/status-events.tsx b/apps/status-page/src/components/status-page/status-events.tsx
index c5d0f0ad1..f574aa0e0 100644
--- a/apps/status-page/src/components/status-page/status-events.tsx
+++ b/apps/status-page/src/components/status-page/status-events.tsx
@@ -116,7 +116,11 @@ export function StatusEventTimelineReport({
key={index}
report={update}
duration={
- index === 0 && update.status === "resolved" ? duration : undefined
+ index === 0 &&
+ update.status === "resolved" &&
+ duration !== "0 seconds"
+ ? duration
+ : undefined
}
withSeparator={index !== updates.length - 1}
withDot={withDot}
diff --git a/apps/status-page/src/components/status-page/status-tracker.tsx b/apps/status-page/src/components/status-page/status-tracker.tsx
index 36e830a2d..8116d7457 100644
--- a/apps/status-page/src/components/status-page/status-tracker.tsx
+++ b/apps/status-page/src/components/status-page/status-tracker.tsx
@@ -375,7 +375,7 @@ function StatusTrackerEvent({
<div className="mt-1 text-muted-foreground text-xs">
{formatDateRange(from, to ?? undefined)}{" "}
<span className="ml-1.5 font-mono text-muted-foreground/70">
- {duration}
+ {duration === "0 seconds" ? null : duration}
</span>
</div>
</div>
diff --git a/apps/status-page/src/components/status-page/status-updates.tsx b/apps/status-page/src/components/status-page/status-updates.tsx
index 9e403c041..00f5436bf 100644
--- a/apps/status-page/src/components/status-page/status-updates.tsx
+++ b/apps/status-page/src/components/status-page/status-updates.tsx
@@ -14,7 +14,7 @@ import { cn } from "@/lib/utils";
import { Inbox } from "lucide-react";
import { useState } from "react";
-type StatusUpdateType = "email" | "rss" | "atom";
+type StatusUpdateType = "email" | "rss" | "atom" | "ssh";
interface StatusUpdatesProps extends React.ComponentProps<typeof Button> {
types?: StatusUpdateType[];
@@ -55,6 +55,9 @@ export function StatusUpdates({
{types.includes("atom") ? (
<TabsTrigger value="atom">Atom</TabsTrigger>
) : null}
+ {types.includes("ssh") ? (
+ <TabsTrigger value="ssh">SSH</TabsTrigger>
+ ) : null}
</TabsList>
<TabsContent value="email" className="flex flex-col gap-2">
{success ? (
@@ -86,8 +89,7 @@ export function StatusUpdates({
<div className="border-b px-2 pb-2">
<Input
placeholder={`https://${slug}.openstatus.dev/feed/rss`}
- className="disabled:opacity-90"
- disabled
+ readOnly
/>
</div>
<div className="px-2 pb-2">
@@ -101,8 +103,7 @@ export function StatusUpdates({
<div className="border-b px-2 pb-2">
<Input
placeholder={`https://${slug}.openstatus.dev/feed/atom`}
- className="disabled:opacity-90"
- disabled
+ readOnly
/>
</div>
<div className="px-2 pb-2">
@@ -112,6 +113,17 @@ export function StatusUpdates({
/>
</div>
</TabsContent>
+ <TabsContent value="ssh" className="flex flex-col gap-2">
+ <div className="border-b px-2 pb-2">
+ <Input placeholder={`ssh ${slug}@ssh.openstatus.dev`} readOnly />
+ </div>
+ <div className="px-2 pb-2">
+ <CopyButton
+ className="w-full"
+ value={`ssh ${slug}@ssh.openstatus.dev`}
+ />
+ </div>
+ </TabsContent>
</Tabs>
</PopoverContent>
</Popover>
@@ -135,7 +147,7 @@ function CopyButton({
}}
{...props}
>
- {isCopied ? "Copied" : "Copy link"}
+ {isCopied ? "Copied" : "Copy"}
</Button>
);
}
diff --git a/apps/status-page/src/lib/formatter.ts b/apps/status-page/src/lib/formatter.ts
index f091532af..ec131fada 100644
--- a/apps/status-page/src/lib/formatter.ts
+++ b/apps/status-page/src/lib/formatter.ts
@@ -72,6 +72,9 @@ export function formatDateRange(from?: Date, to?: Date) {
const isToEndDay = to && endOfDay(to).getTime() === to.getTime();
if (sameDay) {
+ if (from.getTime() === to.getTime()) {
+ return formatDateTime(from);
+ }
if (from && to) {
return `${formatDateTime(from)} - ${formatTime(to)}`;
}
diff --git a/packages/api/src/router/statusPage.utils.ts b/packages/api/src/router/statusPage.utils.ts
index 1757758d2..f541bed3d 100644
--- a/packages/api/src/router/statusPage.utils.ts
+++ b/packages/api/src/router/statusPage.utils.ts
@@ -156,6 +156,21 @@ export function getEvents({
const firstUpdate = updates[0];
const lastUpdate = updates[updates.length - 1];
if (!firstUpdate?.date || firstUpdate.date < pastThreshod) return;
+
+ // HACKY: LEGACY: we shouldn't have report.status anymore and instead use the update status for that.
+ // Ideally, we could replace the status with "downtime", "degraded", "operational" to indicate the gravity of the issue
+ if (report.status === "resolved") {
+ events.push({
+ id: report.id,
+ name: report.title,
+ from: firstUpdate?.date,
+ to: lastUpdate?.date,
+ type: "report",
+ status: "success" as const,
+ });
+ return;
+ }
+
events.push({
id: report.id,
name: report.title,
diff --git a/packages/tinybird/src/client.ts b/packages/tinybird/src/client.ts
index e210e981f..827c5d785 100644
--- a/packages/tinybird/src/client.ts
+++ b/packages/tinybird/src/client.ts
@@ -1049,11 +1049,7 @@ export class OSTinybird {
error: z.number().default(0),
monitorId: z.coerce.string(),
}),
- opts: {
- next: {
- revalidate: PUBLIC_CACHE,
- },
- },
+ opts: { next: { revalidate: REVALIDATE } },
});
}