@@ -35,11 +35,12 @@ export interface IEppoClient {
35
35
/**
36
36
* Maps a subject to a variation for a given experiment.
37
37
*
38
- * @param subjectKey an identifier of the experiment subject, for example a user ID.
39
38
* @param flagKey feature flag identifier
39
+ * @param subjectKey an identifier of the experiment subject, for example a user ID.
40
40
* @param subjectAttributes optional attributes associated with the subject, for example name and email.
41
+ * @param defaultValue default value to return if the subject is not part of the experiment sample
41
42
* The subject attributes are used for evaluating any targeting rules tied to the experiment.
42
- * @returns a variation value if the subject is part of the experiment sample, otherwise null
43
+ * @returns a variation value if the subject is part of the experiment sample, otherwise the default value
43
44
* @public
44
45
*/
45
46
getStringAssignment (
@@ -49,27 +50,73 @@ export interface IEppoClient {
49
50
defaultValue : string ,
50
51
) : string ;
51
52
53
+ /**
54
+ * @deprecated use getBooleanAssignment instead.
55
+ */
52
56
getBoolAssignment (
53
57
flagKey : string ,
54
58
subjectKey : string ,
55
59
subjectAttributes : Record < string , AttributeType > ,
56
60
defaultValue : boolean ,
57
61
) : boolean ;
58
62
63
+ /**
64
+ * Maps a subject to a boolean variation for a given experiment.
65
+ *
66
+ * @param flagKey feature flag identifier
67
+ * @param subjectKey an identifier of the experiment subject, for example a user ID.
68
+ * @param subjectAttributes optional attributes associated with the subject, for example name and email.
69
+ * @param defaultValue default value to return if the subject is not part of the experiment sample
70
+ * @returns a boolean variation value if the subject is part of the experiment sample, otherwise the default value
71
+ */
72
+ getBooleanAssignment (
73
+ flagKey : string ,
74
+ subjectKey : string ,
75
+ subjectAttributes : Record < string , AttributeType > ,
76
+ defaultValue : boolean ,
77
+ ) : boolean ;
78
+
79
+ /**
80
+ * Maps a subject to an Integer variation for a given experiment.
81
+ *
82
+ * @param flagKey feature flag identifier
83
+ * @param subjectKey an identifier of the experiment subject, for example a user ID.
84
+ * @param subjectAttributes optional attributes associated with the subject, for example name and email.
85
+ * @param defaultValue default value to return if the subject is not part of the experiment sample
86
+ * @returns a number variation value if the subject is part of the experiment sample, otherwise the default value
87
+ */
59
88
getIntegerAssignment (
60
89
flagKey : string ,
61
90
subjectKey : string ,
62
91
subjectAttributes : Record < string , AttributeType > ,
63
92
defaultValue : number ,
64
93
) : number ;
65
94
95
+ /**
96
+ * Maps a subject to a Numeric variation for a given experiment.
97
+ *
98
+ * @param flagKey feature flag identifier
99
+ * @param subjectKey an identifier of the experiment subject, for example a user ID.
100
+ * @param subjectAttributes optional attributes associated with the subject, for example name and email.
101
+ * @param defaultValue default value to return if the subject is not part of the experiment sample
102
+ * @returns a number variation value if the subject is part of the experiment sample, otherwise the default value
103
+ */
66
104
getNumericAssignment (
67
105
flagKey : string ,
68
106
subjectKey : string ,
69
107
subjectAttributes : Record < string , AttributeType > ,
70
108
defaultValue : number ,
71
109
) : number ;
72
110
111
+ /**
112
+ * Maps a subject to a JSON variation for a given experiment.
113
+ *
114
+ * @param flagKey feature flag identifier
115
+ * @param subjectKey an identifier of the experiment subject, for example a user ID.
116
+ * @param subjectAttributes optional attributes associated with the subject, for example name and email.
117
+ * @param defaultValue default value to return if the subject is not part of the experiment sample
118
+ * @returns a JSON object variation value if the subject is part of the experiment sample, otherwise the default value
119
+ */
73
120
getJSONAssignment (
74
121
flagKey : string ,
75
122
subjectKey : string ,
@@ -232,6 +279,15 @@ export default class EppoClient implements IEppoClient {
232
279
subjectKey : string ,
233
280
subjectAttributes : Record < string , AttributeType > ,
234
281
defaultValue : boolean ,
282
+ ) : boolean {
283
+ return this . getBooleanAssignment ( flagKey , subjectKey , subjectAttributes , defaultValue ) ;
284
+ }
285
+
286
+ public getBooleanAssignment (
287
+ flagKey : string ,
288
+ subjectKey : string ,
289
+ subjectAttributes : Record < string , AttributeType > ,
290
+ defaultValue : boolean ,
235
291
) : boolean {
236
292
return (
237
293
this . getAssignmentVariation (
0 commit comments