From 663f7482f043344d96ed81564cda8ecf85691195 Mon Sep 17 00:00:00 2001 From: Chris Raible Date: Wed, 9 Jul 2025 20:47:26 -0700 Subject: [PATCH 1/4] Updated Ghost config and Tinybird instructions to replace stats token with JWTs --- .env.example | 2 +- TINYBIRD.md | 6 ++++-- compose.yml | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index d1c35042..d920031e 100644 --- a/.env.example +++ b/.env.example @@ -28,7 +28,7 @@ ENABLE_ACTIVITYPUB=false # Tinybird configuration TINYBIRD_API_URL=https://api.tinybird.co TINYBIRD_TRACKER_TOKEN=p.eyJxxxxx -TINYBIRD_STATS_TOKEN=p.eyJxxxxx +TINYBIRD_ADMIN_TOKEN=p.eyJxxxxx # Data locations # Location to store uploaded data diff --git a/TINYBIRD.md b/TINYBIRD.md index fd9769fd..5a50f794 100644 --- a/TINYBIRD.md +++ b/TINYBIRD.md @@ -7,9 +7,11 @@ Steps: 1. Run `docker compose run --rm tinybird-login` to login to your Tinybird account 1. Run `docker compose --profile=analytics up tinybird-sync`. This will copy the Tinybird files from the Ghost container into a shared volume. The service should log "Tinybird files synced into shared volume.", then exit. 1. Run `docker compose --profile=analytics up tinybird-deploy` and wait for the service to exit successfully. This will create your Tinybird datasources, pipes and API endpoints. It may take a minute or two to complete the first time. You should see "Deployment #1 is live!" in your terminal before the service exits. -1. Find your workspace's events API endpoint: `docker compose run --rm tinybird-login tb --cloud info`, copy the value of "api", and add it to your `.env` file as `TINYBIRD_API_URL`. You can also find this value in your Tinybird Workspace's UI. +1. Find your workspace's ID and events API endpoint: `docker compose run --rm tinybird-login tb --cloud info` + - Copy the value of "api", and add it to your `.env` file as `TINYBIRD_API_URL`. You can also find this value in your Tinybird Workspace's UI. + - Copy the value of "workspace_id", and add it to your `.env` file as `TINYBIRD_WORKSPACE_ID` 1. Using the UI link from the previous step, open your workspace and click on *Tokens* in the left hand menu -1. Copy your Tinybird `stats_page` token and add it to your `.env` file as `TINYBIRD_STATS_TOKEN` +1. Copy your Tinybird "Workspace admin token" and add it to your `.env` file as `TINYBIRD_ADMIN_TOKEN` 1. Copy your Tinybird `tracker` token and add it to your `.env` file as `TINYBIRD_TRACKER_TOKEN` 1. Run `docker compose --profile=analytics up -d` to start all services in the background 1. Set `COMPOSE_PROFILES=analytics` in your `.env` file to automatically include the `analytics` profile when running `docker compose` commands diff --git a/compose.yml b/compose.yml index 61c4ee8a..c844be67 100644 --- a/compose.yml +++ b/compose.yml @@ -38,9 +38,10 @@ services: enableDeveloperExperiments: ${ENABLE_DEVELOPER_EXPERIMENTS:-false} labs__ActivityPub: ${ENABLE_ACTIVITYPUB:-false} tinybird__tracker__endpoint: https://${DOMAIN:?DOMAIN environment variable is required}/.ghost/analytics/api/v1/page_hit + tinybird__adminToken: ${TINYBIRD_ADMIN_TOKEN:-} + tinybird__workspaceId: ${TINYBIRD_WORKSPACE_ID:-} tinybird__tracker__datasource: analytics_events tinybird__stats__endpoint: ${TINYBIRD_API_URL:-https://api.tinybird.co} - tinybird__stats__token: ${TINYBIRD_STATS_TOKEN:-} volumes: - ${UPLOAD_LOCATION:-./data/ghost}:/var/lib/ghost/content depends_on: From 838a5cb982ae6ee9892e96a3c1042ee193bb730e Mon Sep 17 00:00:00 2001 From: Chris Raible Date: Thu, 10 Jul 2025 17:32:45 -0700 Subject: [PATCH 2/4] --wip-- [skip ci] --- .env.example | 1 + compose.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.env.example b/.env.example index d920031e..840214ee 100644 --- a/.env.example +++ b/.env.example @@ -24,6 +24,7 @@ ENABLE_DEVELOPER_EXPERIMENTS=false # Developer Experiments must be enabled above ENABLE_ACTIVITYPUB=false +ENABLE_ANALYTICS=false # Tinybird configuration TINYBIRD_API_URL=https://api.tinybird.co diff --git a/compose.yml b/compose.yml index c844be67..0ebc9c08 100644 --- a/compose.yml +++ b/compose.yml @@ -37,6 +37,7 @@ services: database__connection__database: ghost enableDeveloperExperiments: ${ENABLE_DEVELOPER_EXPERIMENTS:-false} labs__ActivityPub: ${ENABLE_ACTIVITYPUB:-false} + labs__trafficAnalytics: ${ENABLE_TRAFFIC_ANALYTICS:-false} tinybird__tracker__endpoint: https://${DOMAIN:?DOMAIN environment variable is required}/.ghost/analytics/api/v1/page_hit tinybird__adminToken: ${TINYBIRD_ADMIN_TOKEN:-} tinybird__workspaceId: ${TINYBIRD_WORKSPACE_ID:-} From 018514df722e5075750a465abfb1bc03a5838953 Mon Sep 17 00:00:00 2001 From: Chris Raible Date: Thu, 10 Jul 2025 20:15:20 -0700 Subject: [PATCH 3/4] Updated .env.example --- .env.example | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 840214ee..e8ae8f0c 100644 --- a/.env.example +++ b/.env.example @@ -24,12 +24,13 @@ ENABLE_DEVELOPER_EXPERIMENTS=false # Developer Experiments must be enabled above ENABLE_ACTIVITYPUB=false -ENABLE_ANALYTICS=false +ENABLE_TRAFFIC_ANALYTICS=false # Tinybird configuration TINYBIRD_API_URL=https://api.tinybird.co TINYBIRD_TRACKER_TOKEN=p.eyJxxxxx TINYBIRD_ADMIN_TOKEN=p.eyJxxxxx +TINYBIRD_WORKSPACE_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx # Data locations # Location to store uploaded data From 22d290e08490a3a4c2828f139af9c3a06ad8c32c Mon Sep 17 00:00:00 2001 From: James Loh Date: Mon, 14 Jul 2025 16:20:18 +1000 Subject: [PATCH 4/4] Tweak README with new installation steps --- TINYBIRD.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/TINYBIRD.md b/TINYBIRD.md index 5a50f794..beae53bf 100644 --- a/TINYBIRD.md +++ b/TINYBIRD.md @@ -1,18 +1,17 @@ # Tinybird Configuration -Note: Currently Traffic Analytics features are behind a feature flag. For now, you'll need to enable developer experiments by setting `ENABLE_DEV_EXPERIMENTS=true` in your `.env` file, and enable the Traffic Analytics feature flag under Settings > Labs > Private Features. +Note: Currently Traffic Analytics features are behind a feature flag. For now, you'll need to enable it by following the steps below: -Steps: 1. Create a Tinybird account and a Tinybird workspace at [tinybird.co](https://auth.tinybird.co/login). You can select any cloud/region you choose. -1. Run `docker compose run --rm tinybird-login` to login to your Tinybird account +1. Run `docker compose run --rm tinybird-login` to login to your Tinybird account following the steps given 1. Run `docker compose --profile=analytics up tinybird-sync`. This will copy the Tinybird files from the Ghost container into a shared volume. The service should log "Tinybird files synced into shared volume.", then exit. 1. Run `docker compose --profile=analytics up tinybird-deploy` and wait for the service to exit successfully. This will create your Tinybird datasources, pipes and API endpoints. It may take a minute or two to complete the first time. You should see "Deployment #1 is live!" in your terminal before the service exits. 1. Find your workspace's ID and events API endpoint: `docker compose run --rm tinybird-login tb --cloud info` - - Copy the value of "api", and add it to your `.env` file as `TINYBIRD_API_URL`. You can also find this value in your Tinybird Workspace's UI. - - Copy the value of "workspace_id", and add it to your `.env` file as `TINYBIRD_WORKSPACE_ID` + 1. Copy the value of "api", and add it to your `.env` file as `TINYBIRD_API_URL`. You can also find this value in your Tinybird Workspace's UI. + 1. Copy the value of "workspace_id", and add it to your `.env` file as `TINYBIRD_WORKSPACE_ID` 1. Using the UI link from the previous step, open your workspace and click on *Tokens* in the left hand menu 1. Copy your Tinybird "Workspace admin token" and add it to your `.env` file as `TINYBIRD_ADMIN_TOKEN` 1. Copy your Tinybird `tracker` token and add it to your `.env` file as `TINYBIRD_TRACKER_TOKEN` 1. Run `docker compose --profile=analytics up -d` to start all services in the background -1. Set `COMPOSE_PROFILES=analytics` in your `.env` file to automatically include the `analytics` profile when running `docker compose` commands +1. Add `analytics` to `COMPOSE_PROFILES=` in the top of your `.env` file to automatically include the `analytics` profile when running `docker compose` commands 1. At this point, everything should be working. You can test it's working by visiting your site's homepage, then checking the Stats page in Ghost Admin — you should see a view recorded.