@splitsoftware/splitio-commons 1.2.1-rc.5 → 1.2.1-rc.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/logger/constants.js +3 -2
- package/cjs/logger/messages/debug.js +3 -3
- package/cjs/logger/messages/error.js +2 -2
- package/cjs/logger/messages/info.js +4 -3
- package/cjs/sdkClient/client.js +3 -8
- package/cjs/sdkClient/clientInputValidation.js +6 -8
- package/cjs/sdkClient/sdkClient.js +1 -4
- package/cjs/sdkFactory/index.js +3 -3
- package/cjs/sdkFactory/userConsentProps.js +11 -8
- package/cjs/storages/KeyBuilder.js +1 -5
- package/cjs/sync/streaming/SSEClient/index.js +2 -1
- package/cjs/sync/submitters/eventsSyncTask.js +8 -1
- package/cjs/trackers/eventTracker.js +8 -1
- package/cjs/trackers/impressionObserver/utils.js +8 -1
- package/cjs/trackers/impressionsTracker.js +6 -5
- package/cjs/utils/lang/index.js +8 -1
- package/cjs/utils/settingsValidation/consent.js +2 -2
- package/cjs/utils/settingsValidation/impressionsMode.js +2 -2
- package/esm/logger/constants.js +1 -0
- package/esm/logger/messages/debug.js +3 -3
- package/esm/logger/messages/error.js +2 -2
- package/esm/logger/messages/info.js +4 -3
- package/esm/sdkClient/client.js +4 -9
- package/esm/sdkClient/clientInputValidation.js +6 -8
- package/esm/sdkClient/sdkClient.js +1 -4
- package/esm/sdkFactory/index.js +3 -3
- package/esm/sdkFactory/userConsentProps.js +12 -9
- package/esm/storages/KeyBuilder.js +2 -6
- package/esm/sync/streaming/SSEClient/index.js +2 -1
- package/esm/sync/submitters/eventsSyncTask.js +8 -1
- package/esm/trackers/eventTracker.js +8 -1
- package/esm/trackers/impressionObserver/utils.js +7 -1
- package/esm/trackers/impressionsTracker.js +6 -5
- package/esm/utils/lang/index.js +6 -0
- package/esm/utils/settingsValidation/consent.js +2 -2
- package/esm/utils/settingsValidation/impressionsMode.js +2 -2
- package/package.json +1 -1
- package/src/logger/constants.ts +1 -0
- package/src/logger/messages/debug.ts +3 -3
- package/src/logger/messages/error.ts +2 -2
- package/src/logger/messages/info.ts +4 -3
- package/src/sdkClient/client.ts +4 -5
- package/src/sdkClient/clientInputValidation.ts +8 -7
- package/src/sdkClient/sdkClient.ts +2 -5
- package/src/sdkFactory/index.ts +3 -3
- package/src/sdkFactory/types.ts +0 -1
- package/src/sdkFactory/userConsentProps.ts +12 -9
- package/src/storages/KeyBuilder.ts +2 -6
- package/src/sync/streaming/SSEClient/index.ts +2 -1
- package/src/sync/submitters/eventsSyncTask.ts +8 -1
- package/src/trackers/eventTracker.ts +11 -3
- package/src/trackers/impressionObserver/utils.ts +8 -1
- package/src/trackers/impressionsTracker.ts +7 -8
- package/src/utils/lang/index.ts +8 -1
- package/src/utils/settingsValidation/consent.ts +4 -2
- package/src/utils/settingsValidation/impressionsMode.ts +2 -1
- package/types/logger/constants.d.ts +1 -0
- package/types/sdkClient/clientInputValidation.d.ts +2 -3
- package/types/sdkFactory/types.d.ts +0 -1
- package/types/trackers/eventTracker.d.ts +2 -2
- package/types/trackers/impressionObserver/utils.d.ts +4 -0
- package/types/trackers/impressionsTracker.d.ts +2 -3
- package/types/utils/lang/index.d.ts +4 -0
- package/types/utils/settingsValidation/consent.d.ts +3 -2
package/src/utils/lang/index.ts
CHANGED
|
@@ -89,7 +89,7 @@ export function get(obj: any, prop: any, val: any): any {
|
|
|
89
89
|
/**
|
|
90
90
|
* Parses an array into a map of different arrays, grouping by the specified prop value.
|
|
91
91
|
*/
|
|
92
|
-
export function groupBy<T extends Record<string, any
|
|
92
|
+
export function groupBy<T extends Record<string, any>>(source: T[], prop: string): Record<string, T[]> {
|
|
93
93
|
const map: Record<string, any[]> = {};
|
|
94
94
|
|
|
95
95
|
if (Array.isArray(source) && isString(prop)) {
|
|
@@ -164,6 +164,13 @@ export function isString(val: any): val is string {
|
|
|
164
164
|
return typeof val === 'string' || val instanceof String;
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
+
/**
|
|
168
|
+
* String sanitizer. Returns the provided value converted to uppercase if it is a string.
|
|
169
|
+
*/
|
|
170
|
+
export function stringToUpperCase(val: any) {
|
|
171
|
+
return isString(val) ? val.toUpperCase() : val;
|
|
172
|
+
}
|
|
173
|
+
|
|
167
174
|
/**
|
|
168
175
|
* Deep copy version of Object.assign using recursion.
|
|
169
176
|
* There are some assumptions here. It's for internal use and we don't need verbose errors
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { ERROR_INVALID_CONFIG_PARAM } from '../../logger/constants';
|
|
2
2
|
import { ILogger } from '../../logger/types';
|
|
3
|
+
import { ConsentStatus } from '../../types';
|
|
3
4
|
import { CONSENT_DECLINED, CONSENT_GRANTED, CONSENT_UNKNOWN } from '../constants';
|
|
5
|
+
import { stringToUpperCase } from '../lang';
|
|
4
6
|
|
|
5
7
|
const userConsentValues = [CONSENT_DECLINED, CONSENT_GRANTED, CONSENT_UNKNOWN];
|
|
6
8
|
|
|
7
|
-
export function validateConsent({ userConsent, log }: { userConsent
|
|
8
|
-
|
|
9
|
+
export function validateConsent({ userConsent, log }: { userConsent?: any, log: ILogger }): ConsentStatus {
|
|
10
|
+
userConsent = stringToUpperCase(userConsent);
|
|
9
11
|
|
|
10
12
|
if (userConsentValues.indexOf(userConsent) > -1) return userConsent;
|
|
11
13
|
|
|
@@ -2,9 +2,10 @@ import { ERROR_INVALID_CONFIG_PARAM } from '../../logger/constants';
|
|
|
2
2
|
import { ILogger } from '../../logger/types';
|
|
3
3
|
import { SplitIO } from '../../types';
|
|
4
4
|
import { DEBUG, OPTIMIZED } from '../constants';
|
|
5
|
+
import { stringToUpperCase } from '../lang';
|
|
5
6
|
|
|
6
7
|
export function validImpressionsMode(log: ILogger, impressionsMode: any): SplitIO.ImpressionsMode {
|
|
7
|
-
|
|
8
|
+
impressionsMode = stringToUpperCase(impressionsMode);
|
|
8
9
|
|
|
9
10
|
if ([DEBUG, OPTIMIZED].indexOf(impressionsMode) > -1) return impressionsMode;
|
|
10
11
|
|
|
@@ -68,6 +68,7 @@ export declare const SYNC_STOP_POLLING = 119;
|
|
|
68
68
|
export declare const EVENTS_TRACKER_SUCCESS = 120;
|
|
69
69
|
export declare const IMPRESSIONS_TRACKER_SUCCESS = 121;
|
|
70
70
|
export declare const USER_CONSENT_UPDATED = 122;
|
|
71
|
+
export declare const USER_CONSENT_NOT_UPDATED = 123;
|
|
71
72
|
export declare const ENGINE_VALUE_INVALID = 200;
|
|
72
73
|
export declare const ENGINE_VALUE_NO_ATTRIBUTES = 201;
|
|
73
74
|
export declare const CLIENT_NO_LISTENER = 202;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { IReadinessManager } from '../readiness/types';
|
|
2
|
-
import { SplitIO } from '../types';
|
|
3
|
-
import { ILogger } from '../logger/types';
|
|
2
|
+
import { ISettings, SplitIO } from '../types';
|
|
4
3
|
/**
|
|
5
4
|
* Decorator that validates the input before actually executing the client methods.
|
|
6
5
|
* We should "guard" the client here, while not polluting the "real" implementation of those methods.
|
|
7
6
|
*/
|
|
8
|
-
export declare function clientInputValidationDecorator<TClient extends SplitIO.IClient | SplitIO.IAsyncClient>(
|
|
7
|
+
export declare function clientInputValidationDecorator<TClient extends SplitIO.IClient | SplitIO.IAsyncClient>(settings: ISettings, client: TClient, readinessManager: IReadinessManager): TClient;
|
|
@@ -36,7 +36,6 @@ export interface ISdkFactoryParams {
|
|
|
36
36
|
settings: ISettings, // Used by BrowserSignalListener
|
|
37
37
|
storage: IStorageSync | IStorageAsync, // Used by BrowserSignalListener
|
|
38
38
|
serviceApi: ISplitApi | undefined) => ISignalListener;
|
|
39
|
-
impressionListener?: SplitIO.IImpressionListener;
|
|
40
39
|
integrationsManagerFactory?: (params: IIntegrationFactoryParams) => IIntegrationManager | undefined;
|
|
41
40
|
impressionsObserverFactory?: () => IImpressionObserver;
|
|
42
41
|
extraProps?: (settings: ISettings, syncManager?: ISyncManager) => object;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { IEventsCacheBase } from '../storages/types';
|
|
2
2
|
import { IEventsHandler, IEventTracker } from './types';
|
|
3
|
-
import {
|
|
3
|
+
import { ISettings } from '../types';
|
|
4
4
|
/**
|
|
5
5
|
* Event tracker stores events in cache and pass them to the integrations manager if provided.
|
|
6
6
|
*
|
|
7
7
|
* @param eventsCache cache to save events
|
|
8
8
|
* @param integrationsManager optional event handler used for integrations
|
|
9
9
|
*/
|
|
10
|
-
export declare function eventTrackerFactory(
|
|
10
|
+
export declare function eventTrackerFactory(settings: ISettings, eventsCache: IEventsCacheBase, integrationsManager?: IEventsHandler): IEventTracker;
|
|
@@ -7,3 +7,7 @@ export declare function shouldAddPt(settings: ISettings): boolean;
|
|
|
7
7
|
* Checks if it should dedupe impressions or not.
|
|
8
8
|
*/
|
|
9
9
|
export declare function shouldBeOptimized(settings: ISettings): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Storage is async if mode is consumer or partial consumer
|
|
12
|
+
*/
|
|
13
|
+
export declare function isStorageSync(settings: ISettings): boolean;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { IImpressionCountsCacheSync, IImpressionsCacheBase } from '../storages/types';
|
|
2
2
|
import { IImpressionsHandler, IImpressionsTracker } from './types';
|
|
3
|
-
import {
|
|
3
|
+
import { ISettings } from '../types';
|
|
4
4
|
import { IImpressionObserver } from './impressionObserver/types';
|
|
5
|
-
import { ILogger } from '../logger/types';
|
|
6
5
|
/**
|
|
7
6
|
* Impressions tracker stores impressions in cache and pass them to the listener and integrations manager if provided.
|
|
8
7
|
*
|
|
@@ -13,4 +12,4 @@ import { ILogger } from '../logger/types';
|
|
|
13
12
|
* @param observer optional impression observer. If provided, previous time (pt property) is included in impression instances
|
|
14
13
|
* @param countsCache optional cache to save impressions count. If provided, impressions will be deduped (OPTIMIZED mode)
|
|
15
14
|
*/
|
|
16
|
-
export declare function impressionsTrackerFactory(
|
|
15
|
+
export declare function impressionsTrackerFactory(settings: ISettings, impressionsCache: IImpressionsCacheBase, integrationsManager?: IImpressionsHandler, observer?: IImpressionObserver, countsCache?: IImpressionCountsCacheSync): IImpressionsTracker;
|
|
@@ -62,6 +62,10 @@ export declare function isObject(obj: any): boolean;
|
|
|
62
62
|
* Checks if a given value is a string.
|
|
63
63
|
*/
|
|
64
64
|
export declare function isString(val: any): val is string;
|
|
65
|
+
/**
|
|
66
|
+
* String sanitizer. Returns the provided value converted to uppercase if it is a string.
|
|
67
|
+
*/
|
|
68
|
+
export declare function stringToUpperCase(val: any): any;
|
|
65
69
|
/**
|
|
66
70
|
* Deep copy version of Object.assign using recursion.
|
|
67
71
|
* There are some assumptions here. It's for internal use and we don't need verbose errors
|