Skip to main content

Events

Models and methods for fetching the event history of a profile.

TFApplicationProfileEvent

A single event in a profile's history.

public struct TFApplicationProfileEvent: Decodable {
public typealias RawIdentifier = Identifier<Self, String>

public enum EventType: String, Codable, CaseIterable {
case contractRemoveFromAnotherDevice
case contractShare
case contractRecover
case contractAssociation
case contractAssociationV2
case contractRemove
case contractReset
case operation
}

public let uniqueKey: RawIdentifier
public let profileID: TFApplicationProfile.ID
public let data: Data
public var createdOn: Date { get }
}

TFApplicationProfileEvent.EventType

public enum TFApplicationProfileEvent.EventType: String, Codable, CaseIterable {
case contractRemoveFromAnotherDevice
case contractShare
case contractRecover
case contractAssociation
case contractAssociationV2
case contractRemove
case contractReset
case operation
}

TFApplicationProfileEvent.Data

The payload attached to an event. Fields are populated based on the event type.

public struct TFApplicationProfileEvent.Data: Decodable {
public let eventType: TFApplicationProfileEvent.EventType?
public let affected: TFApplicationProfileEvent.Device?
public let device: TFApplicationProfileEvent.Device?
public let deviceIP: String?
public let transaction: TFOperation?
public let from_device: TFApplicationProfileEvent.Device?
public let to_device: TFApplicationProfileEvent.Device?
}

TFApplicationProfileEvent.Device

A snapshot of a device as recorded at event time.

public struct TFApplicationProfileEvent.Device: Codable {
public let maskedDeviceIDSHA: String
public let key: String
public let name: String
public let manufacturer: String
public let model: String
public let operatingSystem: String
public let osVersion: String
public let marketingName: String
}

TFProfileEventsFeed

A paginated list of profile events returned by the server.

public struct TFProfileEventsFeed {
public let events: [TFApplicationProfileEvent]
public let maxResults: Int
public let count: Int

public init(events: [TFApplicationProfileEvent], maxResults: Int, count: Int)
}

TFEventsFeedFilter

A filter to narrow down events returned by fetchEventsHistory. Multiple filters of the same kind are combined.

public enum TFEventsFeedFilter {
case devices([TFApplicationProfileDevice.KeyIdentifier])
case eventTypes([TFApplicationProfileEvent.EventType])
case risk([TFOperation.Risk])
case status([TFOperation.Status])
case dateInterval(DateInterval)

// Convenience variadic initializers
public static func devices(_ ids: TFApplicationProfileDevice.KeyIdentifier...) -> Self
public static func eventTypes(_ types: TFApplicationProfileEvent.EventType...) -> Self
public static func risk(_ risks: TFOperation.Risk...) -> Self
public static func status(_ status: TFOperation.Status...) -> Self
}

/// A list of filters. Repeated entries of the same kind are merged.
public typealias TFEventsFeedFilters = [TFEventsFeedFilter]