@@ -7,6 +7,7 @@ import { MAX_EVENT_QUEUE_SIZE } from '../constants';
7
7
import { IAllocation } from '../dto/allocation-dto' ;
8
8
import { IExperimentConfiguration } from '../dto/experiment-configuration-dto' ;
9
9
import { EppoValue , ValueType } from '../eppo_value' ;
10
+ import { getMD5Hash } from '../obfuscation' ;
10
11
import { findMatchingRule } from '../rule_evaluator' ;
11
12
import { getShard , isShardInRange } from '../shard' ;
12
13
import { validateNotBlank } from '../validation' ;
@@ -100,11 +101,17 @@ export default class EppoClient implements IEppoClient {
100
101
// eslint-disable-next-line @typescript-eslint/no-explicit-any
101
102
subjectAttributes : Record < string , any > = { } ,
102
103
assignmentHooks ?: IAssignmentHooks | undefined ,
104
+ obfuscated = false ,
103
105
) : string | null {
104
106
try {
105
107
return (
106
- this . getAssignmentVariation ( subjectKey , flagKey , subjectAttributes , assignmentHooks )
107
- . stringValue ?? null
108
+ this . getAssignmentVariation (
109
+ subjectKey ,
110
+ flagKey ,
111
+ subjectAttributes ,
112
+ assignmentHooks ,
113
+ obfuscated ,
114
+ ) . stringValue ?? null
108
115
) ;
109
116
} catch ( error ) {
110
117
return this . rethrowIfNotGraceful ( error ) ;
@@ -117,6 +124,7 @@ export default class EppoClient implements IEppoClient {
117
124
// eslint-disable-next-line @typescript-eslint/no-explicit-any
118
125
subjectAttributes : Record < string , any > = { } ,
119
126
assignmentHooks ?: IAssignmentHooks | undefined ,
127
+ obfuscated = false ,
120
128
) : string | null {
121
129
try {
122
130
return (
@@ -125,6 +133,7 @@ export default class EppoClient implements IEppoClient {
125
133
flagKey ,
126
134
subjectAttributes ,
127
135
assignmentHooks ,
136
+ obfuscated ,
128
137
ValueType . StringType ,
129
138
) . stringValue ?? null
130
139
) ;
@@ -139,6 +148,7 @@ export default class EppoClient implements IEppoClient {
139
148
// eslint-disable-next-line @typescript-eslint/no-explicit-any
140
149
subjectAttributes : Record < string , any > = { } ,
141
150
assignmentHooks ?: IAssignmentHooks | undefined ,
151
+ obfuscated = false ,
142
152
) : boolean | null {
143
153
try {
144
154
return (
@@ -147,6 +157,7 @@ export default class EppoClient implements IEppoClient {
147
157
flagKey ,
148
158
subjectAttributes ,
149
159
assignmentHooks ,
160
+ obfuscated ,
150
161
ValueType . BoolType ,
151
162
) . boolValue ?? null
152
163
) ;
@@ -160,6 +171,7 @@ export default class EppoClient implements IEppoClient {
160
171
flagKey : string ,
161
172
subjectAttributes ?: Record < string , EppoValue > ,
162
173
assignmentHooks ?: IAssignmentHooks | undefined ,
174
+ obfuscated = false ,
163
175
) : number | null {
164
176
try {
165
177
return (
@@ -168,6 +180,7 @@ export default class EppoClient implements IEppoClient {
168
180
flagKey ,
169
181
subjectAttributes ,
170
182
assignmentHooks ,
183
+ obfuscated ,
171
184
ValueType . NumericType ,
172
185
) . numericValue ?? null
173
186
) ;
@@ -182,6 +195,7 @@ export default class EppoClient implements IEppoClient {
182
195
// eslint-disable-next-line @typescript-eslint/no-explicit-any
183
196
subjectAttributes : Record < string , any > = { } ,
184
197
assignmentHooks ?: IAssignmentHooks | undefined ,
198
+ obfuscated = false ,
185
199
) : string | null {
186
200
try {
187
201
return (
@@ -190,6 +204,7 @@ export default class EppoClient implements IEppoClient {
190
204
flagKey ,
191
205
subjectAttributes ,
192
206
assignmentHooks ,
207
+ obfuscated ,
193
208
ValueType . JSONType ,
194
209
) . stringValue ?? null
195
210
) ;
@@ -204,6 +219,7 @@ export default class EppoClient implements IEppoClient {
204
219
// eslint-disable-next-line @typescript-eslint/no-explicit-any
205
220
subjectAttributes : Record < string , any > = { } ,
206
221
assignmentHooks ?: IAssignmentHooks | undefined ,
222
+ obfuscated = false ,
207
223
) : object | null {
208
224
try {
209
225
return (
@@ -212,6 +228,7 @@ export default class EppoClient implements IEppoClient {
212
228
flagKey ,
213
229
subjectAttributes ,
214
230
assignmentHooks ,
231
+ obfuscated ,
215
232
ValueType . JSONType ,
216
233
) . objectValue ?? null
217
234
) ;
@@ -234,13 +251,15 @@ export default class EppoClient implements IEppoClient {
234
251
// eslint-disable-next-line @typescript-eslint/no-explicit-any
235
252
subjectAttributes : Record < string , any > = { } ,
236
253
assignmentHooks : IAssignmentHooks | undefined ,
254
+ obfuscated : boolean ,
237
255
valueType ?: ValueType ,
238
256
) : EppoValue {
239
257
const { allocationKey, assignment } = this . getAssignmentInternal (
240
258
subjectKey ,
241
259
flagKey ,
242
260
subjectAttributes ,
243
261
assignmentHooks ,
262
+ obfuscated ,
244
263
valueType ,
245
264
) ;
246
265
assignmentHooks ?. onPostAssignment ( flagKey , subjectKey , assignment , allocationKey ) ;
@@ -256,14 +275,17 @@ export default class EppoClient implements IEppoClient {
256
275
flagKey : string ,
257
276
subjectAttributes = { } ,
258
277
assignmentHooks : IAssignmentHooks | undefined ,
278
+ obfuscated : boolean ,
259
279
expectedValueType ?: ValueType ,
260
280
) : { allocationKey : string | null ; assignment : EppoValue } {
261
281
validateNotBlank ( subjectKey , 'Invalid argument: subjectKey cannot be blank' ) ;
262
282
validateNotBlank ( flagKey , 'Invalid argument: flagKey cannot be blank' ) ;
263
283
264
284
const nullAssignment = { allocationKey : null , assignment : EppoValue . Null ( ) } ;
265
285
266
- const experimentConfig = this . configurationStore . get < IExperimentConfiguration > ( flagKey ) ;
286
+ const experimentConfig = this . configurationStore . get < IExperimentConfiguration > (
287
+ obfuscated ? getMD5Hash ( flagKey ) : flagKey ,
288
+ ) ;
267
289
const allowListOverride = this . getSubjectVariationOverride (
268
290
subjectKey ,
269
291
experimentConfig ,
@@ -288,7 +310,11 @@ export default class EppoClient implements IEppoClient {
288
310
}
289
311
290
312
// Attempt to match a rule from the list.
291
- const matchedRule = findMatchingRule ( subjectAttributes || { } , experimentConfig . rules ) ;
313
+ const matchedRule = findMatchingRule (
314
+ subjectAttributes || { } ,
315
+ experimentConfig . rules ,
316
+ obfuscated ,
317
+ ) ;
292
318
if ( ! matchedRule ) return nullAssignment ;
293
319
294
320
// Check if subject is in allocation sample.
0 commit comments