Skip to content

feat: generate dynamic og image for status page#370

Merged
izadoesdev merged 3 commits intodatabuddy-analytics:mainfrom
mezotv:feat/dynamic-status-og-image
Mar 30, 2026
Merged

feat: generate dynamic og image for status page#370
izadoesdev merged 3 commits intodatabuddy-analytics:mainfrom
mezotv:feat/dynamic-status-og-image

Conversation

@mezotv
Copy link
Copy Markdown
Contributor

@mezotv mezotv commented Mar 30, 2026

Description

Adds a clean and simple og image to the status/:slug routes

Checklist
  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
databuddy-links Skipped Skipped Mar 30, 2026 0:17am
documentation Skipped Skipped Mar 30, 2026 0:17am

@vercel vercel Bot temporarily deployed to Preview – documentation March 30, 2026 00:06 Inactive
@mezotv
Copy link
Copy Markdown
Contributor Author

mezotv commented Mar 30, 2026

@greptile review

@vercel vercel Bot temporarily deployed to Preview – databuddy-links March 30, 2026 00:06 Inactive
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 30, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: d52f9e02-66e4-4b87-9b2a-c5412e76acb3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 30, 2026

@mezotv is attempting to deploy a commit to the Databuddy OSS Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 30, 2026

Greptile Summary

This PR replaces the simple OG image for status pages with a richly redesigned one: it now renders the Databuddy logo, the organisation name, a styled status banner (operational / degraded / outage), and uptime bar charts for up to three monitors, with a "N more services" overflow indicator. A new twitter-image.tsx re-exports everything from opengraph-image.tsx so both social cards use the same image.

Key changes:

  • Replaced flat STATUS_COLORS with a STATUS_BANNER map that carries background, border, text, and label values for each status variant
  • Added MONITOR_STATUS_COLORS and a graded getBarColor function for the 90-day uptime bars
  • The zero-uptime bar color issue noted in previous review rounds has been resolved — getBarColor(0) now correctly returns red (#ef4444) with no hasData gate
  • Monitor display is capped at MAX_MONITORS = 3 with the remainder summarised as a plain text count
  • The revalidate = 60 edge-cache setting is preserved on both routes

Confidence Score: 5/5

Safe to merge — no new critical issues introduced; the 0%-uptime bar colour bug from previous review is resolved.

All remaining concerns (degraded per-monitor status icon, schema mismatch) were already flagged in earlier review rounds and are pre-existing API-layer issues unrelated to this PR. The new rendering logic is straightforward, error-safe (null data falls back cleanly), and the getBarColor function correctly handles the full 0–100 uptime range.

No files require special attention.

Important Files Changed

Filename Overview
apps/dashboard/app/status/[slug]/opengraph-image.tsx Complete redesign of the status page OG image; adds monitor uptime bars, styled status banner, and the Databuddy wordmark SVG. No new critical issues beyond those already flagged in previous threads.
apps/dashboard/app/status/[slug]/twitter-image.tsx New file; re-exports the OG image handler so Twitter/X and Open Graph cards share one implementation.

Sequence Diagram

sequenceDiagram
    participant Browser
    participant Next.js OG Handler
    participant publicRPCClient
    participant statusPageRouter

    Browser->>Next.js OG Handler: GET /status/[slug]/opengraph-image
    Next.js OG Handler->>publicRPCClient: statusPage.getBySlug({ slug, days: 90 })
    publicRPCClient->>statusPageRouter: POST /statusPage/getBySlug
    statusPageRouter-->>publicRPCClient: { organization, overallStatus, monitors[] }
    publicRPCClient-->>Next.js OG Handler: data (or null on error)
    Note over Next.js OG Handler: Slice monitors to MAX_MONITORS=3<br/>Compute banner from overallStatus<br/>Render bar chart via getBarColor()
    Next.js OG Handler-->>Browser: image/png (1200x630, revalidate=60s)
Loading

Reviews (2): Last reviewed commit: "fix: handle 0% uptime days as real data ..." | Re-trigger Greptile

Comment on lines +48 to +68
function getBarColor(uptime: number, hasData: boolean): string {
if (!hasData) {
return THEME.secondary;
}
if (uptime >= 99.9) {
return "#10b981";
}
if (uptime >= 99) {
return "#fcd34d";
}
if (uptime >= 97) {
return "#fbbf24";
}
if (uptime >= 95) {
return "#f59e0b";
}
if (uptime >= 90) {
return "#f97316";
}
return "#ef4444";
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Zero-uptime days shown as "no data"

getBarColor treats uptime_percentage === 0 as having no data because hasData is computed as day.uptime_percentage > 0. However, a day where every check failed is real data — it should render red (#ef4444) to indicate a complete outage, not THEME.secondary (the grey "no data" colour).

The API only returns rows for days that have at least one recorded check, so every entry in monitor.dailyData represents actual data. Days with no data are already handled separately by the Array.from({ length: Math.max(0, BAR_DAYS - barDays.length) }) padding below. Passing uptime > 0 as hasData therefore incorrectly hides 0 % outage days.

Suggested change
function getBarColor(uptime: number, hasData: boolean): string {
if (!hasData) {
return THEME.secondary;
}
if (uptime >= 99.9) {
return "#10b981";
}
if (uptime >= 99) {
return "#fcd34d";
}
if (uptime >= 97) {
return "#fbbf24";
}
if (uptime >= 95) {
return "#f59e0b";
}
if (uptime >= 90) {
return "#f97316";
}
return "#ef4444";
}
function getBarColor(uptime: number): string {
if (uptime >= 99.9) {
return "#10b981";
}
if (uptime >= 99) {
return "#fcd34d";
}
if (uptime >= 97) {
return "#fbbf24";
}
if (uptime >= 95) {
return "#f59e0b";
}
if (uptime >= 90) {
return "#f97316";
}
return "#ef4444";
}

And update the call site accordingly:

backgroundColor: getBarColor(day.uptime_percentage),

Comment on lines +282 to +297
{monitorStatus === "degraded" ? (
<path
d="M12 7v6M12 16v1"
fill="none"
stroke="#fff"
strokeLinecap="round"
strokeWidth="2.5"
/>
) : monitorStatus === "down" ? (
<path
d="M8 8l8 8M16 8l-8 8"
fill="none"
stroke="#fff"
strokeLinecap="round"
strokeWidth="2.5"
/>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 "degraded" monitor status is never reached

The RPC output schema for individual monitors only allows currentStatus: z.enum(["up", "down", "unknown"])"degraded" is intentionally excluded (see packages/rpc/src/routers/status-page.ts line 31). As a result, the monitorStatus === "degraded" branch for the per-monitor status icon will never render. The fallback else branch (the checkmark) is displayed for both "up" and any unrecognised value.

If the intent is to display a degraded icon when a monitor is partially failing, the monitorSchema in the router would need to be updated to include "degraded" first.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel vercel Bot temporarily deployed to Preview – databuddy-links March 30, 2026 00:15 Inactive
@vercel vercel Bot temporarily deployed to Preview – documentation March 30, 2026 00:15 Inactive
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel vercel Bot temporarily deployed to Preview – databuddy-links March 30, 2026 00:17 Inactive
@vercel vercel Bot temporarily deployed to Preview – documentation March 30, 2026 00:17 Inactive
@mezotv mezotv marked this pull request as ready for review March 30, 2026 00:17
@izadoesdev izadoesdev merged commit c95c5d5 into databuddy-analytics:main Mar 30, 2026
12 of 13 checks passed
@mezotv mezotv deleted the feat/dynamic-status-og-image branch March 30, 2026 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants