Google Apps Script is a Google-hosted JavaScript environment. All Google Data Studio community connectors (i.e. plugins not developed by Google) are developed and run in this environment. There is a web editor available for Apps Script, but at Supermetrics we typically prefer to write code locally and push to the cloud environment via clasp. The web editor is still useful for testing and deployment of the connector however.
Detailed documentation on writing Data Studio connectors can be found here.
In order to deploy and test a connector you will require a Google account, and will have to accept the Terms & Conditions of use for Data Studio.
In this repo there is an incomplete implementation of a very basic Data Studio connector.
The connector already has user authentication, connection configuration, and schema retrieval implemented. You should,
You should fetch the data from the API described below, making use of the configuration values provided by the user. The data provided by the API will require some processing to produce the correct metrics and dimensions.
It is expected that the user will provide their own client_id
when authenticating the connector, you can use ju16a6m81mhid5ue1z3v2g0uh
for testing.
Use the following endpoint to register a token:
POST: https://api.supermetrics.com/assignment/register
PARAMS:
*client_id:* Client ID from user authentication
*email:* User's email from configuration screen
*name:* User's name from configuration screen
RETURNS
*sl_token:* This token string should be used in the subsequent queries. Please note that this token will only last 1 hour from when the REGISTER call happens. You will need to register and fetch a new token as you need it.
*client_id:* Returned for informational purposes only
*email:* Returned for informational purposes only
Use the following endpoint to fetch posts:
GET: https://api.supermetrics.com/assignment/posts
PARAMS:
*sl_token:* Token from the register call
*page:* Integer page number of posts (1-10)
RETURNS:
*page:* What page was requested or retrieved
*posts:* 100 posts per page
The user can configure a limit on the number of posts fetched from the API, your implementation of getData
should respect this setting.
The connector is very simple, and not necessarily written following best practices. Feel free to refactor or extend any part of the connector code. Even if you choose not to improve the connector much, we will discuss potential improvements in the interview.
After installing the project dependencies via yarn
, you can run the convenience script yarn setup
to login to clasp
and create a new script to work with. You can push your local code to the script with yarn build
.