Ping

public class Ping<ReasonCodesEnum> where ReasonCodesEnum : ReasonCodes

This implements the developer facing API for custom pings.

Instances of this class type are automatically generated by the parsers at build time.

The Ping API only exposes the Ping.sumbit() method, which collects and schedules a ping for eventual upload.

  • The public constructor used by automatically generated metrics.

    Declaration

    Swift

    public init(
        name: String,
        includeClientId: Bool,
        sendIfEmpty: Bool,
        preciseTimestamps: Bool,
        includeInfoSections: Bool,
        enabled: Bool,
        schedulesPings: [String],
        reasonCodes: [String],
        followsCollectionEnabled: Bool
    )
  • Test-only API

    Attach a callback to be called right before a new ping is submitted. The provided function is called exactly once before submitting a ping.

    Note: The callback will be called on any call to submit. A ping might not be sent afterwards, e.g. if the ping is otherwise empty (and send_if_empty is false).

    Declaration

    Swift

    public func testBeforeNextSubmit(cb: @escaping (ReasonCodesEnum?) throws -> Void)
  • Collect and submit the ping for eventual uploading.

    While the collection of metrics into pings happens synchronously, the ping queuing and ping uploading happens asyncronously. There are no guarantees that this will happen immediately.

    If the ping currently contains no content, it will not be queued.

    Declaration

    Swift

    public func submit(reason: ReasonCodesEnum? = nil)

    Parameters

    reason

    The reason the ping is being submitted.

  • Enable or disable a ping.

    Disabling a ping causes all data for that ping to be removed from storage and all pending pings of that type to be deleted.

    Declaration

    Swift

    public func setEnabled(enabled: Bool)