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

Discovery Bid Adapter : parameter updates #9249

Merged
merged 14 commits into from
Nov 16, 2022
55 changes: 38 additions & 17 deletions modules/discoveryBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ let itemMaps = {};
const MEDIATYPE = [BANNER, NATIVE];

/* ----- _ss_pp_id:start ------ */
const COOKIE_KEY_MGUID = '_ss_pp_id';
const COOKIE_KEY_SSPPID = '_ss_pp_id';
const COOKIE_KEY_MGUID = '__mguid_';

const NATIVERET = {
id: 'id',
Expand Down Expand Up @@ -58,14 +59,20 @@ const NATIVERET = {
* @return {string}
*/
const getUserID = () => {
const i = storage.getCookie(COOKIE_KEY_MGUID);
let idd = storage.getCookie(COOKIE_KEY_SSPPID);
let idm = storage.getCookie(COOKIE_KEY_MGUID);

if (i === null) {
if (idd && !idm) {
idm = idd
} else if (idm && !idd) {
idd = idm
} else if (!idd && !idm) {
const uuid = utils.generateUUID();
storage.setCookie(COOKIE_KEY_MGUID, uuid);
storage.setCookie(COOKIE_KEY_SSPPID, uuid);
return uuid;
}
return i;
return idd;
};

/* ----- _ss_pp_id:end ------ */
Expand All @@ -80,7 +87,6 @@ function getKv(obj, ...keys) {
let o = obj;

for (let key of keys) {
// console.log(key, o);
if (o && o[key]) {
o = o[key];
} else {
Expand Down Expand Up @@ -222,7 +228,7 @@ function getItems(validBidRequests, bidderRequest) {
let id = '' + (i + 1);

if (mediaTypes.native) {
ret = {...NATIVERET, ...{id, bidFloor}}
ret = { ...NATIVERET, ...{ id, bidFloor } }
}
// banner
if (mediaTypes.banner) {
Expand All @@ -249,6 +255,7 @@ function getItems(validBidRequests, bidderRequest) {
pos: 1,
},
ext: {},
tagid: globals['tagid'],
};
}
itemMaps[id] = {
Expand All @@ -273,14 +280,19 @@ function getParam(validBidRequests, bidderRequest) {
let auctionId = getKv(bidderRequest, 'auctionId');
let items = getItems(validBidRequests, bidderRequest);

const location = utils.deepAccess(bidderRequest, 'refererInfo.referer');

const timeout = bidderRequest.timeout || 2000;

const domain = utils.deepAccess(bidderRequest, 'refererInfo.domain') || document.domain;
const location = utils.deepAccess(bidderRequest, 'refererInfo.referer');
const page = utils.deepAccess(bidderRequest, 'refererInfo.page');
const referer = utils.deepAccess(bidderRequest, 'refererInfo.ref');

if (items && items.length) {
let c = {
id: 'pp_hbjs_' + auctionId,
at: 1,
bcat: globals['bcat'],
badv: globals['adv'],
cur: ['USD'],
device: {
connectiontype: 0,
Expand All @@ -295,16 +307,16 @@ function getParam(validBidRequests, bidderRequest) {
},
tmax: timeout,
site: {
name: globals['media'],
domain: globals['media'],
page: location,
ref: location,
name: domain,
domain: domain,
page: page || location,
ref: referer,
mobile: isMobile,
cat: [], // todo
publisher: {
id: globals['publisher']
// todo
id: globals['media'],
name: globals['media'],
// name: xxx
},
},
imp: items,
Expand All @@ -329,10 +341,19 @@ export const spec = {
if (bid.params.token) {
globals['token'] = bid.params.token;
}
if (bid.params.media) {
globals['media'] = bid.params.media;
if (bid.params.publisher) {
globals['publisher'] = bid.params.publisher;
}
if (bid.params.tagid) {
globals['tagid'] = bid.params.tagid;
}
if (bid.params.bcat) {
globals['bcat'] = Array.isArray(bid.params.bcat) ? bid.params.bcat : [];
}
if (bid.params.badv) {
globals['badv'] = Array.isArray(bid.params.badv) ? bid.params.badv : [];
}
return !!(bid.params.token && bid.params.media);
return !!(bid.params.token && bid.params.publisher && bid.params.tagid);
},

/**
Expand Down
13 changes: 7 additions & 6 deletions modules/discoveryBidAdapter.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Overview

```
Module Name: DiscoveryDSP Bid Adapter
Module Name: discovery Bid Adapter
Module Type: Bidder Adapter
```

# Description

Module that connects to popIn's demand sources
Module that connects to popIn's demand sources.

The DiscoveryDSP Bidding adapter requires setup before beginning. Please contact us at <media-support@popin.cc>
The discovery Bidding adapter requires setup before beginning. Please contact us at <media-support@popin.cc>

# Test Parameters
```
Expand All @@ -32,7 +32,8 @@ The DiscoveryDSP Bidding adapter requires setup before beginning. Please contact
bidder: "discovery",
params: {
token: "a1b067897e4ae093d1f94261e0ddc6c9",
media: 'test_media' // your media host
tagid: 'test_tagid',
publisher: 'test_publisher'
},
},
],
Expand All @@ -45,13 +46,13 @@ The DiscoveryDSP Bidding adapter requires setup before beginning. Please contact
sizes: [[300, 250]],
},
},
// Replace this object to test a new adapter!
bids: [
{
bidder: "discovery",
params: {
token: "d0f4902b616cc5c38cbe0a08676d0ed9",
media: 'test_media' // your media host
tagid: 'test_tagid',
publisher: 'test_publisher'
},
},
],
Expand Down
17 changes: 9 additions & 8 deletions test/spec/modules/discoveryBidAdapter_spec.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.