TealiumSignposter

public class TealiumSignposter

A wrapper around the OSSignposter API to make it easier to use when supporting iOS < 15. Enable it by changing the enabled static flag on this class.

On iOS < 15 this class does nothing.

For normal usecases of intervals being signposted you can use the TealiumSignpostInterval instead of this class, so you can avoid handling the SignpostStateWrapper yourself. If instead you want to handle it yourself, or you have to send singular events, you can use this class like so:

 let signposter = TealiumSignposter("Networking")
 let state = signposter.beginInterval("Start Request", "\(request)")
 urlSession.dataTask(request) { _, response, _ in
      signposter.endInterval("Start Request", state: state, "\(response)")
      // Handle the HTTP response
 }

Note that the beginInterval name needs to match with the endInterval name.

  • Set this to true at the start of the app to make sure Signposting is enabled

    Declaration

    Swift

    public static var enabled: Bool
  • Creates and returns a TealiumSignposter with the given category

    Declaration

    Swift

    public init(category: String)
  • Begins a new interval with the given name on iOS 15+.

    No-op on iOS < 15.

    Declaration

    Swift

    public func beginInterval(_ name: StaticString) -> SignpostStateWrapper?

    Parameters

    name

    the StaticString used to name this interval

    Return Value

    an optional SignpostStateWrapper used to pass it to the endInterval method. Nil on iOS < 15

  • Begins a new interval with the given name on iOS 15+.

    No-op on iOS < 15.

    Declaration

    Swift

    public func beginInterval(_ name: StaticString, _ messageProvider: @autoclosure @escaping () -> String) -> SignpostStateWrapper?

    Parameters

    name

    the StaticString used to name this interval

    messageProvider

    the autoclosure String used to describe some parameters for this begin interval

    Return Value

    an optional SignpostStateWrapper used to pass it to the endInterval method. Nil on iOS < 15

  • Ends an interval previously created with the given name on iOS 15+.

    No-op on iOS < 15.

    Declaration

    Swift

    public func endInterval(_ name: StaticString, state: SignpostStateWrapper?)

    Parameters

    name

    the StaticString used to name the interval. Must be an exact match with the begin interval call

    state

    the SignpostStateWrapper returned by the begin interval call

    Return Value

    an optional SignpostStateWrapper used to pass it to the endInterval method. Nil on iOS < 15

  • Ends an interval previously created with the given name on iOS 15+.

    No-op on iOS < 15.

    Declaration

    Swift

    public func endInterval(_ name: StaticString, state: SignpostStateWrapper?, _ messageProvider: @autoclosure @escaping () -> String)

    Parameters

    name

    the StaticString used to name the interval. Must be an exact match with the begin interval call

    state

    the SignpostStateWrapper returned by the begin interval call

    messageProvider

    the autoclosure String used to describe some parameters for this end interval call

    Return Value

    an optional SignpostStateWrapper used to pass it to the endInterval method. Nil on iOS < 15

  • Emits a single event on this signpost with the given name

    Declaration

    Swift

    public func event(_ name: StaticString)

    Parameters

    name

    the StaticString used to name the event

  • Emits a single event on this signpost with the given name

    Declaration

    Swift

    public func event(_ name: StaticString, _ messageProvider: @autoclosure @escaping () -> String)

    Parameters

    name

    the StaticString used to name the event

    messageProvider

    the autoclosure String used to describe some parameters for this event call