Skip to content
Merged
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
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@splitsoftware/splitio-commons",
"version": "1.0.1-rc.4",
"version": "1.0.1-rc.5",
"description": "Split Javascript SDK common components",
"main": "cjs/index.js",
"module": "esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/testUtils/eventSourceMock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

import EventEmitter from '../../utils/MinEvents';
import { EventEmitter } from '../../utils/MinEvents';
import { IEventEmitter } from '../../types';

type ReadyStateType = 0 | 1 | 2;
Expand Down
7 changes: 3 additions & 4 deletions src/evaluator/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Engine from './Engine';
import thenable from '../utils/promise/thenable';
import * as LabelsConstants from '../utils/labels';
import { get } from '../utils/lang';
import { CONTROL } from '../utils/constants';
import { ISplit, MaybeThenable } from '../dtos/types';
import { IStorageAsync, IStorageSync } from '../storages/types';
Expand Down Expand Up @@ -106,17 +105,17 @@ function getEvaluation(
const split = Engine.parse(log, splitJSON, storage);
evaluation = split.getTreatment(key, attributes, evaluateFeature);

// If the storage is async, evaluation and changeNumber will return a thenable
// If the storage is async and the evaluated split uses segment, evaluation is thenable
if (thenable(evaluation)) {
return evaluation.then(result => {
result.changeNumber = split.getChangeNumber();
result.config = get(splitJSON, `configurations.${result.treatment}`, null);
result.config = splitJSON.configurations && splitJSON.configurations[result.treatment] || null;

return result;
});
} else {
evaluation.changeNumber = split.getChangeNumber(); // Always sync and optional
evaluation.config = get(splitJSON, `configurations.${evaluation.treatment}`, null);
evaluation.config = splitJSON.configurations && splitJSON.configurations[evaluation.treatment] || null;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/logger/messages/warn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ export const codesWarn: [number, string][] = codesError.concat([
[c.WARN_TRIMMING_PROPERTIES, '%s: Event has more than 300 properties. Some of them will be trimmed when processed.'],
[c.WARN_CONVERTING, '%s: %s "%s" is not of type string, converting.'],
[c.WARN_TRIMMING, '%s: %s "%s" has extra whitespace, trimming.'],
[c.WARN_NOT_EXISTENT_SPLIT, '%s: split "%s" does not exist in this environment, please double check what splits exist in the web console.'],
[c.WARN_NOT_EXISTENT_SPLIT, '%s: split "%s" does not exist in this environment, please double check what splits exist in the Split web console.'],
[c.WARN_LOWERCASE_TRAFFIC_TYPE, '%s: traffic_type_name should be all lowercase - converting string to lowercase.'],
[c.WARN_NOT_EXISTENT_TT, '%s: traffic type "%s" does not have any corresponding split in this environment, make sure you\'re tracking your events to a valid traffic type defined in the web console.'],
[c.WARN_NOT_EXISTENT_TT, '%s: traffic type "%s" does not have any corresponding split in this environment, make sure you\'re tracking your events to a valid traffic type defined in the Split web console.'],
// initialization / settings validation
[c.WARN_INTEGRATION_INVALID, c.LOG_PREFIX_SETTINGS+': %s integration item(s) at settings is invalid. %s'],
[c.WARN_SPLITS_FILTER_IGNORED, c.LOG_PREFIX_SETTINGS+': split filters have been configured but will have no effect if mode is not "%s", since synchronization is being deferred to an external tool.'],
Expand Down
2 changes: 1 addition & 1 deletion src/readiness/__tests__/readinessManager.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { readinessManagerFactory } from '../readinessManager';
import EventEmitter from '../../utils/MinEvents';
import { EventEmitter } from '../../utils/MinEvents';
import { IReadinessManager } from '../types';
import { SDK_READY, SDK_UPDATE, SDK_SPLITS_ARRIVED, SDK_SEGMENTS_ARRIVED, SDK_READY_FROM_CACHE, SDK_SPLITS_CACHE_LOADED, SDK_READY_TIMED_OUT } from '../constants';

Expand Down
2 changes: 1 addition & 1 deletion src/sdkFactory/__tests__/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ISdkFactoryParams } from '../types';
import { sdkFactory } from '../index';
import { fullSettings } from '../../utils/settingsValidation/__tests__/settings.mocks';
import { SplitIO } from '../../types';
import EventEmitter from '../../utils/MinEvents';
import { EventEmitter } from '../../utils/MinEvents';

/** Mocks */

Expand Down
2 changes: 1 addition & 1 deletion src/sdkFactory/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function sdkFactory(params: ISdkFactoryParams): SplitIO.ICsSDK | SplitIO.
// Callback used to emit SDK_READY in consumer mode, where `syncManagerFactory` is undefined
// or only instantiates submitters, and therefore it is not able to emit readiness events.
onReadyCb: (error) => {
if (error) return; // don't emit SDK_READY if storage failed to connect.
if (error) return; // Don't emit SDK_READY if storage failed to connect. Error message is logged by wrapperAdapter
readinessManager.splits.emit(SDK_SPLITS_ARRIVED);
readinessManager.segments.emit(SDK_SEGMENTS_ARRIVED);
},
Expand Down
4 changes: 2 additions & 2 deletions src/storages/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export interface IPluggableStorageWrapper {
/** Integer operations */

/**
* Increments in 1 the given `key` value or set it in 1 if the value doesn't exist.
* Increments in 1 the given `key` value or set it to 1 if the value doesn't exist.
*
* @function incr
* @param {string} key Key to increment
Expand All @@ -79,7 +79,7 @@ export interface IPluggableStorageWrapper {
*/
incr: (key: string) => Promise<number>
/**
* Decrements in 1 the given `key` value or set it in -1 if the value doesn't exist.
* Decrements in 1 the given `key` value or set it to -1 if the value doesn't exist.
*
* @function decr
* @param {string} key Key to decrement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { splitChangesUpdaterFactory, parseSegments, computeSplitsMutation } from
import splitChangesMock1 from '../../../../__tests__/mocks/splitchanges.since.-1.json';
import fetchMock from '../../../../__tests__/testUtils/fetchMock';
import { settingsSplitApi } from '../../../../utils/settingsValidation/__tests__/settings.mocks';
import EventEmitter from '../../../../utils/MinEvents';
import { EventEmitter } from '../../../../utils/MinEvents';
import { loggerMock } from '../../../../logger/__tests__/sdkLogger.mock';

const activeSplitWithSegments = {
Expand Down
2 changes: 1 addition & 1 deletion src/sync/streaming/AuthClient/__tests__/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { splitApiFactory } from '../../../../services/splitApi';
import { authDataResponseSample, authDataSample, jwtSampleInvalid, jwtSampleNoChannels, jwtSampleNoIat, userKeySample, userKeyBase64HashSample } from '../../__tests__/dataMocks';
import fetchMock from '../../../../__tests__/testUtils/fetchMock';
import { settingsSplitApi } from '../../../../utils/settingsValidation/__tests__/settings.mocks';
import EventEmitter from '../../../../utils/MinEvents';
import { EventEmitter } from '../../../../utils/MinEvents';

// module to test
import { authenticateFactory, hashUserKey } from '../index';
Expand Down
2 changes: 1 addition & 1 deletion src/sync/streaming/__tests__/pushManager.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pushManagerFactory from '../pushManager';
import EventEmitter from '../../../utils/MinEvents';
import { EventEmitter } from '../../../utils/MinEvents';
import { fullSettings } from '../../../utils/settingsValidation/__tests__/settings.mocks';
import { IPushManagerCS } from '../types';

Expand Down
9 changes: 2 additions & 7 deletions src/utils/MinEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,9 @@ var ReflectApply = R && typeof R.apply === 'function'
return Function.prototype.apply.call(target, receiver, args);
};

function EventEmitter() {
export const EventEmitter: { new(): IEventEmitter } = function EventEmitter() {
EventEmitter.init.call(this);
}

export default EventEmitter as new () => IEventEmitter;

// Backwards-compat with node 0.10.x
EventEmitter.EventEmitter = EventEmitter;
};

EventEmitter.prototype._events = undefined;
EventEmitter.prototype._eventsCount = 0;
Expand Down