Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AdTelligent Bid Adapter: remove onefiftytwo alias #10025

Merged
merged 8 commits into from
Jun 1, 2023
29 changes: 20 additions & 9 deletions integrationExamples/gpt/growthcode.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
<script async src="../../build/dev/prebid.js"></script>
<script async src="https://www.googletagservices.com/tag/js/gpt.js"></script>
<script>
var FAILSAFE_TIMEOUT = 3300;
var PREBID_TIMEOUT = 1000;
var FAILSAFE_TIMEOUT = 33000;
var PREBID_TIMEOUT = 10000;

var adUnits = [{
debugging: {
enabled: true
},
code: 'div-gpt-ad-1460505748561-0',
mediaTypes: {
banner: {
Expand All @@ -23,6 +26,11 @@
params: {
placementId: 13144370
}
},{
bidder: 'criteo',
params: {
zoneId: 497747
},
}],
}];

Expand Down Expand Up @@ -67,12 +75,15 @@
pbjs.setConfig({
debugging: {
enabled: true,
bids: [{
bidder: 'appnexus',
adUnitCode: '/19968336/header-bid-tag-0',
cpm: 1.5,
adId: '111111',
ad: '<html><body><img src="https://files.prebid.org/creatives/prebid300x250.png"></body></html>'
},
realTimeData: {
auctionDelay: 1000,
dataProviders: [{
name: 'growthCodeRtd',
waitForIt: true,
params: {
pid: 'TEST01',
}
}]
},
userSync: {
Expand All @@ -81,7 +92,7 @@
storage: {
type: "html5",
name: "_sharedID", // create a cookie with this name
expires: 365 // expires in 1 years
expires: 365 // expires in 1 year
}
},{
name: 'growthCodeId',
Expand Down
19 changes: 14 additions & 5 deletions modules/adgenerationBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {tryAppendQueryString, getBidIdParameter, escapeUnsafeChars} from '../src/utils.js';
import {tryAppendQueryString, getBidIdParameter, escapeUnsafeChars, deepAccess} from '../src/utils.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {BANNER, NATIVE} from '../src/mediaTypes.js';
import {config} from '../src/config.js';
import { convertOrtbRequestToProprietaryNative } from '../src/native.js';
import {convertOrtbRequestToProprietaryNative} from '../src/native.js';

const ADG_BIDDER_CODE = 'adgeneration';

Expand All @@ -21,14 +21,14 @@ export const spec = {
},
/**
* Make a server request from the list of BidRequests.
*
* @param {validBidRequests[]} - an array of bids
* @param validBidRequests
* @param bidderRequest
* @return ServerRequest Info describing the request to the server.
*/
buildRequests: function (validBidRequests, bidderRequest) {
// convert Native ORTB definition to old-style prebid native definition
validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests);
const ADGENE_PREBID_VERSION = '1.5.0';
const ADGENE_PREBID_VERSION = '1.6.0';
let serverRequests = [];
for (let i = 0, len = validBidRequests.length; i < len; i++) {
const validReq = validBidRequests[i];
Expand All @@ -38,6 +38,9 @@ export const spec = {
const criteoId = getCriteoId(validReq);
const id5id = getId5Id(validReq);
const id5LinkType = getId5LinkType(validReq);
const imuid = deepAccess(validReq, 'userId.imuid');
const gpid = deepAccess(validReq, 'ortb2Imp.ext.gpid');
const sua = deepAccess(validReq, 'ortb2.device.sua');
let data = ``;
data = tryAppendQueryString(data, 'posall', 'SSPLOC');
const id = getBidIdParameter('id', validReq.params);
Expand All @@ -54,6 +57,12 @@ export const spec = {
data = tryAppendQueryString(data, 'adgext_criteo_id', criteoId);
data = tryAppendQueryString(data, 'adgext_id5_id', id5id);
data = tryAppendQueryString(data, 'adgext_id5_id_link_type', id5LinkType);
data = tryAppendQueryString(data, 'adgext_imuid', imuid);
data = tryAppendQueryString(data, 'adgext_uid2', validReq.userId ? validReq.userId.uid2 : null);
data = tryAppendQueryString(data, 'gpid', gpid ? encodeURIComponent(gpid) : null);
data = tryAppendQueryString(data, 'uach', sua ? JSON.stringify(sua) : null);
data = tryAppendQueryString(data, 'schain', validReq.schain ? encodeURIComponent(JSON.stringify(validReq.schain)) : null);

// native以外にvideo等の対応が入った場合は要修正
if (!validReq.mediaTypes || !validReq.mediaTypes.native) {
data = tryAppendQueryString(data, 'imark', '1');
Expand Down
2 changes: 0 additions & 2 deletions modules/adtelligentBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const HOST_GETTERS = {
}()),
navelix: () => 'ghb.hb.navelix.com',
appaloosa: () => 'ghb.hb.appaloosa.media',
onefiftytwomedia: () => 'ghb.ads.152media.com',
bidsxchange: () => 'ghb.hbd.bidsxchange.com',
streamkey: () => 'ghb.hb.streamkey.net',
janet: () => 'ghb.bidder.jmgads.com',
Expand All @@ -42,7 +41,6 @@ export const spec = {
code: BIDDER_CODE,
gvlid: 410,
aliases: [
'onefiftytwomedia',
'appaloosa',
'bidsxchange',
'streamkey',
Expand Down
131 changes: 131 additions & 0 deletions modules/growthCodeRtdProvider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/**
* This module adds GrowthCode HEM and other Data to Bid Requests
* @module modules/growthCodeRtdProvider
*/
import { submodule } from '../src/hook.js'
import { getStorageManager } from '../src/storageManager.js';
import {
logMessage, logError, tryAppendQueryString, mergeDeep
} from '../src/utils.js';
import * as ajax from '../src/ajax.js';
import { MODULE_TYPE_RTD } from '../src/activities/modules.js';

const MODULE_NAME = 'growthCodeRtd';
const LOG_PREFIX = 'GrowthCodeRtd: ';
const ENDPOINT_URL = 'https://p2.gcprivacy.com/v2/rtd?'
const RTD_EXPIRE_KEY = 'gc_rtd_expires_at'
const RTD_CACHE_KEY = 'gc_rtd_items'

export const storage = getStorageManager({ moduleType: MODULE_TYPE_RTD, moduleName: MODULE_NAME });
let items

export const growthCodeRtdProvider = {
name: MODULE_NAME,
init: init,
getBidRequestData: alterBidRequests,
addData: addData,
callServer: callServer
};

/**
* Parse json if possible, else return null
* @param data
* @returns {any|null}
*/
function tryParse(data) {
try {
return JSON.parse(data);
} catch (err) {
logError(err);
return null;
}
}

/**
* Init The RTD Module
* @param config
* @param userConsent
* @returns {boolean}
*/
function init(config, userConsent) {
logMessage(LOG_PREFIX + 'Init RTB');

if (config == null) {
return false
}

const configParams = (config && config.params) || {};
let expiresAt = parseInt(storage.getDataFromLocalStorage(RTD_EXPIRE_KEY, null));

items = tryParse(storage.getDataFromLocalStorage(RTD_CACHE_KEY, null));

return callServer(configParams, items, expiresAt, userConsent);
}
function callServer(configParams, items, expiresAt, userConsent) {
// Expire Cache
let now = Math.trunc(Date.now() / 1000);
if ((!isNaN(expiresAt)) && (now > expiresAt)) {
expiresAt = NaN;
storage.removeDataFromLocalStorage(RTD_CACHE_KEY, null)
storage.removeDataFromLocalStorage(RTD_EXPIRE_KEY, null)
}
if ((items === null) && (isNaN(expiresAt))) {
let gcid = localStorage.getItem('gcid')

let url = configParams.url ? configParams.url : ENDPOINT_URL;
url = tryAppendQueryString(url, 'pid', configParams.pid);
url = tryAppendQueryString(url, 'u', window.location.href);
url = tryAppendQueryString(url, 'gcid', gcid);
if ((userConsent !== null) && (userConsent.gdpr !== null) && (userConsent.gdpr.consentData.getTCData.tcString)) {
url = tryAppendQueryString(url, 'tcf', userConsent.gdpr.consentData.getTCData.tcString)
}

ajax.ajaxBuilder()(url, {
success: response => {
let respJson = tryParse(response);
// If response is a valid json and should save is true
if (respJson && respJson.results >= 1) {
storage.setDataInLocalStorage(RTD_CACHE_KEY, JSON.stringify(respJson.items), null);
storage.setDataInLocalStorage(RTD_EXPIRE_KEY, respJson.expires_at, null)
} else {
storage.setDataInLocalStorage(RTD_EXPIRE_KEY, respJson.expires_at, null)
}
},
error: error => {
logError(LOG_PREFIX + 'ID fetch encountered an error', error);
}
}, undefined, {method: 'GET', withCredentials: true})
}

return true;
}

function addData(reqBidsConfigObj, items) {
let merge = false

for (let j = 0; j < items.length; j++) {
let item = items[j]
let data = JSON.parse(item.parameters);
if (item['attachment_point'] === 'data') {
mergeDeep(reqBidsConfigObj.ortb2Fragments.bidder, data)
merge = true
}
}
return merge
}

/**
* Alter the Bid Request for additional information such as HEM or 3rd Party Ids
* @param reqBidsConfigObj
* @param callback
* @param config
* @param userConsent
*/
function alterBidRequests(reqBidsConfigObj, callback, config, userConsent) {
if (items != null) {
addData(reqBidsConfigObj, items)
}
callback();
}

submodule('realTimeData', growthCodeRtdProvider);
55 changes: 55 additions & 0 deletions modules/growthCodeRtdProvider.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
## GrowthCode Real-time Data Submodule

The [GrowthCode](https://growthcode.io) real-time data module in Prebid enables publishers to fully
leverage the potential of their first-party audiences and contextual data.
With an integrated cookieless GrowthCode identity, this module offers real-time
contextual and audience segmentation (IAB Taxonomy 2.2, cattax: 6) capabilities, and HEMs that can seamlessly
integrate into your existing Prebid deployment, making it easy to maximize
your advertising strategies.

## Building Prebid with GrowthCode Support

Compile the GrowthCode RTD module into your Prebid build:

`gulp serve --modules=userId,rtdModule,appnexusBidAdapter,growthCodeRtdProvider,sharedIdSystem,criteoBidAdapter`

Please visit https://growthcode.io/ for more information.

```
pbjs.setConfig(
...
realTimeData: {
auctionDelay: 1000,
dataProviders: [
{
name: 'growthCodeRtd',
waitForIt: true,
params: {
pid: 'TEST01',
}
}
]
}
...
}
```

### Parameter Descriptions for the GrowthCode Configuration Section

| Name | Type | Description | Notes |
|:---------------------------------|:--------|:--------------------------------------------------------------------------|:----------------------------|
| name | String | Real time data module name | Always 'growthCodeRtd' |
| waitForIt | Boolean | Required to ensure that the auction is delayed until prefetch is complete | Optional. Defaults to false |
| params | Object | | |
| params.pid | String | This is the Parter ID value obtained from GrowthCode | `TEST01` |
| params.url | String | Custom URL for server | Optional |

## Testing

To view an example of GrowthCode backends:

`gulp serve --modules=userId,rtdModule,appnexusBidAdapter,growthCodeRtdProvider,sharedIdSystem,criteoBidAdapter`

and then point your browser at:

`http://localhost:9999/integrationExamples/gpt/growthcode.html`
7 changes: 5 additions & 2 deletions modules/ixBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export const FEATURE_TOGGLES = {
let siteID = 0;
let gdprConsent = '';
let usPrivacy = '';
let defaultVideoPlacement = false;

// Possible values for bidResponse.seatBid[].bid[].mtype which indicates the type of the creative markup so that it can properly be associated with the right sub-object of the BidRequest.Imp.
const MEDIA_TYPES = {
Expand Down Expand Up @@ -223,7 +224,8 @@ function bidToVideoImp(bid) {
if (deepAccess(videoParamRef, 'playerConfig.floatOnScroll')) {
imp.video.placement = 5;
} else {
imp.video.placement = 4;
imp.video.placement = 3;
defaultVideoPlacement = true;
}
} else {
logWarn(`IX Bid Adapter: Video context '${context}' is not supported`);
Expand Down Expand Up @@ -1111,7 +1113,8 @@ function buildIXDiag(validBidRequests) {
ren: false,
version: '$prebid.version$',
userIds: _getUserIds(validBidRequests[0]),
url: window.location.href.split('?')[0]
url: window.location.href.split('?')[0],
vpd: defaultVideoPlacement
};

// create ad unit map and collect the required diag properties
Expand Down
4 changes: 2 additions & 2 deletions modules/sharethroughBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ export const sharethroughAdapterSpec = {
if (videoRequest) {
// default playerSize, only change this if we know width and height are properly defined in the request
let [w, h] = [640, 360];
if (videoRequest.playerSize && videoRequest.playerSize[0] && videoRequest.playerSize[1]) {
[w, h] = videoRequest.playerSize;
if (videoRequest.playerSize && videoRequest.playerSize[0] && videoRequest.playerSize[0][0] && videoRequest.playerSize[0][1]) {
[w, h] = videoRequest.playerSize[0];
}

impression.video = {
Expand Down
5 changes: 5 additions & 0 deletions modules/smartadserverBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ export const spec = {
sdc: sellerDefinedContext
};

const gpid = deepAccess(bid, 'ortb2Imp.ext.gpid', deepAccess(bid, 'ortb2Imp.ext.data.pbadslot', ''));
if (gpid) {
payload.gpid = gpid;
}

if (bidderRequest) {
if (bidderRequest.gdprConsent) {
payload.addtl_consent = bidderRequest.gdprConsent.addtlConsent;
Expand Down
Loading