6.6.15 • Published 1 year ago

@mediatool/mt-integrations v6.6.15

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

Mediatool Integrations

Mediatool is a SaaS platform where our clients collaborate over planning of their advertisements. As part of our service we provide the possibility for our clients to connect to their different marketing platforms such as Facebook Marketing, Google Ads etc in order to fetch the results of their marketing activities so that they can compare those results to their initial planning.

The purpose of this project is to add connections to new services that we do not currently have.

Overview

When a user wants to sync data from an API in Mediatool they create what we call a connection in our database. The process goes throught the steps below.

  1. The user connects to the remote service, usually via Oauth2. At a successful authentication a connection is created.
  2. On a successful authentication the users profile is also fetched and stored on the connection.
  3. The accounts for the user is then fetched. For Google Analytics this would be the websites the user has access to, for Facebook Marketing its the marketing accounts etc.
  4. The user selects which account(s) to fetch data from.
  5. The available metrics and dimensions for the provider is fetched.
  6. The user selects which measures and dimensions to fetch and how to map them to their measures and dimensions in Mediatool.
  7. The user saves the connection and at this point and the actual data is fetched based on the settings done in the previous steps.

How to add a connection to a new api

Setup oauth connection flow

First make sure an app is created at the provider and that you have the client id and the client secret. Also make sure that the correct callback uri have been configured for that app. These tasks should be taken care of by Mediatool.

  1. Open the file ./lib/api/api-public-conf.js and add the configuration to it for the new API. The configuration should contain clientId, scope, access token URL and redirect url. If the provider for the api you are integrating to is already in this file, you can re-use some properties like client id and secret. You can see several examples of this in the file.
  2. Create a "connection"-file in ./web/api/[apiKeyName].js. These files contain the same generic functions an provide you with the ability to customize the behavior for making the Oauth request and parsing the response. As in step 1, many APIs have the same provider and can therefore share configurations with other APIs. In that case, create a configuration by merging common props with the ones specific for the API you are working with.
  3. Add the new connection to the list in the file web/available-apis.js. Make sure to set the properties { released: false, completed: false }.
  4. Test the flow by starting the demo server with yarn demo, and go to the MTAvailableIntegrationsList component. If there is no icon for the API, ignore this, Mediatool will fix that part.

Fetch and normalize the user

This step is only needed if there are no existing integrations for the provider.

Create a function in lib/api/fetch-[provider]-account-info. The function should fetch the user that authenticated the connection.

Create a function in lib/api/normalize-[provider]-account-info. The function should take the result of the fetch function and return an object with the format:

{
  imageURL: [String],
  displayName: [String],
}

Fetch and normalize "profiles" available from the API

Create a function in lib/api/fetch-[provider]-[profiles/addacounts/etc]. The function should fetch the accounts that the user has access to.

Create a function in lib/api/normalize-[provider]-[profiles/addacounts/etc]. The function should take the result of the fetch function and return an array of objects with a property suitable for the api, in the case of Google Analytics it is availableViews and for Facebook Marketing it is availableAdAccounts. The property should map to a list of objects that has the property name, and other API specific properties needed to fetch the data.

Fetch and normalize fields available from the API

Fields are what populate the dimension and metrics selectors. They represent what can be queried from the API. How to get the available fields from an API depends on how the API provides them but the implementation for getting them to the user should be in the getFields function of the APIs connection object.

Fields should be returned as an object with two list properties, dimensions and metrics. Each list should contain objects with properties key, name and description. If description is not available, it can be left out.

Below are different methods of getting the fields:

  • Some providers have open routes where a user can request them (e.g. analytics). If this is the case, getFields can be implemented as a request using the superagent module. The response then needs to be proccesed so that the returned fields are normalized into the format described above. See web/api/analytics.js for an example.

  • Some providers only allow this information to be fetched with an authorized request. In that case, getFields will receive an object as its only parameter with a function called fetchFields that can should be called. This function is provided through our webapp and makes a request to our backend where the users refresh token is used to make the authorized request needed. See examples in web/api/facebook-marketing.js and web/api/dcm.js.

  • Some providers do not give any API endpoint at all for fetching fields. In this case the data needs to be found and stored locally in some way, probably a JSON or js file. The getFields function can then return a Future of the stored data. See web/api/google-ads.js for an example.

Create profile selector UI component used in the API form

Create a file in web/[apiName]-account-selector.js. This will be the React component that will let users select which profiles / ad accounts etc. they want to fetch data from. For most cases, you can use the "createAccountSelector" function which wraps the behaviour and requires only some configuration parameters. For an example, see web/google-analytics-account-selector.js. In special cases, you will need to write the component from scratch and include the custom behaviour you want to achieve, however like mentionned this is rarely the case.

