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.

OptionTypeNotes
apiKeystringRequired. Your project key, in the form cal_live_…. Use the test key for cal_test_….
environmentenumOptional. 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.

TriggerMeaning
firstOpenFirst launch on a clean install (default).
sessionNThe Nth session. Takes a session count.
customEventAfter your app reports a named event. Takes the event name.

.sync(...)

Names the destinations the answer is forwarded to.

DestinationStatus
adjustLive
appsflyerLive
branchPlanned
slackDaily digest
warehouseGrowth+ 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.

CallbackFires whenReceives
onAnsweredThe person selects an answer.The answer, plus any auto-suggest refinement.
onSkippedThe 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.