Skip to content

Commit

Permalink
address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bwschmidt committed May 11, 2022
1 parent bd63aa4 commit 95a704b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 12 deletions.
4 changes: 2 additions & 2 deletions modules/pafIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
* @returns {IdResponse|undefined}
*/
getId(config, consentData) {
if (window.PAF) {
return {id: window.PAF.getIdsAndPreferences()};
if (window.PAF && window.PAF.getIdsAndPreferences()) {
return {id: window.PAF.getIdsAndPreferences()};
} else {
return undefined;
}
Expand Down
18 changes: 11 additions & 7 deletions modules/pafRtdProvider.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import { submodule } from '../src/hook.js';
import { mergeDeep, isPlainObject, logMessage, deepSetValue, generateUUID } from '../src/utils.js';
import { mergeDeep, isPlainObject, logError, logMessage, deepSetValue, generateUUID } from '../src/utils.js';
import { getGlobal } from '../src/prebidGlobal.js';
import {config} from '../src/config.js';

Expand All @@ -14,14 +14,14 @@ const SUBMODULE_NAME = 'paf';
* @param {Object} userConsent
*/
function getBidRequestData(reqBidsConfigObj, onDone, rtdConfig, userConsent) {
logMessage('DEBUG(paf):', rtdConfig);
let idsAndPreferences;
const adUnits = (reqBidsConfigObj.adUnits || getGlobal().adUnits);

if (rtdConfig.params && rtdConfig.params.proxyHostName && window.PAF) {
idsAndPreferences = window.PAF.getIdsAndPreferences();
if (!idsAndPreferences) {
onDone();
logMessage(SUBMODULE_NAME, 'No id and preferences. Not creating Seed.');
return;
}

Expand All @@ -32,7 +32,6 @@ function getBidRequestData(reqBidsConfigObj, onDone, rtdConfig, userConsent) {
deepSetValue(adUnits[i], `ortb2Imp.ext.data.paf.transaction_id`, uuid)
}

logMessage('DEBUG(idsAndPreferences):', idsAndPreferences);
window.PAF.createSeed({proxyHostName: rtdConfig.params.proxyHostName, callback: function (seed) {setData(seed, rtdConfig, onDone);}}, transaction_ids)
} else {
onDone();
Expand All @@ -58,14 +57,19 @@ function getBidRequestData(reqBidsConfigObj, onDone, rtdConfig, userConsent) {
}

function setData(seed, rtdConfig, onDone) {
logMessage('DEBUG(seed):', seed);
if (!seed) {
logError(SUBMODULE_NAME, 'Could not createSeed');
onDone()
return;
}
logMessage(SUBMODULE_NAME, 'Created Seed:', seed);
const pafOrtb2 = {
ortb2: {
user: {
ext: {
paf: {
transmission: {
seed: seed
seed
}
}
}
Expand All @@ -75,7 +79,7 @@ function setData(seed, rtdConfig, onDone) {

if (rtdConfig.params && rtdConfig.params.bidders) {
let bidderConfig = config.getBidderConfig();
logMessage(`set ortb2 for: ${rtdConfig.params.bidders}`, pafOrtb2);
logMessage(SUBMODULE_NAME, `set ortb2 for: ${rtdConfig.params.bidders}`, pafOrtb2);
rtdConfig.params.bidders.forEach(bidder => {
let bidderOptions = {};
if (isPlainObject(bidderConfig[bidder])) {
Expand All @@ -89,7 +93,7 @@ function setData(seed, rtdConfig, onDone) {
});
} else {
let ortb2 = config.getConfig('ortb2') || {};
logMessage('DEBUG(set ortb2):', pafOrtb2);
logMessage(SUBMODULE_NAME, 'set ortb2:', pafOrtb2);
config.setConfig({ortb2: mergeLazy(ortb2, pafOrtb2.ortb2)});
}
onDone();
Expand Down
7 changes: 4 additions & 3 deletions modules/pafRtdProvider.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Both modules are required. This module will pass transmission requests to your p
while the pafIdSystem will pass the pafData.

Background information:
https://github.com/prebid/addressability-framework
https://github.com/prebid/paf-mvp-implementation
- [prebid/addressability-framework](https://github.com/prebid/addressability-framework)
- [prebid/paf-mvp-implementation](https://github.com/prebid/paf-mvp-implementation)



Expand Down Expand Up @@ -50,7 +50,7 @@ pbjs.setConfig(
| name | String | Real time data module name | Always 'paf' |
| waitForIt | Boolean | Required to ensure that the auction is delayed until prefetch is complete | Optional. Defaults to false |
| params | Object | | |
| params.proxyHostName | String | URL of the PAF Proxy which will generate seeds. | Required |
| params.proxyHostName | String | servername of the PAF Proxy which will generate seeds. | Required |
| params.bidders | Array | List of bidders to restrict the data to. | Optional |

### Data for bidders
Expand Down Expand Up @@ -78,6 +78,7 @@ The following is an example of the format of the data:
}
}
}
```


```json
Expand Down
19 changes: 19 additions & 0 deletions modules/userId/eids.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,25 @@ export const USER_IDS_CONFIG = {
return data.envelope;
}
},

'pafData': {
getValue: function(data) {
return data.identifiers[0].value;
},
source: 'paf',
atype: 1,
getEidExt: function(data) {
return {preferences: data.preferences};
},
getUidExt: function(data) {
const id = data.identifiers[0];
return {
version: id.version,
type: id.type,
source: id.source
};
}
}
};

// this function will create an eid object for the given UserId sub-module
Expand Down

0 comments on commit 95a704b

Please sign in to comment.