Welcome to the demonstration repository for synchronizing a semantic layer with Statsig. This repository showcases how to integrate Statsig with your data metrics and sources through an automated process. Utilizing a script executed by a GitHub Action, this setup automatically synchronizes changes to .yml
files located in the /metrics
or /metric_sources
directories. This means that whenever you create or update these files, the script either updates existing metrics or metric sources in Statsig or creates new ones accordingly. Note: The current setup does not handle deletions.
To integrate this process into your workflow, follow these steps:
- Fork this repository to get started.
- In your forked repository, add your Statsig Console API Key to GitHub Secrets.
- Tailor the metric definitions to align with your data needs.
- Verify the automation by modifying relevant files and observing the triggered GitHub Action.
- Navigate to
Settings > Secrets and variables > Actions
in your repository settings. Create a new secret namedSTATSIG_API_KEY
with your Statsig Console API key as its value. This key facilitates authentication with the Statsig Console API for the synchronization process.
-
Metric definitions reside within the
./metrics
directory, and metric source definitions are found in the./metric_sources/
directory. To customize:- Utilize the Statsig Console API to fetch an existing metric_source or metric using GET requests for metric sources and metrics.
- Remove the provided example metrics and metric sources, and replace them with your definitions in
./metric_sources/*.yml
and./metrics/*.yml
.
Note: For enhanced readability, we modified metric.warehouseNative[]
to metric.metricDefinition[]
in our examples. You can see this change here. Feel free to adjust the translations or revert to using metric.warehouseNative[]
in your definitions.
- To test, edit a metric or metric source description in your repository. This action should trigger the GitHub Action, visible under the
Actions
tab. The process will then either create or update your metrics and metric sources in Statsig based on the repository's semantic definitions.
- This example serves as a basic MVP. We encourage testing and further development to meet production standards. Please share any feedback or improvements you've made to this workflow. Thank you for your contributions!