Spec Version:

RudderTyper v2 Command Reference Beta

Complete RudderTyper v2 command reference for generating type-safe client bindings via Rudder CLI.
Available Plans
  • starter
  • growth
  • enterprise

This page serves as a detailed reference for the RudderTyper v2 CLI commands available through Rudder CLI.

Overview

RudderTyper v2 is integrated into Rudder CLI and provides the following commands to generate type-safe client bindings from your Tracking Plans:

CommandUse case
workspace tracking-plans listList all Tracking Plans in your workspace
typer generateGenerate type-safe client bindings from a Tracking Plan
typer optionsView available platform-specific options for customizing generated code

List Tracking Plans

The workspace tracking-plans list command displays an interactive table with all available Tracking Plans in your workspace.

Command syntax

rudder-cli workspace tracking-plans list

Description

This command displays an interactive interface showing all Tracking Plans in your workspace.

Selecting a Tracking Plan from the list shows its details in a panel on the right, including the plan’s name, description, and current version, as shown:

List of Tracking Plans in your workspace

Generate bindings

The typer generate command generates type-safe bindings for a specified platform from a Tracking Plan.

Command syntax

rudder-cli typer generate --platform=<PLATFORM> --tracking-plan-id=<TRACKING_PLAN_ID> [options]

Parameters

ParameterType
Description
--platform
Required
StringSpecifies the platform for code generation. Supported values: kotlin, swift.
--tracking-plan-id
Required
StringSpecifies the ID of the Tracking Plan to generate bindings from. You can obtain this ID using the List Tracking Plans command or from your RudderStack dashboard URL: https://app.rudderstack.com/trackingPlans/<ID>.
-o, --outputStringSpecifies the output directory for storing generated files. If omitted, defaults to the current working directory.
--optionStringSpecifies platform-specific options to customize the generated code. Accepts key/value pairs separated by =. You can specify multiple options by repeating the flag — see Platform options for available options.
-h, --helpFlagDisplays help information for the command.

Examples

  • Generate Kotlin bindings with default settings:
rudder-cli typer generate --platform=kotlin --tracking-plan-id=tp_1234567890abcdef
  • Generate Swift bindings with default settings:
rudder-cli typer generate --platform=swift --tracking-plan-id=tp_1234567890abcdef
  • Generate bindings to a specific output directory:
rudder-cli typer generate --platform=kotlin --tracking-plan-id=tp_1234567890abcdef -o ./generated-code
  • Generate Kotlin bindings with a custom package name:
rudder-cli typer generate --platform=kotlin --tracking-plan-id=tp_1234567890abcdef --option packageName=com.example.package

View platform options

The typer options command displays available platform-specific options for customizing generated code.

Command syntax

rudder-cli typer options --platform=<platform>

Parameters

ParameterTypeDescription
--platform
Required
StringSpecifies the platform to view options for. Supported values: kotlin, swift.
-h, --helpFlagDisplays help information for the command.

Description

This command displays an interactive interface showing all available options for the specified platform, along with their descriptions and usage examples.

Rudder CLI Kotlin platform options

Example

rudder-cli typer options --platform=kotlin

Platform options

Platform-specific options customize how code is generated for each platform. Pass these options to the typer generate command using the --option flag with a key/value pair format: --option key=value.

Kotlin platform options

OptionTypeDescriptionExample
packageNameStringPackage name to use for the generated Kotlin code. If not specified, defaults to com.rudderstack.ruddertyper.--option packageName=com.example.package

Example:

rudder-cli typer generate --platform=kotlin --tracking-plan-id=tp_1234567890abcdef --option packageName=com.example.package

Swift platform options

The Swift platform does not currently expose any platform-specific options.

Supported platforms

PlatformLanguageUse case
kotlinKotlinAndroid and JVM applications
swiftSwiftiOS applications

Generated code structure

The generated code structure depends on the platform and options specified.

Kotlin

By default, Kotlin bindings are generated with the package name com.rudderstack.ruddertyper. The generated files should be placed in a directory structure that matches the package name:

src/main/kotlin/com/rudderstack/ruddertyper/

Custom package structure

If you specify a custom packageName option, place the generated files in a directory structure that matches your custom package name. For example, with packageName=com.example.package:

src/main/kotlin/com/example/package/

Swift

Swift bindings are generated as a single RudderTyper.swift file. The file is organized into the following sections:

RudderTyper.swift
├── Custom Types        (type aliases and structs for custom types)
├── Property Types      (type aliases for property types)
├── Event Properties    (structs for event properties and traits)
└── RudderTyperAnalytics (wrapper class with type-safe event methods)

The generated file imports Foundation and RudderStackAnalytics.

Using generated code

After generating the code, import it into your project and use the type-safe methods for tracking.

The generated code provides:

  • Type-safe event methods: Each event in your Tracking Plan becomes a method
  • Required parameters: Required properties are enforced at compile time
  • Property validation: Property types match your Tracking Plan schema

See the RudderTyper v2 Walkthrough Guide for a complete setup example including SDK initialization.

Type mappings

RudderTyper maps YAML types from your Tracking Plan definitions to native types for each platform.

Properties that support multiple types are represented as a sealed class in Kotlin or an enum with associated values in Swift. Each type variant is represented as a distinct case, and a value property provides access to the underlying value.

Naming conventions

RudderTyper applies consistent naming conventions when generating code from your Tracking Plan definitions. These conventions are the same across both Kotlin and Swift.

Event methods

Event typeMethod name patternExample
tracktrack{EventName}trackUserSignedUp
identifyidentifyidentify
screenscreen{EventName}screenProductViewed
groupgroupgroup

Properties and traits structs

Event typeStruct name patternExample
trackTrack{EventName}PropertiesTrackUserSignedUpProperties
identifyIdentify{EventName}TraitsIdentifyUserTraits
screenScreen{EventName}PropertiesScreenProductViewedProperties
groupGroup{EventName}TraitsGroupCompanyTraits

Type name prefixes

SourcePrefixExample
PropertyPropertyPropertySomeString
Custom typeCustomTypeCustomTypeSomeStringType

Event names are converted to CamelCase for method and struct names, with the original event name preserved in the underlying SDK call.

Supported event types

RudderTyper generates type-safe methods for the following event types:

Event typeMethod signatureNotes
tracktrack{EventName}(properties:options:)Properties struct with typed fields
identifyidentify(userId:traits:options:)Traits struct with typed fields
screenscreen{EventName}(properties:category:options:)Properties struct with typed fields; category is optional
groupgroup(groupId:traits:options:)Traits struct with typed fields

Every generated method includes an optional options parameter that lets you pass additional configuration (such as integration overrides) to the underlying SDK call. RudderTyper automatically injects a ruddertyper context object into every call for attribution.

See more

Questions? We're here to help.

Join the RudderStack Slack community or email us for support