diff --git a/TINYBIRD.md b/TINYBIRD.md index f30c56f..a9a8e70 100644 --- a/TINYBIRD.md +++ b/TINYBIRD.md @@ -4,11 +4,12 @@ Note: Currently Traffic Analytics features are behind a feature flag. For now, y 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. -2. Follow the first two steps in the Quickstart to install the Tinybird CLI and run `tb login`, but _do not proceed any further with the Quickstart instructions_. -3. 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. -4. 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. -5. Copy your Tinybird `stats_page` token: `tb --cloud token copy stats_page` and add it to your `.env` file as `TINYBIRD_STATS_TOKEN`. You can also copy the `stats_page` token from your Tinybird Workspace's UI. -6. Copy your Tinybird `tracker` token: `tb --cloud token copy tracker` and add it to your `.env` file as `TINYBIRD_TRACKER_TOKEN`. You can also copy the `tracker` token from your Tinybird Workspace's UI. -7. Find your workspace's events API endpoint: `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. -8. Run `docker compose --profile=analytics up -d` to start all services in the background. You can also set `COMPOSE_PROFILES=analytics` in your `.env` file to automatically include the `analytics` profile when running `docker compose` commands. -9. 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. +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. 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 `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. You can also set `COMPOSE_PROFILES=analytics` in 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. diff --git a/tinybird/handleLogin.sh b/tinybird/handleLogin.sh index 48989de..087ed39 100755 --- a/tinybird/handleLogin.sh +++ b/tinybird/handleLogin.sh @@ -1,5 +1,17 @@ #!/usr/bin/env bash +# If arguments are provided, run tb command with those arguments +if [[ $# -gt 0 ]]; then + # Check if logged in first + if [[ ! -f "/home/tinybird/.tinyb" ]]; then + echo "Not logged in to Tinybird. Please run 'docker compose run --rm tinybird-login' first" + exit 1 + fi + # Run the tb command with provided arguments + exec tb "$@" +fi + +# Default behavior: login # Check if already logged in if [[ -f "/home/tinybird/.tinyb" ]] then