Skip to content

Commit ddfae4a

Browse files
Merge branch 'breaking_changes_update_supported_runtimes' into breaking_changes_ready_method
2 parents 65d5dc7 + e1a49f5 commit ddfae4a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+301
-654
lines changed

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
"message": "Don't declare const enum, because it is not supported by Babel used for building RN SDK"
8181
}
8282
],
83-
"compat/compat": ["error", "defaults, ie 10, node 6"],
83+
"compat/compat": ["error", "defaults, node >=14"],
8484
"no-throw-literal": "error",
8585
"import/no-default-export": "error",
8686
"import/no-self-import": "error"

CHANGES.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
- Removed `/mySegments` endpoint from SplitAPI module, as it is replaced by `/memberships` endpoint.
88
- Removed support for MY_SEGMENTS_UPDATE and MY_SEGMENTS_UPDATE_V2 notification types, as they are replaced by MEMBERSHIPS_MS_UPDATE and MEMBERSHIPS_LS_UPDATE notification types.
99
- Removed the deprecated `GOOGLE_ANALYTICS_TO_SPLIT` and `SPLIT_TO_GOOGLE_ANALYTICS` integrations.
10-
- Bugfixing - Fixed an issue with the client `ready` method that was causing the returned promise to hang on async/await syntax if the promise was rejected. The fix implies a breaking change, since the promise rejection must be handled by the user.
10+
- Removed internal ponyfills for `Map`, `Set` and `Array.from` global objects, dropping support for IE and other outdated browsers. The SDK now requires the runtime environment to support these features natively or to provide a polyfill.
11+
- Bugfixing - Fixed an issue with the client `ready` method that was causing the returned promise to hang on async/await syntax if the promise was rejected. The fix implies a breaking change, since now the user must handle the promise rejection explicitly.
1112

1213
1.17.0 (September 6, 2024)
1314
- Added `sync.requestOptions.getHeaderOverrides` configuration option to enhance SDK HTTP request Headers for Authorization Frameworks.

package-lock.json

Lines changed: 104 additions & 90 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"@typescript-eslint/parser": "^6.6.0",
6565
"cross-env": "^7.0.2",
6666
"eslint": "^8.48.0",
67-
"eslint-plugin-compat": "^4.2.0",
67+
"eslint-plugin-compat": "^6.0.1",
6868
"eslint-plugin-import": "^2.25.3",
6969
"fetch-mock": "^9.11.0",
7070
"ioredis": "^4.28.0",

src/evaluator/__tests__/evaluate-features.spec.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import { evaluateFeatures, evaluateFeaturesByFlagSets } from '../index';
33
import { EXCEPTION, NOT_IN_SPLIT, SPLIT_ARCHIVED, SPLIT_KILLED, SPLIT_NOT_FOUND } from '../../utils/labels';
44
import { loggerMock } from '../../logger/__tests__/sdkLogger.mock';
5-
import { _Set } from '../../utils/lang/sets';
65
import { WARN_FLAGSET_WITHOUT_FLAGS } from '../../logger/constants';
76

