mirror of
https://github.com/A6-9V/MQL5-Google-Onedrive.git
synced 2026-04-10 22:30:56 +00:00
# Vercel Web Analytics Implementation ## Summary Successfully implemented Vercel Web Analytics for the MQL5 Trading Automation dashboard project. The implementation follows Vercel's recommended HTML/plain JavaScript approach, which is ideal for this Flask-based application. ## Changes Made ### Modified Files: 1. **dashboard/index.html** - Added Vercel Web Analytics script tags before the closing `</body>` tag - Implemented the standard HTML analytics tracking code that initializes the `window.va` function - Added deferred loading of the Vercel insights script from `/_vercel/insights/script.js` 2. **scripts/web_dashboard.py** - Updated the Flask application's HTML template to include Vercel Web Analytics - Added the same analytics script tags to the dynamically generated HTML - Ensures analytics tracking works on both the static and Flask-rendered pages ### Created Files: 3. **vercel.json** - Created Vercel deployment configuration file - Configured builds for both the Python Flask app and static dashboard files - Set up routing to properly serve the Flask app and static assets - Added production environment variables for Flask ## Implementation Details The implementation uses Vercel's HTML/JavaScript approach for web analytics, which: - Requires no package installation (no @vercel/analytics npm package needed) - Works seamlessly with Flask and static HTML pages - Automatically tracks page views and visitor metrics - Uses deferred script loading for optimal performance - Will be activated once the project is deployed to Vercel with Web Analytics enabled ## Next Steps for Deployment To complete the Vercel Web Analytics setup: 1. **Enable Web Analytics in Vercel Dashboard:** - Go to your Vercel project dashboard - Click the "Analytics" tab - Click "Enable" to activate Web Analytics - This will make the `/_vercel/insights/*` routes available 2. **Deploy to Vercel:** - Run `vercel deploy` or push to your connected Git repository - The analytics will automatically start tracking after deployment 3. **Verify Installation:** - After deployment, visit your site - Open browser DevTools > Network tab - Look for a request to `/_vercel/insights/view` to confirm tracking is active ## Technical Notes - No changes to requirements.txt were needed (Python-only dependencies) - No package manager operations required (npm/yarn/pnpm) - The implementation is framework-agnostic and works with plain HTML/JavaScript - Analytics tracking is non-blocking and won't affect page load performance - The solution supports both the static HTML dashboard and Flask-rendered pages Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
26 lines
408 B
JSON
26 lines
408 B
JSON
{
|
|
"version": 2,
|
|
"builds": [
|
|
{
|
|
"src": "scripts/web_dashboard.py",
|
|
"use": "@vercel/python"
|
|
},
|
|
{
|
|
"src": "dashboard/**",
|
|
"use": "@vercel/static"
|
|
}
|
|
],
|
|
"routes": [
|
|
{
|
|
"src": "/dashboard/(.*)",
|
|
"dest": "/dashboard/$1"
|
|
},
|
|
{
|
|
"src": "/(.*)",
|
|
"dest": "scripts/web_dashboard.py"
|
|
}
|
|
],
|
|
"env": {
|
|
"FLASK_ENV": "production"
|
|
}
|
|
}
|