Skip to content
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

[SDKS-7830] flag sets #44

Merged
merged 2 commits into from
Dec 18, 2023
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
8 changes: 8 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
2.0.0 (Dec XX, 2023)
Copy link

@EmilianoSanchez EmilianoSanchez Dec 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to add an item for flag sets (either here or in a different PR). Also other updates like defaultTreatment in SplitView, etc.

- Updated @splitsoftware/splitio-browserjs package to version 0.13.0
- Updated the minimum Angular version to match Angular's support up to date. Breaking change version is regarding the Angular minimum version update, there are no breaking changes to Split's plugin API or functionality itself.
Copy link

@EmilianoSanchez EmilianoSanchez Dec 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would check other CHANGES.txt files if there is a format for breaking change, something like: - BREAKING CHANGE: Updated ....

- Added support for Flag Sets on the SDK, which enables grouping feature flags and interacting with the group rather than individually (more details in our documentation):
- Added new variations of the get treatment methods to support evaluating flags in given flag set/s.
- getTreatmentsByFlagSet and getTreatmentsByFlagSets
- getTreatmentsWithConfigByFlagSets and getTreatmentsWithConfigByFlagSets
- Added a new optional Split Filter configuration option. This allows the SDK and Split services to only synchronize the flags in the specified flag sets, avoiding unused or unwanted flags from being synced on the SDK instance, bringing all the benefits from a reduced payload.
- Added `sets` property to the `SplitView` object returned by the `split` and `splits` methods of the SDK manager to expose flag sets on flag views.
- Added `defaultTreatment` property to the `SplitView` object returned by the `split` and `splits` methods of the SDK manager (Related to issue https://github.com/splitio/javascript-commons/issues/225).

1.0.2 (May 16, 2023)
- Updated terminology on the SDKs codebase to be more aligned with current standard without causing a breaking change. The core change is the term split for feature flag on things like logs and JSDocs tags.
Expand Down
34 changes: 17 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@splitsoftware/splitio-angular",
"version": "2.0.0",
"version": "1.0.3-rc.0",
"description": "Split Angular utilities to simplify Split SDK browser client usage",
"scripts": {
"ng": "ng",
Expand Down Expand Up @@ -53,7 +53,7 @@
"@angular-eslint/eslint-plugin-template": "15.2.1",
"@angular-eslint/schematics": "15.2.1",
"@angular-eslint/template-parser": "15.2.1",
"@splitsoftware/splitio-browserjs": "0.9.5",
"@splitsoftware/splitio-browserjs": "0.13.0",
"@types/jest": "^29.0.0",
"@typescript-eslint/eslint-plugin": "^5.43.0",
"@typescript-eslint/parser": "^5.43.0",
Expand Down
4 changes: 2 additions & 2 deletions projects/splitio/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@splitsoftware/splitio-angular",
"version": "2.0.0",
"version": "1.0.3-rc.0",
"description": "Split Angular utilities to simplify Split SDK browser client usage",
"repository": {
"type": "git",
Expand All @@ -21,7 +21,7 @@
"bugs": "https://github.com/splitio/angular-sdk-plugin/issues",
"homepage": "https://github.com/splitio/angular-sdk-plugin#readme",
"dependencies": {
"@splitsoftware/splitio-browserjs": "0.9.5"
"@splitsoftware/splitio-browserjs": "0.13.0"
},
"peerDependencies": {
"@angular/core": ">=15.2.1",
Expand Down
14 changes: 8 additions & 6 deletions projects/splitio/src/lib/__tests__/mocks/SplitView.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@ export const mockedFeatureFlagView = [
'changeNumber': 0,
'configs': {},
'killed': false,
'name':
'test_split',
'name': 'test_split',
'trafficType': 'localhost',
'treatments': ['on']
'treatments': ['on'],
'defaultTreatment': 'control',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a mock, but defaultTreatment cannot be 'control'. It is one of the items in treatments list.

'sets': []
},
{
'changeNumber': 0,
'configs': {
'off': '{"bannerText":"Click here."}'
},
'killed': false,
'name':
'test_split2',
'name': 'test_split2',
'trafficType': 'localhost',
'treatments': ['off']
'treatments': ['off'],
'defaultTreatment': 'control',
'sets': []
}
];
44 changes: 44 additions & 0 deletions projects/splitio/src/lib/__tests__/splitio.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,50 @@ describe('SplitService', () => {
});
});

test('Flag sets', (done) => {
expect(service.isSDKReady).toEqual(false);

expect(service.getTreatmentsByFlagSet('set_a')).toEqual({});
expect(logSpy.mock.calls[logCalls++][0]).toEqual('[ERROR] plugin should be initialized');
expect(logSpy.mock.calls[logCalls++][0]).toEqual('[ERROR] client should be initialized first.');

expect(service.getTreatmentsWithConfigByFlagSet('set_a')).toEqual({});
expect(logSpy.mock.calls[logCalls++][0]).toEqual('[ERROR] plugin should be initialized');
expect(logSpy.mock.calls[logCalls++][0]).toEqual('[ERROR] client should be initialized first.');

expect(service.getTreatmentsByFlagSets(['set_a','set_b'])).toEqual({});
expect(logSpy.mock.calls[logCalls++][0]).toEqual('[ERROR] plugin should be initialized');
expect(logSpy.mock.calls[logCalls++][0]).toEqual('[ERROR] client should be initialized first.');

expect(service.getTreatmentsWithConfigByFlagSets(['set_a','set_b'])).toEqual({});
expect(logSpy.mock.calls[logCalls++][0]).toEqual('[ERROR] plugin should be initialized');
expect(logSpy.mock.calls[logCalls++][0]).toEqual('[ERROR] client should be initialized first.');

service.init(localhostConfig).subscribe(() => {

const mainClient = service.getSDKClient();
expect(service.isSDKReady).toEqual(true);

const clientSpy = {
getTreatmentsByFlagSet: jest.spyOn(mainClient, 'getTreatmentsByFlagSet'),
getTreatmentsWithConfigByFlagSet: jest.spyOn(mainClient, 'getTreatmentsWithConfigByFlagSet'),
getTreatmentsByFlagSets: jest.spyOn(mainClient, 'getTreatmentsByFlagSets'),
getTreatmentsWithConfigByFlagSets: jest.spyOn(mainClient, 'getTreatmentsWithConfigByFlagSets'),
};

service.getTreatmentsByFlagSet('set_a');
expect(clientSpy.getTreatmentsByFlagSet.mock.calls[0]).toEqual(['set_a', undefined]);
service.getTreatmentsWithConfigByFlagSet('set_a', {attr: true});
expect(clientSpy.getTreatmentsWithConfigByFlagSet.mock.calls[0]).toEqual(['set_a', {attr: true}]);
service.getTreatmentsByFlagSets(['set_a','set_b'], {attr: true});
expect(clientSpy.getTreatmentsByFlagSets.mock.calls[0]).toEqual([['set_a','set_b'], {attr: true}]);
service.getTreatmentsWithConfigByFlagSets(['set_a','set_b']);
expect(clientSpy.getTreatmentsWithConfigByFlagSets.mock.calls[0]).toEqual([['set_a','set_b'], undefined]);

done();
});
});

test('SDK Manager', (done) => {
expect(service.getSplitNames()).toEqual([]);
service.init(localhostConfig);
Expand Down
Loading
Loading