Skip to content

feat: add custom 404 page with Rudderstack docs_404 tracking#191

Merged
rachaelrenk merged 2 commits into
mainfrom
oz/fix-404-instrumentation
Jun 8, 2026
Merged

feat: add custom 404 page with Rudderstack docs_404 tracking#191
rachaelrenk merged 2 commits into
mainfrom
oz/fix-404-instrumentation

Conversation

@rachaelrenk

Copy link
Copy Markdown
Contributor

Summary

Adds a custom src/pages/404.astro page that overrides Starlight's built-in 404 to fire a Rudderstack docs_404 track event with the originally-requested broken URL.

Why this matters: Every 404 visit currently logs https://docs.warp.dev/404/ as the page URL in analytics. This means we have ~3,800 broken-URL visits/week but zero visibility into which URLs are broken. With this change, the event captures broken_url (the actual path the visitor tried to reach) and referrer, enabling the weekly automated 404 monitoring agent (Step 5 of the redirect-fix plan) to surface the top missing redirects.

Changes

src/pages/404.astro (new file)

  • Uses StarlightPage to inherit full site chrome (nav, custom Head, Rudderstack snippet, Vercel Analytics)
  • Adds an is:inline script that fires window.rudderanalytics.track('docs_404', { broken_url, referrer }) via the existing RS queue pattern — works reliably before the async SDK finishes loading
  • Minimal "Page not found" content with a link back to home

Testing

  • npm run build passes (337 pages built)
  • Page inherits the same Rudderstack, Vercel Analytics, and Kapa AI setup as all other pages

Part of

Broken redirects fix plan — Step 1 (instrumentation prerequisite for all other steps).

Co-Authored-By: Oz oz-agent@warp.dev

Overrides Starlight's built-in 404 to fire a `docs_404` track event
via Rudderstack with the originally-requested broken URL and referrer.

Without this, every 404 hit logs https://docs.warp.dev/404/ as the
page URL in analytics — hiding which paths are actually broken. The
new event captures `broken_url` (window.location.href) and
`referrer` (document.referrer) so we can identify the top missing
redirects and fix them systematically.

The script uses the RS queue pattern (is:inline + window.rudderanalytics)
so it fires reliably before the async SDK finishes loading.

Part of the broken-redirects fix plan.

Co-Authored-By: Oz <oz-agent@warp.dev>
@cla-bot cla-bot Bot added the cla-signed label Jun 8, 2026
@vercel

vercel Bot commented Jun 8, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Jun 8, 2026 6:31pm

Request Review

@oz-for-oss

oz-for-oss Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

@rachaelrenk

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@oz-for-oss oz-for-oss Bot left a comment

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.

Overview

This PR adds a custom src/pages/404.astro page that uses Starlight chrome and emits a docs_404 RudderStack event for missing docs URLs. No approved spec context was available, so this review is based on the attached PR description and annotated diff.

Concerns

  • The new telemetry payload sends the full requested URL and full referrer to analytics, which can include query strings or fragments containing sensitive values. Capture only the redirect-monitoring data needed, or redact sensitive components before tracking.

Security

  • Full 404 URLs and referrers can contain tokens, email addresses, OAuth codes, or other private values; avoid sending them unredacted to RudderStack.

Verdict

Found: 0 critical, 1 important, 0 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Comment thread src/pages/404.astro Outdated
@rachaelrenk rachaelrenk self-assigned this Jun 8, 2026
Co-authored-by: oz-for-oss[bot] <277970191+oz-for-oss[bot]@users.noreply.github.com>
@rachaelrenk rachaelrenk merged commit cfa40ed into main Jun 8, 2026
8 checks passed
@rachaelrenk rachaelrenk deleted the oz/fix-404-instrumentation branch June 8, 2026 18:32
rachaelrenk added a commit that referenced this pull request Jun 8, 2026
Adds a new Oz skill + helper script for a recurring Monday morning
agent that surfaces broken docs.warp.dev URLs, diffs them against
vercel.json, and posts a Slack summary.

The skill (SKILL.md) defines the full runbook:
- Queries stg_website_events for docs_404 track events (past 7 days)
- Loads vercel.json redirect sources from disk or GitHub raw URL
- Identifies uncovered broken URLs and computes week-over-week delta
- Posts a Block Kit Slack summary to the docs team channel
- Writes a CSV artifact to data/404-reports/ (run artifact, not committed)
- Handles no-data state (when PR #191 hasn't been live long enough)
- Handles failure gracefully with Slack error notices

The helper (run_404_report.py) implements the BigQuery queries via
Metabase API, diff logic, and CSV writing. Outputs JSON summary to
stdout for the agent to use when constructing the Slack message.

Schedule: every Monday 9am PT (cron: 0 17 * * 1 UTC).
Deploy via oz.warp.dev once METABASE_API_KEY, SLACK_BOT_TOKEN, and
SLACK_CHANNEL_ID are sSLACK_CHANNEL_ID are sSLACK_CHANNEL_ID a
Part of the broken-redirecPart of the broken-redirecPart of the broken-regent@warp.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants