Skip to content

Commit ebe9c30

Browse files
committed
Simplify TB initial setup
no ref - By outputting the tokens in the format the `.env` file expects this greatly simplifies the initial setup by just makign it copy -> paste able - This will mean users don't need to load up the UI and copy/paste tokens at all and can do the whole setup (after they've signed up for TB) from the CLI
1 parent ff9e886 commit ebe9c30

2 files changed

Lines changed: 6 additions & 11 deletions

File tree

TINYBIRD.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@ Note: Currently Traffic Analytics features are behind a feature flag. For now, y
66
1. Run `docker compose run --rm tinybird-login` to login to your Tinybird account following the steps given
77
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.
88
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.
9-
1. Find your workspace's ID and events API endpoint: `docker compose run --rm tinybird-login tb --cloud info`
10-
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.
11-
1. Copy the value of "workspace_id", and add it to your `.env` file as `TINYBIRD_WORKSPACE_ID`
12-
1. Using the UI link from the previous step, open your workspace and click on *Tokens* in the left hand menu
13-
1. Copy your Tinybird "Workspace admin token" and add it to your `.env` file as `TINYBIRD_ADMIN_TOKEN`
14-
1. Copy your Tinybird `tracker` token and add it to your `.env` file as `TINYBIRD_TRACKER_TOKEN`
9+
1. Run `docker compose --profile=analytics run --rm tinybird-login get-tokens`
10+
1. Copy and paste the values from the previous step into your `.env` file
1511
1. Run `docker compose --profile=analytics up -d` to start all services in the background
1612
1. Add `analytics` to `COMPOSE_PROFILES=` in the top of your `.env` file to automatically include the `analytics` profile when running `docker compose` commands
1713
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.

tinybird/getTokens.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
# Get token from .tinyb JSON file
44
USER_TOKEN=$(jq -r '.token' .tinyb)
5-
echo "User token: $USER_TOKEN"
65

76
if [ -z "$USER_TOKEN" ] || [ "$USER_TOKEN" = "null" ]; then
87
echo "Error: Could not find token in .tinyb file"
@@ -11,7 +10,7 @@ fi
1110

1211
# Get host from .tinyb JSON file
1312
HOST=$(jq -r '.host' .tinyb)
14-
echo "Host: $HOST"
13+
echo "TINYBIRD_API_URL=$HOST"
1514

1615
if [ -z "$HOST" ] || [ "$HOST" = "null" ]; then
1716
echo "Error: Could not find host in .tinyb file"
@@ -20,7 +19,7 @@ fi
2019

2120
# Get id from .tinyb JSON file
2221
WORKSPACE_ID=$(jq -r '.id' .tinyb)
23-
echo "Workspace ID: $WORKSPACE_ID"
22+
echo "TINYBIRD_WORKSPACE_ID=$WORKSPACE_ID"
2423

2524
if [ -z "$WORKSPACE_ID" ] || [ "$WORKSPACE_ID" = "null" ]; then
2625
echo "Error: Could not find id in .tinyb file"
@@ -37,5 +36,5 @@ ADMIN_TOKEN=$(echo "$RESPONSE" | jq -r '.tokens[] | select(.name == "admin token
3736
TRACKER_TOKEN=$(echo "$RESPONSE" | jq -r '.tokens[] | select(.name == "tracker") | .token')
3837

3938
# Echo the tokens as proof of concept
40-
echo "Admin token: $ADMIN_TOKEN"
41-
echo "Tracker token: $TRACKER_TOKEN"
39+
echo "TINYBIRD_ADMIN_TOKEN=$ADMIN_TOKEN"
40+
echo "TINYBIRD_TRACKER_TOKEN=$TRACKER_TOKEN"

0 commit comments

Comments
 (0)