CLI Commands

Realanalytics CLI reference

Install or run with npx

# global
npm install -g realanalytics

# one-off
npx realanalytics <command>

Available commands

CommandPurpose
loginOpen browser login and exchange one-time token
logoutDelete local auth file
initCreate project + scaffold analytics files
buildCompile analytics TS files to JSON
deployBuild and deploy events + dashboards
lintValidate analytics definitions
whoamiShow authenticated user ID
statusShow auth and local project status

login

login opens /cli/auth in your browser. After signing in, copy the token shown on that page and paste it back into the terminal.

npx realanalytics login

# terminal prompt:
# Paste your token here: ...

You can also skip browser open by passing a one-time token directly: npx realanalytics login --token <token>.

init

npx realanalytics init

Optional project naming: npx realanalytics init --name my-project.

Creates project credentials and starter files:

  • analytics/events.ts
  • analytics/dashboards/overview.ts
  • .realanalytics/credentials.json

build

npx realanalytics build

# custom output directory
npx realanalytics build --output dist/analytics

Output files: events.json and dashboards.json.

deploy

npx realanalytics deploy

Runs build, then POSTs compiled JSON to the platform using your project secret key + CLI session token.

lint

npx realanalytics lint

Validates your analytics definitions by checking event references, property references, naming conventions, and unused events. Exits with code 1 if errors are found.

See Governance for full details on what the linter checks.

whoami and status

npx realanalytics whoami
npx realanalytics status

Typical workflow

# one-time
npx realanalytics login
npx realanalytics init

# repeat for changes
npx realanalytics lint
npx realanalytics deploy

Automation note

For CI/non-interactive deploys, set REALANALYTICS_TOKEN to a valid CLI access token and run npx realanalytics deploy.

Next Steps