@splitsoftware/splitio-commons 1.2.1-rc.7 → 1.3.0
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/CHANGES.txt +14 -0
- package/cjs/{utils/consent.js → consent/index.js} +1 -1
- package/cjs/consent/sdkUserConsent.js +58 -0
- package/cjs/listeners/browser.js +1 -1
- package/cjs/logger/constants.js +3 -2
- package/cjs/logger/messages/info.js +1 -0
- package/cjs/sdkClient/client.js +4 -9
- package/cjs/sdkClient/clientCS.js +1 -1
- package/cjs/sdkClient/clientInputValidation.js +6 -8
- package/cjs/sdkClient/sdkClient.js +4 -7
- package/cjs/sdkClient/sdkClientMethodCS.js +3 -9
- package/cjs/sdkClient/sdkClientMethodCSWithTT.js +3 -13
- package/cjs/sdkFactory/index.js +6 -5
- package/cjs/storages/inRedis/RedisAdapter.js +9 -2
- package/cjs/sync/syncManagerOnline.js +1 -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/inputValidation/attributes.js +1 -1
- package/cjs/utils/lang/index.js +4 -2
- package/cjs/utils/lang/maps.js +16 -2
- package/cjs/utils/settingsValidation/index.js +21 -3
- package/esm/{utils/consent.js → consent/index.js} +1 -1
- package/esm/consent/sdkUserConsent.js +54 -0
- package/esm/listeners/browser.js +1 -1
- package/esm/logger/constants.js +1 -0
- package/esm/logger/messages/info.js +1 -0
- package/esm/sdkClient/client.js +5 -10
- package/esm/sdkClient/clientCS.js +1 -1
- package/esm/sdkClient/clientInputValidation.js +6 -8
- package/esm/sdkClient/sdkClient.js +4 -7
- package/esm/sdkClient/sdkClientMethodCS.js +3 -9
- package/esm/sdkClient/sdkClientMethodCSWithTT.js +3 -13
- package/esm/sdkFactory/index.js +6 -5
- package/esm/storages/inRedis/RedisAdapter.js +9 -2
- package/esm/sync/syncManagerOnline.js +1 -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/inputValidation/attributes.js +1 -1
- package/esm/utils/lang/index.js +4 -2
- package/esm/utils/lang/maps.js +14 -1
- package/esm/utils/settingsValidation/index.js +21 -3
- package/package.json +1 -1
- package/src/{utils/consent.ts → consent/index.ts} +1 -1
- package/src/consent/sdkUserConsent.ts +58 -0
- package/src/evaluator/parser/index.ts +1 -1
- package/src/evaluator/types.ts +2 -2
- package/src/evaluator/value/index.ts +2 -2
- package/src/evaluator/value/sanitize.ts +2 -2
- package/src/integrations/pluggable.ts +2 -2
- package/src/listeners/browser.ts +1 -1
- package/src/logger/constants.ts +1 -0
- package/src/logger/messages/info.ts +1 -0
- package/src/sdkClient/client.ts +7 -9
- package/src/sdkClient/clientCS.ts +1 -1
- package/src/sdkClient/clientInputValidation.ts +8 -7
- package/src/sdkClient/sdkClient.ts +6 -9
- package/src/sdkClient/sdkClientMethod.ts +2 -2
- package/src/sdkClient/sdkClientMethodCS.ts +5 -11
- package/src/sdkClient/sdkClientMethodCSWithTT.ts +6 -16
- package/src/sdkFactory/index.ts +6 -5
- package/src/sdkFactory/types.ts +13 -4
- package/src/storages/inRedis/RedisAdapter.ts +8 -2
- package/src/sync/syncManagerOnline.ts +1 -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/types.ts +1 -1
- package/src/utils/inputValidation/attributes.ts +1 -2
- package/src/utils/lang/index.ts +7 -3
- package/src/utils/lang/maps.ts +15 -1
- package/src/utils/settingsValidation/index.ts +21 -3
- package/src/utils/settingsValidation/types.ts +5 -1
- package/types/consent/index.d.ts +2 -0
- package/types/consent/sdkUserConsent.d.ts +13 -0
- package/types/evaluator/types.d.ts +2 -2
- package/types/evaluator/value/index.d.ts +1 -1
- package/types/evaluator/value/sanitize.d.ts +1 -1
- package/types/logger/constants.d.ts +1 -0
- package/types/sdkClient/client.d.ts +2 -2
- package/types/sdkClient/clientInputValidation.d.ts +2 -3
- package/types/sdkClient/sdkClient.d.ts +2 -2
- package/types/sdkClient/sdkClientMethod.d.ts +2 -2
- package/types/sdkClient/sdkClientMethodCS.d.ts +2 -2
- package/types/sdkClient/sdkClientMethodCSWithTT.d.ts +2 -2
- package/types/sdkFactory/types.d.ts +12 -4
- package/types/storages/inRedis/RedisAdapter.d.ts +1 -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/types.d.ts +1 -1
- package/types/utils/lang/index.d.ts +2 -1
- package/types/utils/lang/maps.d.ts +7 -0
- package/types/utils/settingsValidation/types.d.ts +5 -1
- package/cjs/sdkClient/types.js +0 -2
- package/cjs/sdkFactory/userConsentProps.js +0 -37
- package/esm/sdkClient/types.js +0 -1
- package/esm/sdkFactory/userConsentProps.js +0 -33
- package/src/sdkClient/types.ts +0 -21
- package/src/sdkFactory/userConsentProps.ts +0 -40
|
@@ -5,6 +5,8 @@ import { STANDALONE_MODE, OPTIMIZED, LOCALHOST_MODE } from '../constants';
|
|
|
5
5
|
import { validImpressionsMode } from './impressionsMode';
|
|
6
6
|
import { ISettingsValidationParams } from './types';
|
|
7
7
|
import { ISettings } from '../../types';
|
|
8
|
+
import { validateKey } from '../inputValidation/key';
|
|
9
|
+
import { validateTrafficType } from '../inputValidation/trafficType';
|
|
8
10
|
|
|
9
11
|
const base = {
|
|
10
12
|
// Define which kind of object you want to retrieve from SplitFactory
|
|
@@ -129,9 +131,25 @@ export function settingsValidation(config: unknown, validationParams: ISettingsV
|
|
|
129
131
|
// @ts-ignore, modify readonly prop
|
|
130
132
|
if (storage) withDefaults.storage = storage(withDefaults);
|
|
131
133
|
|
|
132
|
-
//
|
|
133
|
-
if (
|
|
134
|
-
withDefaults.core.key
|
|
134
|
+
// Validate key and TT (for client-side)
|
|
135
|
+
if (validationParams.acceptKey) {
|
|
136
|
+
const maybeKey = withDefaults.core.key;
|
|
137
|
+
// Although `key` is required in client-side, it can be omitted in LOCALHOST mode. In that case, the value `localhost_key` is used.
|
|
138
|
+
if (withDefaults.mode === LOCALHOST_MODE && maybeKey === undefined) {
|
|
139
|
+
withDefaults.core.key = 'localhost_key';
|
|
140
|
+
} else {
|
|
141
|
+
// Keeping same behaviour than JS SDK: if settings key or TT are invalid,
|
|
142
|
+
// `false` value is used as binded key/TT of the default client, which leads to some issues.
|
|
143
|
+
// @ts-ignore, @TODO handle invalid keys as a non-recoverable error?
|
|
144
|
+
withDefaults.core.key = validateKey(log, maybeKey, 'Client instantiation');
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (validationParams.acceptTT) {
|
|
148
|
+
const maybeTT = withDefaults.core.trafficType;
|
|
149
|
+
if (maybeTT !== undefined) { // @ts-ignore
|
|
150
|
+
withDefaults.core.trafficType = validateTrafficType(log, maybeTT, 'Client instantiation');
|
|
151
|
+
}
|
|
152
|
+
}
|
|
135
153
|
}
|
|
136
154
|
|
|
137
155
|
// Current ip/hostname information
|
|
@@ -10,7 +10,11 @@ export interface ISettingsValidationParams {
|
|
|
10
10
|
* Version and startup properties are required, because they are not defined in the base settings.
|
|
11
11
|
*/
|
|
12
12
|
defaults: Partial<ISettings> & { version: string } & { startup: ISettings['startup'] },
|
|
13
|
-
/**
|
|
13
|
+
/** If true, validates core.key */
|
|
14
|
+
acceptKey?: boolean,
|
|
15
|
+
/** If true, validates core.trafficType */
|
|
16
|
+
acceptTT?: boolean,
|
|
17
|
+
/** Define runtime values (`settings.runtime`) */
|
|
14
18
|
runtime: (settings: ISettings) => ISettings['runtime'],
|
|
15
19
|
/** Storage validator (`settings.storage`) */
|
|
16
20
|
storage?: (settings: ISettings) => ISettings['storage'],
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ISdkFactoryContext } from '../sdkFactory/types';
|
|
2
|
+
/**
|
|
3
|
+
* The public user consent API exposed via SplitFactory, used to control if the SDK tracks and sends impressions and events or not.
|
|
4
|
+
*/
|
|
5
|
+
export declare function createUserConsentAPI(params: ISdkFactoryContext): {
|
|
6
|
+
setStatus(consent: unknown): boolean;
|
|
7
|
+
getStatus(): import("../types").ConsentStatus | undefined;
|
|
8
|
+
Status: {
|
|
9
|
+
GRANTED: string;
|
|
10
|
+
DECLINED: string;
|
|
11
|
+
UNKNOWN: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -5,7 +5,7 @@ import { SplitIO } from '../types';
|
|
|
5
5
|
import { ILogger } from '../logger/types';
|
|
6
6
|
export interface IDependencyMatcherValue {
|
|
7
7
|
key: SplitIO.SplitKey;
|
|
8
|
-
attributes
|
|
8
|
+
attributes?: SplitIO.Attributes;
|
|
9
9
|
}
|
|
10
10
|
export interface IMatcherDto {
|
|
11
11
|
type: number;
|
|
@@ -23,6 +23,6 @@ export interface IEvaluation {
|
|
|
23
23
|
export declare type IEvaluationResult = IEvaluation & {
|
|
24
24
|
treatment: string;
|
|
25
25
|
};
|
|
26
|
-
export declare type ISplitEvaluator = (log: ILogger, key: SplitIO.SplitKey, splitName: string, attributes: SplitIO.Attributes, storage: IStorageSync | IStorageAsync) => MaybeThenable<IEvaluation>;
|
|
26
|
+
export declare type ISplitEvaluator = (log: ILogger, key: SplitIO.SplitKey, splitName: string, attributes: SplitIO.Attributes | undefined, storage: IStorageSync | IStorageAsync) => MaybeThenable<IEvaluation>;
|
|
27
27
|
export declare type IEvaluator = (key: SplitIO.SplitKey, seed: number, trafficAllocation?: number, trafficAllocationSeed?: number, attributes?: SplitIO.Attributes, splitEvaluator?: ISplitEvaluator) => MaybeThenable<IEvaluation | undefined>;
|
|
28
28
|
export declare type IMatcher = (...args: any) => MaybeThenable<boolean>;
|
|
@@ -4,4 +4,4 @@ import { ILogger } from '../../logger/types';
|
|
|
4
4
|
/**
|
|
5
5
|
* Defines value to be matched (key / attribute).
|
|
6
6
|
*/
|
|
7
|
-
export declare function sanitizeValue(log: ILogger, key: string, matcherDto: IMatcherDto, attributes
|
|
7
|
+
export declare function sanitizeValue(log: ILogger, key: string, matcherDto: IMatcherDto, attributes?: SplitIO.Attributes): string | number | boolean | (string | number)[] | import("../types").IDependencyMatcherValue | undefined;
|
|
@@ -4,4 +4,4 @@ import { ILogger } from '../../logger/types';
|
|
|
4
4
|
/**
|
|
5
5
|
* Sanitize matcher value
|
|
6
6
|
*/
|
|
7
|
-
export declare function sanitize(log: ILogger, matcherTypeID: number, value: string | number | boolean | Array<string | number> | undefined, dataType: string, attributes
|
|
7
|
+
export declare function sanitize(log: ILogger, matcherTypeID: number, value: string | number | boolean | Array<string | number> | undefined, dataType: string, attributes?: SplitIO.Attributes): string | number | boolean | (string | number)[] | IDependencyMatcherValue | undefined;
|
|
@@ -69,6 +69,7 @@ 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
71
|
export declare const USER_CONSENT_NOT_UPDATED = 123;
|
|
72
|
+
export declare const USER_CONSENT_INITIAL = 124;
|
|
72
73
|
export declare const ENGINE_VALUE_INVALID = 200;
|
|
73
74
|
export declare const ENGINE_VALUE_NO_ATTRIBUTES = 201;
|
|
74
75
|
export declare const CLIENT_NO_LISTENER = 202;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IClientFactoryParams } from './types';
|
|
2
1
|
import { SplitIO } from '../types';
|
|
2
|
+
import { ISdkFactoryContext } from '../sdkFactory/types';
|
|
3
3
|
/**
|
|
4
4
|
* Creator of base client with getTreatments and track methods.
|
|
5
5
|
*/
|
|
6
|
-
export declare function clientFactory(params:
|
|
6
|
+
export declare function clientFactory(params: ISdkFactoryContext): SplitIO.IClient | SplitIO.IAsyncClient;
|
|
@@ -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;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SplitIO } from '../types';
|
|
2
|
-
import {
|
|
2
|
+
import { ISdkFactoryContext } from '../sdkFactory/types';
|
|
3
3
|
/**
|
|
4
4
|
* Creates an Sdk client, i.e., a base client with status and destroy interface
|
|
5
5
|
*/
|
|
6
|
-
export declare function sdkClientFactory(params:
|
|
6
|
+
export declare function sdkClientFactory(params: ISdkFactoryContext, isSharedClient?: boolean): SplitIO.IClient | SplitIO.IAsyncClient;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ISdkClientFactoryParams } from './types';
|
|
2
1
|
import { SplitIO } from '../types';
|
|
2
|
+
import { ISdkFactoryContext } from '../sdkFactory/types';
|
|
3
3
|
/**
|
|
4
4
|
* Factory of client method for server-side SDKs (ISDK and IAsyncSDK)
|
|
5
5
|
*/
|
|
6
|
-
export declare function sdkClientMethodFactory(params:
|
|
6
|
+
export declare function sdkClientMethodFactory(params: ISdkFactoryContext): () => SplitIO.IClient | SplitIO.IAsyncClient;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ISdkClientFactoryParams } from './types';
|
|
2
1
|
import { SplitIO } from '../types';
|
|
2
|
+
import { ISdkFactoryContext } from '../sdkFactory/types';
|
|
3
3
|
/**
|
|
4
4
|
* Factory of client method for the client-side API variant where TT is ignored and thus
|
|
5
5
|
* clients don't have a binded TT for the track method.
|
|
6
6
|
*/
|
|
7
|
-
export declare function sdkClientMethodCSFactory(params:
|
|
7
|
+
export declare function sdkClientMethodCSFactory(params: ISdkFactoryContext): (key?: SplitIO.SplitKey) => SplitIO.ICsClient;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ISdkClientFactoryParams } from './types';
|
|
2
1
|
import { SplitIO } from '../types';
|
|
2
|
+
import { ISdkFactoryContext } from '../sdkFactory/types';
|
|
3
3
|
/**
|
|
4
4
|
* Factory of client method for the client-side (browser) variant of the Isomorphic JS SDK,
|
|
5
5
|
* where clients can have a binded TT for the track method, which is provided via the settings
|
|
6
6
|
* (default client) or the client method (shared clients).
|
|
7
7
|
*/
|
|
8
|
-
export declare function sdkClientMethodCSFactory(params:
|
|
8
|
+
export declare function sdkClientMethodCSFactory(params: ISdkFactoryContext): (key?: SplitIO.SplitKey, trafficType?: string) => SplitIO.ICsClient;
|
|
@@ -2,12 +2,21 @@ import { IIntegrationManager, IIntegrationFactoryParams } from '../integrations/
|
|
|
2
2
|
import { ISignalListener } from '../listeners/types';
|
|
3
3
|
import { ILogger } from '../logger/types';
|
|
4
4
|
import { ISdkReadinessManager } from '../readiness/types';
|
|
5
|
-
import { ISdkClientFactoryParams } from '../sdkClient/types';
|
|
6
5
|
import { IFetch, ISplitApi, IEventSourceConstructor } from '../services/types';
|
|
7
6
|
import { IStorageAsync, IStorageSync, ISplitsCacheSync, ISplitsCacheAsync, IStorageFactoryParams } from '../storages/types';
|
|
8
7
|
import { ISyncManager, ISyncManagerFactoryParams } from '../sync/types';
|
|
9
8
|
import { IImpressionObserver } from '../trackers/impressionObserver/types';
|
|
9
|
+
import { IImpressionsTracker, IEventTracker } from '../trackers/types';
|
|
10
10
|
import { SplitIO, ISettings, IEventEmitter } from '../types';
|
|
11
|
+
export interface ISdkFactoryContext {
|
|
12
|
+
storage: IStorageSync | IStorageAsync;
|
|
13
|
+
sdkReadinessManager: ISdkReadinessManager;
|
|
14
|
+
settings: ISettings;
|
|
15
|
+
impressionsTracker: IImpressionsTracker;
|
|
16
|
+
eventTracker: IEventTracker;
|
|
17
|
+
signalListener?: ISignalListener;
|
|
18
|
+
syncManager?: ISyncManager;
|
|
19
|
+
}
|
|
11
20
|
/**
|
|
12
21
|
* Environment related dependencies.
|
|
13
22
|
* These getters are called a fixed number of times per factory instantiation.
|
|
@@ -28,7 +37,7 @@ export interface ISdkFactoryParams {
|
|
|
28
37
|
splitApiFactory?: (settings: ISettings, platform: IPlatform) => ISplitApi;
|
|
29
38
|
syncManagerFactory?: (params: ISyncManagerFactoryParams) => ISyncManager;
|
|
30
39
|
sdkManagerFactory: (log: ILogger, splits: ISplitsCacheSync | ISplitsCacheAsync, sdkReadinessManager: ISdkReadinessManager) => SplitIO.IManager | SplitIO.IAsyncManager;
|
|
31
|
-
sdkClientMethodFactory: (params:
|
|
40
|
+
sdkClientMethodFactory: (params: ISdkFactoryContext) => ({
|
|
32
41
|
(): SplitIO.ICsClient;
|
|
33
42
|
(key: SplitIO.SplitKey, trafficType?: string | undefined): SplitIO.ICsClient;
|
|
34
43
|
} | (() => SplitIO.IClient) | (() => SplitIO.IAsyncClient));
|
|
@@ -36,8 +45,7 @@ export interface ISdkFactoryParams {
|
|
|
36
45
|
settings: ISettings, // Used by BrowserSignalListener
|
|
37
46
|
storage: IStorageSync | IStorageAsync, // Used by BrowserSignalListener
|
|
38
47
|
serviceApi: ISplitApi | undefined) => ISignalListener;
|
|
39
|
-
impressionListener?: SplitIO.IImpressionListener;
|
|
40
48
|
integrationsManagerFactory?: (params: IIntegrationFactoryParams) => IIntegrationManager | undefined;
|
|
41
49
|
impressionsObserverFactory?: () => IImpressionObserver;
|
|
42
|
-
extraProps?: (
|
|
50
|
+
extraProps?: (params: ISdkFactoryContext) => object;
|
|
43
51
|
}
|
|
@@ -20,5 +20,5 @@ export declare class RedisAdapter extends ioredis {
|
|
|
20
20
|
/**
|
|
21
21
|
* Parses the options into what we care about.
|
|
22
22
|
*/
|
|
23
|
-
static _defineOptions({ connectionTimeout, operationTimeout, url, host, port, db, pass }: Record<string, any>): object;
|
|
23
|
+
static _defineOptions({ connectionTimeout, operationTimeout, url, host, port, db, pass, tls }: Record<string, any>): object;
|
|
24
24
|
}
|
|
@@ -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;
|
package/types/types.d.ts
CHANGED
|
@@ -389,7 +389,7 @@ interface IBasicClient extends IStatusInterface {
|
|
|
389
389
|
* @returns {Promise<void>}
|
|
390
390
|
*/
|
|
391
391
|
destroy(): Promise<void>;
|
|
392
|
-
|
|
392
|
+
isClientSide: boolean;
|
|
393
393
|
}
|
|
394
394
|
/**
|
|
395
395
|
* Common definitions between SDK instances for different environments interface.
|
|
@@ -55,7 +55,8 @@ export declare function isIntegerNumber(val: any): boolean;
|
|
|
55
55
|
*/
|
|
56
56
|
export declare function isNaNNumber(val: any): boolean;
|
|
57
57
|
/**
|
|
58
|
-
* Validates if a value is an object
|
|
58
|
+
* Validates if a value is an object created by the Object constructor (plain object).
|
|
59
|
+
* It checks `constructor.name` to avoid false negatives when validating values on a separate VM context, which has its own global built-ins.
|
|
59
60
|
*/
|
|
60
61
|
export declare function isObject(obj: any): boolean;
|
|
61
62
|
/**
|
|
@@ -44,5 +44,12 @@ interface IMapConstructor {
|
|
|
44
44
|
new <K, V>(entries?: readonly (readonly [K, V])[] | null): IMap<K, V>;
|
|
45
45
|
readonly prototype: IMap<any, any>;
|
|
46
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* return the Map constructor to use. If native Map is not available or it doesn't support the required features (e.g., IE11),
|
|
49
|
+
* a ponyfill with minimal features is returned instead.
|
|
50
|
+
*
|
|
51
|
+
* Exported for testing purposes only.
|
|
52
|
+
*/
|
|
53
|
+
export declare function __getMapConstructor(): IMapConstructor;
|
|
47
54
|
export declare const _Map: IMapConstructor;
|
|
48
55
|
export {};
|
|
@@ -13,7 +13,11 @@ export interface ISettingsValidationParams {
|
|
|
13
13
|
} & {
|
|
14
14
|
startup: ISettings['startup'];
|
|
15
15
|
};
|
|
16
|
-
/**
|
|
16
|
+
/** If true, validates core.key */
|
|
17
|
+
acceptKey?: boolean;
|
|
18
|
+
/** If true, validates core.trafficType */
|
|
19
|
+
acceptTT?: boolean;
|
|
20
|
+
/** Define runtime values (`settings.runtime`) */
|
|
17
21
|
runtime: (settings: ISettings) => ISettings['runtime'];
|
|
18
22
|
/** Storage validator (`settings.storage`) */
|
|
19
23
|
storage?: (settings: ISettings) => ISettings['storage'];
|
package/cjs/sdkClient/types.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.userConsentProps = void 0;
|
|
4
|
-
var constants_1 = require("../logger/constants");
|
|
5
|
-
var constants_2 = require("../utils/constants");
|
|
6
|
-
var lang_1 = require("../utils/lang");
|
|
7
|
-
// Extend client-side factory instances with user consent getter/setter
|
|
8
|
-
function userConsentProps(settings, syncManager) {
|
|
9
|
-
var log = settings.log;
|
|
10
|
-
return {
|
|
11
|
-
setUserConsent: function (consent) {
|
|
12
|
-
var _a, _b;
|
|
13
|
-
// validate input param
|
|
14
|
-
if (!(0, lang_1.isBoolean)(consent)) {
|
|
15
|
-
log.warn(constants_1.ERROR_NOT_BOOLEAN, ['setUserConsent']);
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
var newConsentStatus = consent ? constants_2.CONSENT_GRANTED : constants_2.CONSENT_DECLINED;
|
|
19
|
-
if (settings.userConsent !== newConsentStatus) { // @ts-ignore, modify readonly prop
|
|
20
|
-
settings.userConsent = newConsentStatus;
|
|
21
|
-
if (consent)
|
|
22
|
-
(_a = syncManager === null || syncManager === void 0 ? void 0 : syncManager.submitter) === null || _a === void 0 ? void 0 : _a.start(); // resumes submitters if transitioning to GRANTED
|
|
23
|
-
else
|
|
24
|
-
(_b = syncManager === null || syncManager === void 0 ? void 0 : syncManager.submitter) === null || _b === void 0 ? void 0 : _b.stop(); // pauses submitters if transitioning to DECLINED
|
|
25
|
-
log.info(constants_1.USER_CONSENT_UPDATED, [settings.userConsent, newConsentStatus]);
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
log.info(constants_1.USER_CONSENT_NOT_UPDATED, [newConsentStatus]);
|
|
29
|
-
}
|
|
30
|
-
return true;
|
|
31
|
-
},
|
|
32
|
-
getUserConsent: function () {
|
|
33
|
-
return settings.userConsent;
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
exports.userConsentProps = userConsentProps;
|
package/esm/sdkClient/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { ERROR_NOT_BOOLEAN, USER_CONSENT_UPDATED, USER_CONSENT_NOT_UPDATED } from '../logger/constants';
|
|
2
|
-
import { CONSENT_GRANTED, CONSENT_DECLINED } from '../utils/constants';
|
|
3
|
-
import { isBoolean } from '../utils/lang';
|
|
4
|
-
// Extend client-side factory instances with user consent getter/setter
|
|
5
|
-
export function userConsentProps(settings, syncManager) {
|
|
6
|
-
var log = settings.log;
|
|
7
|
-
return {
|
|
8
|
-
setUserConsent: function (consent) {
|
|
9
|
-
var _a, _b;
|
|
10
|
-
// validate input param
|
|
11
|
-
if (!isBoolean(consent)) {
|
|
12
|
-
log.warn(ERROR_NOT_BOOLEAN, ['setUserConsent']);
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
var newConsentStatus = consent ? CONSENT_GRANTED : CONSENT_DECLINED;
|
|
16
|
-
if (settings.userConsent !== newConsentStatus) { // @ts-ignore, modify readonly prop
|
|
17
|
-
settings.userConsent = newConsentStatus;
|
|
18
|
-
if (consent)
|
|
19
|
-
(_a = syncManager === null || syncManager === void 0 ? void 0 : syncManager.submitter) === null || _a === void 0 ? void 0 : _a.start(); // resumes submitters if transitioning to GRANTED
|
|
20
|
-
else
|
|
21
|
-
(_b = syncManager === null || syncManager === void 0 ? void 0 : syncManager.submitter) === null || _b === void 0 ? void 0 : _b.stop(); // pauses submitters if transitioning to DECLINED
|
|
22
|
-
log.info(USER_CONSENT_UPDATED, [settings.userConsent, newConsentStatus]);
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
log.info(USER_CONSENT_NOT_UPDATED, [newConsentStatus]);
|
|
26
|
-
}
|
|
27
|
-
return true;
|
|
28
|
-
},
|
|
29
|
-
getUserConsent: function () {
|
|
30
|
-
return settings.userConsent;
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
}
|
package/src/sdkClient/types.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ISignalListener } from '../listeners/types';
|
|
2
|
-
import { ISdkReadinessManager } from '../readiness/types';
|
|
3
|
-
import { IStorageAsync, IStorageSync } from '../storages/types';
|
|
4
|
-
import { ISyncManager } from '../sync/types';
|
|
5
|
-
import { IEventTracker, IImpressionsTracker } from '../trackers/types';
|
|
6
|
-
import { ISettings } from '../types';
|
|
7
|
-
|
|
8
|
-
export interface IClientFactoryParams {
|
|
9
|
-
storage: IStorageSync | IStorageAsync,
|
|
10
|
-
sdkReadinessManager: ISdkReadinessManager,
|
|
11
|
-
settings: ISettings
|
|
12
|
-
impressionsTracker: IImpressionsTracker,
|
|
13
|
-
eventTracker: IEventTracker,
|
|
14
|
-
// @TODO add time tracker and metricCollectors (a.k.a metricTracker)?
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface ISdkClientFactoryParams extends IClientFactoryParams {
|
|
18
|
-
signalListener?: ISignalListener
|
|
19
|
-
syncManager?: ISyncManager,
|
|
20
|
-
sharedClient?: boolean
|
|
21
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { ERROR_NOT_BOOLEAN, USER_CONSENT_UPDATED, USER_CONSENT_NOT_UPDATED } from '../logger/constants';
|
|
2
|
-
import { ISyncManager } from '../sync/types';
|
|
3
|
-
import { ISettings } from '../types';
|
|
4
|
-
import { CONSENT_GRANTED, CONSENT_DECLINED } from '../utils/constants';
|
|
5
|
-
import { isBoolean } from '../utils/lang';
|
|
6
|
-
|
|
7
|
-
// Extend client-side factory instances with user consent getter/setter
|
|
8
|
-
export function userConsentProps(settings: ISettings, syncManager?: ISyncManager) {
|
|
9
|
-
|
|
10
|
-
const log = settings.log;
|
|
11
|
-
|
|
12
|
-
return {
|
|
13
|
-
setUserConsent(consent: unknown) {
|
|
14
|
-
// validate input param
|
|
15
|
-
if (!isBoolean(consent)) {
|
|
16
|
-
log.warn(ERROR_NOT_BOOLEAN, ['setUserConsent']);
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const newConsentStatus = consent ? CONSENT_GRANTED : CONSENT_DECLINED;
|
|
21
|
-
|
|
22
|
-
if (settings.userConsent !== newConsentStatus) { // @ts-ignore, modify readonly prop
|
|
23
|
-
settings.userConsent = newConsentStatus;
|
|
24
|
-
|
|
25
|
-
if (consent) syncManager?.submitter?.start(); // resumes submitters if transitioning to GRANTED
|
|
26
|
-
else syncManager?.submitter?.stop(); // pauses submitters if transitioning to DECLINED
|
|
27
|
-
|
|
28
|
-
log.info(USER_CONSENT_UPDATED, [settings.userConsent, newConsentStatus]);
|
|
29
|
-
} else {
|
|
30
|
-
log.info(USER_CONSENT_NOT_UPDATED, [newConsentStatus]);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return true;
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
getUserConsent() {
|
|
37
|
-
return settings.userConsent;
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
}
|