Skip to content

Commit 12af338

Browse files
Merge pull request #289 from splitio/development
Release v1.13.0
2 parents 1453af8 + eed03d3 commit 12af338

File tree

11 files changed

+33
-35
lines changed

11 files changed

+33
-35
lines changed

.github/workflows/update-license-year.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Checkout
16-
uses: actions/checkout@v2
16+
uses: actions/checkout@v4
1717
with:
1818
fetch-depth: 0
1919

@@ -24,7 +24,7 @@ jobs:
2424
run: "echo PREVIOUS=$(($CURRENT-1)) >> $GITHUB_ENV"
2525

2626
- name: Update LICENSE
27-
uses: jacobtomlinson/gha-find-replace@v2
27+
uses: jacobtomlinson/gha-find-replace@v3
2828
with:
2929
find: ${{ env.PREVIOUS }}
3030
replace: ${{ env.CURRENT }}
@@ -38,7 +38,7 @@ jobs:
3838
git commit -m "Updated License Year" -a
3939
4040
- name: Create Pull Request
41-
uses: peter-evans/create-pull-request@v3
41+
uses: peter-evans/create-pull-request@v5
4242
with:
4343
token: ${{ secrets.GITHUB_TOKEN }}
4444
title: Update License Year

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
1.13.0 (January 4, 2024)
2+
- Removed the `getOptions` method from the `IPlatform` interface to simplify implementation. Request options can be handled within the `getFetch` method.
3+
14
1.12.1 (December 12, 2023)
25
- 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.
36
- Bugfixing - Fixed an issue when tracking telemetry latencies for the new `getTreatmentsByFlagSet(s)` methods in Redis and Pluggable storages, which was causing the SDK to not track those stats.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright © 2023 Split Software, Inc.
1+
Copyright © 2024 Split Software, Inc.
22

33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.

package-lock.json

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@splitsoftware/splitio-commons",
3-
"version": "1.12.1",
3+
"version": "1.13.0",
44
"description": "Split Javascript SDK common components",
55
"main": "cjs/index.js",
66
"module": "esm/index.js",
@@ -72,7 +72,7 @@
7272
"jest": "^27.2.3",
7373
"jest-localstorage-mock": "^2.4.3",
7474
"lodash": "^4.17.21",
75-
"node-fetch": "^2.6.7",
75+
"node-fetch": "^2.7.0",
7676
"redis-server": "1.2.2",
7777
"rimraf": "^3.0.2",
7878
"ts-jest": "^27.0.5",

