Skip to content
LienThuan04 edited this page Dec 1, 2026 · 4 revisions

Waka-TRACE icon

Waka-TRACE Wiki

TRACE is the Telemetry Render & Activity Coding Engine: coding activity SVG snapshots for GitHub profile READMEs and live auto-resizing embeds for personal websites, maintained by LianHarman(LienThuan04). Everything is on this one page.

Quick start: Enable both public profile checkboxes in WakaTime (see WakaTime and Wakapi setup), open Card Studio (/), enter your username or User ID, pick a layout and pattern, and copy Markdown, Picture, HTML, Live iframe, SVG URL, or JSON. No WakaTime API key is required for public profiles.

Contents

  1. Card Studio
  2. Themes
  3. Style axes, patterns, and icons
  4. Options
  5. WakaTime and Wakapi setup
  6. Public API vs. server-only owner API key
  7. README snapshot
  8. Live card
  9. Self-hosting and environment variables
  10. Deploying to Vercel and Cloudflare Workers
  11. Caching and GitHub Camo
  12. SVG size and performance tips
  13. Troubleshooting
  14. Development
  15. Feedback and ideas

Card Studio

Card Studio runs at the root route / of your Waka-TRACE deployment. It renders live previews using the exact React theme components shared by /live/{username} and can switch directly to the /api/{username} SVG snapshot (loaded as a standalone image) to verify GitHub README parity before copying embed code.

  1. Identity & Source (01 Identity & Source):

    • Username or WakaTime User ID starts blank so visitors can type immediately without clearing a prefilled handle. Leading @ characters are stripped automatically.
    • Display name also starts blank (Optional custom name), while Card title defaults to empty placeholder Coding Activity.
    • When the username input is blank, Studio previews the instance's configured demo handle (NEXT_PUBLIC_DEMO_USERNAME / NEXT_PUBLIC_DEMO_DISPLAY_NAME). Typing any valid handle (^[A-Za-z0-9_.-]{1,64}$) automatically switches the preview toggle to Live API so you immediately see live stats for that profile.
    • Provider selects WakaTime (Public API) (source=wakatime) or Wakapi (Compat API) (source=wakapi).
    • Time range lists auto (profile default), last_7_days, last_30_days, last_6_months, last_year, and all_time. Same-day today is only shown when the server has WAKATIME_API_KEY + WAKATIME_OWNER_USERNAME configured and the active handle matches WAKATIME_OWNER_USERNAME (see Public API vs. server-only owner API key).
  2. Theme picker (02 Pick a Theme):

    • Choose among all 10 themes (Editorial, Bento, Terminal, Glass, Wave, Compact, Neon, Badge, Mesh, Blueprint).
    • Selecting a theme automatically applies that theme's default width (460px for most cards, 480px for bento/terminal/blueprint, auto-sized pill width for badge).
    • The grid ends with a Coming soon tile (SOON · Suggest a theme or feature) linked to FEEDBACK_URL.
  3. Style & Visibility (03 Style & Visibility):

    • Controls are filtered dynamically to the selected theme's supportedParams list (Filtered for <Theme>). Unsupported controls never appear in Studio and are stripped from generated URLs.
    • <ColorControl /> provides quick swatches (including Auto, Transparent, Gradient, GitHub dark/light tones), a native color picker, and direct hex entry for bg and accent.
    • <GradientControl /> appears automatically whenever bg=gradient, border=gradient, an atmospheric/glow pattern (grid_glow, aurora, spotlight, horizon, mesh) is active, theme is glass or mesh, or 2+ custom gradient stops are set. Adjust 2–4 color stops and gradient_angle (0–360°).
    • <PatternControl /> displays a visual thumbnail grid for all 14 PatternCraft-inspired patterns, plus Intensity (pattern_opacity 5–100%), Scale (pattern_scale 50–200%), Pattern color swatches/picker (pattern_color), and a local Reset action.
    • Toggle switches control animated, hide_header, hide_total, hide_daily_avg, hide_best_day, hide_langs, hide_projects, hide_editors, hide_os, hide_categories, hide_percent, and hide_other. Enabling Projects reveals the Max projects slider (1–5).
  4. Preview stage & embed output:

    • Data mode: switch between Live API (fetches /api/{username}/stats with a 5-minute refresh interval) and Sample Data (offline rich fixture data for exploring layouts even if a new WakaTime account has 0 aggregated seconds yet).
    • Render target: switch between Card (direct React render) and SVG URL (rendered as a standalone SVG image from /api/{username}).
    • Stage backdrop: test how bg=transparent and glow borders behave over dark, light, or checker backgrounds.
    • Embed tabs: copy Markdown, HTML, Picture (<picture> dark/light media query), Live iframe (includes safe wt:height auto-resize script), SVG URL, or JSON (/api/{username}/stats). Studio omits options equal to their defaults so URLs stay concise. Reset clears Username, Display name, Title, and restores DEFAULT_OPTIONS.

↑ Back to contents

Themes

All 10 built-in themes implement docs/THEME-CONTRACT.md: pure React components rendered to inline SVG via renderToStaticMarkup (react-dom/server.edge), zero external image or font network fetches, deterministic measure() height calculation matching the rendered layout, automatic WCAG sRGB contrast polarity switching on custom backgrounds or gradients, and inline active IDE header emblems via IdeMark.

