-
Notifications
You must be signed in to change notification settings - Fork 0
Add events metadata #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2edf70b
Add events metadata
ZamoraEmmanuel cc5142e
Fix lint
ZamoraEmmanuel 6c87923
Apply suggestion from @EmilianoSanchez
ZamoraEmmanuel cabacb1
Merge branch 'development' into fme-12878
ZamoraEmmanuel fb507c3
Fix versions and readme
ZamoraEmmanuel 08d85f6
required changes
ZamoraEmmanuel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,8 @@ | ||
| 1.1.0 (February 12, 2026) | ||
| - Added ProviderEvents.Ready payload with Split SdkReadyMetadata | ||
| - Updated ConfigurationChanged to forward SdkUpdateMetadata in metadata | ||
| - Requires @splitsoftware/splitio-browserjs ^1.7.0 for SDK_UPDATE metadata support | ||
|
|
||
| 1.0.0 (October 1, 2025) | ||
| - First release. | ||
| - Up to date with @openfeature/web-sdk v1.6.1, and @splitsoftware/splitio-browserjs 1.4.0 | ||
| - First release. | ||
| - Up to date with @openfeature/web-sdk v1.6.1, and @splitsoftware/splitio-browserjs 1.4.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| import { transformContext } from '../lib/context'; | ||
|
|
||
| describe('context', () => { | ||
| describe('transformContext', () => { | ||
| const defaultTrafficType = 'user'; | ||
|
|
||
| test('uses defaultTrafficType when context has no trafficType', () => { | ||
| const result = transformContext({ targetingKey: 'key-1' }, defaultTrafficType); | ||
| expect(result.trafficType).toBe('user'); | ||
| expect(result.targetingKey).toBe('key-1'); | ||
| expect(result.attributes).toEqual({}); | ||
| }); | ||
|
|
||
| test('uses context trafficType when present and non-empty', () => { | ||
| const result = transformContext( | ||
| { targetingKey: 'key-1', trafficType: 'account' }, | ||
| defaultTrafficType | ||
| ); | ||
| expect(result.trafficType).toBe('account'); | ||
| expect(result.targetingKey).toBe('key-1'); | ||
| expect(result.attributes).toEqual({}); | ||
| }); | ||
|
|
||
| test('falls back to default when trafficType is empty string', () => { | ||
| const result = transformContext( | ||
| { targetingKey: 'key-1', trafficType: '' }, | ||
| defaultTrafficType | ||
| ); | ||
| expect(result.trafficType).toBe('user'); | ||
| }); | ||
|
|
||
| test('falls back to default when trafficType is whitespace', () => { | ||
| const result = transformContext( | ||
| { targetingKey: 'key-1', trafficType: ' ' }, | ||
| defaultTrafficType | ||
| ); | ||
| expect(result.trafficType).toBe('user'); | ||
| }); | ||
|
|
||
| test('passes remaining context as attributes', () => { | ||
| const result = transformContext( | ||
| { | ||
| targetingKey: 'key-1', | ||
| trafficType: 'user', | ||
| region: 'eu', | ||
| plan: 'pro', | ||
| }, | ||
| defaultTrafficType | ||
| ); | ||
| expect(result.attributes).toEqual({ region: 'eu', plan: 'pro' }); | ||
| }); | ||
|
|
||
| test('deep-clones attributes (no reference)', () => { | ||
| const attrs = { nested: { value: 1 } }; | ||
| const result = transformContext( | ||
| { targetingKey: 'k', ...attrs }, | ||
| defaultTrafficType | ||
| ); | ||
| expect(result.attributes).toEqual({ nested: { value: 1 } }); | ||
| expect(result.attributes).not.toBe(attrs); | ||
| expect(result.attributes.nested).not.toBe(attrs.nested); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| /* eslint-disable @typescript-eslint/no-unused-vars */ | ||
| import { FlagNotFoundError, StandardResolutionReasons } from '@openfeature/web-sdk'; | ||
| import { evaluateTreatment } from '../lib/evaluation'; | ||
| import { CONTROL_TREATMENT } from '../lib/types'; | ||
|
|
||
| describe('evaluation', () => { | ||
| describe('evaluateTreatment', () => { | ||
| let mockClient; | ||
|
|
||
| beforeEach(() => { | ||
| mockClient = { | ||
| getTreatmentWithConfig: jest.fn((flagKey, attributes) => ({ | ||
| treatment: 'v1', | ||
| config: '{"x":1}', | ||
| })), | ||
| }; | ||
| }); | ||
|
|
||
| test('returns resolution details with value, variant, flagMetadata, reason', () => { | ||
| const consumer = { targetingKey: 'u1', trafficType: 'user', attributes: {} }; | ||
| const result = evaluateTreatment(mockClient, 'my-flag', consumer); | ||
|
|
||
| expect(result.value).toBe('v1'); | ||
| expect(result.variant).toBe('v1'); | ||
| expect(result.flagMetadata).toEqual({ config: '{"x":1}' }); | ||
| expect(result.reason).toBe(StandardResolutionReasons.TARGETING_MATCH); | ||
| expect(mockClient.getTreatmentWithConfig).toHaveBeenCalledWith('my-flag', {}); | ||
| }); | ||
|
|
||
| test('calls getTreatmentWithConfig with consumer attributes', () => { | ||
| const consumer = { | ||
| targetingKey: 'u1', | ||
| trafficType: 'account', | ||
| attributes: { region: 'eu', plan: 'pro' }, | ||
| }; | ||
| evaluateTreatment(mockClient, 'flag', consumer); | ||
| expect(mockClient.getTreatmentWithConfig).toHaveBeenCalledWith('flag', { | ||
| region: 'eu', | ||
| plan: 'pro', | ||
| }); | ||
| }); | ||
|
|
||
| test('uses empty string for config when config is falsy', () => { | ||
| mockClient.getTreatmentWithConfig.mockReturnValue({ treatment: 'on', config: null }); | ||
| const result = evaluateTreatment(mockClient, 'f', { | ||
| targetingKey: undefined, | ||
| trafficType: 'user', | ||
| attributes: {}, | ||
| }); | ||
| expect(result.flagMetadata.config).toBe(''); | ||
| }); | ||
|
|
||
| test('throws FlagNotFoundError when flagKey is null', () => { | ||
| const consumer = { targetingKey: 'u1', trafficType: 'user', attributes: {} }; | ||
| expect(() => evaluateTreatment(mockClient, null, consumer)).toThrow(FlagNotFoundError); | ||
| expect(() => evaluateTreatment(mockClient, null, consumer)).toThrow( | ||
| /flagKey must be a non-empty string/ | ||
| ); | ||
| }); | ||
|
|
||
| test('throws FlagNotFoundError when flagKey is empty string', () => { | ||
| const consumer = { targetingKey: 'u1', trafficType: 'user', attributes: {} }; | ||
| expect(() => evaluateTreatment(mockClient, '', consumer)).toThrow(FlagNotFoundError); | ||
| }); | ||
|
|
||
| test('throws FlagNotFoundError when treatment is control', () => { | ||
| mockClient.getTreatmentWithConfig.mockReturnValue({ | ||
| treatment: CONTROL_TREATMENT, | ||
| config: '', | ||
| }); | ||
| const consumer = { targetingKey: 'u1', trafficType: 'user', attributes: {} }; | ||
| expect(() => evaluateTreatment(mockClient, 'flag', consumer)).toThrow(FlagNotFoundError); | ||
| expect(() => evaluateTreatment(mockClient, 'flag', consumer)).toThrow(/control/); | ||
| }); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change: raising the minimum supported peer version and dropping compatibility with @splitsoftware/splitio-browserjs 1.4.x–1.6.x.