generate
opentp generate
Section titled “opentp generate”Exports your tracking plan to various output formats.
opentp generate <target> [options]Targets
Section titled “Targets”| Target | Description | Output |
|---|---|---|
json | JSON export | stdout (or --output <file>) |
yaml | YAML export | stdout (or --output <file>) |
template | Custom template | Configured output |
Options
Section titled “Options”| Option | Description |
|---|---|
--root <path> | Project root directory |
--output <path> | Output file path |
--pretty / --no-pretty | Pretty print output (JSON generator; default: true) |
--file <path> | Template file path (template generator) |
--external-generators <path> | Load custom generators |
Examples
Section titled “Examples”Export to JSON
Section titled “Export to JSON”opentp generate jsonPrints JSON to stdout. Use --output to write a file.
Export to YAML
Section titled “Export to YAML”opentp generate yamlPrints YAML to stdout. Use --output to write a file.
Custom output path
Section titled “Custom output path”opentp generate json --output ./dist/events.jsonUsing custom generators
Section titled “Using custom generators”opentp generate my-format --external-generators ./my-generatorsExternal generators are loaded only via --external-generators (the spec does not include external plugin loading).
Output Format
Section titled “Output Format”JSON Output
Section titled “JSON Output”{ "opentp": "2026-01", "info": { "title": "My App Tracking Plan", "version": "1.0.0" }, "events": [ { "key": "auth::login_click", "taxonomy": { "area": "auth", "event": "login_click", "action": "User clicks the login button" }, "lifecycle": { "status": "active" }, "payload": { "schema": { "event_name": { "value": "login_click" }, "dimension_1": { "type": "string", "name": "orgType", "example": "enterprise" } } } } ], "dictionaries": {}}YAML Output
Section titled “YAML Output”opentp: 2026-01info: title: My App Tracking Plan version: 1.0.0events: - key: auth::login_click taxonomy: area: auth event: login_click action: User clicks the login button lifecycle: status: active payload: schema: event_name: value: login_click dimension_1: type: string name: orgType example: enterprisedictionaries: {}Custom Generators
Section titled “Custom Generators”Create custom generators for any output format:
module.exports = { name: 'typescript', generate: async (context) => { const { config, events, dictionaries, options } = context; // Generate TypeScript SDK return { files: [ { path: 'events.ts', content: '...' } ] }; }};See Custom Generators for details.