Theme Aesthetic / Use case Width range & default Sample dark size
editorial Signature deep indigo & warm alabaster paper surface with crisp hierarchy 300–900 (default 460) 460×364 (460×456 with projects)
bento Modular multi-tile dashboard grid separating metrics, languages, and telemetry 320–900 (default 480) 480×396
terminal Monospace command-line telemetry frame with traffic-light prompt chrome 320–900 (default 480; defaults to mono font) 480×330
glass Frosted translucent layered panels over a subtle multi-stop ambient wash 300–900 (default 460) 460×380
wave Liquid curved banner colored by your #1 language with automatic ink contrast 300–900 (default 460) 460×360
compact Slim 100px README strip highlighting primary language, total time, and bar 300–900 (default 460) 460×100 (88 high on error notice)
neon High-contrast luminescent frame and glowing metric highlights 300–900 (default 460) 460×364
badge Compact 32px shields-style pill showing handle, total time, and top language 180–520 auto-sized; ignores width; fixed 32 high 362×32
mesh Multi-corner studio gradient mesh wash with luminous typography and balanced tiles 300–900 (default 460) 460×362
blueprint Precision technical drafting sheet with twin crosshair grid lines and coordinate metadata 320–900 (default 480) 480×362

Dark and light previews

Every preview below comes directly from the deterministic offline SVG generator (public/examples/) built from sanitized fixture metrics. Browse the interactive browser gallery at public/examples/index.html.

Theme Dark Mode Light Mode
editorial Editorial dark Editorial light
bento Bento dark Bento light
terminal Terminal dark Terminal light
glass Glass dark Glass light
wave Wave dark Wave light
compact Compact dark Compact light
neon Neon dark Neon light
badge Badge dark Badge light
mesh Mesh dark Mesh light
blueprint Blueprint dark Blueprint light

Notice states, projects grid, and contrast

State / Feature What it verifies Preview
Projects grid (hide_projects=false) Renders top active project chips (max_projects=1..5) below the languages chart with adjusted card height (456px) Editorial with projects
Empty coding window (empty) Clean, informative empty notice returned as HTTP 200 when a new account has 0 aggregated seconds yet Editorial empty notice
Private profile notice (private) Step-by-step fix card pointing to the two WakaTime Profile Settings checkboxes without breaking README <img> tags Editorial private notice
Wave bright language contrast When the #1 language has a bright swatch (like JavaScript #f1e05a), the liquid wave automatically switches overlay text ink to dark charcoal Wave bright background contrast

Supported options by theme

Every theme validates options against its declared supportedParams. Passing an unsupported query parameter is harmless (it is ignored gracefully) and Studio automatically hides unsupported controls:

Theme group Supported parameters Special notes
Full themes (editorial, bento, terminal, glass, wave, neon, mesh, blueprint) All 34 OPTION_NAMES terminal forces font=mono unless another font is explicitly chosen; editorial, glass, and neon automatically yield their default ambient glow when a light-based pattern (aurora, spotlight, horizon, mesh, grid_glow) is selected
compact 25 parameters: theme, mode, range, source, accent, bg, radius, width, animated, lang_icon, display_name, title, hide_total, hide_langs, hide_percent, hide_other, hide_header, plus all surface params (pattern, pattern_color, pattern_opacity, pattern_scale, border, font, gradient, gradient_angle) Single-strip 100px layout omits secondary stats (daily_avg, best_day), project chips, footer rows, and multi-language chart_style
badge 16 parameters: theme, mode, range, source, accent, bg, gradient, gradient_angle, radius, font, border, lang_icon, display_name, hide_total, hide_langs, hide_other Width is calculated dynamically from label + total + top language (180–520px), height is fixed at 32px, and corner radius is capped at 16px

↑ Back to contents

Style axes, patterns, and icons

All visual customization options compose cleanly across SVG snapshots and live browser renders using inline SVG geometry, CSS gradients, and system font stacks — with zero external runtime network requests.

Language chart styles

Pass chart_style=<value> on any full-size theme (bar is default):

Value Description Preview (editorial dark)
bar Clean horizontal bars scaled proportionally to coding share with rounded caps chart_style=bar
stacked Unified multi-segment ribbon bar followed by compact language legend entries chart_style=stacked
blocks Segmented 10-cell horizontal equalizer meter per language chart_style=blocks
pills High-density wrapped rounded badges displaying language marker, name, and share chart_style=pills
ring Concentric SVG donut breakdown paired alongside a ranked language legend chart_style=ring
dots Crisp minimalist proportional dot matrix next to each language row chart_style=dots

Active IDE logos and language SVG icons