put it all together in getAPIFunctions

Add a new registration in lib/api/get-api-functions.js where the key is the key of your API and the values are the functions you have created in the steps above.

6.6.15

1 year ago

6.6.14

1 year ago

6.6.13

1 year ago

6.6.12

1 year ago

6.6.11

1 year ago

6.6.10

2 years ago

6.6.9

2 years ago

6.6.8

2 years ago

6.6.7

2 years ago

6.6.6

2 years ago

6.6.5

2 years ago

6.6.4

2 years ago

6.6.3

2 years ago

6.6.2

2 years ago

6.6.1

2 years ago

6.6.0

2 years ago

6.5.2

2 years ago

6.5.1

2 years ago

6.5.0

2 years ago

6.4.9

2 years ago

6.4.8

2 years ago

6.4.7

2 years ago

6.4.6

2 years ago

6.4.5

2 years ago

6.4.4

2 years ago

6.4.3

2 years ago

6.4.2

2 years ago

6.4.1

2 years ago

6.4.0

2 years ago

6.3.7

2 years ago

6.3.6

2 years ago

6.3.5

2 years ago

6.3.4

2 years ago

6.3.3

2 years ago

6.3.2

2 years ago

6.3.1

2 years ago

6.3.0

2 years ago

6.2.21

2 years ago

6.2.20

2 years ago

6.2.19

2 years ago

6.2.18

2 years ago

6.2.17

2 years ago

6.2.16

2 years ago

6.2.15

2 years ago

6.2.14

2 years ago

6.2.13

2 years ago

6.2.12

3 years ago

6.2.11

3 years ago

6.2.10

3 years ago

6.2.9

3 years ago

6.2.8

3 years ago

6.2.7

3 years ago

6.2.6

3 years ago

6.2.5

3 years ago

6.2.4

3 years ago

6.2.3

3 years ago

6.2.2

3 years ago

6.2.1

3 years ago

6.2.0

3 years ago

6.1.2

3 years ago

6.1.1

3 years ago

6.1.0

3 years ago

6.0.0

3 years ago

5.7.1

3 years ago

5.7.0

3 years ago

5.6.7

3 years ago

5.6.6

3 years ago

5.6.5

3 years ago

5.6.4

3 years ago

5.6.3

3 years ago

5.6.2

3 years ago

5.6.1

3 years ago

5.6.0

3 years ago

5.5.7

3 years ago

5.5.6

3 years ago

5.5.5

3 years ago

5.5.4

3 years ago

5.5.3

3 years ago

5.5.2

3 years ago

5.5.1

3 years ago

5.5.0

3 years ago

5.4.2

3 years ago

5.4.1

3 years ago

5.4.0

3 years ago

5.3.8

3 years ago

5.3.7

3 years ago

5.3.6

3 years ago

5.3.5

3 years ago

5.3.4

3 years ago

5.3.3

3 years ago

5.3.2

3 years ago

5.3.1

3 years ago

5.3.0

3 years ago

5.2.10

3 years ago

5.2.9

3 years ago

5.2.8

3 years ago

5.2.7

3 years ago

5.2.6

3 years ago

5.2.5

3 years ago

5.2.4

3 years ago

5.2.3

3 years ago

5.2.2

3 years ago

5.2.1

4 years ago

5.2.0

4 years ago

5.1.1

4 years ago

5.1.0

4 years ago

5.0.3

4 years ago

5.0.2

4 years ago

5.0.1

4 years ago

5.0.0

4 years ago

4.1.0

4 years ago

4.0.14

4 years ago

4.0.13

4 years ago

4.0.12

4 years ago

4.0.11

4 years ago

4.0.10

4 years ago

4.0.9

4 years ago

4.0.8

4 years ago

4.0.7

4 years ago

4.0.6

4 years ago

4.0.5

4 years ago

4.0.4

4 years ago

4.0.3

4 years ago

4.0.2

4 years ago

4.0.1

4 years ago

4.0.0

4 years ago

3.5.3

4 years ago

3.5.2

4 years ago

3.5.1

4 years ago

3.5.0

4 years ago

3.4.0

4 years ago

3.3.0

4 years ago

3.2.8

4 years ago

3.2.7

4 years ago

3.2.6

4 years ago

3.2.5

4 years ago

3.2.4

4 years ago

3.2.3

4 years ago

3.2.2

4 years ago

3.2.1

4 years ago

3.2.0

4 years ago

3.1.18

4 years ago

3.1.17

4 years ago

3.1.16

4 years ago

3.1.15

4 years ago

3.1.14

4 years ago

3.1.13

4 years ago

3.1.12

