Skip to content

Commit ceeb09b

Browse files
committed
added error logging for invalid privacy flags
1 parent 7e8885b commit ceeb09b

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

src/privacyManager.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { SDKLoggerApi } from './sdkRuntimeModels';
2+
import { isBoolean } from './utils';
3+
24

35
/**
46
* Privacy flags control SDK behavior based on user consent preferences for Rokt integration.
@@ -54,14 +56,18 @@ export default class PrivacyManager implements IPrivacyManager {
5456

5557
const { noFunctional, noTargeting } = flags;
5658

57-
if (typeof noFunctional === 'boolean') {
59+
if (isBoolean(noFunctional)) {
5860
this.privacyFlags.noFunctional = noFunctional;
5961
logger?.verbose(`PrivacyManager: noFunctional set to ${noFunctional}`);
62+
} else if (noFunctional !== undefined) {
63+
logger?.error('PrivacyManager: noFunctional must be a boolean');
6064
}
61-
62-
if (typeof noTargeting === 'boolean') {
65+
66+
if (isBoolean(noTargeting)) {
6367
this.privacyFlags.noTargeting = noTargeting;
6468
logger?.verbose(`PrivacyManager: noTargeting set to ${noTargeting}`);
69+
} else if (noTargeting !== undefined) {
70+
logger?.error('PrivacyManager: noTargeting must be a boolean');
6571
}
6672
}
6773

src/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ export {
461461
toDataPlanSlug,
462462
isString,
463463
isNumber,
464+
isBoolean,
464465
isFunction,
465466
isDataPlanSlug,
466467
isEmpty,

0 commit comments

Comments
 (0)