Waka-TRACE bundles tree-shaken subpath icons from thesvg directly into server & client builds. normalizeInlineSvg() (src/card/parts/ide-icons.tsx) strips outer <svg> XML chrome, normalizes dark/light icon variants (#000 / #281733 / omitted root fill), and scopes every gradient, clipPath, and mask ID with a unique prefix (wt-ide-... / wt-lg-...) so multiple cards or icons on one README page never collide.

Mode (lang_icon) Behavior Preview
dot (default) GitHub Linguist color dots for every language, keeping SVG byte weight minimal lang_icon=dot
svg Renders the inline thesvg logo whenever a language is recognized and falls back automatically to the Linguist colored dot for obscure or unlisted languages lang_icon=svg

31 Active IDE Header Marks (IdeMark):
The top-left header emblem automatically reflects your #1 recorded editor (editors[0].name). Supported IDEs (thesvg): VS Code, VSCodium, Cursor, Windsurf, Antigravity, Visual Studio, LazyVim, Neovim, Vim, IntelliJ IDEA, WebStorm, PyCharm, GoLand, PhpStorm, Rider, CLion, DataGrip, JetBrains Fleet, Android Studio, Xcode, Zed, Sublime Text, Emacs, Trae, Jupyter, Eclipse, Helix, Atom, Replit, Kiro, and RStudio. Unlisted editor names render a clean generic IDE vector icon, and empty telemetry states render the signature <TraceMark /> flame emblem.

57 Language SVG Icons (LanguageMarker):
Exact normalized alias matching (preventing short language names like C or R from false-matching longer strings) supports:

  • Web & Frontend: TypeScript (tsx, typescriptreact), JavaScript (jsx, javascriptreact), HTML, CSS, Sass (scss), Less, React, Vue, Svelte, Astro, SVG
  • Systems, App & General Purpose: Python, Go, Rust, Java, C, C++, C#, PHP, Ruby, Swift, Kotlin, Dart, Scala, Elixir, Haskell, Lua, Perl, R, Zig, Julia, Clojure (clojurescript), Erlang, OCaml, F#, MATLAB, Solidity, WebAssembly (wasm)
  • Shells, Data, Markup & Infra: Bash (sh, shell, shellscript), PowerShell (pwsh), Zsh, MySQL, PostgreSQL (postgres, plpgsql), SQLite, JSON (jsonc, json5), YAML (yml), TOML, Markdown, MDX, GraphQL, Prisma, Docker (dockerfile), Terraform (hcl), LaTeX (tex), CMake, XML, Nix

PatternCraft-inspired patterns and tuning

Inspired by patterncraft.fun, Waka-TRACE renders 14 subtle vector textures and layered radial glows inside <StyleLayers />. Geometric patterns include radial <mask> edge fades so lines dissolve softly toward the card border rather than terminating harshly.

Pattern (pattern) Group / Behavior Preview (editorial dark)
none (default) Clean card surface with no extra texture overlay pattern=none
dots Finely spaced geometric dot matrix with radial edge fade pattern=dots
grid Orthogonal coordinate grid overlay pattern=grid
grid_glow Orthogonal coordinate grid layered over a soft centered glow pattern=grid_glow
blueprint Dual-step engineering drafting grid with major/minor subdivisions pattern=blueprint
crosshatch Woven crisscross architectural hatch lines pattern=crosshatch
diagonal Angled parallel technical pinstripes pattern=diagonal
hex Seamless geometric honeycomb lattice pattern=hex
circuit PCB trace nodes and orthogonal circuit paths pattern=circuit
waves Flowing parallel topographic contour curves pattern=waves
aurora Dual northern-lights radial glow using theme accent or gradient stops pattern=aurora
spotlight Overhead conical beam illuminating the header and top metrics pattern=spotlight
horizon Bottom-lit atmospheric horizon glow rising behind footer telemetry pattern=horizon
mesh Multi-corner studio mesh wash blending 2–4 palette or gradient hues pattern=mesh

Pattern tuning parameters:

  • pattern_color — Optional 3/6/8-digit hex tint (default null follows accent/ink contrast automatically).
  • pattern_opacity — Integer 5–100 percentage (default 20), controlling line/dot or radial glow visibility.
  • pattern_scale — Integer 50–200 percentage (default 100), scaling geometric SVG <pattern> tile dimensions proportionally (dots, grid, grid_glow, blueprint, crosshatch, diagonal, hex, circuit, waves).

Borders and typography

6 Frame Borders (border):

Value Effect Preview
subtle (default) Clean translucent hairline stroke adapted to dark/light mode border=subtle
none Borderless surface edge border=none
accent Crisp solid 1.5px border tinted with the active accent color border=accent
gradient Multi-stop linear gradient frame driven by gradient & gradient_angle border=gradient
glow Accent perimeter with an ambient halo ring border=glow
dashed Technical dashed outline (strokeDasharray="6 4") border=dashed

5 Font Stacks (font):
Every font stack relies strictly on local/system font families (never external @font-face fetches inside SVGs so GitHub Camo renders crisply without missing glyphs).

Value CSS font stack (src/lib/style-options.ts) Preview
default var(--font-inter), "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif font=default
rounded "SF Pro Rounded", "Nunito", "Quicksand", "Segoe UI", system-ui, sans-serif font=rounded
mono ui-monospace, "SFMono-Regular", "Cascadia Code", Menlo, Consolas, monospace font=mono
serif Georgia, "Times New Roman", Cambria, serif font=serif
condensed "Bahnschrift", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif font=condensed

Custom gradients and automatic WCAG contrast

  • Pass bg=gradient alongside gradient=hex1-hex2[-hex3-hex4] (2–4 hex stops separated by - or ,, optional #) and gradient_angle=0..360 (default 135) to apply a custom linear gradient surface on any theme.
  • When fewer than 2 stops are passed, Waka-TRACE automatically builds a harmonious fallback ramp ([accent, #3f2b96, #155555]).
  • The same gradient and gradient_angle parameters also power border=gradient, atmospheric patterns (grid_glow, aurora, spotlight, horizon, mesh), glass backdrops, and mesh theme washes.
  • Automatic WCAG sRGB contrast: getEditorialPalette() computes WCAG relative luminance (isLightHex / isLightGradient) on custom hex backgrounds and gradients. Even if mode=dark, setting a bright surface such as bg=f6f8fa or a pastel gradient like gradient=fef08a-bae6fd flips card inks to dark charcoal (#292827 / theme dark ink) automatically so metrics always remain readable.

↑ Back to contents

Options

Parsing and fallback rules

All query parsing lives in src/lib/options.ts and feeds both /api/{username}, /live/{username}, and /api/{username}/stats:

  • Repeated keys: Uses the first value when a key appears multiple times.
  • Unknown keys: Silently ignored (never throw HTTP 400 or 500 on typos).
  • Per-field isolation: An invalid value for one parameter falls back independently to that field's default while keeping all other valid options intact.
  • Booleans: Strictly "true" or "false"; anything else falls back to default.
  • Numbers: Parsed as finite numbers, rounded (Math.round), and clamped to the field's [min, max] range (NaN/Infinity fall back to default).
  • Hex colors: normalizeHex() accepts 3, 6, or 8 hex digits with or without a leading # (3-digit shorthand expands automatically; invalid strings return null).
  • Text bounds: title trims whitespace and caps at 60 characters (null if empty); display_name trims whitespace and caps at 48 characters.
  • Themes: Validated against /^[a-z0-9_-]{1,32}$/i, then resolved through getTheme() (src/card/theme-registry.ts), falling back to editorial for unknown theme names.

Parameter reference

Parameter Accepted values Default Effect
theme editorial, bento, terminal, glass, wave, compact, neon, badge, mesh, blueprint editorial Card visual layout
mode dark, light dark Base palette polarity (auto-flipped when custom bg or gradient luminance demands opposite ink)
range auto, last_7_days, last_30_days, last_6_months, last_year, all_time, today auto Telemetry aggregation window (auto uses WakaTime public default; today requires server-side owner API key)
source wakatime, wakapi wakatime Telemetry provider
accent 3, 6, or 8 hex digits; optional # null (theme auto) Accent color override
bg Hex color, transparent, or gradient null (theme auto) Card surface override; custom hex and gradient trigger automatic WCAG ink contrast
gradient 2–4 hex colors separated by - or , [] Multi-stop linear gradient colors consumed by bg=gradient, border=gradient, atmospheric patterns, glass, and mesh
gradient_angle Number, 0–360 135 Linear gradient angle in degrees
radius Number, 0–48 16 Outer corner radius (badge caps at 16)
width Number, 300–900 460 (bento/terminal/blueprint 480) Card width in px (badge ignores width and auto-sizes 180–520)
animated true, false true Enables CSS progress bar, wave, and pulse animations (always respects prefers-reduced-motion)
chart_style bar, stacked, blocks, pills, ring, dots bar Top Languages visualization style
lang_icon dot, svg dot Language marker (dot Linguist dot vs. svg inline thesvg logo with automatic dot fallback)
pattern none, dots, grid, grid_glow, blueprint, crosshatch, diagonal, hex, circuit, waves, aurora, spotlight, horizon, mesh none PatternCraft-inspired background texture or atmospheric glow layer
pattern_color 3, 6, or 8 hex digits; optional # null (auto) Tint color override for geometric patterns and atmospheric glows
pattern_opacity Number, 5–100 20 Pattern / glow opacity percentage
pattern_scale Number, 50–200 100 Geometric pattern tile scale percentage (50%–200%)
border subtle, none, accent, gradient, glow, dashed subtle Card frame border style
font default, rounded, mono, serif, condensed default Font stack override (terminal and badge default to mono)
max_langs Number, 1–8 5 Maximum number of languages returned & rendered
max_projects Number, 1–5 3 Maximum number of project chips rendered when hide_projects=false
title Trimmed non-empty string, max 60 chars null (Coding Activity) Custom card header title
display_name Trimmed non-empty string, max 48 chars null Override handle label displayed next to provider metadata
hide_total true, false false Hide Total Time metric
hide_daily_avg true, false false Hide Daily Average metric
hide_best_day true, false false Hide Best Day metric
hide_langs true, false false Hide Top Languages section
hide_editors true, false false Hide top IDE / editor footer telemetry
hide_os true, false false Hide operating system footer telemetry
hide_projects true, false true Hide Projects grid (false displays top projects)
hide_categories true, false true Hide coding/debugging categories footer item
hide_header true, false false Hide the top card header row
hide_percent true, false false Hide language percentages
hide_other true, false false Filter out the Other language bucket before capping max_langs

Full URL examples

GitHub dark/light <picture> embed with SVG language icons, aurora glow, and custom projects:

<picture>
  <source media="(prefers-color-scheme: dark)" srcset="https://your-deployment.vercel.app/api/YOUR_WAKATIME_USERNAME?theme=editorial&mode=dark&chart_style=bar&lang_icon=svg&pattern=aurora&pattern_opacity=25&hide_projects=false" />
  <source media="(prefers-color-scheme: light)" srcset="https://your-deployment.vercel.app/api/YOUR_WAKATIME_USERNAME?theme=editorial&mode=light&chart_style=bar&lang_icon=svg&pattern=aurora&pattern_opacity=25&hide_projects=false" />
  <img src="https://your-deployment.vercel.app/api/YOUR_WAKATIME_USERNAME?theme=editorial&mode=dark&chart_style=bar&lang_icon=svg&pattern=aurora&pattern_opacity=25&hide_projects=false" alt="Coding Activity" width="460" height="456" />
</picture>

Blueprint card with custom tint, scale, dashed border, and monospace typography:

https://your-deployment.vercel.app/api/YOUR_WAKATIME_USERNAME?theme=blueprint&pattern=blueprint&pattern_color=38bdf8&pattern_opacity=30&pattern_scale=120&border=dashed&font=mono&lang_icon=svg

Self-hosted Wakapi user over last_30_days:

https://your-deployment.vercel.app/api/YOUR_WAKAPI_USERNAME?source=wakapi&range=last_30_days&theme=terminal

↑ Back to contents

WakaTime and Wakapi setup

WakaTime public profile checklist

  1. Install the official WakaTime plugin inside your IDE (VS Code, Cursor, Antigravity, Neovim, JetBrains, Xcode, Zed, etc.) and edit code for a few minutes.
  2. Sign in to WakaTime → Settings → Profile and enable both public stats checkboxes:
    • Display code time publicly
    • Display languages, editors, os, categories publicly
  3. Copy your WakaTime Username (e.g. LianHarman) or your WakaTime User ID UUID (e.g. 66e506fe-4593-425e-9957-fefffdd20a83 if your account does not set a public alias).
    • Valid characters (sanitizeUsername): letters, numbers, ., _, and -, 1–64 characters.
    • Leading @ symbols are stripped automatically before calling WakaTime.

Time ranges and HTTP 400 fallback

WakaTime lets users choose which single historical range is shown publicly in Profile Settings. Because of that:

  • range=auto (default) calls /api/v1/users/{username}/stats without a fixed range suffix, letting WakaTime return whichever public range your profile exposes.
  • If you request a specific range (for example range=last_30_days) that differs from your WakaTime public profile setting, WakaTime returns HTTP 400 with a "time range" error message. Waka-TRACE automatically detects HTTP 400 time-range mismatch errors (isRangeMismatchError) and transparently falls back to /users/{username}/stats (range=auto) so your README card still renders instead of failing.

Wakapi compatibility

To use Wakapi (wakapi.dev or a self-hosted Wakapi instance):

  1. Enable public stats in your Wakapi user settings.
  2. Pass source=wakapi in query parameters (or choose Wakapi (Compat API) in Card Studio).
  3. Requests automatically route to {WAKAPI_API_URL}/api/compat/wakatime/v1/users/{username}/stats/{range} (mapping auto and today safely to last_7_days, since Wakapi's WakaTime compat stats route requires an explicit range segment).
  4. Override WAKAPI_API_URL in .env or Cloudflare secrets if you host your own Wakapi domain.

↑ Back to contents

Public API vs. server-only owner API key

One of the most frequent questions when adopting Waka-TRACE is whether users need to paste a personal WakaTime API key into the web app. They do not.

Why visitors never need an API key

  • All six standard public ranges (auto, last_7_days, last_30_days, last_6_months, last_year, all_time) read WakaTime's unauthenticated public /api/v1/users/{username}/stats endpoint. Once you enable the two checkboxes in WakaTime Profile Settings, your public username or User ID is all Waka-TRACE needs.
  • Asking visitors to paste a secret WakaTime API key into a public web form or pass ?api_key=... inside a README <img> URL would leak full account read credentials in browser history, server logs, and GitHub Markdown source. Waka-TRACE never accepts API keys in URL query parameters or browser requests.
  • Why range=today is hidden for other handles: WakaTime only exposes real-time same-day activity (/api/v1/users/current/status_bar/today) to authenticated requests using WAKATIME_API_KEY. On a hosted instance, allowing another person's handle to trigger the host's WAKATIME_API_KEY would expose the host's own /users/current/ telemetry or fail. Therefore:
    1. Card Studio hides today from the Time range dropdown unless source === "wakatime", both WAKATIME_API_KEY and WAKATIME_OWNER_USERNAME are set on the server, and the active Studio handle matches WAKATIME_OWNER_USERNAME (case-insensitive, @ stripped).
    2. If another username calls /api/someone_else?range=today directly, canUseOwnerKey() returns null and Waka-TRACE falls through safely to someone_else's unauthenticated public /stats endpoint — never touching WAKATIME_API_KEY.

Enabling today on your personal deployment

When you clone or fork Waka-TRACE to run your own deployment:

  1. Copy your personal WakaTime API key (waka_...) and store it in your host's encrypted server-side environment settings (WAKATIME_API_KEY in Vercel Environment Variables or wrangler secret put WAKATIME_API_KEY on Cloudflare Workers).
  2. Set WAKATIME_OWNER_USERNAME to your exact WakaTime username or User ID (66e506fe-...). Use your User ID UUID if WakaTime returns username: null on your public stats payload.
  3. Redeploy so Server Components (src/app/page.tsx) pass ownerApiKeyEnabled and ownerUsername accurately to Card Studio.
  4. Once live, leaving Username blank (previewing your own NEXT_PUBLIC_DEMO_USERNAME) or typing your matching WAKATIME_OWNER_USERNAME unlocks today (Owner API key enabled label in Studio), while anyone else entering their own handle continues using public ranges cleanly without seeing 401 Unauthorized errors.

↑ Back to contents

README snapshot

GET /api/{username} (configured with runtime = "nodejs" in src/app/api/[username]/route.ts) produces standalone SVG documents tailored for GitHub's README image proxy (GitHub Camo):

  • Always returns HTTP 200: Even when a profile is private (401/403), still compiling (202), missing (404), invalid, or has 0 aggregated seconds yet, /api/{username} renders a styled notice card matching your chosen theme, mode, and bg with HTTP 200 so GitHub READMEs never display broken image icons.
  • Security headers: Responds with Content-Type: image/svg+xml; charset=utf-8 and X-Content-Type-Options: nosniff.
  • Self-contained rendering: Card layouts render cleanly into SVG <foreignObject> alongside inline vector pattern <defs>, mask fades, <IdeMark />, <LanguageMarker />, and scoped CSS @keyframes (wtGrow, wtWaveSlide). Zero external images, stylesheets, or @font-face URLs are requested when viewing the SVG.
  • Motion accessibility: CSS animations only emit when animated=true (default) and automatically disable inside @media (prefers-reduced-motion: reduce). Pass animated=false for completely static SVG output.

↑ Back to contents

Live card

GET /live/{username} (dynamic = "force-dynamic" in src/app/live/[username]/page.tsx) renders a transparent HTML page hosting the interactive React <LiveCard /> component (src/live/LiveCard.tsx) backed by useWakaStats:

  • Server-renders initial telemetry immediately on load, then performs a background client check 40ms after mount (and every 300ms debounced on studio option updates).
  • Automatically refreshes telemetry every 5 minutes (300,000ms) while the browser tab is visible, and triggers an immediate refresh on visibilitychange when returning to the tab.
  • Retains last known data cleanly if a background refresh fails transiently.

Iframe and auto-resize

<LiveCard /> attaches a ResizeObserver to its outer frame and posts { type: "wt:height", height } via window.parent.postMessage(...) whenever the rendered height changes. Copy Live iframe from Card Studio or use the hardened snippet below, always validating both event.origin and event.source before resizing the <iframe>:

<iframe
  id="waka-trace-card"
  src="https://your-deployment.vercel.app/live/YOUR_WAKATIME_USERNAME?theme=editorial&mode=dark&bg=transparent"
  title="Live Coding Activity"
  width="460"
  height="364"
  style="border: 0; width: 100%; max-width: 460px; background: transparent;"
  loading="lazy"
></iframe>
<script>
  (() => {
    const frame = document.getElementById("waka-trace-card");
    if (!frame) return;
    window.addEventListener("message", (event) => {
      if (event.origin !== new URL(frame.src).origin || event.source !== frame.contentWindow) return;
      const { type, height } = event.data || {};
      if (type === "wt:height" && Number.isFinite(height) && height > 0 && height < 10000) {
        frame.style.height = Math.ceil(height) + "px";
      }
    });
  })();
</script>

JSON stats API

Custom portfolio sites, Astro/Next.js components, or terminal scripts can consume normalized metrics directly from GET /api/{username}/stats:

  • Responds with HTTP 200, Content-Type: application/json; charset=utf-8, Access-Control-Allow-Origin: *, X-Content-Type-Options: nosniff, and the same edge Cache-Control headers as /api/{username}.
  • Accepts source, range, display_name, max_langs, max_projects, and hide_other.

Example response envelope:

{
  "status": "ok",
  "complete": true,
  "fromStore": false,
  "data": {
    "username": "LianHarman",
    "displayName": "LianHarman",
    "source": "wakatime",
    "range": "last_7_days",
    "rangeLabel": "Last 7 Days",
    "totalSeconds": 124560,
    "totalText": "34 hrs 36 mins",
    "dailyAverageText": "4 hrs 56 mins",
    "bestDay": { "date": "2026-11-28", "text": "7 hrs 18 mins", "totalSeconds": 26280 },
    "languages": [{ "name": "TypeScript", "percent": 62.4, "text": "21 hrs 35 mins", "color": "#3178c6" }],
    "editors": [{ "name": "VS Code", "percent": 82.0, "text": "28 hrs 22 mins", "color": "#8c72df" }],
    "operatingSystems": [{ "name": "Windows", "percent": 100.0, "text": "34 hrs 36 mins", "color": "#8c72df" }],
    "projects": [{ "name": "Waka-TRACE", "percent": 68.0, "text": "23 hrs 31 mins", "color": "#8c72df" }],
    "categories": [{ "name": "Coding", "percent": 94.2, "text": "32 hrs 35 mins", "color": "#8c72df" }]
  },
  "error": null
}

↑ Back to contents

Self-hosting and environment variables

Clone Waka-TRACE to customize defaults, host behind your own domain, enable the optional Upstash Redis snapshot cache, or unlock private range=today telemetry for your own profile:

git clone https://github.com/LienThuan04/Waka-TRACE.git
cd Waka-TRACE
pnpm install --frozen-lockfile
cp .env.example .env
pnpm dev

Never commit .env (already listed in .gitignore). Full environment table from .env.example:

Variable Default / Required Scope Purpose
WAKATIME_API_URL https://wakatime.com/api/v1 Server Base URL for WakaTime v1 requests
WAKAPI_API_URL https://wakapi.dev Server Base URL for Wakapi compat routes (source=wakapi)
WAKATIME_API_KEY Optional (empty) Server only Optional personal WakaTime API key unlocking range=today for WAKATIME_OWNER_USERNAME; never exposed to browsers or URL params
WAKATIME_OWNER_USERNAME Optional (empty) Server (page.tsx + client.ts) Exact WakaTime username or UUID matching WAKATIME_API_KEY so today is enabled only for your own handle
NEXT_PUBLIC_SITE_URL Optional (empty) Build / Public Public origin embedded into generated Studio URLs; falls back to x-forwarded-host / host headers when empty
NEXT_PUBLIC_DEMO_USERNAME Owner demo ID Build / Public Default preview user loaded in Studio when the Username input is left blank
NEXT_PUBLIC_DEMO_DISPLAY_NAME LianHarman Build / Public Display name paired with NEXT_PUBLIC_DEMO_USERNAME when no custom display name is typed
FEEDBACK_URL https://github.com/LienThuan04 Server Destination URL for Studio's Coming soon tile and footer feedback link
KV_REST_API_URL (UPSTASH_REDIS_REST_URL) Optional (empty) Server only Upstash Redis REST endpoint used for snapshot fallback caching (https:// or localhost http:// only)
KV_REST_API_TOKEN (UPSTASH_REDIS_REST_TOKEN) Optional (empty) Server only Bearer token for Upstash Redis REST API
WAKA_STORE On when URL + token set (off disables) Server Set WAKA_STORE=off to disable Redis snapshot reads/writes explicitly

↑ Back to contents

Deploying to Vercel and Cloudflare Workers

Vercel

  1. Push your fork or clone to GitHub and import the repository in Vercel.
  2. Ensure Node.js Version matches 24.x (package.json engines.node) and pnpm@12.21.0 (packageManager) — Vercel uses pnpm install --frozen-lockfile and pnpm build automatically.
  3. Optional environment variables in Project Settings → Environment Variables:
    • NEXT_PUBLIC_DEMO_USERNAME and NEXT_PUBLIC_DEMO_DISPLAY_NAME (your own default handle and display name in Studio).
    • NEXT_PUBLIC_SITE_URL (your production https://... domain).
    • WAKATIME_API_KEY and WAKATIME_OWNER_USERNAME if you want range=today on your personal instance.
    • KV_REST_API_URL and KV_REST_API_TOKEN (from Upstash Redis / Vercel Marketplace Redis integration) to serve cached snapshots during WakaTime 202 compiling responses.
  4. Smoke test after deploy:
    • / — loads Card Studio with empty Username/Display name fields.
    • /api/YOUR_WAKATIME_USERNAME — returns Content-Type: image/svg+xml; charset=utf-8 with HTTP 200.
    • /api/YOUR_WAKATIME_USERNAME/stats — returns normalized JSON with HTTP 200.
    • /live/YOUR_WAKATIME_USERNAME — renders transparent live card.

Cloudflare Workers

Waka-TRACE ships preconfigured for OpenNext (@opennextjs/cloudflare) via wrangler.jsonc and open-next.config.ts:

pnpm preview   # opennextjs-cloudflare build && preview locally in workerd
pnpm deploy    # build & deploy Worker to Cloudflare

Store WAKATIME_API_KEY, KV_REST_API_URL, and KV_REST_API_TOKEN using wrangler secret put — never hardcode secrets inside wrangler.jsonc. Complete setup, custom domains, compatibility flags, and troubleshooting steps are in docs/DEPLOY-CLOUDFLARE.md.

↑ Back to contents

Caching and GitHub Camo

GitHub proxies every external Markdown image through GitHub Camo, which enforces a short upstream fetch deadline (~4 seconds) and caches image responses downstream. Waka-TRACE pairs fast timeouts with a two-tier cache policy (src/lib/cache-policy.ts):

Response state Cache-Control header Behavior
Complete snapshot (result.complete === true) public, max-age=0, s-maxage=300, stale-while-revalidate=3600 Browsers revalidate immediately; edge CDN serves warm snapshots for 5 minutes (300s) and can serve stale for 1 hour (3600s) while refreshing asynchronously so Camo never blocks
Partial / Cached fallback / Compiling / Error (result.complete === false) public, max-age=0, s-maxage=30 Short 30-second edge TTL without stale-while-revalidate so private toggle changes, finished 202 compilations, or recovered upstreams clear rapidly

Resilience details (src/lib/waka/client.ts & src/lib/waka/stats-store.ts):

  • Upstream WakaTime/Wakapi fetches abort cleanly at 4000ms (UPSTREAM_TIMEOUT_MS), protecting GitHub Camo from gateway timeouts.
  • When optional Upstash Redis REST env vars are present (KV_REST_API_URL / UPSTASH_REDIS_REST_*), every successful snapshot is written under key waka-trace:v1:{source}:{username}:{range} with a 7-day TTL (604800s, fail-open 1500ms timeout).
  • If WakaTime returns HTTP 202 (compiling), HTTP 5xx, an unreadable payload, or times out, Waka-TRACE serves the cached Redis snapshot (fromCache: true, complete: false, 30s edge TTL) instead of degrading to an error card.

Inspect live headers and payload size directly with curl:

curl -sI "https://your-deployment.vercel.app/api/YOUR_WAKATIME_USERNAME?theme=editorial"

↑ Back to contents

SVG size and performance tips

Every Waka-TRACE theme renders clean vector primitives and CSS variables without base64 bitmaps or embedded webfont blobs. Measured offline example sizes (public/examples/manifest.json):

  • badge pill: ~5.8 KB (5,836 B)
  • compact strip: ~8.0 KB (8,025 B)
  • terminal card: ~9.3 KB (9,260 B)
  • Standard full themes (editorial, bento, glass, wave, neon, mesh, blueprint): ~13.6–15.5 KB
  • editorial with lang_icon=svg (5 inline thesvg language vectors): ~20.2 KB (20,175 B)

Practical tips for fast README loads:

  • Keep lang_icon=dot (default) when embedding several full cards side by side, or use lang_icon=svg selectively on your hero card (still ~20 KB, well inside GitHub Camo limits).
  • Use theme=compact or theme=badge inside profile README badges or dense dashboard grids.
  • Omit options equal to their defaults (theme=editorial&mode=dark etc.) — Card Studio strips default parameters automatically to keep URLs clean.
  • Keep hide_projects=true (default) unless showcasing project breakdowns, and pass animated=false when preferring zero CSS animation overhead.

↑ Back to contents

Troubleshooting

Profile stats are private

Card notice: Profile stats are private (status: "private", triggered on HTTP 401/403 or is_coding_activity_visible === false).

  1. Open WakaTime Settings → Profile.
  2. Enable both:
    • Display code time publicly
    • Display languages, editors, os, categories publicly
  3. Save profile settings and wait up to 30–60 seconds for edge cache (s-maxage=30) to clear.

No public coding activity yet

Card notice: No public coding activity yet (status: "empty", totalSeconds <= 0 and languages.length === 0).

  • Brand-new WakaTime accounts or newly enabled public stats often report 0 seconds until WakaTime finishes aggregating the first completed day in your public range.
  • Keep coding with the WakaTime plugin active, or verify whether your WakaTime account's public profile range matches an active window. Meanwhile, click Sample Data in Card Studio to design your card styling.

Compiling coding stats

Card notice: Compiling coding stats (status: "compiling", HTTP 202 or is_up_to_date === false with zero metrics).

  • WakaTime calculates statistics lazily when an uncached range is requested for the first time.
  • Wait 1–2 minutes and refresh. Self-hosters who configure Upstash Redis (KV_REST_API_URL / KV_REST_API_TOKEN) automatically serve the previous cached snapshot while WakaTime finishes compiling.

Time range mismatch

  • WakaTime returns HTTP 400 if ?range=last_30_days (or another explicit range) is requested while your WakaTime public settings only expose a different window (for instance last_7_days or all_time).
  • Waka-TRACE detects "time range" HTTP 400 responses automatically and retries /users/{username}/stats (range=auto), returning your configured public window seamlessly. To show another range on public profiles, change the public range inside WakaTime Settings.

Today range missing in Card Studio

  • today is intentionally hidden unless all three conditions hold: source=wakatime, server env vars WAKATIME_API_KEY + WAKATIME_OWNER_USERNAME are both set, and the active handle in Studio matches WAKATIME_OWNER_USERNAME.
  • Double-check whether your WakaTime account uses a UUID User ID instead of a public username alias (WAKATIME_OWNER_USERNAME must match the exact handle or UUID).
  • If deploying for personal use, configure both variables on Vercel or Cloudflare Workers and redeploy.

WakaTime user not found

Card notice: WakaTime user not found (status: "not_found", HTTP 404).

  • Verify spelling at https://wakatime.com/@YOUR_USERNAME.
  • If you never claimed a WakaTime @username alias, paste your UUID User ID instead (found in your WakaTime Profile URL or Account Settings).

Invalid username

Card notice: Invalid username (status: "invalid_username").

  • Ensure the path segment /api/{username} only uses A–Z, a–z, 0–9, ., _, or - (1–64 characters). Leading @ is stripped cleanly in Studio and API helpers.

Broken or stale README image

  • Check /api/YOUR_WAKATIME_USERNAME directly in your browser. If it displays cleanly there, GitHub Camo is simply serving an older cached snapshot (s-maxage=300, SWR 3600s + Camo proxy TTL). Wait a few minutes or purge Camo by appending/removing a benign option change when updating your README.
  • Verify no reverse proxy or deployment protection (such as Vercel Deployment Protection SSO) intercepts anonymous GitHub Camo requests to /api/*.

Live iframe clipped or stuck at default height

  • Ensure you copied the entire Live iframe snippet including the inline <script>.
  • Verify the listener checks new URL(frame.src).origin and frame.contentWindow — if a reverse proxy rewrites the src host or if an intermediate wrapper strips postMessage, height updates (wt:height) are ignored for safety.

↑ Back to contents

Development

Prerequisites: Node.js 24.x, pnpm@12.21.0 (run pnpm.cmd on Windows PowerShell), and Python 3 (for doc/anchor link checking).

Command Purpose
pnpm dev Start Next.js development server at http://localhost:3000
pnpm lint Run ESLint across all TypeScript/React/config files
pnpm typecheck Run TypeScript typechecking (tsc --noEmit)
pnpm test Execute full Vitest unit & integration suite (tests/*.test.ts[x])
pnpm examples Regenerate all 56 deterministic offline SVGs, public/examples/index.html, and public/examples/manifest.json
pnpm build Build production Next.js app (Vercel / Node)
pnpm start Serve production Next.js build
pnpm preview Build and preview locally on Cloudflare Workers runtime (opennextjs-cloudflare)
pnpm deploy Build and deploy to Cloudflare Workers (opennextjs-cloudflare)
python scripts/check-doc-links.py Validate all local paths, anchors, and repository image references across README.md, wiki/Home.md, and docs/DEPLOY-CLOUDFLARE.md (--remote checks live URLs too)

Generate and inspect examples

scripts/generate-examples.ts renders 56 deterministic offline SVG fixtures without network calls:

  • 20 theme dark/light previews (10 themes × 2 modes)
  • 4 showcase states (editorial-projects-dark, editorial-empty-dark, editorial-private-dark, wave-js-contrast-dark)
  • 32 style axis previews (6 chart_style, 1 lang_icon=svg, 14 pattern, 6 border, 5 font)

Output writes to public/examples/ with exact dimensions, byte weights, and SHA-256 checksums recorded in public/examples/manifest.json. Every generated SVG is validated by tests/examples.test.ts for strict XML well-formedness (@xmldom/xmldom), zero external http:///https:// image URLs, and consistent dimensions.

Add or modify a theme

Follow docs/THEME-CONTRACT.md and docs/DESIGN.md:

  1. Implement src/card/themes/<name>.tsx with pure rendering (target: "svg" | "live"), deterministic measure(), IdeMark, LanguageMarker, <StyleLayers />, and explicit supportedParams.
  2. Register the theme in src/lib/options.ts (THEME_CHOICES) and src/card/theme-registry.ts (themes & THEME_WIDTHS), plus its Studio blurb in src/components/studio/CardStudio.tsx.
  3. Add test coverage in tests/themes.test.tsx and tests/registry.test.ts (including light/dark contrast, hide flags, project rows, and notice states).
  4. Run pnpm examples, pnpm lint, pnpm typecheck, pnpm test, python scripts/check-doc-links.py, and pnpm build, then update README.md and this wiki page.

Architecture references & CI

↑ Back to contents

Feedback and ideas

More themes and telemetry integrations are always welcome. Suggest a new theme layout, pattern, language alias, IDE mark, or bug fix through:

↑ Back to contents