All files adobeDMP.js

85.71% Statements 12/14
75% Branches 6/8
100% Functions 5/5
100% Lines 11/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36              3x 2x 2x 2x   2x 2x 2x 2x                   3x     30x         2x    
/* Temporary internal state that avoids blocking tracking until getting DMP */
let isDmpReady
 
/**
 * Check if DMP is consented by the user using boros API
 * @return {Promise<boolean>}
 */
export const checkIsDMPReady = () => {
  return new Promise(resolve => {
    Iif (typeof window === 'undefined') return resolve()
    Iif (window.__borosTcf === undefined) return resolve()
 
    window.__borosTcf.push(api => {
      api('isDmpAccepted', ({success, value}) => {
        isDmpReady = success && value
        return resolve(isDmpReady)
      })
    })
  })
}
 
/**
 * Get if DMP is consented value
 * @return {Promise<boolean>}
 */
export const getIsDMPReady = () => {
  // if we have some value defined for isDmpReady
  // we returning it and don't check anything else
  if (isDmpReady !== undefined) return isDmpReady
 
  // if we don't have any value, we must check async
  // but as we don't want to block anything yet
  // we assume we don't have the consent and return false
  checkIsDMPReady()
}