Skip to content

Commit 4cfbd3b

Browse files
Merge pull request #128 from splitio/remove_pluggable_localhost_mode
[Breaking change] Remove `LocalhostFromObject` export
2 parents 4c5f3c6 + eb06c6a commit 4cfbd3b

17 files changed

Lines changed: 28 additions & 104 deletions

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
],
4545
"rules": {
4646
"no-restricted-syntax": ["error", "ForOfStatement", "ForInStatement", "ArrayPattern"],
47-
"compat/compat": ["error", "defaults, ie 10"],
47+
"compat/compat": ["error", "defaults"],
4848
"no-throw-literal": "error",
4949
"import/no-default-export": "error",
5050
"import/no-self-import": "error",

CHANGES.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- BREAKING CHANGES:
66
- Removed internal ponyfills for the `Map` and `Set` global objects, dropping support for IE and other outdated browsers. The SDK now requires the runtime environment to support these features natively or provide a polyfill.
77
- Removed the deprecated `GoogleAnalyticsToSplit` and `SplitToGoogleAnalytics` pluggable integration modules, along with the related interfaces in the TypeScript definitions.
8+
- Removed the `LocalhostFromObject` export from the default import (`import { LocalhostFromObject } from '@splitsoftware/splitio-browserjs'`). It is no longer necessary to manually import and configure it in the `sync.localhostMode` option to enable localhost mode.
89

910
0.15.0 (September 13, 2024)
1011
- Updated @splitsoftware/splitio-commons package to version 1.17.0 that includes minor updates:
@@ -70,7 +71,7 @@
7071

7172
0.9.4 (May 4, 2023)
7273
- Updated some transitive dependencies for vulnerability fixes.
73-
- Bugfixing - Updated `unfetch` package as a runtime dependency, required when using the "full" entrypoint (`import { SplitFactory } from '@splitsoftware/splitio-browserjs/full'`).
74+
- Bugfixing - Updated `unfetch` package as a runtime dependency, required when using the "full" import (`import { SplitFactory } from '@splitsoftware/splitio-browserjs/full'`).
7475

7576
0.9.3 (March 20, 2023)
7677
- Updated @splitsoftware/splitio-commons package to version 1.8.1 that includes minor improvements.

package-lock.json

Lines changed: 7 additions & 7 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
@@ -61,7 +61,7 @@
6161
"bugs": "https://github.com/splitio/javascript-browser-client/issues",
6262
"homepage": "https://github.com/splitio/javascript-browser-client#readme",
6363
"dependencies": {
64-
"@splitsoftware/splitio-commons": "2.0.0-rc.2",
64+
"@splitsoftware/splitio-commons": "2.0.0-rc.3",
6565
"tslib": "^2.3.1",
6666
"unfetch": "^4.2.0"
6767
},

src/__tests__/consumer/browser_consumer.spec.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ const config = {
3232
}),
3333
sync: {
3434
impressionsMode: 'DEBUG',
35-
// ignored
36-
largeSegmentsEnabled: true,
3735
},
3836
};
3937

src/__tests__/consumer/browser_consumer_partial.spec.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ const config = {
3333
events: 'https://events.baseurl/impressionsSuite',
3434
telemetry: 'https://telemetry.baseurl/impressionsSuite'
3535
},
36-
sync: {
37-
// ignored
38-
largeSegmentsEnabled: true,
39-
},
4036
};
4137

