forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
consentManagementTcf: add flag to set dsarequired (prebid#11824)
* consentManagementTcf: add flag to set dsarequired * Fix duplication
- Loading branch information
Showing
4 changed files
with
71 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import {timedAuctionHook} from '../../src/utils/perfMetrics.js'; | ||
import {logError, logInfo, logWarn} from '../../src/utils.js'; | ||
|
||
export function consentManagementHook(name, getConsent, loadConsentData) { | ||
function loadIfMissing(cb) { | ||
if (getConsent()) { | ||
logInfo('User consent information already known. Pulling internally stored information...'); | ||
// eslint-disable-next-line standard/no-callback-literal | ||
cb(false); | ||
} else { | ||
loadConsentData(cb); | ||
} | ||
} | ||
|
||
return timedAuctionHook(name, function requestBidsHook(fn, reqBidsConfigObj) { | ||
loadIfMissing(function (shouldCancelAuction, errMsg, ...extraArgs) { | ||
if (errMsg) { | ||
let log = logWarn; | ||
if (shouldCancelAuction) { | ||
log = logError; | ||
errMsg = `${errMsg} Canceling auction as per consentManagement config.`; | ||
} | ||
log(errMsg, ...extraArgs); | ||
} | ||
|
||
if (shouldCancelAuction) { | ||
fn.stopTiming(); | ||
if (typeof reqBidsConfigObj.bidsBackHandler === 'function') { | ||
reqBidsConfigObj.bidsBackHandler(); | ||
} else { | ||
logError('Error executing bidsBackHandler'); | ||
} | ||
} else { | ||
fn.call(this, reqBidsConfigObj); | ||
} | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters