> ## Documentation Index
> [HTML page](https://blode.md/docs/cli/analytics)
> [Documentation index](https://blode.md/docs/llms.txt)
> Use the index to discover all available pages before exploring further.

# edda analytics

Use edda analytics to read and write PostHog project keys for a tenant, script rollouts in CI, and keep analytics config in your docs repo.

`edda analytics` reads and writes the per-project analytics config that the dashboard exposes at **Settings → Analytics**. Use it to script rollouts, wire analytics into CI, or keep your docs repo the source of truth.

## Subcommands

```bash title="Read current config"
edda analytics get [--project <slug>] [--json]
```

```bash title="Set PostHog"
edda analytics set posthog <projectKey> [--host <url>] [--project <slug>]
```

```bash title="Remove a provider"
edda analytics unset posthog [--project <slug>]
```

The project slug is resolved in this order: `--project`, `BLODEMD_PROJECT`, `slug` in your local `docs.json`. Run from inside your docs repo and you never need to pass it.

## Examples

```bash
# Set PostHog with the EU cloud host
edda analytics set posthog phc_abc123def456 --host https://eu.i.posthog.com

# Check what's configured, as JSON, so you can pipe it
edda analytics get --json

# Remove PostHog
edda analytics unset posthog
```

## Options

- `--project <slug>` (type: string): Project slug. Defaults to BLODEMD_PROJECT or docs.json.
- `--api-url <url>` (type: string): Edda API URL. Override for self-hosted deployments.
- `--json` (type: boolean, default: false): Print the analytics config as JSON (only on `get`).
- `--host <url>` (type: string): PostHog host (only on `set posthog`). Defaults to https://us.i.posthog.com.

## Validation

The CLI validates inputs before hitting the API:

- **PostHog project key** must start with `phc_` and be at least 24 characters. Personal API keys (`phx_`) are rejected: they have far more privilege than the project key needs and would leak to the browser.
- **PostHog host** must be an `https://` URL.

## Authentication

`edda analytics` requires you to be logged in. Run `edda login` if the CLI reports you are not authenticated.