GoodData for VS Code
GoodData for VS Code is available for you to try out and provide feedback. Avoid using GoodData for VS Code in a production environment.
Manage your analytics as code directly from Visual Studio Code.
GoodData for VS Code consists of two components:
Together these tools allow you to:
- Retrieve analytical objects from a GoodData server.
- Create or update analytical objects in Visual Studio Code.
- Test analytical objects locally in Visual Studio Code.
- Deploy analytical objects to a GoodData server of your choice.
The analytical objects you can work with include datasets, which form the logical data model, and metrics. Additionally, we have plans to incorporate support for visualizations in the near future.
By adopting a code-based approach to your analytics, you gain the following benefits:
- Version your analytics by committing your code to a git version control system.
- Implement automatic tests to ensure the quality and reliability of your analytics solutions.
Prerequisites
Before getting started, ensure that you have:
Install VS Code Extension
Start by installing GoodData Visual Studio Code Extension (VS Code Extension) that provides tools for developer effectiveness, such as IntelliSense, syntax highlighting, and validation.
Steps:
- Open extensions tab in your VS Code.
- In the search bar, look for "GoodData".
- Select the GoodData extension and install it.
Install CLI
Now you will install GoodData Command-line Interface (CLI) that will let you sync your local working directory with the GoodData server.
In terminal, run npm i -g @gooddata/code-cli
.
You should have a new CLI command available, try running gd -v
or gd --help
.
Initialize Project
Once the CLI is installed you are able to initialize your project locally.
Steps:
- Open a terminal and navigate to a folder where you want to build and store your analytics.
- To initialize your project, run
gd init
and follow the instructions to create a gooddata.yaml
definition file.
- Create a
.env
file in the same folder as gooddata.yaml
and add an environmental variable that stores
your API access token. For example:GD_API_TOKEN="fd6f9a71541856b4c9617f74a8576e131"
.
- To clone your GoodData analytical environment to your local machine, run
gd clone
.
Make sure you do not store the .env
file in you version control system (like Git).
For example, you can add the file to .gitignore
.
You should now have an analytics
folder that contains your datasets
and metrics
.
Create and Test a New Metric
Create a new analytical object and run it directly from VS Code.
Steps:
- Create a new yaml file in your metrics folder to represent your new metric. For example
revenue_per_customer.yaml
.
- Define a metric:
type: metric
id: revenue_per_customer
title: Revenue per Customer
description: The average revenue generated by each customer
maql: SELECT AVG(SELECT {metric/revenue} BY {label/customer_id})
Notice the Run button appearing above the type
property in the YAML file.
- Click the Run to run your metric on the data source that you defined when initializing your
gooddata.yaml
project configuration file to verify your metric works as designed.
- Save the file.
Deploy Your Changes
To deploy your project to a GoodData server, ensure all your changes are saved and run gd deploy
.
Your changes will be deployed to the hostname and workspace you defined in the gooddata.yaml
definition file.