{"id":13625423,"url":"https://github.com/jorgelbg/dashflare","last_synced_at":"2025-04-07T19:31:28.571Z","repository":{"id":40668095,"uuid":"246158540","full_name":"jorgelbg/dashflare","owner":"jorgelbg","description":"🕵🏼‍♀️ Open Source and privacy-focused analytics solution. 📊 Advanced monitoring for your website behind Cloudflare","archived":false,"fork":false,"pushed_at":"2023-01-27T04:42:34.000Z","size":1038,"stargazers_count":154,"open_issues_count":11,"forks_count":29,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-22T23:04:01.708Z","etag":null,"topics":["analytics","cloudflare","edge-worker","google-analytics","grafana","grafana-loki","hacktoberfest","metrics","privacy","web-analytics","wrangler"],"latest_commit_sha":null,"homepage":"https://jorgelbg.me/dashflare","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jorgelbg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE_APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["jorgelbg"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2020-03-09T22:52:41.000Z","updated_at":"2025-03-08T11:58:31.000Z","dependencies_parsed_at":"2023-02-06T12:15:47.652Z","dependency_job_id":null,"html_url":"https://github.com/jorgelbg/dashflare","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jorgelbg%2Fdashflare","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jorgelbg%2Fdashflare/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jorgelbg%2Fdashflare/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jorgelbg%2Fdashflare/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jorgelbg","download_url":"https://codeload.github.com/jorgelbg/dashflare/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247716262,"owners_count":20984208,"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":["analytics","cloudflare","edge-worker","google-analytics","grafana","grafana-loki","hacktoberfest","metrics","privacy","web-analytics","wrangler"],"created_at":"2024-08-01T21:01:55.545Z","updated_at":"2025-04-07T19:31:28.052Z","avatar_url":"https://github.com/jorgelbg.png","language":"TypeScript","funding_links":["https://github.com/sponsors/jorgelbg"],"categories":["TypeScript"],"sub_categories":[],"readme":"[![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/jorgelbg/dashflare)\n\n# dashflare\n\nDashflare is a privacy first analytics solution for monitoring your websites. It can be self hosted\non a practically any hosting solution and it should scale with your needs. Data collection is handled\nby a [Cloudflare Edge](https://workers.cloudflare.com/) Worker running the code included in this repository.\n\nTwo additional components are required for having the full suite running:\n\n- Grafana (handles the data visualization)\n- Grafana Loki (handles the data persistence)\n\nThe default provided dashboard looks like:\n\n\u003cp align=\"center\"\u003e\n    \u003cimg class=\"center\" src=\"http://screen.jorgelbg.me/jorgelbg-dropshare/w6nAqMZzsPVz57ab.png\" alt=\"Screenshot of the Grafana dashboard\"/\u003e\n\u003c/p\u003e\n\n## 🌥 Cloudflare\n\nOne requirement to use the current solution is to be already using [Cloudflare](https://www.cloudflare.com/) for the\nwebsite that you want to monitor.\n\n## 🎮 Installation / Getting started\n\nA minimal production-like environment is provided and can be used through\n[docker-compose](https://docs.docker.com/compose/):\n\n```\n❯ docker-compose up\n```\n\n### 🔑 Grafana authentication\n\nGrafana will be accessible in `http://localhost:3000/` and the default user and password are:\n\n- user: admin\n- password: admin\n\n\u003e **You will be asked to change it after the first successful login.**\n\nCloudflare Edge Workers have certain limitations that prohibit any connection between the edge worker\nand any outside resource that cannot be reached through the ports `80` or `443`. By default Loki is\nlistening on port `3100`, you can either change this or run Loki behind a transparent proxy. Grafana is listening in the default port (`3000`).\n\nAnother security practice of Cloudflare Edge Workers is that requests from the edge worker can only be made\nagainst endpoints that are associated with a domain. This means that if you try to set the\n`LOKI_HOST` environment variable to an IP address, the edge worker will not be able send any data.\n\n\u003e It is still possible to run loki locally, we need to expose the loki instance\n\u003e to the Internet directly in a domain/subdomain. Another posibility (especially\n\u003e useful for development) is to use a service like [ngrok](https://ngrok.com/)\n\u003e to forward the traffic.\n\n## 🤠 wrangler\n\nIn order to deploy the edge worker a workable node/npm environment is needed. After installing\nnode/npm on your development environment, we need to install\n[wrangler](https://github.com/cloudflare/wrangler) which is the CLI tool that cloudflare offers to\ninteract with the edge workers platform.\n\n```sh\n❯ npm install -g @cloudflare/wrangler\n```\n\n`wrangler` CLI tool needs access to your Cloudflare account. This is normally achieved by running:\n\n```sh\n❯ wrangler config\n```\n\nOr you can directly go to https://dash.cloudflare.com/profile/api-tokens, and create a new token\nusing the \"Edit Cloudflare Workers\" template. You can also expose the token via the `CF_API_TOKEN`\nenvironment variable.\n\nThere are two values needed for wrangler to work: `CF_ACCOUNT_ID` and `CF_ZONE_ID`. `CF_ACCOUNT_ID` is\nyour Cloudflare's Accound ID and you can get it (along with the `CF_ZONE_ID`) from your Cloudflare\ndashboard: dash.cloudflare.com.\n\nYou can use the `.envrc.example` file as an example of the variables that should be set. We recommend\ncopying the `.envrc.example` file into `.envrc` and loading the configuration into your shell\nenvironment after editing the file:\n\n```sh\n❯ cp .envrc.example .envrc\n# edit `.envrc` to adjust the values\n❯ source .envrc\n```\n\n### Environment variables\n\nThis is a list of the environment variables that are needed for the Dashflare edge worker to generate\nthe events:\n\nWe extract the country name from your visitor's requests. We also provide additional geolocation capabilities via the\nintegration with the [ipgeolocationapi.com] API.\n\n- `IPINFO`: (optional) [ipgeolocationapi.com] is used to capture additionl geolocation data from your visitors. It is still possible to opt out of this feature by setting this variable to `false`.\n- `CLIENT_ID`: If you're self hosting Dashflare, `CLIENT_ID` can be omitted, or set to any value.\n  By default it is set to `fake` in [`.envrc.example`](./.envrc.example).\n- `LOKI_HOST`: URL where the Loki instance is accessible, it cannot be an IP address (`1.2.3.4`) nor a domain\n  containing a custom port (`loki.example.com:31001`). A subdomain will work just fine (i.e loki.example.com)\n- `FINGERPRINT`: Its used as the key for the session id hash calculation. A random key can be\n  generated using:\n\n  ```sh\n  ❯ openssl rand -base64 32  | md5\n  ```\n\n- `DOMAIN`: URL of your \"primary domain\". The edge worker will be deployed into a custom subdomain\n  (within `.workers.dev` if you're using the free tier). This variable is used to generate\n  automatic [routes](https://developers.cloudflare.com/workers/about/routes/). This can be configured\n  through the Cloudflare's Dashboard as well.\n\n## 🗺 Routes\n\nWhen the edge worker is deployed it will be running in a custom domain (`.workers.dev` if you're\nusing the free tier). We need to \"forward\" the requests from the main domain to the edge worker\ndomain. Cloudflare handles this via routes\n[routes](https://developers.cloudflare.com/workers/about/routes/). When using the `make wrangler`\ncommand a default set of routes will be generated using the `DOMAIN` environment variable.\n\nSince the forwarding will be done by Cloudflare there is no change required to the website on your\noriginal domain. Not even a new `script` tag is needed.\n\n## 🔥 Publishing the edge worker\n\nAfter `wrangler` is installed, and the environment variables are set, we can deploy our edge worker.\nBefore we need to generate a valid `wrangler.toml` file. A handy make target is provided to do this:\n\n```sh\n❯ make wrangler\n```\n\n\u003e The `make wrangler` command depends on [envsubst](https://linux.die.net/man/1/envsubst).\n\nThis command will take the [wrangler.toml.template](./wrangler.toml.template) file as a template a\ngenerate a valid wrangler configuration file (`wrangler.toml`).\n\n\u003e You can inspect/edit the `wrangler.toml` file. Especially the `routes` section might be of interest\n\u003e to you.\n\nFinally we can publish/deploy our edge worker:\n\n```sh\n❯ wrangler publish\n```\n\nThis command will build and publish the worker to Cloudflare's edge network.\n\n\u003c!-- ## 👨🏻‍💻 Developing --\u003e\n\n## 🤚🏻 Contributing\n\nIf you'd like to contribute, please fork the repository and use a feature\nbranch. Pull requests are warmly welcome.\n\n## 🚀 Links\n\n- Project Homepage/Demo/Waiting List: https://jorgelbg.me/dashflare\n\n[ipgeolocationapi.com]: https://ipgeolocationapi.com/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjorgelbg%2Fdashflare","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjorgelbg%2Fdashflare","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjorgelbg%2Fdashflare/lists"}