Skip to content

Commit

Permalink
Merge branch 'development' into sdks-7658
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoZelaya authored Nov 6, 2023
2 parents 965df61 + 50cd611 commit afa0784
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 12 deletions.
3 changes: 2 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
1.11.0 (November XX, 2023)
1.11.0 (November 3, 2023)
- 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.
- Note: Only applicable when the SDK is in charge of the rollout data synchronization. When not applicable, the SDK will log a warning on init.
- 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.
- Bugfixing - Fixed SDK key validation in NodeJS to ensure the SDK_READY_TIMED_OUT event is emitted when a client-side type SDK key is provided instead of a server-side one (Related to issue https://github.com/splitio/javascript-client/issues/768).

1.10.0 (October 20, 2023)
- 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).
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@splitsoftware/splitio-commons",
"version": "1.10.1-rc.3",
"version": "1.11.0",
"description": "Split Javascript SDK common components",
"main": "cjs/index.js",
"module": "esm/index.js",
Expand Down
7 changes: 5 additions & 2 deletions src/evaluator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export function evaluateFeaturesByFlagSets(
flagSets: string[],
attributes: SplitIO.Attributes | undefined,
storage: IStorageSync | IStorageAsync,
): MaybeThenable<Record<string,IEvaluationResult>> {
): MaybeThenable<Record<string, IEvaluationResult>> {
let storedFlagNames: MaybeThenable<ISet<string>>;

// get features by flag sets
Expand All @@ -107,7 +107,10 @@ export function evaluateFeaturesByFlagSets(

// evaluate related features
return thenable(storedFlagNames) ?
storedFlagNames.then((splitNames) => evaluateFeatures(log, key, setToArray(splitNames), attributes, storage)) :
storedFlagNames.then((splitNames) => evaluateFeatures(log, key, setToArray(splitNames), attributes, storage))
.catch(() => {
return {};
}) :
evaluateFeatures(log, key, setToArray(storedFlagNames), attributes, storage);
}

Expand Down
5 changes: 5 additions & 0 deletions src/readiness/readinessManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,12 @@ export function readinessManagerFactory(
return readinessManagerFactory(EventEmitter, readyTimeout, splits);
},

// @TODO review/remove next methods when non-recoverable errors are reworked
// Called on consumer mode, when storage fails to connect
timeout,
// Called on 403 error (client-side SDK key on server-side), to set the SDK as destroyed for
// tracking and evaluations, while keeping event listeners to emit SDK_READY_TIMED_OUT event
setDestroyed() { isDestroyed = true; },

destroy() {
isDestroyed = true;
Expand Down
1 change: 1 addition & 0 deletions src/readiness/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export interface IReadinessManager {
isOperational(): boolean,

timeout(): void,
setDestroyed(): void,
destroy(): void,

/** for client-side */
Expand Down
2 changes: 1 addition & 1 deletion src/storages/__tests__/KeyBuilder.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ test('KEYS / flag set keys', () => {
const builder = new KeyBuilder(prefix);

const flagSetName = 'flagset_x';
const expectedKey = `${prefix}.flagset.${flagSetName}`;
const expectedKey = `${prefix}.flagSet.${flagSetName}`;

expect(builder.buildFlagSetKey(flagSetName)).toBe(expectedKey);

Expand Down
2 changes: 1 addition & 1 deletion src/storages/inRedis/SplitsCacheInRedis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ILogger } from '../../logger/types';
import { LOG_PREFIX } from './constants';
import { ISplit } from '../../dtos/types';
import { AbstractSplitsCacheAsync } from '../AbstractSplitsCacheAsync';
import { ISet, _Set } from '../../utils/lang/sets';
import { ISet } from '../../utils/lang/sets';

/**
* Discard errors for an answer of multiple operations.
Expand Down
6 changes: 3 additions & 3 deletions src/storages/pluggable/SplitsCachePluggable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ILogger } from '../../logger/types';
import { ISplit } from '../../dtos/types';
import { LOG_PREFIX } from './constants';
import { AbstractSplitsCacheAsync } from '../AbstractSplitsCacheAsync';
import { ISet, _Set } from '../../utils/lang/sets';
import { ISet } from '../../utils/lang/sets';

/**
* ISplitsCacheAsync implementation for pluggable storages.
Expand Down Expand Up @@ -162,8 +162,8 @@ export class SplitsCachePluggable extends AbstractSplitsCacheAsync {
* @todo this is a no-op method to be implemented
*/
getNamesByFlagSets(): Promise<ISet<string>> {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
return new Promise(flagSets => new _Set([]));
this.log.error(LOG_PREFIX + 'ByFlagSet/s evaluations are not supported with pluggable storage yet.');
return Promise.reject();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/sync/polling/updaters/segmentChangesUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export function segmentChangesUpdaterFactory(
if (error && error.statusCode === 403) {
// If the operation is forbidden, it may be due to permissions. Destroy the SDK instance.
// @TODO although factory status is destroyed, synchronization is not stopped
if (readiness) readiness.destroy();
if (readiness) readiness.setDestroyed();
log.error(`${LOG_PREFIX_INSTANTIATION}: you passed a client-side type authorizationKey, please grab an SDK Key from the Split user interface that is of type server-side.`);
} else {
log.warn(`${LOG_PREFIX_SYNC_SEGMENTS}Error while doing fetch of segments. ${error}`);
Expand Down

0 comments on commit afa0784

Please sign in to comment.