Skip to content

Add Vercel Speed Insights to project - #2

Open
vercel[bot] wants to merge 1 commit into
mainfrom
vercel/vercel-speed-insights-to-proje-5texxr
Open

vercel[bot] wants to merge 1 commit into
mainfrom
vercel/vercel-speed-insights-to-proje-5texxr

Conversation

@vercel

@vercel vercel Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Vercel Speed Insights Implementation

Summary

Successfully installed and configured Vercel Speed Insights for the AnimeTV project following the latest official documentation from Vercel.

What Was Implemented

1. Package Installation

  • Installed @vercel/speed-insights version 2.0.0 via npm
  • Updated package.json with the new dependency
  • Generated new package-lock.json with the Speed Insights package and its dependencies

2. Speed Insights Initialization Script

Created js/speed-insights.js - a vanilla JavaScript initialization script that:

  • Initializes the Speed Insights queue (window.si and window.siq)
  • Dynamically loads the Vercel Speed Insights script from /_vercel/speed-insights/script.js
  • Adds proper SDK metadata (name and version)
  • Includes error handling for script loading failures
  • Runs on DOM ready to ensure proper initialization

3. HTML Integration

Modified both web and Android HTML files to include the Speed Insights script:

  • Added <script defer src="js/speed-insights.js?v=645"></script> to index.html
  • Added the same script tag to android/app/src/main/assets/index.html
  • Positioned the script early in the head section for optimal loading

4. Android Assets

  • Created android/app/src/main/assets/js/ directory
  • Copied speed-insights.js to Android assets to maintain mirror sync

Files Created

  • /js/speed-insights.js - Speed Insights initialization script
  • /android/app/src/main/assets/js/speed-insights.js - Android mirror copy

Files Modified

  • /index.html - Added Speed Insights script tag
  • /android/app/src/main/assets/index.html - Added Speed Insights script tag
  • /package.json - Added @vercel/speed-insights dependency
  • /package-lock.json - Updated with new dependency tree

Implementation Approach

This is a vanilla JavaScript/HTML project (not React, Next.js, or other frameworks), so I used the generic Speed Insights implementation approach:

  1. Created a self-contained initialization script that follows Vercel's recommended pattern
  2. The script initializes the Speed Insights queue before the main script loads
  3. Dynamically injects the Vercel Speed Insights script tag with proper configuration
  4. Uses the default Vercel endpoint /_vercel/speed-insights/script.js which is automatically available on Vercel deployments

Verification Steps Completed

✅ Package successfully installed with npm
✅ Build completed successfully (npm run vercel-build)
✅ All syntax checks passed (npm run check)
✅ All tests passed (metadata, seasons, loading tests)
✅ Mirror sync validated (Android assets match web assets)
✅ Built files contain the Speed Insights script in dist/ directory

How It Works

Once deployed to Vercel:

  1. The browser loads js/speed-insights.js with the defer attribute
  2. The script initializes the Speed Insights queue
  3. The script dynamically injects the Vercel Speed Insights tracking script
  4. Vercel's deployment automatically provides the tracking endpoint at /_vercel/speed-insights/script.js
  5. Performance metrics (Core Web Vitals) are automatically collected and sent to Vercel's Speed Insights dashboard

Notes

  • The Speed Insights script is loaded with defer to avoid blocking page rendering
  • The implementation follows Vercel's official documentation (fetched from https://vercel.com/docs/speed-insights/quickstart)
  • No configuration is needed - Speed Insights will automatically start collecting data once deployed to Vercel
  • The script gracefully handles errors if content blockers prevent loading
  • The implementation maintains compatibility with the project's existing asset versioning system (?v=645)

View Project · Speed Insights

Created by juankisantiago-5844 with Vercel Agent

# Vercel Speed Insights Implementation

## Summary
Successfully installed and configured Vercel Speed Insights for the AnimeTV project following the latest official documentation from Vercel.

## What Was Implemented

### 1. Package Installation
- Installed `@vercel/speed-insights` version 2.0.0 via npm
- Updated `package.json` with the new dependency
- Generated new `package-lock.json` with the Speed Insights package and its dependencies

### 2. Speed Insights Initialization Script
Created `js/speed-insights.js` - a vanilla JavaScript initialization script that:
- Initializes the Speed Insights queue (`window.si` and `window.siq`)
- Dynamically loads the Vercel Speed Insights script from `/_vercel/speed-insights/script.js`
- Adds proper SDK metadata (name and version)
- Includes error handling for script loading failures
- Runs on DOM ready to ensure proper initialization

### 3. HTML Integration
Modified both web and Android HTML files to include the Speed Insights script:
- Added `<script defer src="js/speed-insights.js?v=645"></script>` to `index.html`
- Added the same script tag to `android/app/src/main/assets/index.html`
- Positioned the script early in the head section for optimal loading

### 4. Android Assets
- Created `android/app/src/main/assets/js/` directory
- Copied `speed-insights.js` to Android assets to maintain mirror sync

## Files Created
- `/js/speed-insights.js` - Speed Insights initialization script
- `/android/app/src/main/assets/js/speed-insights.js` - Android mirror copy

