Select spec version:

RudderTyper v1 Command Reference

Commands, CLI arguments, development and production modes, and ruddertyper.yml for RudderTyper v1.
Available Plans
  • free
  • growth
  • enterprise

RudderTyper v1 (npm) is in maintenance mode and will not receive any new features.

For TypeScript, Kotlin, and Swift support, use RudderTyper v2.

Commands

Command
Description
Initialize

$ npx rudder-typer init
Initializes RudderTyper with a quickstart guide to generate your RudderTyper client .
Help

$ npx rudder-typer help
Prints the help message describing different commands available with RudderTyper.
Update plan

$ npx rudder-typer update | u | *   (default)
Syncs plan.json with RudderStack to pull the latest changes from your Tracking Plan and generates an updated development client.
Build development client

$ npx rudder-typer build | b | d | dev | development
Generates a development client from plan.json with runtime validation.
Build production client

$ npx rudder-typer prod | p | production
Generates a production client from plan.json without runtime validation .
Print token configuration

$ npx rudder-typer token | tokens | t
Prints the local RudderStack API token configuration.
Print RudderTyper version

$ npx rudder-typer version
Prints the RudderTyper CLI version.

CLI arguments

Run the help command (npx rudder-typer help) to get the below list of CLI arguments that you can use with RudderTyper:

ArgumentDescription
configOptional path to a ruddertyper.yml (or a directory with ruddertyper.yml).
debugOptional (hidden) flag to turn on/off debug mode.
version / vPrints the RudderTyper CLI version.
help / hPrints help on a command.

RudderTyper modes

RudderTyper operates in two distinct modes: Development and Production mode. Each mode serves a specific purpose in the analytics implementation workflow. By utilizing the required mode, you can streamline the process of implementing and managing analytics with RudderTyper.

Development mode

This mode is designed to facilitate testing and validating your changes before the events go live.

This mode is suitable for local development and debugging and helps you:

  • Validate the JSON schema to ensure correctness.
  • Verify the tracking events against the defined Tracking Plan.
  • Include additional validation logic to catch potential errors early.

Production mode

This mode is optimized for deployment and ensures seamless event tracking in live environments.

This mode is suitable for staging and production environments and helps you:

  • Generate production-ready, optimized code.
  • Adhere strictly to the validated schema to maintain consistency.
  • Remove unnecessary validation and debugging logic for efficiency.

Configuration reference

RudderTyper stores its configuration in a ruddertyper.yml file in the root of your repository.

A sample configuration looks like the following:

yaml
# RudderStack RudderTyper configuration reference (https://github.com/rudderlabs/rudder-typer)
# Run `npx rudder-typer` to regenerate a client with the latest versions of these events.

scripts:
  # You can supply a RudderStack service access token using a `scripts.token` command. The output of `script.token` command should be a valid RudderStack API token.
  token: source .env; echo $RUDDERTYPER_TOKEN

  # You can supply the email address linked to your workspace using a `scripts.email` command.The output of `script.email` command should be an email address registered with your workspace.
  email: source .env; echo $EMAIL

  # You can format any of RudderTyper's auto-generated files using a `scripts.after` command.
  # See `Formatting Generated Files` below.
  after: ./node_modules/.bin/prettier --write analytics/plan.json

client:
  # The RudderStack SDK you are generating the client for
  # Valid values: analytics.js, analytics-node, analytics-ios, analytics-android.
  sdk: analytics.js

  # The target language for your RudderTyper client.
  # Valid values: javascript, typescript, objective-c, swift, java.
  language: typescript

  # JavaScript Transpilation Settings
  # Valid values: 'ES3','ES5','ES2015','ES2016','ES2017','ES2018','ES2019','ESNext','Latest'
  scriptTarget: "ES5"

  # Valid values: 'CommonJS','AMD','UMD','System','ES2015','ESNext'
  moduleTarget: "ESNext"

trackingPlans:
  # The RudderStack Tracking Plan that you are generating a client for.
  # Provide your workspace slug and Tracking Plan id
  # You also need to supply a path to a directory to save your RudderTyper client.
  - id: <TRACKING_PLAN_ID>
    workspaceSlug: rudderstack-demo
    path: ./analytics

    # Valid values: v1 (old Tracking Plan), v2 (new Tracking Plan format)
    APIVersion: v2

Note the following:

  • Store token and email in a .env file created in the same directory as ruddertyper.yml to ensure the scripts automatically use these values. A sample .env file is shown below:
txt
RUDDERTYPER_TOKEN=<SERVICE_ACCESS_TOKEN>
EMAIL=<EMAIL_ADDRESS>
  • You can get the id field by going to the Tracking Plan in the RudderStack dashboard. For example, https://app.rudderstack.com/trackingPlans/<TRACKING_PLAN_ID>.

See more

Questions? Let's figure it out together.

Join the RudderStack Slack community to connect with other users, customers, and the RudderStack team — or reach out for direct support.