-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathSplitClient.java
More file actions
289 lines (256 loc) · 12.7 KB
/
SplitClient.java
File metadata and controls
289 lines (256 loc) · 12.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
package io.split.android.client;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.util.List;
import java.util.Map;
import io.split.android.client.attributes.AttributesManager;
import io.split.android.client.events.SplitEvent;
import io.split.android.client.events.SplitEventTask;
public interface SplitClient extends AttributesManager {
/**
* Returns the treatment to show this key for this feature flag. The set of treatments
* for a feature flag can be configured on the Split user interface.
* <p/>
* <p/>
* This method returns the string 'control' if:
* <ol>
* <li>Any of the parameters were null</li>
* <li>There was an exception in evaluating the treatment</li>
* <li>The SDK does not know of the existence of this feature flag</li>
* <li>The feature flag was deleted through the Split user interface.</li>
* </ol>
* 'control' is a reserved treatment (you cannot create a treatment with the
* same name) to highlight these exceptional circumstances.
* <p/>
* <p/>
* The sdk returns the default treatment of this feature flag if:
* <ol>
* <li>The feature flag was killed</li>
* <li>The key did not match any of the conditions in the feature roll-out plan</li>
* </ol>
* The default treatment of a feature flag is set on the Split user interface.
* <p/>
* <p/>
* This method does not throw any exceptions. It also never returns null.
*
* @param featureFlagName the feature flag we want to evaluate. MUST NOT be null.
* @return the evaluated treatment, the default treatment of this feature flag, or 'control'.
*/
String getTreatment(String featureFlagName);
/**
* This method is useful when you want to determine the treatment to show
* to an customer (user, account etc.) based on an attribute of that customer
* instead of it's key.
* <p/>
* <p/>
* Examples include showing a different treatment to users on trial plan
* vs. premium plan. Another example is to show a different treatment
* to users created after a certain date.
*
* @param featureFlagName the feature flag we want to evaluate. MUST NOT be null.
* @param attributes of the customer (user, account etc.) to use in evaluation. Can be null or empty.
* @return the evaluated treatment, the default treatment of this feature flag, or 'control'.
*/
String getTreatment(String featureFlagName, Map<String, Object> attributes);
String getTreatment(String featureFlagName, Map<String, Object> attributes, EvaluationOptions evaluationOptions);
/**
* This method is useful when you want to determine the treatment to show
* to an customer (user, account etc.) based on an attribute of that customer
* instead of it's key.
* <p/>
* <p/>
* Examples include showing a different treatment to users on trial plan
* vs. premium plan. Another example is to show a different treatment
* to users created after a certain date.
*
* @param featureFlagName the feature flag we want to evaluate. MUST NOT be null.
* @param attributes of the customer (user, account etc.) to use in evaluation. Can be null or empty.
* @return the evaluated treatment, the default treatment of this feature flag, or 'control'
* with its corresponding configurations if it has one.
*/
SplitResult getTreatmentWithConfig(String featureFlagName, Map<String, Object> attributes);
SplitResult getTreatmentWithConfig(String featureFlagName, Map<String, Object> attributes, EvaluationOptions evaluationOptions);
/**
* This method is useful when you want to determine the treatment of several feature flags at
* the same time.
* <p/>
* <p/>
* It can be used to cache treatments you know it won't change very often.
*
* @param featureFlagNames the feature flags you want to evaluate. MUST NOT be null.
* @param attributes of the customer (user, account etc.) to use in evaluation. Can be null or empty.
* @return the evaluated treatments, the default treatment of a feature, or 'control'.
*/
Map<String, String> getTreatments(List<String> featureFlagNames, Map<String, Object> attributes);
Map<String, String> getTreatments(List<String> featureFlagNames, Map<String, Object> attributes, EvaluationOptions evaluationOptions);
/**
* This method is useful when you want to determine the treatment of several feature flags at
* the same time.
* <p/>
* <p/>
* It can be used to cache treatments you know it won't change very often.
*
* @param featureFlagNames the feature flags you want to evaluate. MUST NOT be null.
* @param attributes of the customer (user, account etc.) to use in evaluation. Can be null or empty.
* @return the evaluated treatments, the default treatment of a feature flag, or 'control'
* with its corresponding configurations if it has one.
*/
Map<String, SplitResult> getTreatmentsWithConfig(List<String> featureFlagNames, Map<String, Object> attributes);
Map<String, SplitResult> getTreatmentsWithConfig(List<String> featureFlagNames, Map<String, Object> attributes, EvaluationOptions evaluationOptions);
/**
* This method is useful when you want to determine the treatment of several feature flags
* belonging to a specific Flag Set at the same time.
*
* @param flagSet the Flag Set name that you want to evaluate. Must not be null or empty
* @param attributes of the customer (user, account etc.) to use in evaluation. Can be null or empty
* @return a {@link Map} containing for each feature flag the evaluated treatment, the default treatment of this feature flag, or 'control'
*/
Map<String, String> getTreatmentsByFlagSet(@NonNull String flagSet, @Nullable Map<String, Object> attributes);
Map<String, String> getTreatmentsByFlagSet(@NonNull String flagSet, @Nullable Map<String, Object> attributes, EvaluationOptions evaluationOptions);
/**
* This method is useful when you want to determine the treatment of several feature flags
* belonging to a specific list of Flag Sets at the same time.
*
* @param flagSets the Flag Sets names that you want to evaluate. Must not be null or empty
* @param attributes of the customer (user, account etc.) to use in evaluation. Can be null or empty
* @return a {@link Map} containing for each feature flag the evaluated treatment, the default treatment of this feature flag, or 'control'
*/
Map<String, String> getTreatmentsByFlagSets(@NonNull List<String> flagSets, @Nullable Map<String, Object> attributes);
Map<String, String> getTreatmentsByFlagSets(@NonNull List<String> flagSets, @Nullable Map<String, Object> attributes, EvaluationOptions evaluationOptions);
/**
* This method is useful when you want to determine the treatment of several feature flags
* belonging to a specific Flag Set
*
* @param flagSet the Flag Set name that you want to evaluate. Must not be null or empty
* @param attributes of the customer (user, account etc.) to use in evaluation. Can be null or empty
* @return a {@link Map} containing for each feature flag the evaluated treatment, the default treatment of this feature flag, or 'control'
*/
Map<String, SplitResult> getTreatmentsWithConfigByFlagSet(@NonNull String flagSet, @Nullable Map<String, Object> attributes);
Map<String, SplitResult> getTreatmentsWithConfigByFlagSet(@NonNull String flagSet, @Nullable Map<String, Object> attributes, EvaluationOptions evaluationOptions);
/**
* This method is useful when you want to determine the treatment of several feature flags
* belonging to a specific list of Flag Sets
*
* @param flagSets the Flag Sets names that you want to evaluate. Must not be null or empty
* @param attributes of the customer (user, account etc.) to use in evaluation. Can be null or empty
* @return a {@link Map} containing for each feature flag the evaluated treatment, the default treatment of this feature flag, or 'control'
*/
Map<String, SplitResult> getTreatmentsWithConfigByFlagSets(@NonNull List<String> flagSets, @Nullable Map<String, Object> attributes);
Map<String, SplitResult> getTreatmentsWithConfigByFlagSets(@NonNull List<String> flagSets, @Nullable Map<String, Object> attributes, EvaluationOptions evaluationOptions);
/**
* Destroys the background processes and clears the cache, releasing the resources used by
* any instances of SplitClient or SplitManager generated by the client's parent SplitFactory
*/
void destroy();
/**
* Flushes all memory allocated queues which should be stored on disk or sent to server.
*/
void flush();
/**
* Checks if cached data is ready to perform treatment evaluations
*
* @return true if the sdk is ready, if false, calls to getTreatment will return control
*/
boolean isReady();
void on(SplitEvent event, SplitEventTask task);
/**
* Enqueue a new event to be sent to Split data collection services.
* <p>
* The traffic type used is the one set by trafficType() in SplitClientConfig.
* <p>
* Example:
* client.track(“checkout”)
*
* @param eventType the type of the event
* @return true if the track was successful, false otherwise
*/
boolean track(String eventType);
/**
* Enqueue a new event to be sent to Split data collection services
* <p>
* Example:
* client.track(“account”, “checkout”, 200.00)
*
* @param trafficType the type of the event
* @param eventType the type of the event
* @param value the value of the event
* @return true if the track was successful, false otherwise
*/
boolean track(String trafficType, String eventType, double value);
/**
* Enqueue a new event to be sent to Split data collection services
* <p>
* Example:
* client.track(“account”, “checkout”)
*
* @param trafficType the type of the event
* @param eventType the type of the event
* @return true if the track was successful, false otherwise
*/
boolean track(String trafficType, String eventType);
/**
* Enqueue a new event to be sent to Split data collection services
* <p>
* The traffic type used is the one set by trafficType() in SplitClientConfig.
* <p>
* Example:
* client.track(“checkout”, 200.00)
*
* @param eventType the type of the event
* @param value the value of the event
* @return true if the track was successful, false otherwise
*/
boolean track(String eventType, double value);
/**
* Enqueue a new event to be sent to Split data collection services.
* <p>
* The traffic type used is the one set by trafficType() in SplitClientConfig.
* <p>
* Example:
* client.track(“checkout”)
*
* @param eventType the type of the event
* @param properties custom user data map
* @return true if the track was successful, false otherwise
*/
boolean track(String eventType, Map<String, Object> properties);
/**
* Enqueue a new event to be sent to Split data collection services
* <p>
* Example:
* client.track(“account”, “checkout”, 200.00)
*
* @param trafficType the type of the event
* @param eventType the type of the event
* @param value the value of the event
* @param properties custom user data map
* @return true if the track was successful, false otherwise
*/
boolean track(String trafficType, String eventType, double value, Map<String, Object> properties);
/**
* Enqueue a new event to be sent to split data collection services
* <p>
* Example:
* client.track(“account”, “checkout”)
*
* @param trafficType the type of the event
* @param eventType the type of the event
* @param properties custom user data map
* @return true if the track was successful, false otherwise
*/
boolean track(String trafficType, String eventType, Map<String, Object> properties);
/**
* Enqueue a new event to be sent to Split data collection services
* <p>
* The traffic type used is the one set by trafficType() in SplitClientConfig.
* <p>
* Example:
* client.track(“checkout”, 200.00)
*
* @param eventType the type of the event
* @param value the value of the event
* @param properties custom user data map
* @return true if the track was successful, false otherwise
*/
boolean track(String eventType, double value, Map<String, Object> properties);
}