Skip to content
Merged
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
4 changes: 0 additions & 4 deletions flagsmith-engine/evaluation/evaluationContext/mappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,6 @@ function mapIdentityModelToIdentityContext(
traits: traitsContext
};

if (identity.djangoID !== undefined) {
identityContext.key = identity.djangoID.toString();
}

return identityContext;
}

Expand Down
5 changes: 1 addition & 4 deletions tests/engine/unit/mappers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,7 @@ describe('getEvaluationContext', () => {
[new TraitModel('email', 'test@example.com'), new TraitModel('age', 25)],
[],
'B62qaMZNwfiqT76p38ggrQ',
'test_user',
undefined,
123
'test_user'
);

// When
Expand All @@ -247,7 +245,6 @@ describe('getEvaluationContext', () => {
// Then
expect(context.identity).toBeDefined();
expect(context.identity?.identifier).toBe('test_user');
expect(context.identity?.key).toBe('123');
expect(context.identity?.traits).toEqual({
email: 'test@example.com',
age: 25
Expand Down
43 changes: 0 additions & 43 deletions tests/engine/unit/segments/segment_evaluators.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,49 +82,6 @@ test('test_traits_match_segment_condition_for_trait_existence_operators', () =>
}
});

test('getIdentitySegments uses django ID for hashed percentage when present', () => {
var identityModel = new IdentityModel(
Date.now().toString(),
[],
[],
environment().apiKey,
'identity_1',
undefined,
1
);
const segmentDefinition = {
id: 1,
name: 'percentage_split_segment',
rules: [
{
type: ALL_RULE,
conditions: [
{
operator: PERCENTAGE_SPLIT,
property_: null,
value: '10'
}
],
rules: []
}
],
feature_states: []
};
const segmentModel = buildSegmentModel(segmentDefinition);
const environmentModel = environment();
environmentModel.project.segments = [segmentModel];
const context = getEvaluationContext(environmentModel, identityModel);

var result = getIdentitySegments(context);

expect(result).toHaveLength(1);
expect(getHashedPercentageForObjIds).toHaveBeenCalledTimes(1);
expect(getHashedPercentageForObjIds).toHaveBeenCalledWith([
result[0].key,
context.identity!.key
]);
});

describe('getIdentitySegments integration', () => {
test('returns only matching segments', () => {
const context: EvaluationContext = {
Expand Down