Skip to main content

Code Generation

Ordaze ships production-grade default templates for all 13 supported languages. Pick a source in Settings, optionally customize the Handlebars template, and download the generated file via the API or the dashboard.

Default Templates (13 languages)

Every supported language has a default template. Select a source in Settings → Code Generation to download or customize.

LanguageOutput
SwiftAnalyticsEvents.swift — extension on Analytics with a static func per event
KotlinAnalyticsEvents.kt — sealed AnalyticsEvent class with a data object/class per event
TypeScriptAnalyticsEvents.ts — typed Properties interface + constructor function per event
Pythonanalytics_events.pyTypedDict properties + module function per event
JavaAnalyticsEvents.java — final class with a static method returning Event (boxed primitives, Map<String, Object>)
JavaScriptanalyticsEvents.jsmodule.exports of per-event factory functions with JSDoc-typed parameters
C#AnalyticsEvents.cs — static class + readonly record struct AnalyticsEvent envelope (C# 10+)
Goanalytics_events.go — package-level PascalCase exported functions returning AnalyticsEvent
Rustanalytics_events.rs#[derive(Serialize)] pub struct AnalyticsEvent + snake_case pub fn per event
Rubyanalytics_events.rb — module with self. class methods using keyword args + YARD type comments
PHPAnalyticsEvents.phpdeclare(strict_types=1) final class with static methods returning typed arrays
Dartanalytics_events.dart — class with named required/nullable parameters (Dart 2.12 null safety)
React NativeAnalyticsEvents.ts — same output as TypeScript (RN projects run V8/Hermes with TS tooling)

Every default is a Handlebars template — edit it in the in-app editor to match your SDK, code style, or house conventions. The types and names come from your event registry so output stays in sync with the schema.

Template System

Handlebars

Templates use Handlebars syntax. Write your template in the built-in editor with live preview and validation.

Context Variables

VariableDescription
{{today}}Current date (YYYY-MM-DD)
{{eventCount}}Total number of events
{{categories}}Array of destination names
{{allProperties}}Array of all property names across events

Iterating Events

{{#each eventsByCategory}}
  // Category: {{category}}
  {{#each events}}
    // Event: {{name}} ({{camelCase}}, {{pascalCase}})
    // {{description}}
    {{#if deprecated}}// @deprecated{{/if}}
  {{/each}}
{{/each}}
VariableDescription
{{category}}Destination name
{{name}}Event name in snake_case
{{camelCase}}Event name in camelCase
{{pascalCase}}Event name in PascalCase
{{description}}Event description text
{{deprecated}}Boolean, true if event is deprecated
{{hasProperties}}Boolean, true if event has properties

Property Fields

{{#each properties}}
  {{name}}: {{swiftOptionalType}}  // {{camelCase}}, {{upperSnake}}
{{/each}}
VariableDescription
{{name}}Property name in snake_case
{{camelCase}}Property name in camelCase
{{upperSnake}}Property name in UPPER_SNAKE_CASE
{{swiftOptionalType}}Swift type with optional marker (e.g. String?)
{{kotlinOptionalType}}Kotlin type with nullable marker (e.g. String?)
{{required}}Boolean, true if property is required

Helper Functions

HelperDescription
{{toCamelCase name}}Convert to camelCase
{{toPascalCase name}}Convert to PascalCase
{{toUpperSnakeCase name}}Convert to UPPER_SNAKE_CASE
{{swiftType type required}}Map to Swift type (String, Int, Bool, etc.)
{{kotlinType type required}}Map to Kotlin type (String, Int, Boolean, etc.)
{{#if (eq status "deprecated")}}Equality comparison helper
{{#if (hasItems properties)}}Check if array has items
{{@first}} / {{@last}}Loop boundary checks
{{@index}}Current loop index (0-based)

Full Example

Complete Swift Template

A working template that generates a Swift file with typed event enums. Copy this as a starting point for your own template.

// Auto-generated by Ordaze on {{today}}
// {{eventCount}} events across {{categories.length}} destinations

import Foundation

{{#each eventsByCategory}}
// MARK: - {{category}}

enum {{toPascalCase category}}Events: String {
    {{#each events}}
    /// {{description}}
    {{#if deprecated}}@available(*, deprecated, message: "Use replacement event")
    {{/if}}case {{camelCase}} = "{{name}}"
    {{/each}}
}

{{#each events}}
{{#if hasProperties}}
struct {{pascalCase}}Properties {
    {{#each properties}}
    let {{camelCase}}: {{swiftOptionalType}}
    {{/each}}
}
{{/if}}
{{/each}}
{{/each}}

Customizing in Settings

Every supported language ships with a default template. To customize any of them:

  1. Go to Settings → Code Generation
  2. Select the source you want to customize
  3. Edit the template (the preview updates in real time)
  4. Optionally change the output file name
  5. Save when ready, or reset to restore the default

The editor supports Tab for indentation and Ctrl/Cmd+S to save. Template validation runs on every change.