4238
tape('Browser Consumer Partial mode with pluggable storage', function (t) {

src/__tests__/offline/browser.spec.js

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import sinon from 'sinon';
33
import fetchMock from '../testUtils/fetchMock';
44
import { url } from '../testUtils';
55
import { SplitFactory, InLocalStorage } from '../../full';
6-
import { SplitFactory as SplitFactorySlim, LocalhostFromObject } from '../../';
6+
import { SplitFactory as SplitFactorySlim } from '../../';
77
import { settingsFactory } from '../../settings';
88

99
const settings = settingsFactory({ core: { key: 'facundo@split.io' } });
@@ -61,10 +61,6 @@ tape('Browser offline mode', function (assert) {
6161
readyTimeout: 0.001
6262
},
6363
features: originalFeaturesMap,
64-
sync: {
65-
// ignored
66-
largeSegmentsEnabled: true,
67-
}
6864
};
6965
const factory = SplitFactory(config);
7066
const manager = factory.manager();
@@ -94,24 +90,19 @@ tape('Browser offline mode', function (assert) {
9490

9591
const factoriesReadyFromCache = [
9692
SplitFactory({ ...config, storage: InLocalStorage() }),
97-
SplitFactorySlim({ ...config, storage: InLocalStorage(), sync: { localhostMode: LocalhostFromObject() } }) // slim factory requires localhostFromObject module
93+
SplitFactorySlim({ ...config, storage: InLocalStorage() })
9894
];
9995
const configs = [
100-
{ ...config, features: { ...config.features }, storage: InLocalStorage /* invalid */, sync: { localhostMode: LocalhostFromObject /* invalid */ } },
96+
{ ...config, features: { ...config.features }, storage: InLocalStorage /* invalid */ },
10197
{ ...config },
10298
config,
10399
];
104-
const factoriesReady = [
100+
const factories = [
105101
...configs.map(config => SplitFactory(config)),
106102
...factoriesReadyFromCache
107103
];
108-
const factoriesTimeout = [ // slim factory without a valid localhostFromObject module will timeout
109-
SplitFactorySlim(config),
110-
SplitFactorySlim({ ...config, sync: { localhostMode: LocalhostFromObject /* invalid */ } }),
111-
];
112-
const factories = [...factoriesReady, ...factoriesTimeout];
113104

114-
let readyCount = 0, updateCount = 0, readyFromCacheCount = 0, timeoutCount = 0;
105+
let readyCount = 0, updateCount = 0, readyFromCacheCount = 0;
115106

116107
for (let i = 0; i < factories.length; i++) {
117108
const factory = factories[i], client = factory.client(), manager = factory.manager(), client2 = factory.client('other');
@@ -127,8 +118,7 @@ tape('Browser offline mode', function (assert) {
127118
updateCount++;
128119
});
129120
client.on(client.Event.SDK_READY_TIMED_OUT, () => {
130-
assert.equal(factory.settings.sync.localhostMode, undefined);
131-
timeoutCount++;
121+
assert.fail('Should not emit SDK_READY_TIMED_OUT event');
132122
});
133123

134124
const sdkReadyFromCache = (client) => () => {
@@ -253,8 +243,8 @@ tape('Browser offline mode', function (assert) {
253243
};
254244

255245
// Update the features in all remaining factories except the last one
256-
for (let i = 1; i < factoriesReady.length - 1; i++) {
257-
factoriesReady[i].settings.features = factory.settings.features;
246+
for (let i = 1; i < factories.length - 1; i++) {
247+
factories[i].settings.features = factory.settings.features;
258248
}
259249

260250
// Assigning a new object to the features property in the config object doesn't trigger an update
@@ -369,10 +359,9 @@ tape('Browser offline mode', function (assert) {
369359
assert.equal(sharedUpdateCount, 1, 'Shared client should have emitted SDK_UPDATE event once');
370360

371361
// SDK events on other factory clients
372-
assert.equal(readyCount, factoriesReady.length, 'Each factory client should have emitted SDK_READY event once');
373-
assert.equal(updateCount, factoriesReady.length - 1, 'Each factory client except one should have emitted SDK_UPDATE event once');
362+
assert.equal(readyCount, factories.length, 'Each factory client should have emitted SDK_READY event once');
363+
assert.equal(updateCount, factories.length - 1, 'Each factory client except one should have emitted SDK_UPDATE event once');
374364
assert.equal(readyFromCacheCount, factoriesReadyFromCache.length * 2, 'The main and shared client of the factories with LOCALSTORAGE should have emitted SDK_READY_FROM_CACHE event');
375-
assert.equal(timeoutCount, factoriesTimeout.length, 'The wrongly configured slim factories should have emitted SDK_READY_TIMED_OUT event');
376365

377366
assert.end();
378367
});

src/full/splitFactory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const platform = { getFetch, getEventSource, EventEmitter, now };
1212

1313
/**
1414
* SplitFactory with pluggable modules for Browser.
15-
* Includes localhost mode and fetch polyfill out-of-the-box.
15+
* It includes a `fetch` polyfill out-of-the-box.
1616
*
1717
* @param config configuration object used to instantiate the SDK
1818
* @param __updateModules optional function that lets redefine internal SDK modules. Use with

src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ export { ErrorLogger } from '@splitsoftware/splitio-commons/src/logger/browser/E
44
export { WarnLogger } from '@splitsoftware/splitio-commons/src/logger/browser/WarnLogger';
55
export { InfoLogger } from '@splitsoftware/splitio-commons/src/logger/browser/InfoLogger';
66
export { DebugLogger } from '@splitsoftware/splitio-commons/src/logger/browser/DebugLogger';
7-
export { LocalhostFromObject } from '@splitsoftware/splitio-commons/src/sync/offline/LocalhostFromObject';
87
export { PluggableStorage } from '@splitsoftware/splitio-commons/src/storages/pluggable';

src/platform/getModules.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import { sdkClientMethodCSFactory } from '@splitsoftware/splitio-commons/src/sdk
77
import { BrowserSignalListener } from '@splitsoftware/splitio-commons/src/listeners/browser';
88
import { impressionObserverCSFactory } from '@splitsoftware/splitio-commons/src/trackers/impressionObserver/impressionObserverCS';
99
import { pluggableIntegrationsManagerFactory } from '@splitsoftware/splitio-commons/src/integrations/pluggable';
10-
1110
import { IPlatform, ISdkFactoryParams } from '@splitsoftware/splitio-commons/src/sdkFactory/types';
1211
import { ISettings } from '@splitsoftware/splitio-commons/src/types';
1312
import { CONSUMER_MODE, CONSUMER_PARTIAL_MODE, LOCALHOST_MODE } from '@splitsoftware/splitio-commons/src/utils/constants';
1413
import { createUserConsentAPI } from '@splitsoftware/splitio-commons/src/consent/sdkUserConsent';
14+
import { localhostFromObjectFactory } from '@splitsoftware/splitio-commons/src/sync/offline/LocalhostFromObject';
1515

1616
let syncManagerStandaloneFactory: ISdkFactoryParams['syncManagerFactory'];
1717
let syncManagerSubmittersFactory: ISdkFactoryParams['syncManagerFactory'];
@@ -51,7 +51,7 @@ export function getModules(settings: ISettings, platform: IPlatform): ISdkFactor
5151
switch (settings.mode) {
5252
case LOCALHOST_MODE:
5353
modules.splitApiFactory = undefined;
54-
modules.syncManagerFactory = settings.sync.localhostMode;
54+
modules.syncManagerFactory = localhostFromObjectFactory;
5555
modules.SignalListener = undefined;
5656
break;
5757
case CONSUMER_MODE:

0 commit comments

Comments
 (0)