{"id":13615878,"url":"https://github.com/jiacai2050/pageview-worker","last_synced_at":"2025-04-10T06:51:05.311Z","repository":{"id":189045967,"uuid":"623822365","full_name":"jiacai2050/pageview-worker","owner":"jiacai2050","description":"Page View backend based on Cloudflare Workers and KV.","archived":false,"fork":false,"pushed_at":"2023-04-24T13:11:00.000Z","size":415,"stargazers_count":43,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-24T07:56:54.005Z","etag":null,"topics":["cloudfare-api","cloudflare","cloudflare-worker","cloudflare-workers","pageview"],"latest_commit_sha":null,"homepage":"http://jiacai2050.github.io/pageview-worker/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jiacai2050.png","metadata":{"files":{"readme":"README.org","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-04-05T06:53:49.000Z","updated_at":"2025-03-18T03:50:19.000Z","dependencies_parsed_at":"2023-08-18T03:23:51.418Z","dependency_job_id":"d7f43658-8608-4076-8be8-7f5b247e21d6","html_url":"https://github.com/jiacai2050/pageview-worker","commit_stats":null,"previous_names":["jiacai2050/pageview-worker"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiacai2050%2Fpageview-worker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiacai2050%2Fpageview-worker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiacai2050%2Fpageview-worker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiacai2050%2Fpageview-worker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jiacai2050","download_url":"https://codeload.github.com/jiacai2050/pageview-worker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248173852,"owners_count":21059595,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloudfare-api","cloudflare","cloudflare-worker","cloudflare-workers","pageview"],"created_at":"2024-08-01T20:01:19.730Z","updated_at":"2025-04-10T06:51:05.287Z","avatar_url":"https://github.com/jiacai2050.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"#+TITLE: Pageview Worker\n#+DATE: 2023-04-05T15:09:21+0800\n#+LASTMOD: 2023-04-05T15:09:21+0800\n#+AUTHOR: Jiacai Liu\n#+OPTIONS: toc:nil num:nil\n#+STARTUP: content\n\nPage View backend based on [[https://developers.cloudflare.com/workers/][Cloudflare Workers]] and [[https://developers.cloudflare.com/workers/runtime-apis/kv/][KV]].\n\n[[file:pageview.jpg]]\n\nLive demo:\n- https://jiacai2050.github.io/pageview-worker\n\nThere are two pages containing [[file:demo/tracking.js]] for this live demo:\n- [[https://jiacai2050.github.io/pageview-worker/demo1.html][Demo 1]]\n- [[https://jiacai2050.github.io/pageview-worker/demo2.html][Demo 2]]\n\n#+begin_quote\n⚠️ Demo pages will collect your IP/Country/City, click at your own risk.\n#+end_quote\n* Use at you own website\n- Setup workers, refer to [[https://developers.cloudflare.com/workers/get-started/quickstarts/][quickstarts]]\n  - Publish [[file:worker.js]]\n- Add KV binding, refer to [[https://developers.cloudflare.com/workers/runtime-apis/kv/][referencing KV from Workers]]\n  - Binding name is =KV= in this project.\n- Add following tracking code to HTML files you want to track, replace =apiEndpoint= with your worker address.\n  #+begin_src js\nconst apiEndpoint = 'https://pageview-demo.jiacai2050.workers.dev/write';\nconst payload = {\n  'url': document.location.href,\n  'title': document.title,\n  'referrer': window.frames.top.document.referrer,\n};\nfetch(`${apiEndpoint}?${new URLSearchParams(payload)}`, {mode: 'no-cors'})\n  .catch(console.log);\n  #+end_src\n- Then when visit HTML, following information will be saved to KV via workers:\n  - URL\n  - Title\n  - Referrer\n  - User-Agent\n  - IP\n  - Country\n  - City\n- [[file:demo/index.html]] is provided to view saved pageviews.\n  - Replace =apiEndpoint= with your worker address.\n\n* Other fun workers project\n- [[https://github.com/eidam/cf-workers-status-page][Status page]]\n- [[https://github.com/honojs/hono][honojs/hono: Ultrafast web framework for the Edges]]\n- [[https://github.com/cloudflare/miniflare][cloudflare/miniflare: Fully-local simulator for Cloudflare Workers]]\n* License\n[[file:LICENSE][GPL-3]]\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiacai2050%2Fpageview-worker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjiacai2050%2Fpageview-worker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiacai2050%2Fpageview-worker/lists"}