Appearance
Codegen Schema ​
The codegen config JS file defines how your analytics types and tracking configuration should be generated. It purposefully uses a .js module so that CI can inject env variables into the config.
Note: the voltage codegen config file must be named "voltage.config.js".
Configuration ​
Field | Type | Required | Description |
---|---|---|---|
events | string | yes | Path to the events file that types & tracking config will be generated from |
groups | string[] | no | Paths to group file(s) for tracked events |
dimensions | string[] | no | Paths to dimension file(s) for tracked events |
meta | string | no | Path to meta file(s) to extend tracked events |
disableComments | boolean | no | Disable JSDoc style comments in generated files |
eventKeyPropertyName | string | no | Auto-track the event key under this property name |
output | string | yes | File path for generated types & tracking config |
Example ​
javascript
export default {
generates: [
{
events: "./analytics/events/unauthed-events.volt.yaml",
output: "/__analytics_generated__/unauthed-analytics.ts"
},
{
events: "./analytics/events/authed-events.volt.yaml",
groups: [
"./analytics/groups/user-group.volt.yaml",
"./analytics/groups/team-group.volt.yaml"
],
dimensions: [
"./analytics/dimensions/user-role-dimensions.volt.yaml",
"./analytics/dimensions/team-plan-dimensions.volt.yaml"
],
meta: './analytics/dimensions/user-role-dimensions.volt.yaml',
eventKeyPropertyName: "Event Key",
output: "/__analytics_generated__/authed-analytics.ts"
}
]
}
Running the codegen ​
To generate tracking config & typescript types from your codegen config, run voltage generate
.