Skip to content

Commit 1a2fe44

Browse files
Polishing
1 parent 2bfc800 commit 1a2fe44

File tree

7 files changed

+12
-12
lines changed

7 files changed

+12
-12
lines changed

CHANGES.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
1.13.0 (January 4, 2024)
2-
- Removed the getOptions method from the IPlatform interface to simplify the code. Request options can be handled inside the getFetch method.
2+
- Removed the `getOptions` method from the `IPlatform` interface to simplify the code. Request options can be handled within the `getFetch` method.
33

44
1.12.1 (December 12, 2023)
55
- Updated PluggableStorage, for producer mode, and LocalStorage, for standalone mode, to clear the storage before initiating the synchronization process if it was previously synchronized with a different SDK key (i.e., a different environment) or different Split Filter criteria.

src/sdkFactory/__tests__/index.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function assertModulesCalled(params: any) {
8080
expect(SignalListenerInstanceMock.start).toBeCalledTimes(1);
8181
}
8282
if (params.splitApiFactory) {
83-
expect(params.splitApiFactory.mock.calls).toEqual([[params.settings, params.platform.getFetch, telemetryTrackerMock]]);
83+
expect(params.splitApiFactory.mock.calls).toEqual([[params.settings, params.platform, telemetryTrackerMock]]);
8484
}
8585
if (params.integrationsManagerFactory) {
8686
expect(params.integrationsManagerFactory.mock.calls).toEqual([[{ settings: params.settings, storage: mockStorage, telemetryTracker: telemetryTrackerMock }]]);

src/sdkFactory/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export function sdkFactory(params: ISdkFactoryParams): SplitIO.ICsSDK | SplitIO.
7171
const eventTracker = eventTrackerFactory(settings, storage.events, integrationsManager, storage.telemetry);
7272

7373
// splitApi is used by SyncManager and Browser signal listener
74-
const splitApi = splitApiFactory && splitApiFactory(settings, platform.getFetch, telemetryTracker);
74+
const splitApi = splitApiFactory && splitApiFactory(settings, platform, telemetryTracker);
7575

7676
const ctx: ISdkFactoryContext = { splitApi, eventTracker, impressionsTracker, telemetryTracker, uniqueKeysTracker, sdkReadinessManager, readiness, settings, storage, platform };
7777

src/services/__tests__/splitApi.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('splitApi', () => {
2222
test.each([settingsSplitApi, settingsWithRuntime])('performs requests with expected headers', (settings) => {
2323

2424
const fetchMock = jest.fn(() => Promise.resolve({ ok: true }));
25-
const splitApi = splitApiFactory(settings, () => fetchMock, telemetryTrackerMock);
25+
const splitApi = splitApiFactory(settings, { getFetch: () => fetchMock }, telemetryTrackerMock);
2626

2727
splitApi.fetchAuth(['key1', 'key2']);
2828
let [url, { headers }] = fetchMock.mock.calls[0];
@@ -67,7 +67,7 @@ describe('splitApi', () => {
6767

6868
test('rejects requests if fetch Api is not provided', (done) => {
6969

70-
const splitApi = splitApiFactory(settingsSplitApi, () => undefined, telemetryTrackerMock);
70+
const splitApi = splitApiFactory(settingsSplitApi, { getFetch: () => undefined }, telemetryTrackerMock);
7171

7272
// Invoking any Service method, returns a rejected promise with Split error
7373
splitApi.fetchAuth().catch(error => {
@@ -80,7 +80,7 @@ describe('splitApi', () => {
8080

8181
test('performs requests with overwritten headers', () => {
8282
const fetchMock = jest.fn(() => Promise.resolve({ ok: true }));
83-
const splitApi = splitApiFactory(settingsWithRuntime, () => fetchMock, telemetryTrackerMock);
83+
const splitApi = splitApiFactory(settingsWithRuntime, { getFetch: () => fetchMock }, telemetryTrackerMock);
8484

8585
const newHeaders = { SplitSDKVersion: 'newVersion', SplitSDKMachineIP: 'newIp', SplitSDKMachineName: 'newHostname' };
8686
const expectedHeaders = { ...settingsWithRuntime, version: newHeaders.SplitSDKVersion, runtime: { ip: newHeaders.SplitSDKMachineIP, hostname: newHeaders.SplitSDKMachineName } };
@@ -95,7 +95,7 @@ describe('splitApi', () => {
9595

9696
test('performs APIs health service check', (done) => {
9797
const fetchMock = jest.fn(() => Promise.resolve({ ok: true }));
98-
const splitApi = splitApiFactory(settingsWithRuntime, () => fetchMock, telemetryTrackerMock);
98+
const splitApi = splitApiFactory(settingsWithRuntime, { getFetch: () => fetchMock }, telemetryTrackerMock);
9999

100100
splitApi.getSdkAPIHealthCheck().then((res) => {
101101
expect(res).toEqual(true);

src/services/splitApi.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ function userKeyToQueryParam(userKey: string) {
1717
* Factory of SplitApi objects, which group the collection of Split HTTP endpoints used by the SDK
1818
*
1919
* @param settings validated settings object
20-
* @param getFetch environment-specific `getFetch` method
20+
* @param platform object containing environment-specific dependencies
2121
* @param telemetryTracker telemetry tracker
2222
*/
2323
export function splitApiFactory(
2424
settings: ISettings,
25-
getFetch: IPlatform['getFetch'],
25+
platform: Pick<IPlatform, 'getFetch'>,
2626
telemetryTracker: ITelemetryTracker
2727
): ISplitApi {
2828

2929
const urls = settings.urls;
3030
const filterQueryString = settings.sync.__splitFiltersValidation && settings.sync.__splitFiltersValidation.queryString;
3131
const SplitSDKImpressionsMode = settings.sync.impressionsMode;
32-
const splitHttpClient = splitHttpClientFactory(settings, getFetch);
32+
const splitHttpClient = splitHttpClientFactory(settings, platform.getFetch);
3333

3434
return {
3535
// @TODO throw errors if health check requests fail, to log them in the Synchronizer

src/sync/polling/updaters/__tests__/splitChangesUpdater.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ test('splitChangesUpdater / compute splits mutation with filters', () => {
154154
describe('splitChangesUpdater', () => {
155155

156156
fetchMock.once('*', { status: 200, body: splitChangesMock1 }); // @ts-ignore
157-
const splitApi = splitApiFactory(settingsSplitApi, () => fetchMock, telemetryTrackerFactory());
157+
const splitApi = splitApiFactory(settingsSplitApi, { getFetch: () => fetchMock }, telemetryTrackerFactory());
158158
const fetchSplitChanges = jest.spyOn(splitApi, 'fetchSplitChanges');
159159
const splitChangesFetcher = splitChangesFetcherFactory(splitApi.fetchSplitChanges);
160160

src/sync/streaming/AuthClient/__tests__/index.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { authenticateFactory, hashUserKey } from '../index';
1010

1111
const authorizationKey = settingsSplitApi.core.authorizationKey;
1212
const authUrl = settingsSplitApi.urls.auth; // @ts-ignore
13-
const splitApi = splitApiFactory(settingsSplitApi, () => fetchMock, telemetryTrackerFactory());
13+
const splitApi = splitApiFactory(settingsSplitApi, { getFetch: () => fetchMock }, telemetryTrackerFactory());
1414
const authenticate = authenticateFactory(splitApi.fetchAuth);
1515

1616
test('hashUserKey', () => {

0 commit comments

Comments
 (0)