87
const splitsMock = {
@@ -17,8 +16,8 @@ const splitsMock = {
1716
};
1817

1918
const flagSetsMock = {
20-
reg_and_config: new _Set(['regular', 'config']),
21-
arch_and_killed: new _Set(['killed', 'archived']),
19+
reg_and_config: new Set(['regular', 'config']),
20+
arch_and_killed: new Set(['killed', 'archived']),
2221
};
2322

2423
const mockStorage = {
@@ -38,7 +37,7 @@ const mockStorage = {
3837
return splits;
3938
},
4039
getNamesByFlagSets(flagSets) {
41-
return flagSets.map(flagset => flagSetsMock[flagset] || new _Set());
40+
return flagSets.map(flagset => flagSetsMock[flagset] || new Set());
4241
}
4342
}
4443
};
@@ -192,7 +191,7 @@ describe('EVALUATOR - Multiple evaluations at once by flag sets', () => {
192191
// Should support async storage too
193192
expect(await getResultsByFlagsets(['inexistent_set1', 'inexistent_set2'], {
194193
splits: {
195-
getNamesByFlagSets(flagSets) { return Promise.resolve(flagSets.map(flagset => flagSetsMock[flagset] || new _Set())); }
194+
getNamesByFlagSets(flagSets) { return Promise.resolve(flagSets.map(flagset => flagSetsMock[flagset] || new Set())); }
196195
}
197196
})).toEqual({});
198197
expect(loggerMock.warn.mock.calls).toEqual([

src/evaluator/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { IStorageAsync, IStorageSync } from '../storages/types';
77
import { IEvaluationResult } from './types';
88
import { SplitIO } from '../types';
99
import { ILogger } from '../logger/types';
10-
import { ISet, setToArray, returnSetsUnion, _Set } from '../utils/lang/sets';
10+
import { returnSetsUnion } from '../utils/lang/sets';
1111
import { WARN_FLAGSET_WITHOUT_FLAGS } from '../logger/constants';
1212

1313
const treatmentException = {
@@ -97,12 +97,12 @@ export function evaluateFeaturesByFlagSets(
9797
storage: IStorageSync | IStorageAsync,
9898
method: string,
9999
): MaybeThenable<Record<string, IEvaluationResult>> {
100-
let storedFlagNames: MaybeThenable<ISet<string>[]>;
100+
let storedFlagNames: MaybeThenable<Set<string>[]>;
101101

102102
function evaluate(
103-
featureFlagsByFlagSets: ISet<string>[],
103+
featureFlagsByFlagSets: Set<string>[],
104104
) {
105-
let featureFlags = new _Set();
105+
let featureFlags = new Set<string>();
106106
for (let i = 0; i < flagSets.length; i++) {
107107
const featureFlagByFlagSet = featureFlagsByFlagSets[i];
108108
if (featureFlagByFlagSet.size) {
@@ -113,7 +113,7 @@ export function evaluateFeaturesByFlagSets(
113113
}
114114

115115
return featureFlags.size ?
116-
evaluateFeatures(log, key, setToArray(featureFlags), attributes, storage) :
116+
evaluateFeatures(log, key, Array.from(featureFlags), attributes, storage) :
117117
{};
118118
}
119119

src/evaluator/matchers/semver_inlist.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { _Set } from '../../utils/lang/sets';
21
import { Semver } from '../../utils/Semver';
32

43
export function inListSemverMatcherContext(ruleAttr: string[]) {
54
// @TODO ruleAttr validation should be done at the `parser` or `matchersTransform` level to reuse for all matchers
65
if (!ruleAttr || ruleAttr.length === 0) throw new Error('whitelistMatcherData is required for IN_LIST_SEMVER matcher type');
76

8-
const listOfSemvers = new _Set(ruleAttr.map((version) => new Semver(version).version));
7+
const listOfSemvers = new Set(ruleAttr.map((version) => new Semver(version).version));
98

109
return function inListSemverMatcher(runtimeAttr: string): boolean {
1110
const runtimeSemver = new Semver(runtimeAttr).version;

src/evaluator/matchers/whitelist.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import { _Set } from '../../utils/lang/sets';
2-
31
export function whitelistMatcherContext(ruleAttr: string[]) {
4-
const whitelistSet = new _Set(ruleAttr);
2+
const whitelistSet = new Set(ruleAttr);
53

64
return function whitelistMatcher(runtimeAttr: string): boolean {
75
const isInWhitelist = whitelistSet.has(runtimeAttr);

src/listeners/browser.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ export class BrowserSignalListener implements ISignalListener {
115115
* Returns true if beacon API was used successfully, false otherwise.
116116
*/
117117
private _sendBeacon(url: string, data: any, extraMetadata?: {}) {
118-
// eslint-disable-next-line compat/compat
119118
if (typeof navigator !== 'undefined' && navigator.sendBeacon) {
120119
const json = {
121120
entries: data,
@@ -130,7 +129,7 @@ export class BrowserSignalListener implements ISignalListener {
130129
const payload = JSON.stringify(json);
131130

132131
// https://xgwang.me/posts/you-may-not-know-beacon/#it-may-throw-error%2C-be-sure-to-catch
133-
try { // eslint-disable-next-line compat/compat
132+
try {
134133
return navigator.sendBeacon(url, payload);
135134
} catch (e) {
136135
return false;

src/logger/__tests__/index.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { LogLevel } from '../../types';
2-
import { _Map } from '../../utils/lang/maps';
32
import { Logger, LogLevels, isLogLevelString, _sprintf } from '../index';
43

54
// We'll set this only once. These are the constants we will use for
@@ -59,7 +58,7 @@ function testLogLevels(levelToTest: LogLevel) {
5958
const logMethod = levelToTest.toLowerCase();
6059
const logCategory = `test-category-${logMethod}`;
6160
const instance = new Logger({ prefix: logCategory, showLevel },
62-
useCodes ? new _Map([[1, 'Test log for level %s with showLevel: %s %s']]) : undefined);
61+
useCodes ? new Map([[1, 'Test log for level %s with showLevel: %s %s']]) : undefined);
6362

6463
LOG_LEVELS_IN_ORDER.forEach((logLevel, i) => {
6564
const logMsg = `Test log for level ${levelToTest} with showLevel: ${showLevel} ${logLevelLogsCounter}`;

0 commit comments

Comments
 (0)