Experiments
getExperiment enrols the bound user into an A/B experiment and returns an ExperimentResult.
Generated from the SDK's own /docs/ — also served raw at
https://shipeasy-ai.github.io/sdk-swift/pages/experiments.md.
getExperiment enrols the bound user into an A/B experiment and returns an
ExperimentResult.
The ExperimentResult shape
public struct ExperimentResult: Sendable {
public let inExperiment: Bool // was the user enrolled?
public let group: String // assigned group, e.g. "control" / "treatment"
public let params: Any? // the variant params (or your defaultParams)
}When the user is not enrolled, you get inExperiment: false, group: "control", and your defaultParams echoed back as params.
Enrol and branch
let client = try Client(["user_id": "u_123"])
let r = await client.getExperiment("checkout_button", defaultParams: ["color": "blue"])
if r.inExperiment, r.group == "treatment" {
let color = (r.params as? [String: Any])?["color"] as? String
// render the treatment
}defaultParams is the value returned for params whenever the user isn't
enrolled (or the experiment is absent). Pass nil if you don't need a fallback.
Tracking conversions
Record a conversion event so the analysis pipeline can compute lift. You already
hold a bound Client from getExperiment, so call track straight on it — the
unit is derived from the bound user (user_id, else anonymous_id), no id
argument needed. Experiments are end-to-end Client-only:
let client = try Client(["user_id": "u_123"])
await client.track("{{SUCCESS_EVENT}}", properties: ["amount": 49])logExposure is on the bound Client too — record an exposure explicitly at the
point you present the treatment (re-evaluates and only emits when the bound user
is enrolled). It is a no-op when the bound user has no unit, and a no-op in
testing/offline mode:
await client.logExposure("checkout_button")Kill switches
A kill switch reports whether a panic/disable switch is engaged. It returns a Bool — true means the switch is on (the thing it guards is killed). Kill…
i18n
This is a server SDK — it does not render translated strings itself. There is no t() / label-render helper in the Swift SDK. Translation rendering is a…