Skip to content

Commit

Permalink
Discovery Bid Adapter : parameter updates (prebid#9249)
Browse files Browse the repository at this point in the history
* Mediago Bid Adapter:new adapter

* remove console

* change spec file to fix CircleCI

* change spec file to fix CircleCI

* change spec file

* Update mediagoBidAdapter.js

* Update mediagoBidAdapter.js

* rerun CurcleCi

* update mediagoBidAdapter

* update discoveryBidAdapter

Co-authored-by: BaronYu <baronwei11@gmail.com>
  • Loading branch information
2 people authored and JacobKlein26 committed Feb 8, 2023
1 parent 3c56475 commit 7297c99
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 31 deletions.
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.

0 comments on commit 7297c99

Please sign in to comment.