Code Generation (Codegen) Beta
- free
- growth
- enterprise
2 minute read
This feature is in Public Beta, where we work with early users and customers to test new features and get feedback before making them generally available.
Contact the Product team if you have any questions.
The Code Generation (Codegen) feature in Tracking Plans automatically generates language-specific code snippets based on your defined event schemas. This streamlines the instrumentation process by providing accurate code represents the schema definition, including:
- Clear structure of the
propertiesobject - Correct keys
- Examples that represent the correct data type
- Comments that specify whether properties are optional
Access codegen
- Go to Govern > Tracking Plans.
- Click the tracking plan and select the event to view the generated code snippet.

Supported languages
Currently, the Codegen feature only generates snippets for the JavaScript SDK. Support for additional languages is coming soon.
RudderTyper
Generated code snippets are helpful, but the best way to make it easy for instrumenting events correctly is to use RudderTyper in your IDE.
RudderTyper is a linting tool that generates and autocompletes typesafe code from tracking plan schemas.
Example
The below image shows how RudderStack translates the schema definition into the code snippet:

In this example:
- The value of
priceis set to an example integer. - The
categoryproperty is followed by// optional, denoting that it is not required. - The
product_detailsproperty is structured as an object. - Value of the
saleproperty is set to an example for a Boolean type.