Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
fix: trpc hydration error (#1667)
Maximilian Kaske9009d5503d3e
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.tsxindex edb30978e..923e57ad9 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@@ -38,11 +38,12 @@ export default function Page() {// NOTE: we cannot use `cardType` and `barType` here because of queryKey changes// It wouldn't match the server prefetch keys and we would have to refetch the page here- const { data: pageInitial, error } = useQuery(- trpc.statusPage.get.queryOptions({+ const { data: pageInitial, error } = useQuery({+ ...trpc.statusPage.get.queryOptions({slug: domain,}),- );+ enabled: !!domain,+ });// Handle case where page doesn't exist or query failsif (error || (!pageInitial && domain)) {@@ -61,19 +62,20 @@ export default function Page() {cardType,barType,}),- enabled: hasCustomConfig,+ enabled: !!domain && hasCustomConfig,});// NOTE: we can prefetch that to avoid loading state- const { data: uptimeData, isLoading } = useQuery(- trpc.statusPage.getUptime.queryOptions({+ const { data: uptimeData, isLoading } = useQuery({+ ...trpc.statusPage.getUptime.queryOptions({slug: domain,monitorIds:pageInitial?.monitors?.map((monitor) => monitor.id.toString()) || [],cardType,barType,}),- );+ enabled: !!pageInitial && pageInitial.monitors.length > 0,+ });// NOTE: we need to filter out the incidents as we don't want to show all of them in the banner - a single one is enough// REMINDER: we could move that to the server - but we might wanna have the info of all openEvents actuallydiff --git a/packages/db/src/schema/shared.ts b/packages/db/src/schema/shared.tsindex ece3f498b..caccb1a30 100644--- a/packages/db/src/schema/shared.ts+++ b/packages/db/src/schema/shared.ts@@ -114,35 +114,22 @@ const trackersSchema = z).default([]);+export const statusPageEventSchema = z.object({+ id: z.number(),+ name: z.string(),+ from: z.date(),+ to: z.date().nullable(),+ status: z.enum(["success", "degraded", "error", "info"]).default("success"),+ type: z.enum(["maintenance", "incident", "report"]),+});+export const selectPublicPageSchemaWithRelation = selectPageSchema.extend({monitorGroups: selectMonitorGroupSchema.array().default([]),// TODO: include status of the monitormonitors: selectPublicMonitorWithStatusSchema.array(),trackers: trackersSchema,- lastEvents: z.array(- z.object({- id: z.number(),- name: z.string(),- from: z.date(),- to: z.date().nullable(),- status: z- .enum(["success", "degraded", "error", "info"])- .default("success"),- type: z.enum(["maintenance", "incident", "report"]),- }),- ),- openEvents: z.array(- z.object({- id: z.number(),- name: z.string(),- from: z.date(),- to: z.date().nullable(),- status: z- .enum(["success", "degraded", "error", "info"])- .default("success"),- type: z.enum(["maintenance", "incident", "report"]),- }),- ),+ lastEvents: z.array(statusPageEventSchema),+ openEvents: z.array(statusPageEventSchema),statusReports: z.array(selectStatusReportPageSchema),incidents: z.array(selectIncidentSchema),maintenances: z.array(selectMaintenancePageSchema),