-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Niko/android to new template #550
Open
nikomancy
wants to merge
17
commits into
main
Choose a base branch
from
niko/android-to-new-template
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
f0c924d
Updating versions and lock
nikomancy cbcc809
Updating mdx-js dep
nikomancy d85d6ca
Fixing prismjs theme import.
nikomancy 573235b
Updating package, lock, and config for 3.x Katex support.
nikomancy 8191af9
Changing SDK docs over to mdx and correcting 3.x upgrade breaking cha…
nikomancy 5f5078a
Fixing more 3.x update breaking changess.
nikomancy c4c38fe
Last couple of new MDX syntax errors from 3.x upgrade.
nikomancy 415dae4
Fixing broken links.
nikomancy a2abf18
Link fix
nikomancy 26bfa82
add precomputed assignments documentation for JS client (#541)
leoromanovsky 17705de
typo subject attributes
leoromanovsky 3d4b060
Update precomputed-assignments.mdx evaluation example (#544)
leoromanovsky 0ebd6dc
Merge branch 'main' into niko/upgrade-docusaurus2-to-docusaurus3
nikomancy c86656c
Fixing MDX syntax issue.
nikomancy 14f5214
Rough draft for android.
nikomancy 5318d4e
Remove copy pasted logging examples for Firebase and Mixpanel from An…
nikomancy 407a375
Updating links
nikomancy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# Experiment Update Webhook | ||
|
||
Webhooks let your integrations take action in response to events that occur in Eppo. The Experiment Update Webhook is a good solution when a custom application needs to display or take action on the most up to date state of an experiment. | ||
|
||
## Webhook Events | ||
The webhook sends four types of experiment update events. If you only want to take action based on certain types of events, you can filter to just the events you are interested in subscribing to based on their event type in the request body. | ||
|
||
### Experiment Metric Updated | ||
**Triggers when:** | ||
- Metric is added or removed | ||
- Metric collection is added or removed | ||
|
||
**Request body:** | ||
|
||
```json | ||
{ | ||
"event": "experiment.metric.updated", | ||
"data": { | ||
"experiment_id": "<experiment_id>", | ||
"experiment_key": "<experiment_key>" | ||
}, | ||
"signature": "<signature>" | ||
} | ||
``` | ||
|
||
### Experiment Configuration Updated | ||
**Triggers when:** | ||
- User edits any configuration | ||
|
||
**Request body:** | ||
|
||
```json | ||
{ | ||
"event": "experiment.configuration.updated", | ||
"data": { | ||
"experiment_id": "<experiment_id>", | ||
"experiment_key": "<experiment_key>" | ||
}, | ||
"signature": "<signature>" | ||
} | ||
``` | ||
|
||
### Experiment Status Updated | ||
**Triggers when:** | ||
- Experiment's status changes | ||
|
||
**Request body:** | ||
|
||
```json | ||
{ | ||
"event": "experiment.status.updated", | ||
"data": { | ||
"experiment_id": "<experiment_id>", | ||
"experiment_key": "<experiment_key>" | ||
}, | ||
"signature": "<signature>" | ||
} | ||
``` | ||
|
||
### Experiment Calculated Metrics Updated | ||
**Triggers when:** | ||
- Data pipeline run irrespective of success or failure and mode of trigger manual or scheduled | ||
|
||
|
||
**Request body:** | ||
|
||
```json | ||
{ | ||
"event": "experiment.calculated_metrics.updated", | ||
"data": { | ||
"experiment_id": "<experiment_id>", | ||
"experiment_key": "<experiment_key>", | ||
"meta_data": { | ||
"status": "<success | failure>", | ||
"is_manual_refresh": "<boolean>", | ||
"is_data_updated": "<boolean>", | ||
"time_taken_seconds": "<number>", | ||
"is_traffic_imbalance": "<boolean>", | ||
"assignments_scan_start_date": "<date>", | ||
"assignments_scan_end_date": "<date>" | ||
} | ||
}, | ||
"signature": "<signature>" | ||
} | ||
``` | ||
|
||
## Configuring the webhook | ||
To use the webhook, you first need to setup a URL on your side to receive the webhook payload. Once that is done, contact [Eppo support](emailto:[email protected]) to set and enable the webhook. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"label": "Android", | ||
"position": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
--- | ||
title: Assignments | ||
sidebar_position: 4 | ||
--- | ||
|
||
import Tabs from '@theme/Tabs'; | ||
import TabItem from '@theme/TabItem'; | ||
import ApiOptionRef from '@site/src/components/ApiOptionRef'; | ||
|
||
Assignments are the mechanism through which a given [Subject](/sdks/sdk-features/subjects) is assigned to a variation for a feature flag, experiment, or bandit. | ||
|
||
Currently, the Eppo SDK supports the following assignment types: | ||
|
||
- String | ||
- Boolean | ||
- JSON | ||
- Numeric (Integer and Double) | ||
|
||
## How Assignments Work | ||
|
||
The SDK periodically retrieves configuration rules from the Eppo server that define how subjects should be allocated to variants. When you call an assignment function, the SDK evaluates these rules locally without making additional network requests. | ||
|
||
Each assignment requires: | ||
|
||
- **Flag Key**: Identifies which set of configuration rules to use | ||
- **Subject Key**: A unique identifier for the subject (usually a user ID) | ||
- **Subject Attributes**: Optional key-value pairs containing additional information used for rule evaluation | ||
- **Default Value**: Fallback value if assignment fails or rules don't match | ||
|
||
## String Assignments | ||
|
||
String assignments return a string value that is set as the variation for the experiment. String flags are the most common type of flags and are useful for both A/B/n tests and advanced targeting use cases. | ||
|
||
```java | ||
import cloud.eppo.android.EppoClient; | ||
|
||
EppoClient eppoClient = EppoClient.getInstance(); | ||
|
||
String flagKey = "new-landing-page"; | ||
String subjectKey = getUserId() || "anonymous"; | ||
Map<String, Object> subjectAttributes = new HashMap<>(); | ||
subjectAttributes.put("country", "US"); | ||
subjectAttributes.put("device", "android"); | ||
String defaultValue = "control"; | ||
|
||
String variation = eppoClient.getStringAssignment( | ||
flagKey, | ||
subjectKey, | ||
subjectAttributes, | ||
defaultValue | ||
); | ||
|
||
// Use the variant value to determine which component to render | ||
if (variation.equals("version-a")) { | ||
showVersionA(); | ||
} else if (variation.equals("version-b")) { | ||
showVersionB(); | ||
} else { | ||
showControl(); | ||
} | ||
``` | ||
|
||
## Boolean Assignments | ||
|
||
Boolean flags support simple on/off toggles. They're useful for simple, binary feature switches like blue/green deployments or enabling/disabling a new feature. | ||
|
||
```java | ||
boolean isEnabled = eppoClient.getBooleanAssignment( | ||
"new-feature", | ||
subjectKey, | ||
subjectAttributes, | ||
false // default value | ||
); | ||
|
||
if (isEnabled) { | ||
showNewFeature(); | ||
} else { | ||
showExistingFeature(); | ||
} | ||
``` | ||
|
||
## Numeric Assignments | ||
|
||
The SDK supports both integer and double numeric assignments. These are useful for testing different numeric values like prices, counts, or thresholds. | ||
|
||
```java | ||
// Integer assignment | ||
int itemCount = eppoClient.getIntegerAssignment( | ||
"items-per-page", | ||
subjectKey, | ||
subjectAttributes, | ||
10 // default value | ||
); | ||
|
||
// Double assignment | ||
double price = eppoClient.getDoubleAssignment( | ||
"subscription-price", | ||
subjectKey, | ||
subjectAttributes, | ||
9.99 // default value | ||
); | ||
``` | ||
|
||
## JSON Assignments | ||
|
||
JSON assignments allow for complex configuration objects. They're useful for testing multiple related values together. | ||
|
||
```java | ||
import org.json.JSONObject; | ||
|
||
JSONObject defaultConfig = new JSONObject(); | ||
defaultConfig.put("color", "#FF0000"); | ||
defaultConfig.put("fontSize", 14); | ||
defaultConfig.put("fontFamily", "Roboto"); | ||
|
||
JSONObject config = eppoClient.getJSONAssignment( | ||
"ui-config", | ||
subjectKey, | ||
subjectAttributes, | ||
defaultConfig | ||
); | ||
|
||
// Use the configuration | ||
String color = config.getString("color"); | ||
int fontSize = config.getInt("fontSize"); | ||
String fontFamily = config.getString("fontFamily"); | ||
``` | ||
|
||
## Assignment Logging | ||
|
||
When using the SDK for experiments (rather than just feature flags), you'll need to log assignments to analyze the results. The SDK provides a flexible logging system that can integrate with any analytics or data warehouse solution. | ||
|
||
### Logging Setup | ||
|
||
Configure assignment logging during SDK initialization: | ||
|
||
```java | ||
AssignmentLogger logger = new AssignmentLogger() { | ||
@Override | ||
public void logAssignment(Assignment assignment) { | ||
// Log assignment to your analytics system | ||
analytics.track("Eppo Experiment Assignment", | ||
new Properties() | ||
.putValue("experiment", assignment.getExperiment()) | ||
.putValue("variation", assignment.getVariation()) | ||
.putValue("subject", assignment.getSubject()) | ||
.putValue("timestamp", assignment.getTimestamp()) | ||
); | ||
} | ||
}; | ||
|
||
EppoClient eppoClient = new EppoClient.Builder("YOUR_SDK_KEY", getApplication()) | ||
.assignmentLogger(logger) | ||
.buildAndInit(); | ||
``` | ||
|
||
:::note | ||
More details about logging and examples can be found in the [event logging](/sdks/event-logging/) page. | ||
::: | ||
|
||
## Debugging Assignments | ||
|
||
You may encounter situations where a flag assignment produces unexpected values. The SDK provides debugging functions to help understand how assignments are being made: | ||
|
||
```java | ||
import cloud.eppo.android.dto.AssignmentDebugInfo; | ||
|
||
AssignmentDebugInfo debugInfo = eppoClient.getAssignmentDebugInfo( | ||
flagKey, | ||
subjectKey, | ||
subjectAttributes | ||
); | ||
|
||
// Log debug information | ||
Log.d("Eppo", "Assignment debug info: " + debugInfo.toString()); | ||
``` | ||
|
||
For more information about debugging, see the [debugging documentation](/sdks/sdk-features/debugging-flag-assignment). |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can't use the
||
operator like this in Java (unlike Javascript).You have to do instead: