Flow
Flow configuration is walkerOS's "configuration as code" approach. A single JSON file defines your entire event collection pipeline, making it portable, version-controlled, and deployable across environments.
Configuration structure
A flow configuration uses the Flow.Config format with two required fields:
version- Schema version (3)flows- Named flow configurations (each aFlow.Settings)
Basic example
This captures browser DOM events and sends them to your analytics API endpoint via HTTP POST requests.
Config syntax: package: vs code:
When configuring sources and destinations, you'll see two different syntaxes depending on your operating mode.
Bundled mode (JSON with CLI)
Use package: with a string reference. The CLI downloads and bundles the npm package:
Integrated mode (TypeScript with startFlow)
Use code: with a direct import reference:
Quick reference
| Property | Mode | Value | When to Use |
|---|---|---|---|
package: | Bundled | "@walkeros/..." (string) | CLI resolves and bundles from npm |
code: | Integrated | sourceBrowser (import) | Direct code reference in your app |
Both achieve the same result. The difference is whether the CLI bundles the code for you (Bundled) or you import it directly (Integrated).
See Operating Modes for more details on choosing your approach.
Flow configuration (Flow.Config)
Each flow in flows is a Flow.Settings that defines runtime behavior.
Platform
Platform is determined by the presence of the web or server key:
Platform options:
"server": {}- Node.js server environment (HTTP endpoints, cloud functions)"web": {}- Browser environment (client-side tracking)
The CLI automatically applies platform-specific build defaults:
- Web: IIFE format, ES2020 target
- Server: ESM format, Node20 target
The bundle is written to stdout by default. Use -o to write to a file (e.g., -o ./dist/walker.js for web, -o ./dist/bundle.mjs for server).
Bundle
Build-time configuration lives under flow.<name>.bundle. The packages field specifies npm packages to download and bundle, and overrides pins transitive dependency versions (npm overrides semantics):
packages properties:
version- npm version (semver or "latest", defaults to "latest")imports- Array of named exports to importpath- Local filesystem path (takes precedence overversion)
overrides is a Record<string, string>: for each named package, the version to use for any transitive reference. Direct package specs always win over overrides; overrides only substitute transitive dependencies during resolution.
For development or custom packages, use path to reference a local directory:
See Local Packages in the CLI documentation for more details.
Sources
Sources capture events from various inputs. Each source needs:
package- The npm package (required for package-based sources, optional when usingcode:)config- Source-specific settings
See Sources documentation for all available options.
Destinations
Destinations receive processed events and send them to analytics tools, databases, or APIs:
Configuration options:
settings- Destination-specific configuration (API keys, endpoints, etc.)mapping- Event transformation rules (see Mapping documentation)consent- Required consent statespolicy- Processing rules
Conditional activation:
Sources and destinations support require to delay initialization until specific collector events fire. Use require: ["consent"] to prevent loading until consent is granted:
See Destinations documentation for all available options.
Transformers
Transformers process events between sources and destinations. They validate, enrich, or redact events in the pipeline.
Configuration options:
package- The npm package (required for package-based steps, optional when usingcode:)code- Explicit import variable name (optional, auto-resolved)config- Transformer-specific configurationenv- Environment-specific settingsbefore- Pre-transformer chain (runs before this transformer's push)next- Next transformer in chain (omit to end chain)variables- Transformer-level variable overridesdefinitions- Transformer-level definitions
Chaining transformers:
Link transformers together using next:
Explicit chain control with arrays:
For explicit control over the transformer chain order, use an array instead of a string. This bypasses the automatic chain resolution:
| Syntax | Behavior |
|---|---|
"next": "validate" | Walks chain via each transformer's next property |
"next": ["validate", "enrich"] | Uses exact order specified, ignores transformer next properties |
Connecting to sources and destinations:
- Source preprocessing: Use
beforeon a source for consent-exempt preprocessing (runs before the source's push) - Pre-collector chain: Use
nexton a source to route events through transformers before the collector - Post-collector chain: Use
beforeon a destination to route events through transformers after the collector - Post-push chain: Use
nexton a destination to process events after the destination push completes
All chain fields (before and next) accept arrays for explicit chain control (see "Explicit chain control with arrays" above).
See Transformers documentation for available transformers and custom transformer guide.
Connection rules
Sources, transformers, collectors, and destinations connect in specific ways. This table summarizes every valid connection:
| From | To | Field | Notes |
|---|---|---|---|
| Source | Transformer | before on source | Consent-exempt preprocessing |
| Source | Transformer | next on source | Pre-collector chain |
| Source | Collector | omit next | Default: events go straight to collector |
| Transformer | Transformer | before on transformer | Pre-transform enrichment |
| Transformer | Transformer | next on transformer | Chain continues to next transformer |
| Collector | Transformer | before on destination | Post-collector chain |
| Collector | Destination | omit before | Default: events go straight to destination |
| Destination | Transformer | next on destination | Post-push processing |
Connections that are not allowed:
- Source to source
- Source directly to destination (events must pass through the collector)
- Collector to source
Chain resolution
The next and before fields on sources, transformers, and destinations all accept either a string or an array. The resolution behavior differs:
| Value | Behavior |
|---|---|
"validate" (string) | Walks transformer.next links until the chain ends |
["validate", "enrich"] (array) | Uses the array as-is, ignoring each transformer's next property |
When walking a string chain, three edge cases apply:
- String with array
next: Ifvalidate.nextis["a", "b"], the walker appends that array and stops. The final chain becomes["validate", "a", "b"]. - Missing target: If a transformer name in the chain does not exist, that step is skipped and the event proceeds unchanged. If a string chain points to a nonexistent first transformer, the chain is empty and the event goes through without transformation.
- Circular reference: Detected via a visited set and safely broken, with no infinite loop.
Pre-collector vs post-collector transformers
All transformers live in a single transformers pool. Their position in the pipeline depends on which field references them:
[Source.before] → Source ──[next]──→ Pre-transformers ──→ Collector ──→ Post-transformers ──[before]──→ Destination ──[next]──→ Post-push
The same transformer can appear in both a pre-collector and a post-collector chain. For example, you might use validate in a source's next chain and again in a destination's before chain. Each invocation runs independently.
In this config, validate runs before the collector (pre-chain) and enrich runs after the collector but before the analytics destination (post-chain).
Conditional routing
The next property supports conditional routing via Route[], an array of { match, next } objects evaluated against ingest metadata:
Routes are evaluated in order. The first match wins. If no route matches, the event passes through unchanged to the collector. Conditional routing works on all chain positions: source.before, source.next, transformer.before, transformer.next, destination.before, and destination.next.
Deferred activation with require
Sources and destinations support require to delay initialization until a specific collector event fires. This is commonly used for consent-gated loading:
The analytics destination will not initialize until a "consent" event is pushed to the collector. Until then, events are queued. This works identically for sources:
Combine require with consent on destinations for full consent management: require controls when the destination loads, while consent controls which events it receives. See the Destinations section above for a combined example.
Inline Code (without packages)
For simple one-liner logic, define sources, transformers, or destinations inline without creating a package.
Use code object instead of package:
Inline Transformer:
Inline Destination:
Code object properties:
push- The push function with$code:prefix (required)type- Optional instance type identifierinit- Optional init function with$code:prefix
Rules:
- Use
packageORcode, never both configstays separate (same as package-based)$code:prefix outputs raw JavaScript at bundle time
Collector
The collector processes events from sources and routes them to destinations:
Options:
run- Whether to start the collector automatically (default:true)globals- Properties added to every eventconsent- Default consent state
See Collector documentation for complete options.
Web-specific options
For browser bundles, you can configure window variable names:
Properties:
windowCollector- Global variable name for collector instance (default:"collector")windowElb- Global variable name for event tracking function (default:"elb")
Multi-flow configuration
For managing dev/staging/production flows in one file:
Build specific flows using the CLI:
Dynamic patterns
Flow configurations support four dynamic patterns for reusable, environment-aware configs:
$var.name - Config Variables
Reference variables defined in variables for shared values across your config:
Variables can be defined at three levels (higher specificity wins):
- Source/Destination level - Highest priority
- Flow (Config) level - Middle priority
- Setup level - Lowest priority
$env.NAME - Environment Variables
Reference environment variables with optional defaults:
Syntax:
$env.GA4_ID- Required, throws if not set$env.GA4_ID:default- Uses "default" if not set
$env supports defaultsEnvironment variables are external and unpredictable - they might not be set in all environments. Config variables ($var) are explicitly defined, so a missing one indicates a configuration error.
$def.name - Definition References
Reference reusable configuration blocks defined in definitions:
Definitions cascade like variables - defined at setup, flow, or source/destination level.
$code: - Inline JavaScript
Embed JavaScript code directly in JSON config values:
The $code: prefix is stripped during bundling, outputting raw JavaScript:
Use cases:
fn:callbacks - Transform values in mappingcondition:predicates - Conditional event processing- Custom logic - Any inline function or expression
Syntax notes:
- Multi-line code: Use JSON escapes (
\n,\") - Scope: Same as bundled code (access to imports and variables)
- Errors: Caught at build time by TypeScript/esbuild
Type hierarchy
walkerOS uses a clear type hierarchy:
┌─────────────────────────────────────────────────────────────────┐
│ Flow.Config (config file) │
│ ├── version: 3 │
│ ├── variables?: { currency: "EUR" } │
│ ├── definitions?: { commonMapping: {...} } │
│ └── flows: │
│ └── default: Flow.Settings │
└─────────────────────────────────────────────────────────────────┘
│
│ CLI resolves $var, $env, $def
▼
┌─────────────────────────────────────────────────────────────────┐
│ Flow.Settings (resolved flow) │
│ ├── web: {} or server: {} │
│ ├── packages: { ... } │
│ ├── sources: { ... } │
│ ├── transformers: { ... } │
│ ├── destinations: { ... } │
│ ├── stores: { ... } │
│ └── collector: { ... } │
└─────────────────────────────────────────────────────────────────┘
│
│ CLI bundles and transforms
▼
┌─────────────────────────────────────────────────────────────────┐
│ Collector.InitConfig (runtime) │
│ Passed to startFlow() at runtime │
└─────────────────────────────────────────────────────────────────┘
Flow.Config- Root config file format for CLIFlow.Settings- Single flow configurationCollector.InitConfig- Runtime type passed tostartFlow()
Complete example
Here's a production-ready flow that accepts HTTP events and sends them to BigQuery:
Programmatic usage
You can also use configuration programmatically with the startFlow function:
See the Collector documentation for complete API reference.
Next steps
- CLI - Learn how to bundle and test flows
- Docker - Deploy flows in containers
- Sources - Explore available event sources
- Destinations - Configure analytics destinations
- Mapping - Transform events for destinations