Skip to content
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "tests/engine/engine-tests/engine-test-data"]
path = tests/engine/engine-tests/engine-test-data
url = git@github.com:Flagsmith/engine-test-data.git
branch = v3.7.0
branch = v3.12.1
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,26 @@ export type FeaturePriority = number;
* Feature overrides for the segment.
*/
export type Overrides = FeatureContext[];
/**
* Feature name.
*/
export type Name3 = string;
/**
* Indicates if the feature flag is enabled.
*/
export type Enabled1 = boolean;
/**
* Feature flag value.
*/
export type Value4 = string | number | boolean | null;
/**
* Reason for the feature flag evaluation.
*/
export type Reason = string;
/**
* A stable identifier of the multivariate variant the identity was bucketed into: the variant's key, "control" for the control bucket, or null when no multivariate split applied (a standard feature, an unkeyed variant, or evaluation without an identity).
*/
export type Variant = string | null;

/**
* A context object containing the necessary information to evaluate Flagsmith feature flags.
Expand All @@ -140,6 +160,7 @@ export interface EvaluationContext {
identity?: IdentityContext | null;
segments?: Segments;
features?: Features;
flags?: FlagResults;
[k: string]: unknown;
}
/**
Expand Down Expand Up @@ -250,3 +271,24 @@ export interface SegmentMetadata {
export interface Features {
[k: string]: FeatureContext;
}
/**
* Results of features already evaluated for this context, mapped by feature name. Populated by the engine as evaluation progresses, so that segment conditions may reference `$.flags.<feature name>.enabled`, `.value` and `.variant` to express feature dependencies.
*/
export interface FlagResults {
[k: string]: FlagResult;
}
export interface FlagResult {
name: Name3;
enabled: Enabled1;
value: Value4;
reason: Reason;
variant: Variant;
metadata?: FeatureMetadata1;
[k: string]: unknown;
}
/**
* Additional metadata associated with the feature.
*/
export interface FeatureMetadata1 {
[k: string]: unknown;
}
3 changes: 2 additions & 1 deletion flagsmith-engine/evaluation/evaluationContext/mappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ export function getEvaluationContext(
): GenericEvaluationContext {
const environmentContext = mapEnvironmentModelToEvaluationContext(environment);
if (isEnvironmentEvaluation) {
return environmentContext;
const { segments, ...environmentContextWithoutSegments } = environmentContext;
return environmentContextWithoutSegments;
}
const identityContext = identity
? mapIdentityModelToIdentityContext(identity, overrideTraits)
Expand Down
3 changes: 2 additions & 1 deletion flagsmith-engine/evaluation/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export type SegmentsWithMetadata<T extends SegmentMetadata = SegmentMetadata> =

export interface SegmentResultWithMetadata {
name: string;
metadata: SDKSegmentMetadata;
metadata?: SDKSegmentMetadata;
}

export type EvaluationResultSegments = SegmentResultWithMetadata[];
Expand All @@ -79,6 +79,7 @@ export interface GenericEvaluationContext<
identity?: IdentityContext | null;
segments?: SegmentsWithMetadata<S>;
features?: FeaturesWithMetadata<T>;
flags?: EvaluationResultFlags<T>;
[k: string]: unknown;
}

Expand Down
3 changes: 3 additions & 0 deletions flagsmith-engine/features/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
export enum TARGETING_REASONS {
DEFAULT = 'DEFAULT',
STATIC = 'STATIC',
TARGETING_MATCH = 'TARGETING_MATCH',
SPLIT = 'SPLIT'
}

export const CIRCULAR_DEPENDENCY_REASON = 'ERROR; code=CIRCULAR_DEPENDENCY';
Loading
Loading