Configuration parameters for Realm event recording.

Enabling Realm event recording is done by setting Realm.Configuration.eventConfiguration to any non-nil EventConfiguration. A default-initialized configuration is valid, but some properties may need to be customized.

Using Realm event recording requires including the collection AuditEvent in your schema defined on the server for the App which you will be writing events to. The schema must contain the following fields:

  • _id: ObjectId
  • activity: String
  • event: String?
  • data: String?
  • timestamp: Date In addition, there must be a String? field for each metadata key used.
  • Metadata which is attached to each event generated. Each key in the metadata dictionary is stored in a column with that name in the event Realm, and so the schema configured on the server for the AuditEvent collection must include all metadata fields which will be used. The metadata fields must be of type String? in the server-side schema.

  • The sync user to write event data with. If not supplied, the user from the Realm being traced will be used. This can be a User associated with a different App from the Realm being traced if desired.

    The user must be associated with a partition-based sync app. If the traced Realm is using flexible sync, setting this field to a PBS user is mandatory.

  • A string prepended to the randomly-generated partition values used for uploading event data to the server. This can be customized to ensure that you can distinguish event partitions from partitions used by your application.

  • A logger callback function. This function should be thread-safe as it may be called from multiple threads simultaneously.

  • A logger which will be called to report information about the work done on the background event thread. If nil, this is instead reported to the SyncManager‘s logger.

  • The error handler which will be called if a sync error occurs when uploading event data. If nil, the error will be logged and then abort() will be called. Production usage should always define a custom error handler unless aborting on error is desired.

  • Creates an EventConfiguration which enables Realm event recording.