Class: TrackRelay::DSL::EventBuilder
- Inherits:
-
Object
- Object
- TrackRelay::DSL::EventBuilder
- Defined in:
- lib/track_relay/dsl/event_builder.rb
Overview
The DSL receiver for the body of ‘TrackRelay.catalog do … end`.
Provides two top-level methods:
-
‘event(name, &block)` — defines an event. The block is instance_exec’d against a ParamBuilder so type DSL methods (integer, string, float, boolean, datetime) work without any explicit receiver.
-
‘user_property(name, type)` — declares a catalog-wide user property (registered globally on Catalog, not attached to a single event).
‘event` is the layer where validation runs. After the block populates a ParamBuilder, EventBuilder builds the EventDefinition, calls Validators::CatalogValidator.validate! to enforce GA4 + reserved-key rules, and registers the result. That way the first time a definition exists, it is already validated and immutable.
Instance Method Summary collapse
-
#event(name) { ... } ⇒ EventDefinition
Define a single event in the catalog.
-
#user_property(name, type) ⇒ void
Register a catalog-wide user property (independent of any event).
Instance Method Details
#event(name) { ... } ⇒ EventDefinition
Define a single event in the catalog.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/track_relay/dsl/event_builder.rb', line 38 def event(name, &block) param_builder = ParamBuilder.new(name) param_builder.instance_exec(&block) if block definition = EventDefinition.new( name: name, params: param_builder.params, user_properties: param_builder.user_properties ) Validators::CatalogValidator.validate!(definition) Catalog.register(definition) definition end |
#user_property(name, type) ⇒ void
This method returns an undefined value.
Register a catalog-wide user property (independent of any event).
59 60 61 |
# File 'lib/track_relay/dsl/event_builder.rb', line 59 def user_property(name, type) Catalog.register_user_property(name, type) end |