Skip to content

MetricDimensionHandler

MetricDimensionHandler = (event, dimension, ctx) => Promise<ReadItem | string | undefined>

Resolves the Dimension value of one Event.

AlpyneEvent

Event being projected.

DimensionInstance

Dimension being resolved.

ReadRuntimeInstance

Read context for looking up Items.

Promise<ReadItem | string | undefined>

The Dimension Item, its UUID, or undefined.

Return the Item that is the Dimension value, for example the country Item for a Dimension on the country Template. When the value is not an Item, return its identifier as a string; the string must be a UUID because Dimension values are stored in UUID columns. Return undefined when the Event has no value for the Dimension. A handler that throws or returns a non-UUID string is stored as having no value, and the Event is still projected.

Resolving a Dimension from a Relation

const momentDimensionHandler: MetricDimensionHandler = async (event, _dimension, ctx) => {
const automation = await ctx.getItem(event.itemId);
if (!automation) return undefined;
return await automation.relations.moment.get();
};

MetricBuilder.addDimension