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
iso8601
date 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
string
The string value to set.
forKey
The properties key
-
Removes a property.
Declaration
Swift
public mutating func removeProperty( forKey key: String )
Parameters
forKey
The properties key
-
Sets a property double value.
Declaration
Swift
public mutating func setProperty( double: Double, forKey key: String )
Parameters
double
The double value to set.
forKey
The properties key
-
Sets a property bool value.
Declaration
Swift
public mutating func setProperty( bool: Bool, forKey key: String )
Parameters
bool
The bool value to set.
forKey
The properties key
-
Sets a property value.
Declaration
Swift
public mutating func setProperty( value: Any, forKey key: String, encoder: @autoclosure () -> JSONEncoder = Self.defaultEncoder() ) throws
Parameters
value
The value to set.
forKey
The properties key
encoder
JSONEncoder to use.‘
-
Sets a property value.
Declaration
Swift
public mutating func setProperties( _ object: Any, encoder: @autoclosure () -> JSONEncoder = Self.defaultEncoder() ) throws
Parameters
value
The values to set. The value must result in a JSON object or an error will be thrown.
encoder
JSONEncoder to use.
-
Default constructor.
Declaration
Swift
public init(name: String, value: Double = 1.0)
Parameters
name
The name of the event. The event’s name must not exceed 255 characters or it will invalidate the event.
value
The 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
name
The name of the event. The event’s name must not exceed 255 characters or it will invalidate the event.
value
The 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
accountTemplate
The account template.
properties
Optional additional properties
encoder
Encoder 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
mediaTemplate
The media template.
properties
Media properties.
encoder
Encoder 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
accountTemplate
The retail template.
properties
Optional additional properties
encoder
Encoder 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
accountTemplate
The search template.
properties
Optional additional properties
encoder
Encoder used to encode the additional properties. Defaults to
CustomEvent.defaultEncoder
.