• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

prebid / Prebid.js / 19940596084

04 Dec 2025 06:57PM UTC coverage: 96.209%. Remained the same
19940596084

Pull #14238

github

feaad1
dgirardi
add configuration options for keyword lookup, include both meta and json by default
Pull Request #14238: Core: Add support to also use keywords from application/ld+json to 1p enrichment

53731 of 65825 branches covered (81.63%)

65 of 66 new or added lines in 2 files covered. (98.48%)

53 existing lines in 9 files now uncovered.

205149 of 213233 relevant lines covered (96.21%)

72.07 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.46
/modules/permutiveIdentityManagerIdSystem.js
1
import {MODULE_TYPE_UID} from '../src/activities/modules.js'
1✔
2
import {submodule} from '../src/hook.js'
3
import {getStorageManager} from '../src/storageManager.js'
4
import {deepAccess, prefixLog, safeJSONParse} from '../src/utils.js'
5
import {hasPurposeConsent} from '../libraries/permutiveUtils/index.js'
6
import {VENDORLESS_GVLID} from "../src/consentHandler.js";
7
/**
8
 * @typedef {import('../modules/userId/index.js').Submodule} Submodule
9
 * @typedef {import('../modules/userId/index.js').SubmoduleConfig} SubmoduleConfig
10
 * @typedef {import('../modules/userId/index.js').ConsentData} ConsentData
11
 * @typedef {import('../modules/userId/index.js').IdResponse} IdResponse
12
 */
13

14
const MODULE_NAME = 'permutiveIdentityManagerId'
1✔
15
const PERMUTIVE_ID_DATA_STORAGE_KEY = 'permutive-prebid-id'
1✔
16

17
const ID5_DOMAIN = 'id5-sync.com'
1✔
18
const LIVERAMP_DOMAIN = 'liveramp.com'
1✔
19
const UID_DOMAIN = 'uidapi.com'
1✔
20

21
const PRIMARY_IDS = ['id5id', 'idl_env', 'uid2']
1✔
22

23
export const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME})
1✔
24

25
const logger = prefixLog('[PermutiveID]')
1✔
26

27
const readFromSdkLocalStorage = () => {
1✔
28
  const data = safeJSONParse(storage.getDataFromLocalStorage(PERMUTIVE_ID_DATA_STORAGE_KEY))
5✔
29
  const id = {}
5✔
30
  if (data && typeof data === 'object' && 'providers' in data && typeof data.providers === 'object') {
5✔
31
    const now = Date.now()
3✔
32
    for (const [idName, value] of Object.entries(data.providers)) {
3✔
33
      if (PRIMARY_IDS.includes(idName) && value.userId) {
4✔
34
        if (!value.expiryTime || value.expiryTime > now) {
3✔
35
          id[idName] = value.userId
3✔
36
        }
37
      }
38
    }
39
  }
40
  return id
5✔
41
}
42

43
/**
44
 * Catch and log errors
45
 * @param {function} fn - Function to safely evaluate
46
 */
47
function makeSafe (fn) {
48
  try {
2✔
49
    return fn()
2✔
50
  } catch (e) {
UNCOV
51
    logger.logError(e)
×
52
  }
53
}
54

55
const waitAndRetrieveFromSdk = (timeoutMs) =>
1✔
56
  new Promise(
1✔
57
    resolve => {
58
      const fallback = setTimeout(() => {
1✔
UNCOV
59
        logger.logInfo('timeout expired waiting for SDK - attempting read from local storage again')
×
60
        resolve(readFromSdkLocalStorage())
×
61
      }, timeoutMs)
62
      return window?.permutive?.ready(() => makeSafe(() => {
1!
63
        logger.logInfo('Permutive SDK is ready')
1✔
64
        const onReady = makeSafe(() => window.permutive.addons.identity_manager.prebid.onReady)
1✔
65
        if (typeof onReady === 'function') {
1!
66
          onReady((ids) => {
1✔
67
            logger.logInfo('Permutive SDK has provided ids')
1✔
68
            resolve(ids)
1✔
69
            clearTimeout(fallback)
1✔
70
          })
71
        } else {
UNCOV
72
          logger.logError('Permutive SDK initialised but identity manager prebid api not present')
×
73
        }
74
      }))
75
    }
76
  )
77

78
/** @type {Submodule} */
79
export const permutiveIdentityManagerIdSubmodule = {
1✔
80
  /**
81
   * used to link submodule with config
82
   * @type {string}
83
   */
84
  name: MODULE_NAME,
85
  gvlid: VENDORLESS_GVLID,
86

87
  disclosureURL: "https://assets.permutive.app/tcf/tcf.json",
88

89
  /**
90
   * decode the stored id value for passing to bid requests
91
   * @function decode
92
   * @param {(Object|string)} value
93
   * @param {SubmoduleConfig|undefined} config
94
   * @returns {(Object|undefined)}
95
   */
96
  decode(value, config) {
97
    return value
1✔
98
  },
99

100
  /**
101
   * performs action to obtain id and return a value in the callback's response argument
102
   * @function getId
103
   * @param {SubmoduleConfig} submoduleConfig
104
   * @param {ConsentData} consentData
105
   * @param {(Object|undefined)} cacheIdObj
106
   * @returns {IdResponse|undefined}
107
   */
108
  getId(submoduleConfig, consentData, cacheIdObj) {
109
    const enforceVendorConsent = deepAccess(submoduleConfig, 'params.enforceVendorConsent')
6✔
110
    if (!hasPurposeConsent(consentData, [1], enforceVendorConsent)) {
6✔
111
      logger.logInfo('GDPR purpose 1 consent not satisfied for Permutive Identity Manager')
1✔
112
      return
1✔
113
    }
114

115
    const id = readFromSdkLocalStorage()
5✔
116
    if (Object.entries(id).length > 0) {
5✔
117
      logger.logInfo('found id in sdk storage')
3✔
118
      return { id }
3✔
119
    } else if ('params' in submoduleConfig && submoduleConfig.params.ajaxTimeout) {
2✔
120
      logger.logInfo('failed to find id in sdk storage - waiting for sdk')
1✔
121
      // Is ajaxTimeout an appropriate timeout to use here?
122
      return { callback: (done) => waitAndRetrieveFromSdk(submoduleConfig.params.ajaxTimeout).then(done) }
1✔
123
    } else {
124
      logger.logInfo('failed to find id in sdk storage and no wait time specified')
1✔
125
    }
126
  },
127

128
  primaryIds: PRIMARY_IDS,
129

130
  eids: {
131
    'id5id': {
132
      getValue: function (data) {
UNCOV
133
        return data.uid
×
134
      },
135
      source: ID5_DOMAIN,
136
      atype: 1,
137
      getUidExt: function (data) {
UNCOV
138
        if (data.ext) {
×
UNCOV
139
          return data.ext
×
140
        }
141
      }
142
    },
143
    'idl_env': {
144
      source: LIVERAMP_DOMAIN,
145
      atype: 3,
146
    },
147
    'uid2': {
148
      source: UID_DOMAIN,
149
      atype: 3,
150
      getValue: function(data) {
151
        return data.id
×
152
      },
153
      getUidExt: function(data) {
UNCOV
154
        if (data.ext) {
×
UNCOV
155
          return data.ext
×
156
        }
157
      }
158
    }
159
  }
160
}
161

162
submodule('userId', permutiveIdentityManagerIdSubmodule)
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc