Skip to content

Commit 7a0437d

Browse files
committed
feat: Add support for client-side prerequisite events.
1 parent 7d49d9e commit 7a0437d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/index.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,10 @@ function initialize(env, context, specifiedOptions, platform, extraOptionDefs) {
308308

309309
function variationDetailInternal(key, defaultValue, sendEvent, includeReasonInEvent, isAllFlags) {
310310
let detail;
311+
let flag;
311312

312313
if (flags && utils.objectHasOwnProperty(flags, key) && flags[key] && !flags[key].deleted) {
313-
const flag = flags[key];
314+
flag = flags[key];
314315
detail = getFlagDetail(flag);
315316
if (flag.value === null || flag.value === undefined) {
316317
detail.value = defaultValue;
@@ -320,6 +321,12 @@ function initialize(env, context, specifiedOptions, platform, extraOptionDefs) {
320321
}
321322

322323
if (sendEvent) {
324+
// An event will be send for each of these by virtue of sending events for all flags.
325+
if (!allFlags) {
326+
flag?.prerequisites?.forEach(key => {
327+
variation(key, undefined);
328+
});
329+
}
323330
sendFlagEvent(key, detail, defaultValue, includeReasonInEvent);
324331
}
325332

0 commit comments

Comments
 (0)