Smartype Hubs allow you to import and continously sync your mParticle Data Plans into Github using Github Actions, and quickly generate custom SDKs using Smartype. The generated SDKs can then be imported into your sites and apps via NPM!
Please note that Smartype Hubs currently only support NPM Packages via Github Packages.
- Create one or more Data Plans in your mParticle workspace and note their data plan IDs. For more details, visit the mParticle Data Plan docs.
- Generate an API key and secret for your workspace with access to the Data Planning API
Click the Use this template button above to create your Hub based off of this repository template.
Edit the mp.config.json file in the root directory of your Hub:
- Choose which Data Plan IDs and versions you would like to sync to your Hub, and add each as a separate item to the
dataPlans
array. - Then commit your updated mp.config.json to the
master
branch of your Hub.
{
"smartypeHubConfig": {
"dataPlans": [
{
"dataPlanId": "example_data_plan",
"versions": [1, 2, 3]
},
{
"dataPlanId": "another_example_data_plan",
"versions": [1]
}
],
// This is the directory where data plans will be created
// The directory must exist in your file system before you run the process
"dataplanOutputDirectory": "dataplans"
}
}
Add the following encrypted secrets to your Hub:
MP_WORKSPACE_ID
: The integer ID of the workspace that contains your Data Plan(s)MP_CLIENT_ID
: A client ID with access to the Data Planning APIMP_CLIENT_SECRET
: A matching client secret with access to the Data Planning API
Smartype Hubs use Github Actions to sync your Data Plans and generate your Smartype SDKs. At present, the main Github Actions "workflow" uses a manual trigger that can be executed via the Actions tab in your Hub.
- Navigate to the Github Actions tab of your Hub
- Look for Generate Data Plans
- Select the dropdown Run Workflow
- Select your desired branch and Click the Run Workflow button 🚀
The workflow will then do the following:
- Fetch your latest data plan(s) from mParticle
- Create Smartype SDKs based on each Data Plan ID and version that you configured in your
mp.config.json
file - Publish your Smartype SDKs as NPM packages to your Hub's Github package repository
The resulting package name is based on your Github owner account, the name of your Hub, and a Data Plan ID. For example, if your Github owner name is octocat
and your Smartype Hub repo is called my-smartype-hub
and your Data Plan ID is example_data_plan
, your package will be:
@octocat/my-smartype-hub-example_data_plan
With your packages generated, you can now import them into any other project.
-
Create an
.npmrc
file in the root directory of your project with your github owner account and the github registry url. For example, if your company/owner name isoctocat
:@octocat:registry=https://npm.pkg.github.com/
-
Run
npm install @<github-name>/<smartype-package-distribution>
- For example,
npm install @octocat/my-smartype-project-generic-data-plan
This will automatically update your package.json
and add the latest version of your data plan to your project. Note that if you made your Smartype Hub private, you will need to make sure you configure authentication.
Questions? Give us a shout at support@mparticle.com
Smartype Hubs are available under the Apache License, Version 2.0. See the LICENSE file for more info.