Early access preview
API reference
This is the full designed surface of the Caliper SDK. Early access — may change before GA. Everything below describes intended behavior for the SDK we are building with our first cohort.
The surface is the same across platforms; only the language idiom differs. The canonical shape is:
import Caliper
Caliper.configure(apiKey: "cal_live_…")
Caliper.survey(.howDidYouHear)
.after(.firstOpen)
.sync(to: [.adjust, .slack])
Caliper.configure
Initializes the SDK. Call once, as early in startup as possible, before the first survey can fire.
| Option | Type | Notes |
|---|---|---|
apiKey | string | Required. Your project key, in the form cal_live_…. Use the test key for cal_test_…. |
environment | enum | Optional. production (default) or sandbox. Sandbox isolates events from production reporting. |
Platform signatures:
Caliper.configure(context, apiKey = "cal_live_…")
Caliper.configure({ apiKey: 'cal_live_…' });
Caliper.configure(apiKey: 'cal_live_…');
Android requires a context; the others do not.
The survey builder
A fluent chain that defines one survey: which question, when it fires, and where the answer goes.
.survey(...)
Selects the question. howDidYouHear is the available question.
.after(...)
Sets the trigger that fires the survey. The survey fires once per install regardless of trigger.
| Trigger | Meaning |
|---|---|
firstOpen | First launch on a clean install (default). |
sessionN | The Nth session. Takes a session count. |
customEvent | After your app reports a named event. Takes the event name. |
.sync(...)
Names the destinations the answer is forwarded to.
| Destination | Status |
|---|---|
adjust | Live |
appsflyer | Live |
branch | Planned |
slack | Daily digest |
warehouse | Growth+ plans |
Platform forms of the full chain:
Caliper.survey(Survey.HOW_DID_YOU_HEAR)
.after(Trigger.FIRST_OPEN)
.sync(Destination.ADJUST, Destination.SLACK)
Caliper.survey('how_did_you_hear')
.after('first_open')
.sync(['adjust', 'slack']);
Caliper.survey(Survey.howDidYouHear)
.after(Trigger.firstOpen)
.sync([Destination.adjust, Destination.slack]);
Callbacks
Attach optional handlers to react to outcomes in your own code. They are observational — the answer is forwarded to your destinations regardless of whether you set them.
| Callback | Fires when | Receives |
|---|---|---|
onAnswered | The person selects an answer. | The answer, plus any auto-suggest refinement. |
onSkipped | The person skips. | Nothing; signals a recorded skip. |
Caliper.survey(.howDidYouHear)
.after(.firstOpen)
.sync(to: [.adjust, .slack])
.onAnswered { answer in print("source:", answer) }
.onSkipped { print("skipped") }
Use onAnswered to thank the person or branch onboarding; do not use it to re-prompt, since the survey fires only once per install.
Test mode
Configure with a cal_test_… key or set environment to sandbox to exercise the flow without writing to production reporting. In test mode the survey can be re-triggered on the same install so you do not have to reinstall between runs, and forwarded events are routed to the sandbox side of your MMP rather than your live dashboards. Switch to the cal_live_… key for real installs.
Related
- Configure timing and the answer set: Survey configuration
- Where answers land: MMP sync
- Privacy posture: Data and privacy