Skip to content

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 ​

FieldTypeRequiredDescription
eventsstringyesPath to the events file that types & tracking config will be generated from
groupsstring[]noPaths to group file(s) for tracked events
dimensionsstring[]noPaths to dimension file(s) for tracked events
metastringnoPath to meta file(s) to extend tracked events
disableCommentsbooleannoDisable JSDoc style comments in generated files
eventKeyPropertyNamestringnoAuto-track the event key under this property name
outputstringyesFile 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.