PingManager

Central manager for the Ping analytics system, responsible for coordinating Pinglet tracking, envelope creation, and reliable delivery to backend services.

PingManager serves as the main entry point for the Ping analytics system and acts as a bridge between the platform-specific Kotlin code and the shared C++ implementation. It manages the entire lifecycle of analytics data from Pinglet creation through reliable delivery.

Key Responsibilities:

  • Managing Pinglet queuing via native C++ implementation

  • Creating and sending Pinglet envelopes to backend services

  • Handling retry logic for failed send attempts

  • Coordinating with persistent storage for reliable delivery

  • Managing resource cleanup after Ping usage

Thread Safety: All operations are thread-safe and can be called from multiple threads concurrently. The underlying C++ implementation ensures thread-safe access to the Pinglet queue.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun <P : Pinglet> add(pinglet: P, sessionNumber: Int)

Adds a Pinglet to the analytics tracking queue.

Link copied to clipboard

Retrieves the current trace ID from the native C++ implementation.

Link copied to clipboard
fun retrySendPinglets(actionOnFinish: () -> Unit? = null)

Attempts to retry sending any previously failed Pinglet envelopes.

Link copied to clipboard

Immediately flushes all queued Pinglets to the envelope and attempts to send them to the backend. The operation is asynchronous and runs in the newly launched coroutine on the IO dispatcher. If the envelope fails to send, it will be stored for later retry attempts.

Link copied to clipboard
fun sendPingletsAsync(): Deferred<PingStatus>

Asynchronously flushes all queued Pinglets to the envelope and attempts to send them to the backend.