Skip to content

Commit

Permalink
Merge branch 'master' into upgrade-webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
dgirardi committed Mar 9, 2022
2 parents 22a7b0c + 4e0bd23 commit 9f42bea
Show file tree
Hide file tree
Showing 15 changed files with 622 additions and 135 deletions.
6 changes: 5 additions & 1 deletion integrationExamples/gpt/adloox.html
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,11 @@
},
rubicon: {
singleRequest: true
}
},
// RTD module honors pageUrl for referrer detection and
// the analytics module uses this for the 'pageurl' macro
// N.B. set this to a non-example.com URL to see the video
//pageUrl: 'https://yourdomain.com/some/path/to/content.html'
});
pbjs.enableAnalytics({
provider: 'adloox',
Expand Down
5 changes: 5 additions & 0 deletions modules/adlooxAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {auctionManager} from '../src/auctionManager.js';
import {AUCTION_COMPLETED} from '../src/auction.js';
import CONSTANTS from '../src/constants.json';
import {find} from '../src/polyfill.js';
import {getRefererInfo} from '../src/refererDetection.js';
import {
deepAccess,
getGptSlotInfoForAdUnitCode,
Expand Down Expand Up @@ -58,6 +59,10 @@ MACRO['targetelt'] = function(b, c) {
MACRO['creatype'] = function(b, c) {
return b.mediaType == 'video' ? ADLOOX_MEDIATYPE.VIDEO : ADLOOX_MEDIATYPE.DISPLAY;
};
MACRO['pageurl'] = function(b, c) {
const refererInfo = getRefererInfo();
return (refererInfo.canonicalUrl || refererInfo.referer || '').substr(0, 300).split(/[?#]/)[0];
};
MACRO['pbadslot'] = function(b, c) {
const adUnit = find(auctionManager.getAdUnits(), a => b.adUnitCode === a.code);
return deepAccess(adUnit, 'ortb2Imp.ext.data.pbadslot') || getGptSlotInfoForAdUnitCode(b.adUnitCode).gptSlot || b.adUnitCode;
Expand Down
1 change: 1 addition & 0 deletions modules/adlooxAnalyticsAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ The following macros are available

* `%%pbadslot%%`: [Prebid Ad Slot](https://docs.prebid.org/features/pbAdSlot.html) returns [`AdUnit.code`](https://docs.prebid.org/features/pbAdSlot.html) if set otherwise returns [`AdUnit.code`](https://docs.prebid.org/dev-docs/adunit-reference.html#adunit)
* it is recommended you read the [Prebid Ad Slot section in the Adloox RTD Provider documentation](./adlooxRtdProvider.md#prebid-ad-slot)
* `%%pageurl%%`: [`canonicalUrl`](https://docs.prebid.org/dev-docs/publisher-api-reference/setConfig.html#setConfig-Page-URL) from the [`refererInfo` object](https://docs.prebid.org/dev-docs/bidder-adaptor.html#referrers) otherwise uses `referer`

### Functions

Expand Down
4 changes: 3 additions & 1 deletion modules/adlooxRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {config as _config} from '../src/config.js';
import {submodule} from '../src/hook.js';
import {ajax} from '../src/ajax.js';
import {getGlobal} from '../src/prebidGlobal.js';
import {getRefererInfo} from '../src/refererDetection.js';
import {
_each,
deepAccess,
Expand Down Expand Up @@ -297,6 +298,7 @@ function getBidRequestData(reqBidsConfigObj, callback, config, userConsent) {
}
}

const refererInfo = getRefererInfo();
const args = [
[ 'v', `pbjs-${getGlobal().version}` ],
[ 'c', config.params.clientid ],
Expand All @@ -305,7 +307,7 @@ function getBidRequestData(reqBidsConfigObj, callback, config, userConsent) {
[ 'imp', config.params.imps ],
[ 'fc_ip', config.params.freqcap_ip ],
[ 'fc_ipua', config.params.freqcap_ipua ],
[ 'pn', document.location.pathname ]
[ 'pn', (refererInfo.canonicalUrl || refererInfo.referer || '').substr(0, 300).split(/[?#]/)[0] ]
];

if (!adUnits.length) {
Expand Down
74 changes: 74 additions & 0 deletions modules/adrinoBidAdapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {triggerPixel} from '../src/utils.js';
import {NATIVE} from '../src/mediaTypes.js';

const BIDDER_CODE = 'adrino';
const REQUEST_METHOD = 'POST';
const BIDDER_HOST = 'https://prd-prebid-bidder.adrino.io';
const GVLID = 1072;

export const spec = {
code: BIDDER_CODE,
gvlid: GVLID,
supportedMediaTypes: [NATIVE],

isBidRequestValid: function (bid) {
return !!(bid.bidId) &&
!!(bid.params) &&
!!(bid.params.hash) &&
(typeof bid.params.hash === 'string') &&
!!(bid.mediaTypes) &&
Object.keys(bid.mediaTypes).includes(NATIVE) &&
(bid.bidder === BIDDER_CODE);
},

buildRequests: function (validBidRequests, bidderRequest) {
const bidRequests = [];

for (let i = 0; i < validBidRequests.length; i++) {
let requestData = {
bidId: validBidRequests[i].bidId,
nativeParams: validBidRequests[i].nativeParams,
placementHash: validBidRequests[i].params.hash,
referer: bidderRequest.refererInfo.referer,
userAgent: navigator.userAgent,
}

if (bidderRequest && bidderRequest.gdprConsent) {
requestData.gdprConsent = {
consentString: bidderRequest.gdprConsent.consentString,
consentRequired: bidderRequest.gdprConsent.gdprApplies
}
}

bidRequests.push({
method: REQUEST_METHOD,
url: BIDDER_HOST + '/bidder/bid/',
data: requestData,
options: {
contentType: 'application/json',
withCredentials: false,
}
});
}

return bidRequests;
},

interpretResponse: function (serverResponse, bidRequest) {
const response = serverResponse.body;
const bidResponses = [];
if (!response.noAd) {
bidResponses.push(response);
}
return bidResponses;
},

onBidWon: function (bid) {
if (bid['requestId']) {
triggerPixel(BIDDER_HOST + '/bidder/won/' + bid['requestId']);
}
}
};

registerBidder(spec);
45 changes: 45 additions & 0 deletions modules/adrinoBidAdapter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Overview

```
Module Name: Adrino Bidder Adapter
Module Type: Bidder Adapter
Maintainer: dev@adrino.pl
```

# Description

Module connects to Adrino bidder to fetch bids. Only native format is supported.

# Test Parameters

```
var adUnits = [
code: '/12345678/prebid_native_example_1',
mediaTypes: {
native: {
image: {
required: true,
sizes: [[300, 210],[300,150],[140,100]]
},
title: {
required: true
},
sponsoredBy: {
required: false
},
body: {
required: false
},
icon: {
required: false
}
}
},
bids: [{
bidder: 'adrino',
params: {
hash: 'abcdef123456'
}
}]
];
```
5 changes: 4 additions & 1 deletion modules/consentManagement.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ export function requestBidsHook(fn, reqBidsConfigObj) {

if (!includes(Object.keys(cmpCallMap), userCMP)) {
logWarn(`CMP framework (${userCMP}) is not a supported framework. Aborting consentManagement module and resuming auction.`);
gdprDataHandler.setConsentData(null);
return hookConfig.nextFn.apply(hookConfig.context, hookConfig.args);
}

Expand Down Expand Up @@ -450,6 +451,7 @@ function exitModule(errMsg, hookConfig, extraArgs) {
nextFn.apply(context, args);
} else {
logError(errMsg + ' Canceling auction as per consentManagement config.', extraArgs);
gdprDataHandler.setConsentData(null);
if (typeof hookConfig.bidsBackHandler === 'function') {
hookConfig.bidsBackHandler();
} else {
Expand All @@ -469,7 +471,7 @@ export function resetConsentData() {
consentData = undefined;
userCMP = undefined;
cmpVersion = 0;
gdprDataHandler.setConsentData(null);
gdprDataHandler.reset();
}

/**
Expand Down Expand Up @@ -507,6 +509,7 @@ export function setConsentConfig(config) {
gdprScope = config.defaultGdprScope === true;

logInfo('consentManagement module has been activated...');
gdprDataHandler.enable();

if (userCMP === 'static') {
if (isPlainObject(config.consentData)) {
Expand Down
5 changes: 4 additions & 1 deletion modules/consentManagementUsp.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export function requestBidsHook(fn, reqBidsConfigObj) {

if (!uspCallMap[consentAPI]) {
logWarn(`USP framework (${consentAPI}) is not a supported framework. Aborting consentManagement module and resuming auction.`);
uspDataHandler.setConsentData(null);
return hookConfig.nextFn.apply(hookConfig.context, hookConfig.args);
}

Expand Down Expand Up @@ -276,6 +277,7 @@ function exitModule(errMsg, hookConfig, extraArgs) {

if (errMsg) {
logWarn(errMsg + ' Resuming auction without consent data as per consentManagement config.', extraArgs);
uspDataHandler.setConsentData(null) // let core know that no consent data is available
}
nextFn.apply(context, args);
}
Expand All @@ -287,7 +289,7 @@ function exitModule(errMsg, hookConfig, extraArgs) {
export function resetConsentData() {
consentData = undefined;
consentAPI = undefined;
uspDataHandler.setConsentData(null);
uspDataHandler.reset();
}

/**
Expand Down Expand Up @@ -315,6 +317,7 @@ export function setConsentConfig(config) {
}

logInfo('USPAPI consentManagement module has been activated...');
uspDataHandler.enable();

if (consentAPI === 'static') {
if (isPlainObject(config.consentData) && isPlainObject(config.consentData.getUSPData)) {
Expand Down
Loading

0 comments on commit 9f42bea

Please sign in to comment.