TestimonialKit
@MainActor
public class TestimonialKit
Public entry point for the TestimonialKit SDK.
This type exposes a small static API surface for initializing the SDK,
tracking app events, and conditionally presenting the in‑app feedback prompt.
All methods are @MainActor
to keep UI‑adjacent work on the main thread.
-
Initializes the SDK and configures logging.
Important
Call this early in app launch (e.g., inapplication(_:didFinishLaunchingWithOptions:)
).Declaration
Swift
@MainActor public static func setup(withKey apiKey: String, logLevel: LogLevel = .info)
Parameters
apiKey
Your project’s API key used to authenticate requests.
logLevel
Minimum log level printed to the console (default is
.info
). -
Records an application event that can influence prompt eligibility and analytics.
Note
Events are queued and sent reliably; they may be retried if the device is offline.Declaration
Swift
@MainActor public static func trackEvent( name: String, score: Int, type: AppEventType = .positive, metadata: [String: String]? = nil )
Parameters
name
A domain‑specific identifier for the event (e.g.,
onboarding_completed
).score
A numeric score representing the event impact (e.g., 1–100).
type
Qualifier for the event’s sentiment (positive/neutral/negative). Defaults to
.positive
.metadata
Optional custom key–value pairs to attach to this event.
-
Checks backend eligibility and, if allowed, presents the in‑app feedback prompt.
- Discussion: This method is safe to call multiple times; the SDK will avoid showing the prompt if the user is not eligible at the moment of the call.
Declaration
Swift
@MainActor public static func promptIfPossible( metadata: [String: String]? = nil, promptConfig: PromptConfig = PromptConfig(), completion: (@Sendable (PromptResult) -> Void)? = nil )
Parameters
metadata
Optional key–value pairs attached to all logs for this prompt session.
promptConfig
Appearance and text configuration for the prompt UI (defaults provided).
completion
Optional closure called with the final
PromptResult
after the prompt is dismissed.