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.
public init( name: String, includeClientId: Bool, sendIfEmpty: Bool, preciseTimestamps: Bool, reasonCodes: [String] )
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
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.
public func submit(reason: ReasonCodesEnum? = nil)
The reason the ping is being submitted.