4 years ago

3.1.11

4 years ago

3.1.10

4 years ago

3.1.9

4 years ago

3.1.8

4 years ago

3.1.7

4 years ago

3.1.6

4 years ago

3.1.5

4 years ago

3.1.4

4 years ago

3.1.3

4 years ago

3.1.2

4 years ago

3.1.1

4 years ago

3.1.0

4 years ago

3.0.19

4 years ago

3.0.18

4 years ago

3.0.17

4 years ago

3.0.16

5 years ago

3.0.15

5 years ago

3.0.14

5 years ago

2.2.6

5 years ago

2.2.5

5 years ago

2.2.4

5 years ago

2.2.3

5 years ago

2.2.1

5 years ago

3.0.13

5 years ago

3.0.12

5 years ago

2.2.2

5 years ago

3.0.11

5 years ago

2.2.0

5 years ago

3.0.10

5 years ago

2.1.15

5 years ago

2.1.14

5 years ago

2.1.13

5 years ago

2.1.12

5 years ago

2.1.11

5 years ago

3.0.9

5 years ago

2.1.10

5 years ago

2.1.9

5 years ago

3.0.8

5 years ago

3.0.7

5 years ago

3.0.6

5 years ago

3.0.5

5 years ago

2.1.8

5 years ago

3.0.4

5 years ago

2.1.7

5 years ago

3.0.3

5 years ago

2.1.6

5 years ago

3.0.2

5 years ago

2.1.5

5 years ago

2.1.4

5 years ago

2.1.3

5 years ago

2.1.2

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.0.22

5 years ago

2.0.21

5 years ago

2.0.20

5 years ago

2.0.19

5 years ago

2.0.18

5 years ago

2.0.17

5 years ago

2.0.16

5 years ago

2.0.15

5 years ago

2.0.14

5 years ago

2.0.13

5 years ago

2.0.12

5 years ago

2.0.11

5 years ago

2.0.10

5 years ago

2.0.9

5 years ago

2.0.8

5 years ago

2.0.7

5 years ago

2.0.6

5 years ago

2.0.5

5 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.4.2

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.40

5 years ago

1.3.39

5 years ago

1.3.38

5 years ago

1.3.37

5 years ago

1.3.36

5 years ago

1.3.35

5 years ago

1.3.34

5 years ago

1.3.33

5 years ago

1.3.32

5 years ago

1.3.31

5 years ago

1.3.30

5 years ago

1.3.29

5 years ago

1.3.28

5 years ago

1.3.27

5 years ago

1.3.26

5 years ago

1.3.25

5 years ago

1.3.24

5 years ago

1.3.23

5 years ago

1.3.22

5 years ago

1.3.21

5 years ago

1.3.20

5 years ago

1.3.19

5 years ago

1.3.18

5 years ago

1.3.17

5 years ago

1.3.16

5 years ago

1.3.15

5 years ago

1.3.14

5 years ago

1.3.13

5 years ago

1.3.12

5 years ago

1.3.11

5 years ago

1.3.10

5 years ago

1.3.9

5 years ago

1.3.8

5 years ago

1.3.7

5 years ago

1.3.6

5 years ago

1.3.5

5 years ago

1.3.4

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.5

6 years ago

1.2.4

6 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.11.8

6 years ago

0.11.7

6 years ago

0.11.6

6 years ago

0.11.5

6 years ago

0.11.4

6 years ago

0.11.3

6 years ago

0.11.2

6 years ago

0.11.1

6 years ago

0.11.0

6 years ago

0.10.0

6 years ago

0.9.1

6 years ago

0.9.0

6 years ago

0.8.1

6 years ago

0.8.0

6 years ago

0.7.9

6 years ago

0.7.8

6 years ago

0.7.7

6 years ago

0.7.6

6 years ago

0.7.5

6 years ago

0.7.4

6 years ago

0.7.3

6 years ago

0.7.2

6 years ago

0.7.1

6 years ago

0.7.0

6 years ago

0.6.4

6 years ago

0.6.3

6 years ago

0.6.2

6 years ago

0.6.1

6 years ago

0.6.0

6 years ago

0.5.0

6 years ago

0.4.0

6 years ago

0.3.5

6 years ago

0.3.4

6 years ago

0.3.3

6 years ago

0.3.2

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.4

6 years ago

0.2.3

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.19

6 years ago

0.1.18

6 years ago

0.1.17

6 years ago

0.1.16

6 years ago

0.1.15

6 years ago

0.1.14

6 years ago

0.1.13

6 years ago

0.1.12

6 years ago

0.1.11

6 years ago

0.1.10

6 years ago

0.1.9

6 years ago

0.1.8

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago