EventSink

public protocol EventSink

An EventSink is responsible for sending events to a particular destination.

The EventSink protocol allows you to control where your events go when you call EventBuilder.send(_:_:). The Events package provides a default EventSink that turns events into formatted log messages and logs them with os_log, but you could also send your events to a web service or save them in a database for querying.

Warning

Be careful about privacy if you send your events off-device. You should avoid including data in your events that could be considered personally identifiable information (PII).
  • Send an event to its destination.

    The implementation of this method should encode the event as necessary and then send or store it as appropriate for the sink. There is no way to report progress, success, or failure for sending the event. If you need to account for these, that should be contained within your implementation of this method. Your app will treat sending events as a fire and forget system.

    Declaration

    Swift

    func send(event: Event, level: OSLogType)

    Parameters

    event

    The event that needs to be encoded and sent.

    level

    The log level that the event is being sent at. Not all sinks will have use for this parameter, so you may ignore it if it doesn’t make sense for your sink. While the parameter is an OSLogType, it’s completely valid for the destination to be somewhere other than os_log.