src/sdkFactory/__tests__/index.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ const fullParamsForSyncSDK = {
4949
platform: {
5050
getEventSource: jest.fn(),
5151
getFetch: jest.fn(),
52-
getOptions: jest.fn(),
5352
EventEmitter
5453
},
5554
splitApiFactory: jest.fn(),

src/sdkFactory/types.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { IIntegrationManager, IIntegrationFactoryParams } from '../integrations/
22
import { ISignalListener } from '../listeners/types';
33
import { IReadinessManager, ISdkReadinessManager } from '../readiness/types';
44
import type { sdkManagerFactory } from '../sdkManager';
5+
import type { splitApiFactory } from '../services/splitApi';
56
import { IFetch, ISplitApi, IEventSourceConstructor } from '../services/types';
67
import { IStorageAsync, IStorageSync, IStorageFactoryParams } from '../storages/types';
78
import { ISyncManager } from '../sync/types';
@@ -17,10 +18,6 @@ export interface IPlatform {
1718
* If provided, it is used to retrieve the Fetch API for HTTP requests. Otherwise, the global fetch is used.
1819
*/
1920
getFetch?: () => (IFetch | undefined)
20-
/**
21-
* If provided, it is used to pass additional options to fetch calls.
22-
*/
23-
getOptions?: () => object
2421
/**
2522
* If provided, it is used to retrieve the EventSource constructor for streaming support.
2623
*/
@@ -79,7 +76,7 @@ export interface ISdkFactoryParams {
7976

8077
// Factory of Split Api (HTTP Client Service).
8178
// It is not required when providing an asynchronous storage or offline SyncManager
82-
splitApiFactory?: (settings: ISettings, platform: IPlatform, telemetryTracker: ITelemetryTracker) => ISplitApi,
79+
splitApiFactory?: typeof splitApiFactory,
8380

8481
// SyncManager factory.
8582
// Not required when providing an asynchronous storage (consumer mode), but required in standalone mode to avoid SDK timeout.

src/services/splitApi.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +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 platform object containing environment-specific `getFetch` and `getOptions` dependencies
20+
* @param platform object containing environment-specific dependencies
21+
* @param telemetryTracker telemetry tracker
2122
*/
2223
export function splitApiFactory(
23-
settings: Pick<ISettings, 'urls' | 'sync' | 'log' | 'version' | 'runtime' | 'core'>,
24-
platform: Pick<IPlatform, 'getFetch' | 'getOptions'>,
24+
settings: ISettings,
25+
platform: Pick<IPlatform, 'getFetch'>,
2526
telemetryTracker: ITelemetryTracker
2627
): ISplitApi {
2728

2829
const urls = settings.urls;
2930
const filterQueryString = settings.sync.__splitFiltersValidation && settings.sync.__splitFiltersValidation.queryString;
3031
const SplitSDKImpressionsMode = settings.sync.impressionsMode;
31-
const splitHttpClient = splitHttpClientFactory(settings, platform.getFetch, platform.getOptions);
32+
const splitHttpClient = splitHttpClientFactory(settings, platform.getFetch);
3233

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

src/services/splitHttpClient.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
import { IFetch, IRequestOptions, IResponse, ISplitHttpClient, NetworkError } from './types';
1+
import { IRequestOptions, IResponse, ISplitHttpClient, NetworkError } from './types';
22
import { objectAssign } from '../utils/lang/objectAssign';
33
import { ERROR_HTTP, ERROR_CLIENT_CANNOT_GET_READY } from '../logger/constants';
44
import { ISettings } from '../types';
5+
import { IPlatform } from '../sdkFactory/types';
56

67
const messageNoFetch = 'Global fetch API is not available.';
78

89
/**
910
* Factory of Split HTTP clients, which are HTTP clients with predefined headers for Split endpoints.
1011
*
1112
* @param settings SDK settings, used to access authorizationKey, logger instance and metadata (SDK version, ip and hostname) to set additional headers
12-
* @param options global request options
13-
* @param fetch optional http client to use instead of the global Fetch (for environments where Fetch API is not available such as Node)
13+
* @param getFetch retrieves the Fetch API for HTTP requests
1414
*/
15-
export function splitHttpClientFactory(settings: Pick<ISettings, 'log' | 'version' | 'runtime' | 'core'>, getFetch?: () => (IFetch | undefined), getOptions?: () => object): ISplitHttpClient {
15+
export function splitHttpClientFactory(settings: ISettings, getFetch?: IPlatform['getFetch']): ISplitHttpClient {
1616

1717
const { log, core: { authorizationKey }, version, runtime: { ip, hostname } } = settings;
18-
const options = getOptions && getOptions();
1918
const fetch = getFetch && getFetch();
2019

2120
// if fetch is not available, log Error
@@ -33,11 +32,11 @@ export function splitHttpClientFactory(settings: Pick<ISettings, 'log' | 'versio
3332

3433
return function httpClient(url: string, reqOpts: IRequestOptions = {}, latencyTracker: (error?: NetworkError) => void = () => { }, logErrorsAsInfo: boolean = false): Promise<IResponse> {
3534

36-
const request = objectAssign({
35+
const request = {
3736
headers: reqOpts.headers ? objectAssign({}, headers, reqOpts.headers) : headers,
3837
method: reqOpts.method || 'GET',
3938
body: reqOpts.body
40-
}, options);
39+
};
4140

4241
// using `fetch(url, options)` signature to work with unfetch, a lightweight ponyfill of fetch API.
4342
return fetch ? fetch(url, request)

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, { getFetch: () => fetchMock, EventEmitter }, telemetryTrackerFactory());
157+
const splitApi = splitApiFactory(settingsSplitApi, { getFetch: () => fetchMock }, telemetryTrackerFactory());
158158
const fetchSplitChanges = jest.spyOn(splitApi, 'fetchSplitChanges');
159159
const splitChangesFetcher = splitChangesFetcherFactory(splitApi.fetchSplitChanges);
160160

0 commit comments

Comments
 (0)