@splitsoftware/splitio-commons 1.2.1-rc.9 → 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/sdkClient.js +3 -3
- package/cjs/sdkClient/sdkClientMethodCS.js +3 -5
- package/cjs/sdkClient/sdkClientMethodCSWithTT.js +3 -5
- package/cjs/sdkFactory/index.js +3 -2
- package/cjs/sync/syncManagerOnline.js +1 -1
- package/cjs/utils/inputValidation/attributes.js +1 -1
- package/cjs/utils/lang/index.js +4 -2
- package/cjs/utils/settingsValidation/index.js +8 -6
- 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/sdkClient.js +3 -3
- package/esm/sdkClient/sdkClientMethodCS.js +3 -5
- package/esm/sdkClient/sdkClientMethodCSWithTT.js +3 -5
- package/esm/sdkFactory/index.js +3 -2
- package/esm/sync/syncManagerOnline.js +1 -1
- package/esm/utils/inputValidation/attributes.js +1 -1
- package/esm/utils/lang/index.js +4 -2
- package/esm/utils/settingsValidation/index.js +8 -6
- 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/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 +2 -3
- package/src/sdkClient/sdkClient.ts +4 -4
- package/src/sdkClient/sdkClientMethod.ts +2 -2
- package/src/sdkClient/sdkClientMethodCS.ts +4 -5
- package/src/sdkClient/sdkClientMethodCSWithTT.ts +4 -5
- package/src/sdkFactory/index.ts +3 -2
- package/src/sdkFactory/types.ts +13 -3
- package/src/sync/syncManagerOnline.ts +1 -1
- package/src/utils/inputValidation/attributes.ts +1 -2
- package/src/utils/lang/index.ts +7 -3
- package/src/utils/settingsValidation/index.ts +8 -6
- package/src/utils/settingsValidation/types.ts +4 -2
- 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/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 -3
- package/types/utils/lang/index.d.ts +2 -1
- package/types/utils/settingsValidation/types.d.ts +4 -2
- 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
|
@@ -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
|
-
}
|