Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions packages/experiment-tag/src/experiment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,6 @@ export const initializeExperiment = async (

// allow local evaluation for remote flags
metadata.evaluationMode = 'local';

// Check if any remote flags are blocking
if (!isRemoteBlocking && metadata.blockingEvaluation) {
isRemoteBlocking = true;

// Apply anti-flicker CSS to prevent UI flicker
applyAntiFlickerCss();
}
} else {
// Add locally evaluable flags to the local flag set
localFlagKeys.add(key);
Expand All @@ -162,6 +154,23 @@ export const initializeExperiment = async (
...config,
});

// evaluate variants for page targeting
const variants: Variants = globalScope.webExperiment.all();

for (const [key, variant] of Object.entries(variants)) {
// only apply antiflicker for remote flags active on the page
if (
remoteFlagKeys.has(key) &&
variant.metadata?.blockingEvaluation &&
variant.metadata?.segmentName !== 'Page not targeted' &&
variant.metadata?.segmentName !== 'Page is excluded'
) {
isRemoteBlocking = true;
// Apply anti-flicker CSS to prevent UI flicker
applyAntiFlickerCss();
}
}

// If no integration has been set, use an amplitude integration.
if (!globalScope.experimentIntegration) {
const connector = AnalyticsConnector.getInstance('$default_instance');
Expand Down
Loading