QuartileTracker

public struct QuartileTracker

A value type that tracks quartile progress for a single ad playback.

Reset via reset() whenever a new ad starts, then call evaluate(ad:progress:fire:) on every progress update. The tracker guarantees forward-only state progression: none → first → mid → third.

  • Undocumented

    Declaration

    Swift

    public init()
  • Resets tracking back to the initial .none state.

    Call this every time a new ad starts to clear any state left from the previous ad.

    Declaration

    Swift

    public mutating func reset()
  • Evaluates whether any quartile threshold has been crossed and fires the corresponding AdTrackingEvent via fire.

    Declaration

    Swift

    public mutating func evaluate(ad: Ad, progress: TimeInterval, fire: (AdTrackingEvent) -> Void)

    Parameters

    ad

    The ad currently being played.

    progress

    Elapsed playback time within the ad, in seconds.

    fire

    Closure invoked with the AdTrackingEvent when a threshold is crossed.