From e404075dc256fb471c3c402bc80a56d6c89cc872 Mon Sep 17 00:00:00 2001 From: Varun Pai Date: Wed, 1 May 2024 16:08:00 -0700 Subject: [PATCH] update readme --- README.md | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 100 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e6f15499..40183d0f 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,105 @@ # Eppo Android SDK -[Eppo](https://www.geteppo.com) is a feature management and experimentation platform. This SDK enables feature flagging and experimentation for customers of Eppo. An API key is required to use this SDK. +[![Test and lint SDK](https://github.com/Eppo-exp/android-sdk/actions/workflows/test.yaml/badge.svg)](https://github.com/Eppo-exp/android-sdk/actions/workflows/test.yaml) + +[Eppo](https://www.geteppo.com/) is a modular flagging and experimentation analysis tool. Eppo's Android SDK is built to make assignments for single user client applications. Before proceeding you'll need an Eppo account. + +## Features + +- Feature gates +- Kill switches +- Progressive rollouts +- A/B/n experiments +- Mutually exclusive experiments (Layers) +- Global holdouts +- Dynamic configuration + +## Installation + +Install the SDK using Gradle. + +```java +implementation 'cloud.eppo:android-sdk:1.0.2' +``` + +## Quick start + +Begin by initializing a singleton instance of Eppo's client. Once initialized, the client can be used to make assignments anywhere in your app. + +#### Initialize once + +```java +import cloud.eppo.android.EppoClient; + +EppoClient.init("SDK-KEY-FROM-DASHBOARD"); +``` + + +#### Assign anywhere + +```java +import cloud.eppo.android.EppoClient; + +EppoClient eppoClient = EppoClient.getInstance(); +User user = getCurrentUser(); + +Boolean variant = eppoClient.getBoolAssignment('new-user-onboarding', user.id, user.attributes, false); +``` + +## Assignment functions + +Every Eppo flag has a return type that is set once on creation in the dashboard. Once a flag is created, assignments in code should be made using the corresponding typed function: + +```java +getBooleanAssignment(...) +getDoubleAssignment(...) +getJSONAssignment(...) +getStringAssignment(...) +``` + +Each function has the same signature, but returns the type in the function name. For booleans use `getBooleanAssignment`, which has the following signature: + +```java +public boolean getBooleanAssignment( + String flagKey, + String subjectKey, + Map subjectAttributes, + String defaultValue +) + ``` + +## Assignment logger + +To use the Eppo SDK for experiments that require analysis, pass in a callback logging function to the `init` function on SDK initialization. The SDK invokes the callback to capture assignment data whenever a variation is assigned. The assignment data is needed in the warehouse to perform analysis. + +The code below illustrates an example implementation of a logging callback using [Segment](https://segment.com/), but you can use any system you'd like. The only requirement is that the SDK receives a `logAssignment` callback function. Here we define an implementation of the Eppo `IAssignmentLogger` interface containing a single function named `logAssignment`: + +```java +AssignmentLogger logger = new AssignmentLogger() { + @Override + public void logAssignment(Assignment assignment) { + analytics.enqueue(TrackMessage.builder("Eppo Randomized Assignment") + .userId(assignment.getSubject()) + .properties(ImmutableMap.builder() + .put("timestamp", assignment.getTimestamp()) + .put("experiment", assignment.getExperiment()) + .put("variation", assignment.getVariation()) + .build() + ); + ); + } +}; + +EppoClient eppoClient = new EppoClient.Builder() + .apiKey("YOUR_SDK_KEY") + .assignmentLogger(assignmentLogger) + .application(application) + .buildAndInit(); +``` + +## Philosophy + +Eppo's SDKs are built for simplicity, speed and reliability. Flag configurations are compressed and distributed over a global CDN (Fastly), typically reaching end users in under 15ms. Those configurations are then cached locally, ensuring that each assignment is made instantly. Each SDK is as light as possible, with evaluation logic at around 25 simple lines of code. The simple typed functions listed above are all developers need to know about, abstracting away the complexity of the underlying set of features. -## Getting Started -For information on usage, refer to our [SDK Documentation](https://docs.geteppo.com/feature-flags/sdks/android).