
proba-sdk-android
Mobile framework for Proba platform.
Installation
- On project level
build.gradle add mavenCentral repository to all projects section
allprojects {
// ...
repositories {
mavenCentral()
// ...
}
}
- Add the library to
app level build.gradle dependencies section
dependencies {
// ...
implementation "ai.proba.probasdk:probasdk:${probasdk_version}"
// ...
}
Usage
Initialization:
Kotlin:
val sdk = ProbaSdk.Builder(context) // you can initiate sdk using either application or activity context
.appId("${YOUR_APP_ID}")
.sdkToken("${YOUR_SDK_TOKEN}")
.deviceId("${YOUR_DEVICE_ID}") // optional, UUID generated by default
.deviceProperties(
mapOf(
"installedAt" to "2021-05-20T09:55:05.000+03:00"
)
)// optional, additional information about device
.appsFlyerId("${YOUR_APPS_FLYER_UID}") // optional, use AppsFlyerLib.getInstance().getAppsFlyerUID(context) if AppsFlyer integration is needed
.amplitudeUserId("${YOUR_AMPLITUDE_USER_ID}") // optional, use Amplitude.getInstance().getUserId()
.usingShake(false) // true by default for debug mode, turn it off if you are already using shake motion in your app for other purposes
.defaults(
mapOf(
"${TEST_1_KEY}" to "${TEST_1_DEFAULT_VALUE}",
"${TEST_2_KEY}" to "${TEST_2_DEFAULT_VALUE}"
)
)
.build()
Java:
Map<String, String> defaults = new HashMap<>();
defaults.put("${TEST_1_KEY}", "${TEST_1_DEFAULT_VALUE}");
defaults.put("${TEST_2_KEY}", "${TEST_2_DEFAULT_VALUE}");
Map<String, String> deviceProperties = new HashMap<>();
deviceProperties.put("installedAt", "2021-05-20T09:55:05.000+03:00");
ProbaSdk sdk = new ProbaSdk.Builder(this)
.appId("${YOUR_APP_ID}")
.sdkToken("${YOUR_SDK_TOKEN}")
.deviceId("${YOUR_DEVICE_ID}") // optional, UUID generated by default
.deviceProperties(deviceProperties) // optional, additional information about device
.appsFlyerId("${YOUR_APPS_FLYER_UID}") // optional, use AppsFlyerLib.getInstance().getAppsFlyerUID(context) if AppsFlyer integration is needed
.amplitudeUserId("${YOUR_AMPLITUDE_USER_ID}") // optional, use Amplitude.getInstance().getUserId()
.usingShake(true) // true by default for debug mode, turn it off if you are already using shake motion in your app for other purposes
.defaults(defaults)
.build();
How to fetch known test values that associated with your device?
Kotlin:
sdk.fetch(onSuccessListener = object: ProbaSdk.OnSuccessListener{
override fun onSuccess() {
}
},
onErrorListener = object: ProbaSdk.OnErrorListener{
override fun onError(throwable: Throwable) {
}
})
Java:
sdk.fetch(new ProbaSdk.OnSuccessListener() {
@Override
public void onSuccess() {
...
}
},
new ProbaSdk.OnErrorListener() {
@Override
public void onError(Throwable throwable) {
...
}
});
How to get the value for a specific test?
Kotlin:
val value = sdk["${TEST_KEY}"]
Java:
String value = sdk.getValue("${TEST_KEY}");
In case of problems with no internet connection or another, the values obtained in the previous session will be used, or if they are missing, the default values specified during initialization will be used.
How to get user tests for analytics?
Kotlin:
val experiments = sdk.experiments
// or if you need additional details for experiments
val experimentsWithDetails = sdk.experimentsWithDetails
Java:
Map<String, String> experiments = sdk.getExperiments();
// or if you need additional details for experiments
Map<String, String> experiments = sdk.getExperimentsWithDetails();
Appsflyer users can integrate Proba sdk with analytics as shown below:
Kotlin:
val experiments = sdk.experiments
// or if you need additional details for experiments
// val experimentsWithDetails = sdk.experimentsWithDetails
AppsFlyerLib.getInstance().setAdditionalData(experiments)
Java:
Map<String, String> experiments = sdk.getExperiments();
// or if you need additional details for experiments
// Map<String, String> experiments = sdk.getExperimentsWithDetails();
AppsFlyerLib.getInstance().setAdditionalData(experiments);
Amplitude users can integrate Proba sdk with analytics as shown below:
Kotlin:
val experiments = sdk.experiments
// or if you need additional details for experiments
// val experimentsWithDetails = sdk.experimentsWithDetails
val userProperties = JSONObject(experiments)
Amplitude.getInstance().setUserProperties(userProperties)
Java:
Map<String, String> experiments = sdk.getExperiments();
// or if you need additional details for experiments
// Map<String, String> experiments = sdk.getExperimentsWithDetails();
JSONObject userProperties = new JSONObject(experiments);
AppsFlyerLib.getInstance().setAdditionalData(userProperties);
How to debug?
Before debug make sure that debug-mode for your App is turned-on on settings page

Kotlin:
ProbaSdk.Builder(context)
//...
.showLogs(true) false by default, to print all debugging info in the console
//...
val duration = sdk.lastOperationDurationMillis // the duration of the last operation in milliseconds
Java:
ProbaSdk.Builder(context)
//...
.showLogs(true) false by default, to print all debugging info in the console
//...
long duration = sdk.getLastOperationDurationMillis();
In debug mode you can see all actual tests and check how the user will see each option of the test.
To show the debug activity you just need to turn it on in your personal cabinet and call
Kotlin:
sdk.launchDebugMode(context: Context) // you can use either application or activity context
Java:
sdk.launchDebugMode(Context context); // you can use either application or activity context
By default debug activity will be shown by performing shake motion on your device.
==================================================
You can see the example of usage in ExampleAppKotlin and ExampleAppJava modules in this project.