# Self-hosted product analytics without running a server

Self-hosting analytics usually means a server, Docker, a database and a backup plan. Dataflare is three Cloudflare resources in your own account instead:

- a **Worker** that serves the SDK, ingests events, evaluates flags and runs the dashboard and API,
- a **D1 database** for events, people, flags and experiments,
- an **R2 bucket** for session recordings.

```sh
CLOUDFLARE_API_TOKEN=… npx dataflare-cli init
```

## Upgrades from CI, not from your laptop

`dataflare init` writes `.github/workflows/glass.yml`. To upgrade, run `npx dataflare-cli@latest upgrade`, which stages the new version in `.glass/`, then commit and push; CI deploys it. Dataflare refuses to replace a newer Worker with an older one.

## Limits to know about

- D1 databases hold up to 10 GB on Workers Paid (500 MB on Free). The [cost calculator](/pricing/) shows when you'd reach that at your volume. Set `GLASS_RETENTION_DAYS` to keep a rolling window, or use the lake store (`--lake`, beta), which streams events to Apache Iceberg tables in R2.
- Dataflare is new (0.x). The D1 store, SDK, dashboard, MCP server and CLI are covered by unit, integration and browser tests; the lake store depends on Cloudflare products in beta.

## Read and change everything

The Worker in your account is the code in the [repository](https://github.com/ISNIT0/glass-analytics), MIT licensed. Adding a query type, an MCP tool or a storage engine is a single file each: see [Extending Dataflare](/docs/extending/).
