Personal profile site for Sean, callsign N7SIX, a licensed amateur radio operator in the Philippines, contributor to the UV-K series firmware, and professional in the automotive industry.
Published at https://n7six.github.io/MyProfile
You can monitor usage from a static GitHub Pages site by sending events to a small backend endpoint.
This repository now includes a starter backend in monitoring/cloudflare-worker.js with D1 schema in monitoring/schema.sql.
-
Install Wrangler and login:
npm install -g wrangler wrangler login
-
Create a D1 database and apply schema:
wrangler d1 create uvtools-usage wrangler d1 execute uvtools-usage --file=./monitoring/schema.sql
-
Copy monitoring/wrangler.toml.example to
monitoring/wrangler.tomland set yourdatabase_id. -
Add worker secrets:
wrangler secret put WRITE_KEY
wrangler secret put ADMIN_TOKEN
wrangler secret put ALLOWED_ORIGINSExample ALLOWED_ORIGINS value:
https://n7six.github.io,https://n7six.github.io/MyProfile
bash wrangler secret put WRITE_KEY wrangler secret put ADMIN_TOKEN wrangler secret put ALLOWED_ORIGINS
Example `ALLOWED_ORIGINS` value:
`https://n7six.github.io,https://n7six.github.io/MyProfile`
-
Deploy worker:
cd monitoring wrangler deployIf you are in the repo root, a full one-shot command flow is:
npm install -g wrangler && \ wrangler login && \ wrangler d1 create uvtools-usage && \ wrangler d1 execute uvtools-usage --file=./monitoring/schema.sql
Then set secrets:
wrangler secret put WRITE_KEY wrangler secret put ADMIN_TOKEN wrangler secret put ALLOWED_ORIGINS
Then deploy:
cd monitoring wrangler deploy -
Update tracker config in script.js:
USAGE_TRACKER.eventEndpointUSAGE_TRACKER.publicCountEndpointUSAGE_TRACKER.publicTrendEndpointUSAGE_TRACKER.publicCountriesEndpointUSAGE_TRACKER.writeKeyUSAGE_TRACKER.siteUSAGE_TRACKER.countRefreshMs(optional counter auto-refresh interval)USAGE_TRACKER.trendHours(public trend window, default 24)USAGE_TRACKER.countriesLimit(how many top countries to display)
Automatic mode is available using usage-tracker-config.js, which is loaded by index.html. Edit this file once and the website tracker uses those values automatically.
Code organization:
- usage-monitoring.js contains monitoring/counter logic for the main site
- script.js contains site interaction/animation/social UI logic
-
Track specific usage actions by adding attributes on elements:
<button data-track-event="flash_start_click" data-track-label="Flash Start">Flash</button>
Every click on an element with
data-track-eventsends an event record.
Call:
curl "https://<your-worker>.workers.dev/stats?site=uvtools-multi-firmware-web-flasher&token=<ADMIN_TOKEN>"Public counter endpoint (no admin token):
curl "https://<your-worker>.workers.dev/count?site=n7six-myprofile-website"Public trend endpoint (no admin token, aggregated counts only):
curl "https://<your-worker>.workers.dev/trend?site=n7six-myprofile-website&hours=24"The response includes:
- Total events
- Unique IP count
- Country breakdown
- Event breakdown (by event name)
- Recent usage records
To get counts per action, run this query on D1:
SELECT event, COUNT(*) as count
FROM usage_events
WHERE site = 'uvtools-multi-firmware-web-flasher'
GROUP BY event
ORDER BY count DESC;
Dashboard automatic mode:
- [usage-dashboard.html](usage-dashboard.html) loads [usage-monitor-config.js](usage-monitor-config.js)
- Set `workerUrl`, `siteId`, and `adminToken` there
- With `autoLoad: true`, stats load automatically on page open
`usage-dashboard.html?worker=https://...workers.dev&site=uvtools-multi-firmware-web-flasher&token=...`
- Add `&showTokenField=1` to force-show the token input when needed
It renders:
- Total events
- Unique IPs
- Event counters
- Country counters
---
## License
This project is licensed under the [MIT License](LICENSE).
## Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
## Contact
[Sean (N7SIX)](https://github.com/N7SIX)
### Important note
IP addresses are personal data in many jurisdictions. Add a privacy notice to your site and comply with local laws (for example GDPR/CCPA where applicable).
Security note:
- Set `ALLOWED_ORIGINS` so only your domains can send events.
- `WRITE_KEY` is optional in this setup. If set, the client must send the same key.