## Files Modified
- `/index.html` - Added Speed Insights script tag
- `/android/app/src/main/assets/index.html` - Added Speed Insights script tag
- `/package.json` - Added @vercel/speed-insights dependency
- `/package-lock.json` - Updated with new dependency tree

## Implementation Approach

This is a vanilla JavaScript/HTML project (not React, Next.js, or other frameworks), so I used the generic Speed Insights implementation approach:

1. Created a self-contained initialization script that follows Vercel's recommended pattern
2. The script initializes the Speed Insights queue before the main script loads
3. Dynamically injects the Vercel Speed Insights script tag with proper configuration
4. Uses the default Vercel endpoint `/_vercel/speed-insights/script.js` which is automatically available on Vercel deployments

## Verification Steps Completed

✅ Package successfully installed with npm
✅ Build completed successfully (`npm run vercel-build`)
✅ All syntax checks passed (`npm run check`)
✅ All tests passed (metadata, seasons, loading tests)
✅ Mirror sync validated (Android assets match web assets)
✅ Built files contain the Speed Insights script in dist/ directory

## How It Works

Once deployed to Vercel:
1. The browser loads `js/speed-insights.js` with the defer attribute
2. The script initializes the Speed Insights queue
3. The script dynamically injects the Vercel Speed Insights tracking script
4. Vercel's deployment automatically provides the tracking endpoint at `/_vercel/speed-insights/script.js`
5. Performance metrics (Core Web Vitals) are automatically collected and sent to Vercel's Speed Insights dashboard

## Notes

- The Speed Insights script is loaded with `defer` to avoid blocking page rendering
- The implementation follows Vercel's official documentation (fetched from https://vercel.com/docs/speed-insights/quickstart)
- No configuration is needed - Speed Insights will automatically start collecting data once deployed to Vercel
- The script gracefully handles errors if content blockers prevent loading
- The implementation maintains compatibility with the project's existing asset versioning system (?v=645)

Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
@vercel

vercel Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

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

Project Deployment Actions Updated
animetv Ready Ready Preview, v0 Sep 3, 2026 11:03pm UTC
zenkaitv-scraper Ready Ready Preview Sep 3, 2026 11:03pm UTC

JSolanoDev added a commit that referenced this pull request Sep 7, 2026
AniList is gone. It answers 403 from Vercel, from the browser, from a dev
machine and - proven by run #111, which finished the bake in 3 seconds - from
the GitHub Actions runner as well. The premise the bake was written on, that
Actions is a different network, was wrong, so the chains needed another source.

Jikan labels its relations "Prequel"/"Sequel", which is the same semantics
AniList gave us. The manami offline database supplies each entry's title,
episode count, year and AniList id, so a chain costs one Jikan request per
node rather than one per node per field.

The offline database's own relatedAnime is UNTYPED and is never the relation
source. Measured over this catalogue, untyped components merge 78 Gundam
series into a single "franchise", attach Ponkotsu Quest to Vinland Saga and
SKET Dance to Gintama. A test wires a real TV show in through Spin-off, Side
story and Other and asserts it never becomes a season.

Two things that had to be got right:

- Seeding only the rows we carry closes the component over fetched nodes and
  leaves everything else a leaf. Mushoku Tensei season 1 is reachable only
  through Part 2, which we do not carry, so the first version produced a chain
  that began at Part 2 and silently dropped season 1 - the exact season being
  asked for. The walk now follows the chain outward.
- /anime/{id}/relations answers 504 while /anime/{id}/full, carrying the same
  typed relations, answers 200. Measured across all five Mushoku ids.

Opening Mushoku Tensei III now yields the whole franchise in release order:

  #1 108465  Mushoku Tensei                11ep  2021 WINTER
  #2 127720  Mushoku Tensei Part 2         12ep  2021 FALL
  #3 146065  Mushoku Tensei II             12ep  2023 SUMMER
  #4 166873  Mushoku Tensei II Part 2      12ep  2024 SPRING
  #5 178789  Mushoku Tensei III            14ep  2026 SUMMER

Only #3 and #5 are in our catalogue; the rest render as visible, locked
seasons rather than not existing. The chain is identical opened from any of
them.

Preselection keeps the crawl honest: only rows sitting beside another TV/ONA
entry are worth asking about, 599 of 1071 here. Capped at 1400 requests paced
at 1.1s, and what the cap drops is logged rather than passed off as complete.
Workflow timeout raised to 40 minutes to match.

311 assertions green.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
JSolanoDev added a commit that referenced this pull request Sep 7, 2026
187 typed relation edges, 134 rows with a season chain. The three Mushoku
Tensei links that answered 504 across four consecutive rounds earlier tonight
answered on a later pass, which is exactly what the cache exists to capture:

  #1 2021  Mushoku Tensei                    11ep
  #2 2021  Mushoku Tensei Part 2             12ep
  #3 2023  Mushoku Tensei II                 12ep
  #4 2024  Mushoku Tensei II Part 2          12ep
  #5 2026  Mushoku Tensei III                14ep

Only #3 and #5 are in our catalogue; the rest render as visible, locked
seasons rather than not existing at all.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@JSolanoDev
JSolanoDev marked this pull request as ready for review September 19, 2026 03:18
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.

0 participants