CustomEvent
public struct CustomEvent : Sendable
CustomEvent captures information regarding a custom event for Analytics.
-
Max properties size in bytes
Declaration
Swift
public static let maxPropertiesSize: Int -
Default encoder. Uses
iso8601date encoding strategy.Declaration
Swift
public static func defaultEncoder() -> JSONEncoder -
The event’s value. The value must be between -2^31 and 2^31 - 1 or it will invalidate the event.
Declaration
Swift
public var eventValue: Decimal -
The event’s name. The name’s length must not exceed 255 characters or it will or it will invalidate the event.
Declaration
Swift
public var eventName: String -
The event’s transaction ID. The ID’s length must not exceed 255 characters or it will invalidate the event.
Declaration
Swift
public var transactionID: String? -
The event’s interaction type. The type’s length must not exceed 255 characters or it will invalidate the event.
Declaration
Swift
public var interactionType: String? -
The event’s interaction ID. The ID’s length must not exceed 255 characters or it will invalidate the event.
Declaration
Swift
public var interactionID: String? -
The event’s properties.
Declaration
Swift
public private(set) var properties: [String : AirshipJSON] { get } -
Sets a property string value.
Declaration
Swift
public mutating func setProperty( string: String, forKey key: String )Parameters
stringThe string value to set.
forKeyThe properties key
-
Removes a property.
Declaration
Swift
public mutating func removeProperty( forKey key: String )Parameters
forKeyThe properties key
-
Sets a property double value.
Declaration
Swift
public mutating func setProperty( double: Double, forKey key: String )Parameters
doubleThe double value to set.
forKeyThe properties key
-
Sets a property bool value.
Declaration
Swift
public mutating func setProperty( bool: Bool, forKey key: String )Parameters
boolThe bool value to set.
forKeyThe properties key
-
Sets a property value.
Declaration
Swift
public mutating func setProperty( value: Any, forKey key: String, encoder: @autoclosure () -> JSONEncoder = Self.defaultEncoder() ) throwsParameters
valueThe value to set.
forKeyThe properties key
encoderJSONEncoder to use.‘
-
Sets a property value.
Declaration
Swift
public mutating func setProperties( _ object: Any, encoder: @autoclosure () -> JSONEncoder = Self.defaultEncoder() ) throwsParameters
valueThe values to set. The value must result in a JSON object or an error will be thrown.
encoderJSONEncoder to use.
-
Default constructor.
Declaration
Swift
public init(name: String, value: Double = 1.0)Parameters
nameThe name of the event. The event’s name must not exceed 255 characters or it will invalidate the event.
valueThe event value. The value must be between -2^31 and 2^31 - 1 or it will invalidate the event. Defaults to 1.
-
Default constructor.
Declaration
Swift
public init(name: String, decimalValue: Decimal)Parameters
nameThe name of the event. The event’s name must not exceed 255 characters or it will invalidate the event.
valueThe event value. The value must be between -2^31 and 2^31 - 1 or it will invalidate the event. Defaults to 1.
-
Account template
See moreDeclaration
Swift
enum AccountTemplate : Sendable -
Additional acount template properties
See moreDeclaration
Swift
struct AccountProperties : Encodable, Sendable -
Constructs a custom event using the account template.
Declaration
Swift
init( accountTemplate: AccountTemplate, properties: AccountProperties = AccountProperties(), encoder: @autoclosure () -> JSONEncoder = CustomEvent.defaultEncoder() )Parameters
accountTemplateThe account template.
propertiesOptional additional properties
encoderEncoder used to encode the additional properties. Defaults to
CustomEvent.defaultEncoder. -
Adds the event to analytics. A wrapper arou
Declaration
Swift
public func track() -
Media event types
See moreDeclaration
Swift
enum MediaTemplate : Sendable -
Additional media template properties
See moreDeclaration
Swift
struct MediaProperties : Encodable, Sendable -
Constructs a custom event using the media template.
Declaration
Swift
init( mediaTemplate: MediaTemplate, properties: MediaProperties = MediaProperties(), encoder: @autoclosure () -> JSONEncoder = CustomEvent.defaultEncoder() )Parameters
mediaTemplateThe media template.
propertiesMedia properties.
encoderEncoder used to encode the additional properties. Defaults to
CustomEvent.defaultEncoder. -
Retail templates
See moreDeclaration
Swift
enum RetailTemplate : Sendable -
Additional retail template properties
See moreDeclaration
Swift
struct RetailProperties : Encodable, Sendable -
Constructs a custom event using the retail template.
Declaration
Swift
init( retailTemplate: RetailTemplate, properties: RetailProperties = RetailProperties(), encoder: @autoclosure () -> JSONEncoder = CustomEvent.defaultEncoder() )Parameters
accountTemplateThe retail template.
propertiesOptional additional properties
encoderEncoder used to encode the additional properties. Defaults to
CustomEvent.defaultEncoder. -
Search template
See moreDeclaration
Swift
enum SearchTemplate : Sendable -
Additional search template properties
See moreDeclaration
Swift
struct SearchProperties : Encodable, Sendable -
Constructs a custom event using the search template.
Declaration
Swift
init( searchTemplate: SearchTemplate, properties: SearchProperties = SearchProperties(), encoder: @autoclosure () -> JSONEncoder = CustomEvent.defaultEncoder() )Parameters
accountTemplateThe search template.
propertiesOptional additional properties
encoderEncoder used to encode the additional properties. Defaults to
CustomEvent.defaultEncoder.
View on GitHub