Skip to content
Open
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
28 changes: 18 additions & 10 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-browserjs",
"version": "1.7.1",
"version": "1.7.2-rc.1",
"description": "Split SDK for JavaScript on Browser",
"main": "cjs/index.js",
"module": "esm/index.js",
Expand Down Expand Up @@ -59,7 +59,7 @@
"bugs": "https://github.com/splitio/javascript-browser-client/issues",
"homepage": "https://github.com/splitio/javascript-browser-client#readme",
"dependencies": {
"@splitsoftware/splitio-commons": "2.12.1",
"@splitsoftware/splitio-commons": "3.0.1-rc.1",
"tslib": "^2.3.1",
"unfetch": "^4.2.0"
},
Expand Down
6 changes: 1 addition & 5 deletions src/__tests__/browserSuites/ready-promise.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function assertGetTreatmentWhenReady(assert, client) {
function assertGetTreatmentControlNotReady(assert, client) {
consoleSpy.log.resetHistory();
assert.equal(client.getTreatment('hierarchical_splits_test'), 'control', 'We should get control if client is not ready.');
assert.true(consoleSpy.log.calledWithExactly('[WARN] splitio => getTreatment: the SDK is not ready to evaluate. Results may be incorrect for feature flag hierarchical_splits_test. Make sure to wait for SDK readiness before using this method.'), 'Telling us that calling getTreatment would return CONTROL since SDK is not ready at this point.');
assert.true(consoleSpy.log.calledWithExactly('[WARN] splitio => getTreatment: the SDK is not ready to evaluate. Results may be incorrect. Make sure to wait for SDK readiness before using this method.'), 'Telling us that calling getTreatment would return CONTROL since SDK is not ready at this point.');
}

function assertGetTreatmentControlNotReadyOnDestroy(assert, client) {
Expand Down Expand Up @@ -543,13 +543,9 @@ export default function readyPromiseAssertions(fetchMock, assert) {
consoleSpy.log.resetHistory();
const sharedClientWithCb = splitio.client('nicolas@split.io');
sharedClientWithCb.on(client.Event.SDK_READY, () => {
t.false(consoleSpy.log.calledWithExactly('[WARN] splitio => No listeners for SDK_READY event detected. Incorrect control treatments could have been logged if you called getTreatment/s while the SDK was not yet synchronized with the backend.'),
'No warning logged');

const sharedClientWithoutCb = splitio.client('emiliano@split.io');
setTimeout(() => {
t.true(consoleSpy.log.calledWithExactly('[WARN] splitio => No listeners for SDK_READY event detected. Incorrect control treatments could have been logged if you called getTreatment/s while the SDK was not yet synchronized with the backend.'),
'Warning logged');
Promise.all([sharedClientWithoutCb.destroy(), client.destroy()]).then(() => {
client.whenReady()
.then(() => {
Expand Down
6 changes: 5 additions & 1 deletion src/__tests__/testUtils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ export function hasNoCacheHeader(fetchMockOpts) {

const telemetryEndpointMatcher = /^\/v1\/(metrics|keys)\/(config|usage|ss|cs)/;
const eventsEndpointMatcher = /^\/(testImpressions|metrics|events)/;
const authEndpointMatcher = /^\/v2\/auth/;
const authEndpointMatcher = /^\/(v2|v3)\/auth/;
const streamingEndpointMatcher = /^\/(sse|event-stream)/;
const configsEndpointMatcher = /^\/v1\/(configs|segmentChanges)/;

/**
* Switch URLs servers based on target.
Expand All @@ -69,5 +70,8 @@ export function url(settings, target) {
if (streamingEndpointMatcher.test(target)) {
return `${settings.urls.streaming}${target}`;
}
if (configsEndpointMatcher.test(target)) {
return `${settings.urls.configs}${target}`;
}
return `${settings.urls.sdk}${target}`;
}
8 changes: 3 additions & 5 deletions src/full/splitFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ import { getModules } from '../platform/getModules';
import { sdkFactory } from '@splitsoftware/splitio-commons/src/sdkFactory/index';
import { ISdkFactoryParams } from '@splitsoftware/splitio-commons/src/sdkFactory/types';
import { getFetch } from '../platform/getFetchFull';
import { getEventSource } from '../platform/getEventSource';
import { EventEmitter } from '@splitsoftware/splitio-commons/src/utils/MinEvents';
import { now } from '@splitsoftware/splitio-commons/src/utils/timeTracker/now/browser';
import { platform } from '@splitsoftware/splitio-commons/src/platform/browser';

const platform = { getFetch, getEventSource, EventEmitter, now };
const platformWithFetchPolyfill = { ...platform, getFetch };

/**
* SplitFactory with pluggable modules for Browser.
Expand All @@ -21,7 +19,7 @@ const platform = { getFetch, getEventSource, EventEmitter, now };
*/
export function SplitFactory(config: SplitIO.IClientSideSettings, __updateModules?: (modules: ISdkFactoryParams) => void) {
const settings = settingsFactory(config);
const modules = getModules(settings, platform);
const modules = getModules(settings, platformWithFetchPolyfill);
if (__updateModules) __updateModules(modules);
return sdkFactory(modules);
}
3 changes: 0 additions & 3 deletions src/platform/getEventSource.ts

This file was deleted.

4 changes: 0 additions & 4 deletions src/platform/getFetchSlim.ts

This file was deleted.

9 changes: 2 additions & 7 deletions src/platform/getModules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { pushManagerFactory } from '@splitsoftware/splitio-commons/src/sync/stre
import { pollingManagerCSFactory } from '@splitsoftware/splitio-commons/src/sync/polling/pollingManagerCS';
import { sdkManagerFactory } from '@splitsoftware/splitio-commons/src/sdkManager/index';
import { sdkClientMethodCSFactory } from '@splitsoftware/splitio-commons/src/sdkClient/sdkClientMethodCS';
import { BrowserSignalListener } from '@splitsoftware/splitio-commons/src/listeners/browser';
import { impressionObserverCSFactory } from '@splitsoftware/splitio-commons/src/trackers/impressionObserver/impressionObserverCS';
import { pluggableIntegrationsManagerFactory } from '@splitsoftware/splitio-commons/src/integrations/pluggable';
import { IPlatform, ISdkFactoryParams } from '@splitsoftware/splitio-commons/src/sdkFactory/types';
Expand All @@ -27,17 +26,14 @@ export function getModules(settings: ISettings, platform: IPlatform): ISdkFactor

storageFactory: settings.storage as ISdkFactoryParams['storageFactory'],

splitApiFactory,
serviceApiFactory: splitApiFactory,

syncManagerFactory: syncManagerStandaloneFactory,

sdkManagerFactory,

// @ts-expect-error - To be fixed in commons
sdkClientMethodFactory: sdkClientMethodCSFactory,

SignalListener: BrowserSignalListener as ISdkFactoryParams['SignalListener'],

integrationsManagerFactory: settings.integrations && settings.integrations.length > 0 ? pluggableIntegrationsManagerFactory.bind(null, settings.integrations) : undefined,

impressionsObserverFactory: impressionObserverCSFactory,
Expand All @@ -51,9 +47,8 @@ export function getModules(settings: ISettings, platform: IPlatform): ISdkFactor

switch (settings.mode) {
case LOCALHOST_MODE:
modules.splitApiFactory = undefined;
modules.serviceApiFactory = undefined;
modules.syncManagerFactory = localhostFromObjectFactory;
modules.SignalListener = undefined;
break;
case CONSUMER_MODE:
modules.syncManagerFactory = undefined;
Expand Down
2 changes: 1 addition & 1 deletion src/settings/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type SplitIO from '@splitsoftware/splitio-commons/types/splitio';
import { LogLevels, isLogLevelString } from '@splitsoftware/splitio-commons/src/logger/index';
import { CONSENT_GRANTED } from '@splitsoftware/splitio-commons/src/utils/constants';

const packageVersion = '1.7.1';
const packageVersion = '1.7.2-rc.1';

/**
* In browser, the default debug level, can be set via the `localStorage.splitio_debug` item.
Expand Down
7 changes: 1 addition & 6 deletions src/splitFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ import { settingsFactory } from './settings';
import { getModules } from './platform/getModules';
import { sdkFactory } from '@splitsoftware/splitio-commons/src/sdkFactory/index';
import { ISdkFactoryParams } from '@splitsoftware/splitio-commons/src/sdkFactory/types';
import { getFetch } from './platform/getFetchSlim';
import { getEventSource } from './platform/getEventSource';
import { EventEmitter } from '@splitsoftware/splitio-commons/src/utils/MinEvents';
import { now } from '@splitsoftware/splitio-commons/src/utils/timeTracker/now/browser';

const platform = { getFetch, getEventSource, EventEmitter, now };
import { platform } from '@splitsoftware/splitio-commons/src/platform/browser';

/**
* SplitFactory with pluggable modules for Browser.
Expand Down
Loading