a repository that demonstrates the power of GitHub workflows to enhance management of a Segment Tracking Plan
this project will need the following github respoitory secrets
SEGMENT_PUBLIC_API_TOKEN
DEV_SEGMENT_TRACKING_PLAN_ID_<TP_NAME>
* n number of trackplansPROD_SEGMENT_TRACKING_PLAN_ID_<TP_NAME>
* n number of tracking plans- This repo uses a javascript & server tracking plans
- Which means I have 5 total github secrets
- 1 for the public api
- 2 for javascript (dev & prod)
- 2 for server (dev & prod)
- Any changes to rules located in
tracking-rules/server
ortracking-rules/javascript
pushed to a new branch will trigger DEV workflowupdate-and-save-tracking-plans
does the following- takes the changed yaml files and converts the rule to JSON
PATCH
update rules to update the Segment DEV tracking plan- NOTE you can make changes to multilpe changes in a single branch. the workflow checks to make sure rules have been updated
GET
rules endpoint (Segment Public API) and saves the output toplans/dev/<TP_NAME>/current-rules.json
- Add, commit, and push files to branch
- Any changes to rules located in
tracking-rules/server
ortracking-rules/javascript
from merged branch to main trigger PROD workflowupdate-and-generate-markdown
does the following- takes the changed yaml files and converts the rule to JSON
PATCH
update rules to update the Segment PROD tracking planGET
rules endpoint (Segment Public API) and saves the output toplans/prod/<TP_NAME>/current-rules.json
render-tp.js
outputs a markdown file using the new rules inplans/prod/../current-rules.json
->docs/<TP_NAME>.md
-docs/<TP_NAME>.md
is defined by an arugment value inupdate-prod-tracking-plans.yml
- Add, commit push to main
If a new release is created & the title is RESET DEV
the following workflow will trigger:
GET
PROD tracking plan rulesPUT
(replace all rules) output from step 1 inDEV
tracking plans (Segment)- updates rules in
plans/dev/<TP_NAME>/current-rules.json
If rules are updated in the app and not via yaml the markdown data dictionary may get outdated.
GET
PROD
rulesrender-tp.js
Reccommended to run locally, you can access generate-yaml-rules.js
npm install
node scripts/generate-yaml-rules.js plans/prod/<TP_NAME> tracking-rules/rules/<TP_NAME>
- you may need to create a directory
plans/rules/<TP_NAME>
- you may need to create a directory
- Converts all PROD rules to their own unique yaml file for easy updates