Skip to main content

Sync metrics and fact tables to GrowthBook

Project description

gbsync

Sync artifacts to GrowthBook using a version-controlled YAML configuration, enabling reproducible deployments and safe collaboration.

Currently supports:

  • Fact Tables
  • Fact Table Filters
  • Fact Metrics
  • Environments

Note: gbsync talks directly to the GrowthBook API, so synced resources are flagged as official and cannot be edited from the console — change YAML and re-apply.

Python 3.12+ License: MIT

Features

  • Infrastructure as Code: Define growthbook artifacts in YAML so that it can be version controlled
  • Dry-Run Planning: See what will change before applying
  • Safe Syncing: Automatic conflict detection and validation
  • External File Includes: Organize SQL in separate files

Installation

From PyPI

pip install gbsync

From Source

git clone https://github.com/growthbook/gbsync.git
cd gbsync
pip install -e .

Requirements

  • Python 3.12 or higher
  • GrowthBook account with API access
  • Supported data warehouses: Snowflake, BigQuery, PostgreSQL, MySQL, Redshift, Athena, ClickHouse, MongoDB

Quick Start

1. Get Your API Credentials

  1. Log into GrowthBook
  2. Go to Settings → API Keys
  3. Create a new API key (or copy existing)
  4. Note the API URL (e.g., https://api.growthbook.io)

2. Set Environment Variables

export GB_API_KEY="your_api_key"
export GB_API_URL="https://api.growthbook.io"

3. Create Configuration

Copy the example configuration:

cp examples/gbsync.yaml gbsync.yaml

Edit gbsync.yaml with your datasource ID, SQL, and metrics:

factTables:
  - id: fact_events
    data:
      name: Events
      datasource: ds_YOUR_DATASOURCE_ID
      userIdTypes: [user_id]
      sql: !include fact_tables/events.sql

factMetrics:
  - id: metric_conversion_rate
    data:
      name: Conversion Rate
      metricType: ratio
      numerator:
        factTableId: fact_events
        column: conversions
      denominator:
        factTableId: fact_events
        column: total_events

4. Plan Changes

See what will be created/updated/deleted:

gbsync plan

Output:

GrowthBook: Planning changes...

Tables:
  ✓ Create: Events

Metrics:
  ✓ Create: Conversion Rate

Ready to apply 2 changes

5. Apply Changes

gbsync apply

Output:

GrowthBook: Planning changes...

Tables:
  ✓ Create: Events

Metrics:
  ✓ Create: Conversion Rate

Ready to apply 2 changes
Proceed with apply? [y/N]: y

✓ Applied successfully

Commands

plan

Preview changes without applying them.

gbsync plan [OPTIONS]

Options:

  • --config, -c: Path to configuration file (default: gbsync.yaml)
  • --api-key: GrowthBook API key (or GB_API_KEY env var)
  • --api-url: GrowthBook API URL (or GB_API_URL env var)

Example:

gbsync plan --config ./metrics/prod.yaml
gbsync plan --api-key "sdk-abc123..."

apply

Apply changes to GrowthBook.

gbsync apply [OPTIONS]

Options:

  • --config, -c: Path to configuration file (default: gbsync.yaml)
  • --api-key: GrowthBook API key (or GB_API_KEY env var)
  • --api-url: GrowthBook API URL (or GB_API_URL env var)
  • --auto-approve: Skip confirmation prompt (use with caution)

Example:

gbsync apply
gbsync apply --auto-approve  # Dangerous: skips confirmation

Configuration

See examples/gbsync.yaml for an annotated reference covering projects, environments, fact tables, filters, metrics, template variables.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gbsync-1.0.1.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gbsync-1.0.1-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file gbsync-1.0.1.tar.gz.

File metadata

  • Download URL: gbsync-1.0.1.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for gbsync-1.0.1.tar.gz
Algorithm Hash digest
SHA256 0ad1ea6650ed2732e554484c1729dab981b6b7170a71fae765647991ab28de84
MD5 d8bda294d7918429c3b9b09ffe8bc839
BLAKE2b-256 fa54390781af0d663dfb617706b02ec9429ea0f40995179adda838ae98c7f55a

See more details on using hashes here.

File details

Details for the file gbsync-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: gbsync-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for gbsync-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 701550b97a070c6c0460b8807fb8d3a89845a11112d51e3c6a87b6e29af84bbd
MD5 ff3af9c432c10e0c9ab71d1578eac63a
BLAKE2b-256 c71fc443a6727116843d2cc9049b2eae34e331806eef6318e2f27be1c7053d70

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page