Skip to content

Commit d49476a

Browse files
nikomancytypotter
andauthored
Niko/java doc updates (#576)
* * Adding quickstart * Adding intro * Adding assignment * Adding initialization * Adding bandits * * Updating links * deleting old docs * java doc changes (#599) * Adding additional redirect. * Removing non-API reference link to API reference. * Updating link and redirect. * Event logging link update. * fixing link. --------- Co-authored-by: Tyler Potter <[email protected]>
1 parent aefbf09 commit d49476a

File tree

10 files changed

+761
-390
lines changed

10 files changed

+761
-390
lines changed

docs/sdks/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ The read more about our specific SDKs, check out the SDK-specific docs below:
130130
### Server SDKs
131131

132132
- [Node](server-sdks/node/intro)
133-
- [Java](server-sdks/java)
133+
- [Java](server-sdks/java/intro)
134134
- [Python](server-sdks/python/intro)
135135
- [Go](server-sdks/go/intro)
136136
- [Rust](server-sdks/rust/intro)

docs/sdks/server-sdks/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Eppo's server-side SDKs may be used to implement flags and run experiments in yo
1414

1515
- [Node](/sdks/server-sdks/node/intro)
1616
- [Python](/sdks/server-sdks/python/intro)
17-
- [Java](/sdks/server-sdks/java)
17+
- [Java](/sdks/server-sdks/java/intro)
1818
- [Dot Net](/sdks/server-sdks/dotnet/intro)
1919
- [Go](/sdks/server-sdks/go/intro)
2020
- [Ruby](/sdks/server-sdks/ruby/intro)

docs/sdks/server-sdks/java.mdx

Lines changed: 0 additions & 388 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"label": "Java",
3+
"position": 3
4+
}
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
---
2+
title: Assignments
3+
sidebar_position: 4
4+
---
5+
6+
import ApiOptionRef from '@site/src/components/ApiOptionRef';
7+
8+
Assignments are the mechanism through which a given Subject is assigned to a variation for a feature flag, experiment, or bandit.
9+
10+
## Assignment Types
11+
12+
The Eppo SDK supports the following assignment types:
13+
14+
- String
15+
- Boolean
16+
- JSON
17+
- Integer
18+
- Double
19+
20+
### String Assignments
21+
22+
String assignments are the most common type. They return a string value that is set as the variation for the experiment.
23+
24+
```java
25+
String assignedVariation = eppoClient.getStringAssignment(
26+
"flagkey",
27+
"subjectKey",
28+
"defaultValue"
29+
);
30+
```
31+
32+
### Boolean Assignments
33+
34+
Boolean flags support simple on/off toggles:
35+
36+
```java
37+
Boolean isEnabled = eppoClient.getBooleanAssignment(
38+
"flagkey",
39+
"subjectKey",
40+
false
41+
);
42+
```
43+
44+
### JSON Assignments
45+
46+
JSON assignments are useful for complex configuration values:
47+
48+
```java
49+
JsonNode config = eppoClient.getJSONAssignment(
50+
"flagkey",
51+
"subjectKey",
52+
defaultJsonNode
53+
);
54+
```
55+
56+
If you prefer to use a different JSON library, you can use `getJSONStringAssignment()` to get the unparsed JSON string.
57+
58+
### Numeric Assignments
59+
60+
For numeric values, you can use either integer or double assignments:
61+
62+
```java
63+
Integer count = eppoClient.getIntegerAssignment(
64+
"flagkey",
65+
"subjectKey",
66+
0
67+
);
68+
69+
Double price = eppoClient.getDoubleAssignment(
70+
"flagkey",
71+
"subjectKey",
72+
0.0
73+
);
74+
```
75+
76+
## Subject Attributes
77+
78+
All assignment methods support optional subject attributes that can be used for targeting:
79+
80+
```java
81+
Attributes subjectAttributes = new Attributes(
82+
Map.of(
83+
"country", EppoValue.valueOf("FR"),
84+
"age", EppoValue.valueOf(60),
85+
"isReturningUser", EppoValue.valueOf(true)
86+
)
87+
);
88+
89+
String assignedVariation = eppoClient.getStringAssignment(
90+
"flagkey",
91+
"subjectKey",
92+
subjectAttributes,
93+
"defaultValue"
94+
);
95+
```
96+
97+
## Assignment Logger
98+
99+
For experiments, you'll need to implement an assignment logger to track exposure events. The logger receives an assignment object with the following fields:
100+
101+
<ApiOptionRef
102+
name="timestamp"
103+
type="Date"
104+
defaultValue="undefined"
105+
>
106+
107+
The time when the subject was assigned to the variation
108+
</ApiOptionRef>
109+
110+
<ApiOptionRef
111+
name="experiment"
112+
type="String"
113+
defaultValue="undefined"
114+
>
115+
116+
The key of the experiment
117+
</ApiOptionRef>
118+
119+
<ApiOptionRef
120+
name="featureFlag"
121+
type="String"
122+
defaultValue="undefined"
123+
>
124+
125+
The key of the feature flag
126+
</ApiOptionRef>
127+
128+
<ApiOptionRef
129+
name="allocation"
130+
type="String"
131+
defaultValue="undefined"
132+
>
133+
134+
The key of the allocation
135+
</ApiOptionRef>
136+
137+
<ApiOptionRef
138+
name="variation"
139+
type="String"
140+
defaultValue="undefined"
141+
>
142+
143+
The identifier of the assigned variation
144+
</ApiOptionRef>
145+
146+
<ApiOptionRef
147+
name="subject"
148+
type="String"
149+
defaultValue="undefined"
150+
>
151+
152+
The identifier of the subject
153+
</ApiOptionRef>
154+
155+
<ApiOptionRef
156+
name="subjectAttributes"
157+
type="Attributes"
158+
defaultValue="{}"
159+
>
160+
161+
A map of metadata about the subject
162+
</ApiOptionRef>
163+
164+
:::info
165+
More details about logging and examples (with Segment, Rudderstack, mParticle, and Snowplow) can be found in the [event logging](/sdks/event-logging/assignment-logging) page.
166+
:::

0 commit comments

Comments
 (0)