A self-hosted, privacy-focused analytics dashboard with built-in uptime monitoring and SEO analysis. Powered by Express 5 and PocketBase.
- Multi-website analytics — Track unlimited websites with per-site dashboards and a unified overview
- Privacy-first — All data stays on your infrastructure; no third-party tracking
- Real-time updates — Live session and event counters via Server-Sent Events (SSE)
- JavaScript error tracking — Automatic error capture with stack traces and breadcrumbs
- Visitor identification — Enrich anonymous visitors with user IDs, emails, and custom metadata
- Uptime monitoring — Configurable intervals, incident tracking, MTTR/MTBF metrics, and status notifications
- SEO analyzer — On-demand audits with Lighthouse integration, actionable recommendations, and CSV/JSON export
- Smart notifications — Declarative email rules for new visitors, custom events, error thresholds, uptime alerts, and daily summaries
- Data retention — Automatic cleanup with configurable per-site and global retention policies
- Lightweight client script — ~9KB minified with SPA support, offline queuing, and bot filtering
┌──────────────────┐ ┌─────────────────┐ ┌──────────────┐
│ Browser Script │─────▶│ Express │◀────▶│ PocketBase │
└──────────────────┘ │ Dashboard & │ │ Database │
│ Collection │ └──────────────┘
│ API │ ▲
└─────────────────┘ │
│ │
┌───────▼───────┐ │
│ Services │───────────────┘
│ (Cron, SSE, │
│ Uptime, SEO) │
└───────────────┘
PocketBase stores users, websites, sessions, visitors, events, JS errors, SEO snapshots, uptime checks, uptime incidents, and notification rules.
Express handles authentication, renders EJS views, serves the collection API (/collect), and exposes real-time SSE endpoints.
Background services enforce data retention, send email notifications (via Resend), monitor uptime, and broadcast real-time updates.
- Node.js 20+ (ES modules, top-level await, native fetch)
- PocketBase 0.26.x with the included
pb_schema.json - npm or pnpm
| Service | Purpose |
|---|---|
| Resend | Transactional email notifications |
| Google PageSpeed | Enhanced Lighthouse SEO audits |
| Chapybara | IP intelligence/reputation lookups |
-
Clone the repository:
git clone https://github.com/devAlphaSystem/Alpha-System-Skopos.git cd Alpha-System-Skopos -
Install dependencies:
npm install
-
Configure environment:
Copy
.env.exampleto.envand update:Variable Description PORTDashboard HTTP port (default 3000)NODE_ENVdevelopmentorproductionLOG_LEVELWinston log level ( error,warn,info,debug)POCKETBASE_URLPocketBase instance URL (e.g., http://127.0.0.1:8090)POCKETBASE_ADMIN_EMAILPocketBase admin email POCKETBASE_ADMIN_PASSWORDPocketBase admin password ENCRYPTION_KEY32-byte secret for API key encryption (never commit) DATA_RETENTION_DAYSGlobal data retention period (default 180) -
Start PocketBase:
./pocketbase serve --http=0.0.0.0:8090 --dir ./pb_data --publicDir ./pb_public
Import
pb_schema.jsonvia the PocketBase admin UI or use--auto-migrate. -
Start the dashboard:
npm run dev # Development with hot reload # or node server.js # Production
-
Visit
http://localhost:3000, register the first user, and log in.
| Script | Purpose |
|---|---|
npm run dev |
Start with nodemon for development |
npm run format |
Format codebase with Prettier |
├── public/ # Static assets (CSS, JS, images)
├── script/ # Client tracking script (skopos.min.js)
├── src/
│ ├── controllers/ # Route handlers for pages and API
│ ├── routes/ # Express route definitions
│ ├── services/ # Core business logic
│ │ ├── analyticsService.js # Metrics calculation
│ │ ├── cron.js # Scheduled jobs
│ │ ├── notificationService.js # Email notifications via Resend
│ │ ├── realtime.js # SSE broadcasting
│ │ ├── seoAnalyzer.js # SEO audits + Lighthouse
│ │ ├── uptimeMonitor.js # Uptime checks & incidents
│ │ └── ...
│ └── utils/ # Helpers (logging, encryption, geo, etc.)
├── views/ # EJS templates
├── pb_schema.json # PocketBase collection schema
├── server.js # Application entry point
└── package.json
The tracking script (script/skopos.min.js) is a lightweight (~9KB) privacy-focused tracker.
<script
src="https://cdn.alphasystem.dev/skopos/latest/skopos.min.js"
data-site-id="YOUR_TRACKING_ID"
data-host="https://your-skopos-dashboard.com"
defer
></script>| Attribute | Default | Description |
|---|---|---|
data-site-id |
required | Tracking ID from dashboard |
data-host |
required | Dashboard URL |
data-auto-track |
true |
Auto-track page views |
data-track-errors |
true |
Capture JavaScript errors |
data-track-outbound |
true |
Track outbound link clicks |
data-track-downloads |
true |
Track file downloads |
data-hash-mode |
false |
Hash-based SPA routing |
data-respect-dnt |
false |
Respect Do Not Track setting |
data-debug |
false |
Enable console logging |
// Custom events
skopos('event', 'button_click', { buttonId: 'cta', value: 100 });
// User identification
skopos('identify', 'user123', {
name: 'John Doe',
email: 'john@example.com',
metadata: { plan: 'pro' }
});
// GDPR opt-out/opt-in
skopos('opt-out');
skopos('opt-in');See script/README.md for full documentation.
The /collect endpoint accepts telemetry from the client script:
- Page views — Automatic SPA-aware tracking
- Custom events — Programmatic and declarative (HTML attributes)
- Sessions — Created automatically with device, browser, OS, location, and referrer
- Visitors — Identified by hashed fingerprint; enrichable via
identify()API - JavaScript errors — Aggregated with stack traces, breadcrumbs, and occurrence counts
- Outbound clicks — External link tracking
- File downloads — Automatic for common file extensions
Scheduled tasks run automatically when the server starts:
| Schedule | Job | Description |
|---|---|---|
| Daily (00:00 UTC) | Data retention | Enforces per-site and global retention policies |
| Daily (00:00 UTC) | Orphan cleanup | Removes visitors with no sessions |
| Daily (00:00 UTC) | Daily summaries | Sends summary emails for configured notification rules |
| Hourly | Error threshold checks | Triggers alerts when JS errors exceed configured limits |
| Every 5 minutes | Short session discard | Removes <1s sessions for sites with this option enabled |
Configure email alerts in the dashboard settings:
| Event Type | Trigger |
|---|---|
new_visitor |
When a new unique visitor is detected |
new_session |
When a new session starts |
custom_event |
When a specific custom event fires |
daily_summary |
Daily analytics report |
error_threshold |
When JS errors exceed a threshold |
uptime_status |
When site status changes (up/down) |
Notifications require a configured Resend API key.
Per-website uptime monitoring with:
- Configurable check intervals (default: 5 minutes)
- Automatic incident creation and resolution
- Response time tracking
- DNS fallback for reliability
- MTTR/MTBF calculations
- Daily uptime summaries
- Email alerts on status changes
On-demand SEO audits include:
- Meta tag validation (title, description, canonical, robots)
- Social meta tags (Open Graph, Twitter Cards)
- Heading structure analysis
- Image alt text coverage
- Internal/external link analysis
- Broken link detection
- Technical SEO checks (SSL, robots.txt, sitemap, structured data, compression)
- Lighthouse performance scores (requires Google PageSpeed API for enhanced results)
- Prioritized recommendations
When running behind Nginx, Traefik, or similar:
- Forward
X-Forwarded-For/X-Real-IPheaders for accurate IP geolocation - Disable response buffering for
/dashboard/events(SSE endpoint) - Terminate TLS at the proxy layer
Use PM2, systemd, or Docker to manage the Node process. Ensure SIGTERM is forwarded for graceful shutdown of uptime monitors.
All data lives in PocketBase. Schedule regular backups of the pb_data/ directory.
- Run
npm ci --production - Set
NODE_ENV=production - Use unique
ENCRYPTION_KEYper environment - Import/sync
pb_schema.jsonto PocketBase - Verify the dashboard loads and test event collection
- Monitor logs at
logs/or stdout
The schema includes:
| Collection | Purpose |
|---|---|
users |
Dashboard user accounts |
websites |
Tracked sites and configuration |
visitors |
Unique visitor records (identifiable) |
sessions |
Individual browsing sessions |
events |
Page views, custom events, clicks |
js_errors |
Aggregated JavaScript errors |
seo_data |
SEO analysis snapshots |
uptime_checks |
Individual uptime check results |
uptime_incidents |
Downtime incidents |
uptime_sum |
Aggregated uptime summaries |
notyf_rules |
Notification rule configurations |
api_keys |
Encrypted third-party API keys |
MIT
- Issues & Features: Open a GitHub issue with Node/PocketBase versions and relevant logs
- Security: Report vulnerabilities privately; do not file public issues