Skip to content

Commit

Permalink
Pixfuture Bid Adapter: updated the getUserSyncs method (prebid#7456)
Browse files Browse the repository at this point in the history
* Add files via upload

* Add files via upload

* Update pixfutureBidAdapter.md

* Update pixfutureBidAdapter.md

* Update pixfutureBidAdapter.js

* Update pixfutureBidAdapter_spec.js

* Update pixfutureBidAdapter.js

* Update pixfutureBidAdapter.js

Bug fixing: has been lost "pubext" parameter

* Update pixfutureBidAdapter.js

* Update pixfutureBidAdapter.md

* Update pixfutureBidAdapter.js

* Update pixfutureBidAdapter.js

* Update pixfutureBidAdapter.js

* Update pixfutureBidAdapter.js

Removing the trailing spaces in lines: 168 and 172

* Add files via upload

* Update pixfutureBidAdapter.js

removing trilling spaces in the lines: 168,172,178

* Update pixfutureBidAdapter.md

* Update pixfutureBidAdapter.md

* Update pixfutureBidAdapter.js

* Update pixfutureBidAdapter.js

* Update pixfutureBidAdapter.js

* Update pixfutureBidAdapter.js

* Pixfuture Bid Adapter: updated the getUserSyncs method and changed utils import by separated methods instead whole utils

updated the getUserSyncs method and changed utils import by separated methods instead whole utils

* Fixed utls import

Fixed utls import

* Bugfixing remove non used fill import

Bugfixing remove non used fill import

* Update pixfutureBidAdapter.js

* resolving conflicts

* multiline fix

Co-authored-by: polischukPix <o.polishchuk@pixfuture.com>
Co-authored-by: Alexandr <i.polischukalexandr@gmail.com>
  • Loading branch information
3 people authored and Chris Pabst committed Jan 10, 2022
1 parent f4ceeaf commit 7e28b5c
Show file tree
Hide file tree
Showing 2 changed files with 151 additions and 4 deletions.
28 changes: 24 additions & 4 deletions modules/pixfutureBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { convertCamelToUnderscore, isArray, isNumber, isPlainObject, deepAccess, isEmpty, transformBidderParamKeywords, isFn } from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { getStorageManager } from '../src/storageManager.js';
import { BANNER } from '../src/mediaTypes.js';
import { config } from '../src/config.js';
import includes from 'core-js-pure/features/array/includes.js';
import { convertCamelToUnderscore, isArray, isNumber, isPlainObject, deepAccess, isEmpty, transformBidderParamKeywords, isFn } from '../src/utils.js';
import { auctionManager } from '../src/auctionManager.js';
import find from 'core-js-pure/features/array/find.js';

Expand All @@ -12,7 +12,7 @@ const storageManager = getStorageManager();
const USER_PARAMS = ['age', 'externalUid', 'segments', 'gender', 'dnt', 'language'];
export const spec = {
code: 'pixfuture',
hostname: 'https://prebid-js.pixfuture.com',
hostname: 'https://gosrv.pixfuture.com',

getHostname() {
let ret = this.hostname;
Expand Down Expand Up @@ -77,7 +77,7 @@ export const spec = {
};

if (bidderRequest && bidderRequest.uspConsent) {
payload.us_privacy = bidderRequest.uspConsent
payload.us_privacy = bidderRequest.uspConsent;
}

if (bidderRequest && bidderRequest.refererInfo) {
Expand Down Expand Up @@ -112,7 +112,7 @@ export const spec = {
}

const ret = {
url: `${hostname}/`,
url: `${hostname}/pixservices`,
method: 'POST',
options: {withCredentials: false},
data: {
Expand Down Expand Up @@ -153,6 +153,16 @@ export const spec = {

return bids;
},
getUserSyncs: function (syncOptions, bid, gdprConsent) {
var pixid = '';
if (typeof bid[0] === 'undefined' || bid[0] === null) { pixid = '0'; } else { pixid = bid[0].body.pix_id; }
if (syncOptions.iframeEnabled && hasPurpose1Consent({gdprConsent})) {
return [{
type: 'iframe',
url: 'https://gosrv.pixfuture.com/cookiesync?adsync=' + gdprConsent.consentString + '&pixid=' + pixid + '&gdprconcent=' + gdprConsent.gdprApplies
}];
}
}
};

function newBid(serverBid, rtbBid, placementId, uuid) {
Expand All @@ -179,6 +189,16 @@ function newBid(serverBid, rtbBid, placementId, uuid) {
return bid;
}

function hasPurpose1Consent(bidderRequest) {
let result = true;
if (bidderRequest && bidderRequest.gdprConsent) {
if (bidderRequest.gdprConsent.gdprApplies && bidderRequest.gdprConsent.apiVersion === 2) {
result = !!(deepAccess(bidderRequest.gdprConsent, 'vendorData.purpose.consents.1') === true);
}
}
return result;
}

// Functions related optional parameters
function bidToTag(bid) {
const tag = {};
Expand Down
127 changes: 127 additions & 0 deletions modules/pixfutureBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,130 @@ var adUnits = [{
"pix_id": "Abc123"
}];
```

# Test Example
...
<html>

<head>
<link rel="icon" type="image/png" href="/favicon.ico">
<script async src="//www.googletagservices.com/tag/js/gpt.js"></script>
<script async src="https://cdn.pixfuture.com/pixfuture_prebidjs/prebid.js"></script>
<script>
var div_1_sizes = [
[300, 250],
[300, 600]
];
var div_2_sizes = [
[728, 90],
[970, 250]
];
var PREBID_TIMEOUT = 1000;
var FAILSAFE_TIMEOUT = 3000;

var adUnits = [
{
code: '/19968336/header-bid-tag-0',
mediaTypes: {
banner: {
sizes: div_1_sizes
}
},
bids: [{
bidder: 'pixfuture',
params: {
"pix_id": "777"
}
}]
},
{
code: '/19968336/header-bid-tag-1',
mediaTypes: {
banner: {
sizes: div_2_sizes
}
},
bids: [{
bidder: 'appnexus',
params: {
placementId: 13144370
}
}]
}
];

// ======== DO NOT EDIT BELOW THIS LINE =========== //
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
googletag.cmd.push(function() {
googletag.pubads().disableInitialLoad();
});

var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];

pbjs.que.push(function() {
pbjs.addAdUnits(adUnits);
pbjs.requestBids({
bidsBackHandler: initAdserver,
timeout: PREBID_TIMEOUT
});
});

function initAdserver() {
if (pbjs.initAdserverSet) return;
pbjs.initAdserverSet = true;
googletag.cmd.push(function() {
pbjs.que.push(function() {
pbjs.setTargetingForGPTAsync();
googletag.pubads().refresh();
});
});
}
// in case PBJS doesn't load
setTimeout(function() {
initAdserver();
}, FAILSAFE_TIMEOUT);

googletag.cmd.push(function() {
googletag.defineSlot('/19968336/header-bid-tag-0', div_1_sizes, 'div-1').addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
googletag.cmd.push(function() {
googletag.defineSlot('/19968336/header-bid-tag-1', div_2_sizes, 'div-2').addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});

</script>

</head>

<body>
<h2>Basic Prebid.js Example</h2>
<h5>Div-1</h5>
<div id='div-1'>
<script type='text/javascript'>
googletag.cmd.push(function() {
googletag.display('div-1');
});

</script>
</div>

<br>

<h5>Div-2</h5>
<div id='div-2'>
<script type='text/javascript'>
googletag.cmd.push(function() {
googletag.display('div-2');
});

</script>
</div>

</body>

</html>

0 comments on commit 7e28b5c

Please sign in to comment.