Add cross-cutting properties to Chronicle events
Cross-cutting properties add shared fields to Chronicle event payloads without requiring each event type to declare them. Use them for values supplied outside domain code, such as a tenant identifier or a system-generated timestamp.
In the .NET client, implement ICanProvideAdditionalEventInformation to modify the serialized event before it is appended:
using System.Text.Json.Nodes;using Cratis.Chronicle.Events;
public class CrossCuttingAdditionalEventInformationProvider : ICanProvideAdditionalEventInformation{ public Task ProvideFor(JsonObject @event) { @event.Add("something", Guid.NewGuid()); @event.Add("someTime", DateTimeOffset.UtcNow); return Task.CompletedTask; }}Kotlin does not support this workflow yet.Java does not support this workflow yet.Elixir does not support this workflow yet.TypeScript does not support this workflow yet.The provider receives a JsonObject containing the event’s serialized properties. This example adds something and someTime to that object, so the appended payload includes both fields even though the event type does not declare them.
Chronicle discovers providers automatically and calls their ProvideFor methods during serialization. You do not need to call the provider from each append operation.
These fields belong to the event payload. If you want metadata for selecting events instead, use tags and observer filters.