From d34c542ea551aa46131ccaf71004300ee226b02f Mon Sep 17 00:00:00 2001 From: BaronYu Date: Wed, 17 Aug 2022 20:58:10 +0800 Subject: [PATCH 01/44] Mediago Bid Adapter:new adapter --- modules/mediagoBidAdapter.js | 458 ++++++++++++++++++++ modules/mediagoBidAdapter.md | 34 ++ test/spec/modules/mediagoBidAdapter_spec.js | 89 ++++ 3 files changed, 581 insertions(+) create mode 100644 modules/mediagoBidAdapter.js create mode 100644 modules/mediagoBidAdapter.md create mode 100644 test/spec/modules/mediagoBidAdapter_spec.js diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js new file mode 100644 index 00000000000..c6ab6d6b28a --- /dev/null +++ b/modules/mediagoBidAdapter.js @@ -0,0 +1,458 @@ +/** + * gulp serve --modules=mediagoBidAdapter,pubCommonId --nolint --notest + */ + +import * as utils from '../src/utils.js'; +import { getStorageManager } from '../src/storageManager.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { config } from '../src/config.js'; +// import { isPubcidEnabled } from './pubCommonId.js'; + +const BIDDER_CODE = 'mediago'; +// const PROTOCOL = window.document.location.protocol; +const ENDPOINT_URL = + // ((PROTOCOL === 'https:') ? 'https' : 'http') + + 'https://rtb-us.mediago.io/api/bid?tn='; +const TIME_TO_LIVE = 500; +// const ENDPOINT_URL = '/api/bid?tn='; +const storage = getStorageManager(); +let globals = {}; +let itemMaps = {}; + +/** + * 获取随机id + * @param {number} a random number from 0 to 15 + * @return {string} random number or random string + */ +function getRandomId( + a // placeholder +) { + // if the placeholder was passed, return + // a random number from 0 to 15 + return a + ? ( + a ^ // unless b is 8, + ((Math.random() * // in which case + 16) >> // a random number from + (a / 4)) + ) // 8 to 11 + .toString(16) // in hexadecimal + : ( // or otherwise a concatenated string: + [1e7] + // 10000000 + + 1e3 + // -1000 + + 4e3 + // -4000 + + 8e3 + // -80000000 + + 1e11 + ) // -100000000000, + .replace( + // replacing + /[018]/g, // zeroes, ones, and eights with + getRandomId // random hex digits + ); +} + +/* ----- mguid:start ------ */ +const COOKIE_KEY_MGUID = '__mguid_'; + +/** + * 获取用户id + * @return {string} + */ +const getUserID = () => { + const i = storage.getCookie(COOKIE_KEY_MGUID); + + if (i === null) { + const uuid = utils.generateUUID(); + storage.setCookie(COOKIE_KEY_MGUID, uuid); + return uuid; + } + return i; +}; + +/* ----- mguid:end ------ */ + +/** + * 获取一个对象的某个值,如果没有则返回空字符串 + * @param {Object} obj 对象 + * @param {...string} keys 键名 + * @return {any} + */ +function getProperty(obj, ...keys) { + let o = obj; + + for (let key of keys) { + // console.log(key, o); + if (o && o[key]) { + o = o[key]; + } else { + return ''; + } + } + return o; +} + +/** + * 是不是移动设备或者平板 + * @return {boolean} + */ +function isMobileAndTablet() { + let check = false; + (function (a) { + let reg1 = new RegExp( + [ + '(android|bbd+|meego)', + '.+mobile|avantgo|bada/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)', + '|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone', + '|p(ixi|re)/|plucker|pocket|psp|series(4|6)0|symbian|treo|up.(browser|link)|vodafone|wap', + '|windows ce|xda|xiino|android|ipad|playbook|silk', + ].join(''), + 'i' + ); + let reg2 = new RegExp( + [ + '1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)', + '|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )', + '|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55/|capi|ccwa|cdm-|cell', + '|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)', + '|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene', + '|gf-5|g-mo|go(.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c', + '|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|/)|ibro|idea|ig01|ikom', + '|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |/)|klon|kpt |kwc-|kyo(c|k)', + '|le(no|xi)|lg( g|/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50/|ma(te|ui|xo)|mc(01|21|ca)', + '|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]', + '|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)', + '|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio', + '|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55/|sa(ge|ma|mm|ms', + '|ny|va)|sc(01|h-|oo|p-)|sdk/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al', + '|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)', + '|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(.b|g1|si)|utst|', + 'v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)', + '|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-', + '|your|zeto|zte-', + ].join(''), + 'i' + ); + if (reg1.test(a) || reg2.test(a.substr(0, 4))) { + check = true; + } + })(navigator.userAgent || navigator.vendor || window.opera); + return check; +} + +/** + * 获取底价 + * @param {*} bid + * @param {*} mediaType + * @param {*} sizes + * @returns + */ +// function getBidFloor(bid, mediaType, sizes) { +// var floor; +// var size = sizes.length === 1 ? sizes[0] : "*"; +// if (typeof bid.getFloor === "function") { +// const floorInfo = bid.getFloor({ currency: "USD", mediaType, size }); +// if ( +// typeof floorInfo === "object" && +// floorInfo.currency === "USD" && +// !isNaN(parseFloat(floorInfo.floor)) +// ) { +// floor = parseFloat(floorInfo.floor); +// } +// } +// return floor; +// } +function getBidFloor(bid) { + if (!utils.isFn(bid.getFloor)) { + return utils.deepAccess(bid, 'params.bidfloor', 0); + } + + try { + const bidFloor = bid.getFloor({ + currency: 'USD', + mediaType: '*', + size: '*', + }); + return bidFloor.floor; + } catch (_) { + return 0; + } +} + +/** + * 将尺寸转为RTB识别的尺寸 + * + * @param {Array|Object} requestSizes 配置尺寸 + * @return {Object} + */ +function transformSizes(requestSizes) { + let sizes = []; + let sizeObj = {}; + + if ( + utils.isArray(requestSizes) && + requestSizes.length === 2 && + !utils.isArray(requestSizes[0]) + ) { + sizeObj.width = parseInt(requestSizes[0], 10); + sizeObj.height = parseInt(requestSizes[1], 10); + sizes.push(sizeObj); + } else if (typeof requestSizes === 'object') { + for (let i = 0; i < requestSizes.length; i++) { + let size = requestSizes[i]; + sizeObj = {}; + sizeObj.width = parseInt(size[0], 10); + sizeObj.height = parseInt(size[1], 10); + sizes.push(sizeObj); + } + } + + return sizes; +} + +// 支持的广告尺寸 +const mediagoAdSize = [ + { w: 300, h: 250 }, + { w: 300, h: 600 }, + { w: 728, h: 90 }, + { w: 970, h: 250 }, + { w: 320, h: 50 }, + { w: 160, h: 600 }, + { w: 320, h: 180 }, + { w: 320, h: 100 }, + { w: 336, h: 280 }, +]; + +/** + * 获取广告位配置 + * @param {Array} validBidRequests an an array of bids + * @param {Object} bidderRequest The master bidRequest object + * @return {Object} + */ +function getItems(validBidRequests, bidderRequest) { + let items = []; + items = validBidRequests.map((req, i) => { + let ret = {}; + let mediaTypes = getProperty(req, 'mediaTypes'); + + let sizes = transformSizes(getProperty(req, 'sizes')); + let matchSize; + + // 确认尺寸是否符合我们要求 + for (let size of sizes) { + matchSize = mediagoAdSize.find( + (item) => size.width === item.w && size.height === item.h + ); + if (matchSize) { + break; + } + } + if (!matchSize) { + return {}; + } + + const bidFloor = getBidFloor(req); + // const gpid = + // utils.deepAccess(req, 'ortb2Imp.ext.gpid') || + // utils.deepAccess(req, 'ortb2Imp.ext.data.pbadslot') || + // utils.deepAccess(req, 'params.placementId', 0); + // console.log("wjh getItems:", req, bidFloor, gpid); + + // if (mediaTypes.native) {} + // banner广告类型 + if (mediaTypes.banner) { + let id = '' + (i + 1); + ret = { + id: id, + bidfloor: bidFloor, + banner: { + h: matchSize.h, + w: matchSize.w, + pos: 1, + }, + ext: { + // gpid: gpid, // 加入后无法返回广告 + }, + }; + itemMaps[id] = { + req, + ret, + }; + } + + return ret; + }); + return items; +} + +/** + * 获取rtb请求参数 + * + * @param {Array} validBidRequests an an array of bids + * @param {Object} bidderRequest The master bidRequest object + * @return {Object} + */ +function getParam(validBidRequests, bidderRequest) { + const pubcid = utils.deepAccess(validBidRequests[0], 'crumbs.pubcid'); + // console.log('wjh getParam', validBidRequests, bidderRequest); + let isMobile = isMobileAndTablet() ? 1 : 0; + let isTest = 0; + let auctionId = getProperty(bidderRequest, 'auctionId') || getRandomId(); + let items = getItems(validBidRequests, bidderRequest); + + const domain = document.domain; + const location = utils.deepAccess(bidderRequest, 'refererInfo.referer'); + + const timeout = bidderRequest.timeout || 2000; + + if (items && items.length) { + let c = { + id: 'mgprebidjs_' + auctionId, + test: +isTest, + at: 1, + cur: ['USD'], + device: { + connectiontype: 0, + // ip: '64.188.178.115', + js: 1, + // language: "en", + // os: "Microsoft Windows", + // ua: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.19043", + os: navigator.platform || '', + ua: navigator.userAgent, + language: /en/.test(navigator.language) ? 'en' : navigator.language, + }, + ext: {}, + user: { + buyeruid: getUserID(), + id: pubcid, + }, + site: { + name: domain, + domain: domain, + page: location, + ref: location, + mobile: isMobile, + cat: [], // todo + publisher: { + // todo + id: domain, + name: domain, + }, + }, + imp: items, + tmax: timeout, + }; + return c; + } else { + return null; + } +} + +export const spec = { + code: BIDDER_CODE, + // aliases: ['ex'], // short code + /** + * Determines whether or not the given bid request is valid. + * + * @param {BidRequest} bid The bid params to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: function (bid) { + // console.log('mediago', { + // bid + // }); + if (bid.params.token) { + globals['token'] = bid.params.token; + } + return !!bid.params.token; + }, + + /** + * Make a server request from the list of BidRequests. + * + * @param {Array} validBidRequests an an array of bids + * @param {Object} bidderRequest The master bidRequest object + * @return ServerRequest Info describing the request to the server. + */ + buildRequests: function (validBidRequests, bidderRequest) { + let payload = getParam(validBidRequests, bidderRequest); + + const payloadString = JSON.stringify(payload); + return { + method: 'POST', + url: ENDPOINT_URL + globals['token'], + data: payloadString, + }; + }, + + /** + * Unpack the response from the server into a list of bids. + * + * @param {ServerResponse} serverResponse A successful response from the server. + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: function (serverResponse, bidRequest) { + const bids = getProperty(serverResponse, 'body', 'seatbid', 0, 'bid'); + const cur = getProperty(serverResponse, 'body', 'cur'); + + const bidResponses = []; + for (let bid of bids) { + let impid = getProperty(bid, 'impid'); + if (itemMaps[impid]) { + let bidId = getProperty(itemMaps[impid], 'req', 'bidId'); + const bidResponse = { + requestId: bidId, + cpm: getProperty(bid, 'price'), + width: getProperty(bid, 'w'), + height: getProperty(bid, 'h'), + creativeId: getProperty(bid, 'crid'), + dealId: '', + currency: cur, + netRevenue: true, + ttl: TIME_TO_LIVE, + // referrer: REFERER, + ad: getProperty(bid, 'adm'), + // adserverTargeting: { + // granularityMultiplier: 0.1, + // priceGranularity: "pbHg", + // pbMg: "0.01", + // }, + // pbMg: "0.01", + // granularityMultiplier: 0.1, + // priceGranularity: "pbHg", + }; + bidResponses.push(bidResponse); + } + } + + return bidResponses; + }, + + /** + * Register bidder specific code, which will execute if bidder timed out after an auction + * @param {data} Containing timeout specific data + */ + onTimeout: function (data) { + // console.log('onTimeout', data); + // Bidder specifc code + }, + + /** + * Register bidder specific code, which will execute if a bid from this bidder won the auction + * @param {Bid} The bid that won the auction + */ + onBidWon: function (bid) { + console.log('onBidWon', bid, config.getConfig('priceGranularity')); + // Bidder specific code + }, + + /** + * Register bidder specific code, which will execute when the adserver targeting has been set for a bid from this bidder + * @param {Bid} The bid of which the targeting has been set + */ + onSetTargeting: function (bid) { + // console.log('onSetTargeting', bid); + // Bidder specific code + }, +}; +registerBidder(spec); diff --git a/modules/mediagoBidAdapter.md b/modules/mediagoBidAdapter.md new file mode 100644 index 00000000000..464ea59f11c --- /dev/null +++ b/modules/mediagoBidAdapter.md @@ -0,0 +1,34 @@ +# Overview + +``` +Module Name: MediaGo Bidder Adapter +Module Type: Bidder Adapter +Maintainer: fangsimin@baidu.com +``` + +# Description + +Module that connects to MediaGo's demand sources + +# Test Parameters + +``` + var adUnits = [ + { + code: 'test-div', + mediaTypes: { + banner: { + sizes: [[300, 250]], + } + }, + bids: [ + { + bidder: "mediago", + params: { + token: '' // required, send email to ext_mediago_am@baidu.com to get the corresponding token + } + } + ] + } + ]; +``` diff --git a/test/spec/modules/mediagoBidAdapter_spec.js b/test/spec/modules/mediagoBidAdapter_spec.js new file mode 100644 index 00000000000..c6cb236c1af --- /dev/null +++ b/test/spec/modules/mediagoBidAdapter_spec.js @@ -0,0 +1,89 @@ +import { expect } from 'chai'; +import { spec } from 'modules/mediagoBidAdapter.js'; + +describe('mediago:BidAdapterTests', function () { + let bidRequestData = { + bidderCode: 'mediago', + auctionId: '7fae02a9-0195-472f-ba94-708d3bc2c0d9', + bidderRequestId: '4fec04e87ad785', + bids: [ + { + bidder: 'mediago', + params: { + token: '85a6b01e41ac36d49744fad726e3655d', + }, + mediaTypes: { + banner: { + sizes: [[300, 250]], + }, + }, + adUnitCode: 'div-gpt-ad-1460505748561-0', + transactionId: '5e24a2ce-db03-4565-a8a3-75dbddca9377', + sizes: [[300, 250]], + bidId: '54d73f19c9d47a', + bidderRequestId: '4fec04e87ad785', + auctionId: '7fae02a9-0195-472f-ba94-708d3bc2c0d9', + src: 'client', + bidRequestsCount: 1, + bidderRequestsCount: 1, + bidderWinsCount: 0, + }, + ], + }; + let request = []; + + it('mediago:validate_pub_params', function () { + expect( + spec.isBidRequestValid({ + bidder: 'mediago', + params: { + token: ['85a6b01e41ac36d49744fad726e3655d'], + }, + }) + ).to.equal(true); + }); + + it('mediago:validate_generated_params', function () { + request = spec.buildRequests(bidRequestData.bids, bidRequestData); + let req_data = JSON.parse(request.data); + expect(req_data.imp).to.have.lengthOf(1); + }); + + it('mediago:validate_response_params', function () { + let serverResponse = { + body: { + id: 'mgprebidjs_0b6572fc-ceba-418f-b6fd-33b41ad0ac8a', + seatbid: [ + { + bid: [ + { + id: '6706352e29016b27da84dd422e879369', + impid: '1', + price: 0.2, + adm: "\u003clink rel='stylesheet' href='//cdn.mediago.io/js/style/style_banner_300*250.css'\u003e\u003cdiv id='mgcontainer-50a1cceed7dcd3c99859e20a1d0a66ae' class='mediago-placement imgTopTitleBottom' style='position:relative;width:298px;height:248px;overflow:hidden'\u003e\u003ca href='http://msn.gbudev.com/api/bidder/track?tn=85a6b01e41ac36d49744fad726e3655d\u0026price=ZQc-I4Br8_FTGtNXgAwbVteddoPtwJDcZdJPhEKrZQ8\u0026evt=102\u0026rid=6706352e29016b27da84dd422e879369\u0026campaignid=1001465\u0026impid=27-300x175-1\u0026offerid=1023545\u0026test=0\u0026time=1597646714\u0026cp=65zLqtxPkYHaZbMC9f8kvas6S6nFO8mGkTyb5LFppSc\u0026clickid=27_6706352e29016b27da84dd422e879369_27-300x175-1\u0026acid=1\u0026trackingid=50a1cceed7dcd3c99859e20a1d0a66ae\u0026uid=6dda6c6b70eb4e2d9ab3469d921f2c74\u0026jt=2\u0026url=vMENpLl3Ssfi5PyFJaLiifsd8Gd5IVxcoii1evTTiL5C3PvP27nLeCEESzIf4noyPKskwHpQIoejGPD5J0SEX6SPP55F94l7jcVPT_1vRxu2Zk43M8P4njPyzaXmASSVamprYOurCP3cCZzNOc-fSg' target='_blank'\u003e\u003cimg alt='platform_mobile_test' src='https://d2cli4kgl5uxre.cloudfront.net/ML/3f21c1cc11eb691b6c3d99f7a1daf815__300x175.png' style='height:70%;width:100%;border-width:0;border:none;'\u003e\u003ch3 class='title' style='font-size:16px;'\u003eplatform_mobile_test\u003c/h3\u003e\u003c/a\u003e\u003cspan class='source'\u003e\u003ca class='sourcename' href='//www.mediago.io' target='_blank'\u003e\u003cspan\u003eAd\u003c/span\u003e \u003c/a\u003e\u003ca class='srcnameadslabelurl' href='//www.mediago.io/privacy' target='_blank'\u003e\u003cspan\u003eAce\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\u003c/div\u003e\u003cscript\u003e!function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){'undefined'!=typeof Symbol\u0026\u0026Symbol.toStringTag\u0026\u0026Object.defineProperty(e,Symbol.toStringTag,{value:'Module'}),Object.defineProperty(e,'__esModule',{value:!0})},n.t=function(e,t){if(1\u0026t\u0026\u0026(e=n(e)),8\u0026t)return e;if(4\u0026t\u0026\u0026'object'==typeof e\u0026\u0026e\u0026\u0026e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,'default',{enumerable:!0,value:e}),2\u0026t\u0026\u0026'string'!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e\u0026\u0026e.__esModule?function(){return e.default}:function(){return e};return n.d(t,'a',t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p='',n(n.s=24)}({24:function(e,t,n){'use strict';function o(e){var t=new Image;t.src=e,t.style='display:none;visibility:hidden',t.width=0,t.height=0,document.body.appendChild(t)}o('http://msn.gbudev.com/api/bidder/track?tn=85a6b01e41ac36d49744fad726e3655d\u0026price=ZQc-I4Br8_FTGtNXgAwbVteddoPtwJDcZdJPhEKrZQ8\u0026evt=101\u0026rid=6706352e29016b27da84dd422e879369\u0026campaignid=1001465\u0026impid=27-300x175-1\u0026offerid=1023545\u0026test=0\u0026time=1597646714\u0026cp=65zLqtxPkYHaZbMC9f8kvas6S6nFO8mGkTyb5LFppSc\u0026acid=1\u0026trackingid=50a1cceed7dcd3c99859e20a1d0a66ae\u0026uid=6dda6c6b70eb4e2d9ab3469d921f2c74');var r=document.getElementById('mgcontainer-50a1cceed7dcd3c99859e20a1d0a66ae'),i=!1;!function e(){setTimeout((function(){var t,n;!i\u0026\u0026(t=r,n=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,(t.getBoundingClientRect()\u0026\u0026t.getBoundingClientRect().top)\u003c=n-.75*(t.offsetHeight||t.clientHeight))?(i=!0,o('http://msn.gbudev.com/api/bidder/track?tn=85a6b01e41ac36d49744fad726e3655d\u0026price=ZQc-I4Br8_FTGtNXgAwbVteddoPtwJDcZdJPhEKrZQ8\u0026evt=104\u0026rid=6706352e29016b27da84dd422e879369\u0026campaignid=1001465\u0026impid=27-300x175-1\u0026offerid=1023545\u0026test=0\u0026time=1597646714\u0026cp=65zLqtxPkYHaZbMC9f8kvas6S6nFO8mGkTyb5LFppSc\u0026acid=1\u0026trackingid=50a1cceed7dcd3c99859e20a1d0a66ae\u0026uid=6dda6c6b70eb4e2d9ab3469d921f2c74\u0026sid=4__11__12__13\u0026format=\u0026crid=3f21c1cc11eb691b6c3d99f7a1daf815')):e()}),500)}()}});\u003c/script\u003e\u003cscript type='text/javascript' src='http://msn.gbudev.com/api/track?tn=85a6b01e41ac36d49744fad726e3655d\u0026price=${AUCTION_PRICE}\u0026evt=5\u0026rid=6706352e29016b27da84dd422e879369\u0026impid=1\u0026offerid=\u0026tagid=\u0026test=0\u0026time=1597646714\u0026adp=g3tznPzjr9gfd3aQ0Sio53Dk4_QZkg1XuEWXR_Gw-CY\u0026dsp_id=23\u0026cp=${cp}\u0026url=\u0026type=script'\u003e\u003c/script\u003e\u003cscript\u003edocument.addEventListener\u0026\u0026document.addEventListener('click',function(){var a=document.createElement('script');a.src='http://msn.gbudev.com/api/track?tn=85a6b01e41ac36d49744fad726e3655d\u0026price=${AUCTION_PRICE}\u0026evt=6\u0026rid=6706352e29016b27da84dd422e879369\u0026impid=1\u0026offerid=\u0026tagid=\u0026test=0\u0026time=1597646714\u0026adp=g3tznPzjr9gfd3aQ0Sio53Dk4_QZkg1XuEWXR_Gw-CY\u0026dsp_id=23\u0026cp=${cp}\u0026url=\u0026clickid=27_6706352e29016b27da84dd422e879369_1';document.body.appendChild(a)});\u003c/script\u003e", + cid: '1001465', + crid: '3f21c1cc11eb691b6c3d99f7a1daf815', + w: 300, + h: 250, + }, + ], + }, + ], + cur: 'USD', + }, + }; + + let bids = spec.interpretResponse(serverResponse); + // console.log({ + // bids + // }); + expect(bids).to.have.lengthOf(1); + + let bid = bids[0]; + + expect(bid.creativeId).to.equal('3f21c1cc11eb691b6c3d99f7a1daf815'); + expect(bid.width).to.equal(300); + expect(bid.height).to.equal(250); + expect(bid.currency).to.equal('USD'); + }); +}); From dfea76667b702326a854aae1f90519ebcaf478a5 Mon Sep 17 00:00:00 2001 From: BaronYu Date: Thu, 18 Aug 2022 10:00:05 +0800 Subject: [PATCH 02/44] remove console --- modules/mediagoBidAdapter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js index c6ab6d6b28a..d038378a1f7 100644 --- a/modules/mediagoBidAdapter.js +++ b/modules/mediagoBidAdapter.js @@ -5,7 +5,7 @@ import * as utils from '../src/utils.js'; import { getStorageManager } from '../src/storageManager.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { config } from '../src/config.js'; +// import { config } from '../src/config.js'; // import { isPubcidEnabled } from './pubCommonId.js'; const BIDDER_CODE = 'mediago'; @@ -442,7 +442,7 @@ export const spec = { * @param {Bid} The bid that won the auction */ onBidWon: function (bid) { - console.log('onBidWon', bid, config.getConfig('priceGranularity')); + // console.log('onBidWon', bid, config.getConfig('priceGranularity')); // Bidder specific code }, From ba97c8ac59436ec32a68adddbc82df5edf8c56a1 Mon Sep 17 00:00:00 2001 From: BaronYu Date: Thu, 18 Aug 2022 11:14:29 +0800 Subject: [PATCH 03/44] change spec file to fix CircleCI --- test/spec/modules/mediagoBidAdapter_spec.js | 23 +++++++++++---------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/test/spec/modules/mediagoBidAdapter_spec.js b/test/spec/modules/mediagoBidAdapter_spec.js index c6cb236c1af..2ce04ceb801 100644 --- a/test/spec/modules/mediagoBidAdapter_spec.js +++ b/test/spec/modules/mediagoBidAdapter_spec.js @@ -11,18 +11,19 @@ describe('mediago:BidAdapterTests', function () { bidder: 'mediago', params: { token: '85a6b01e41ac36d49744fad726e3655d', + bidfloor: 0.01, }, mediaTypes: { banner: { sizes: [[300, 250]], }, }, - adUnitCode: 'div-gpt-ad-1460505748561-0', - transactionId: '5e24a2ce-db03-4565-a8a3-75dbddca9377', + adUnitCode: 'regular_iframe', + transactionId: '7b26fdae-96e6-4c35-a18b-218dda11397d', sizes: [[300, 250]], - bidId: '54d73f19c9d47a', - bidderRequestId: '4fec04e87ad785', - auctionId: '7fae02a9-0195-472f-ba94-708d3bc2c0d9', + bidId: '54d73f19c9d47a', // todo + bidderRequestId: '4fec04e87ad785', // todo + auctionId: '883a346a-6d62-4adb-a600-0f3a869061d1', src: 'client', bidRequestsCount: 1, bidderRequestsCount: 1, @@ -57,12 +58,12 @@ describe('mediago:BidAdapterTests', function () { { bid: [ { - id: '6706352e29016b27da84dd422e879369', + id: '6e28cfaf115a354ea1ad8e1304d6d7b8', impid: '1', - price: 0.2, - adm: "\u003clink rel='stylesheet' href='//cdn.mediago.io/js/style/style_banner_300*250.css'\u003e\u003cdiv id='mgcontainer-50a1cceed7dcd3c99859e20a1d0a66ae' class='mediago-placement imgTopTitleBottom' style='position:relative;width:298px;height:248px;overflow:hidden'\u003e\u003ca href='http://msn.gbudev.com/api/bidder/track?tn=85a6b01e41ac36d49744fad726e3655d\u0026price=ZQc-I4Br8_FTGtNXgAwbVteddoPtwJDcZdJPhEKrZQ8\u0026evt=102\u0026rid=6706352e29016b27da84dd422e879369\u0026campaignid=1001465\u0026impid=27-300x175-1\u0026offerid=1023545\u0026test=0\u0026time=1597646714\u0026cp=65zLqtxPkYHaZbMC9f8kvas6S6nFO8mGkTyb5LFppSc\u0026clickid=27_6706352e29016b27da84dd422e879369_27-300x175-1\u0026acid=1\u0026trackingid=50a1cceed7dcd3c99859e20a1d0a66ae\u0026uid=6dda6c6b70eb4e2d9ab3469d921f2c74\u0026jt=2\u0026url=vMENpLl3Ssfi5PyFJaLiifsd8Gd5IVxcoii1evTTiL5C3PvP27nLeCEESzIf4noyPKskwHpQIoejGPD5J0SEX6SPP55F94l7jcVPT_1vRxu2Zk43M8P4njPyzaXmASSVamprYOurCP3cCZzNOc-fSg' target='_blank'\u003e\u003cimg alt='platform_mobile_test' src='https://d2cli4kgl5uxre.cloudfront.net/ML/3f21c1cc11eb691b6c3d99f7a1daf815__300x175.png' style='height:70%;width:100%;border-width:0;border:none;'\u003e\u003ch3 class='title' style='font-size:16px;'\u003eplatform_mobile_test\u003c/h3\u003e\u003c/a\u003e\u003cspan class='source'\u003e\u003ca class='sourcename' href='//www.mediago.io' target='_blank'\u003e\u003cspan\u003eAd\u003c/span\u003e \u003c/a\u003e\u003ca class='srcnameadslabelurl' href='//www.mediago.io/privacy' target='_blank'\u003e\u003cspan\u003eAce\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\u003c/div\u003e\u003cscript\u003e!function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){'undefined'!=typeof Symbol\u0026\u0026Symbol.toStringTag\u0026\u0026Object.defineProperty(e,Symbol.toStringTag,{value:'Module'}),Object.defineProperty(e,'__esModule',{value:!0})},n.t=function(e,t){if(1\u0026t\u0026\u0026(e=n(e)),8\u0026t)return e;if(4\u0026t\u0026\u0026'object'==typeof e\u0026\u0026e\u0026\u0026e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,'default',{enumerable:!0,value:e}),2\u0026t\u0026\u0026'string'!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e\u0026\u0026e.__esModule?function(){return e.default}:function(){return e};return n.d(t,'a',t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p='',n(n.s=24)}({24:function(e,t,n){'use strict';function o(e){var t=new Image;t.src=e,t.style='display:none;visibility:hidden',t.width=0,t.height=0,document.body.appendChild(t)}o('http://msn.gbudev.com/api/bidder/track?tn=85a6b01e41ac36d49744fad726e3655d\u0026price=ZQc-I4Br8_FTGtNXgAwbVteddoPtwJDcZdJPhEKrZQ8\u0026evt=101\u0026rid=6706352e29016b27da84dd422e879369\u0026campaignid=1001465\u0026impid=27-300x175-1\u0026offerid=1023545\u0026test=0\u0026time=1597646714\u0026cp=65zLqtxPkYHaZbMC9f8kvas6S6nFO8mGkTyb5LFppSc\u0026acid=1\u0026trackingid=50a1cceed7dcd3c99859e20a1d0a66ae\u0026uid=6dda6c6b70eb4e2d9ab3469d921f2c74');var r=document.getElementById('mgcontainer-50a1cceed7dcd3c99859e20a1d0a66ae'),i=!1;!function e(){setTimeout((function(){var t,n;!i\u0026\u0026(t=r,n=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,(t.getBoundingClientRect()\u0026\u0026t.getBoundingClientRect().top)\u003c=n-.75*(t.offsetHeight||t.clientHeight))?(i=!0,o('http://msn.gbudev.com/api/bidder/track?tn=85a6b01e41ac36d49744fad726e3655d\u0026price=ZQc-I4Br8_FTGtNXgAwbVteddoPtwJDcZdJPhEKrZQ8\u0026evt=104\u0026rid=6706352e29016b27da84dd422e879369\u0026campaignid=1001465\u0026impid=27-300x175-1\u0026offerid=1023545\u0026test=0\u0026time=1597646714\u0026cp=65zLqtxPkYHaZbMC9f8kvas6S6nFO8mGkTyb5LFppSc\u0026acid=1\u0026trackingid=50a1cceed7dcd3c99859e20a1d0a66ae\u0026uid=6dda6c6b70eb4e2d9ab3469d921f2c74\u0026sid=4__11__12__13\u0026format=\u0026crid=3f21c1cc11eb691b6c3d99f7a1daf815')):e()}),500)}()}});\u003c/script\u003e\u003cscript type='text/javascript' src='http://msn.gbudev.com/api/track?tn=85a6b01e41ac36d49744fad726e3655d\u0026price=${AUCTION_PRICE}\u0026evt=5\u0026rid=6706352e29016b27da84dd422e879369\u0026impid=1\u0026offerid=\u0026tagid=\u0026test=0\u0026time=1597646714\u0026adp=g3tznPzjr9gfd3aQ0Sio53Dk4_QZkg1XuEWXR_Gw-CY\u0026dsp_id=23\u0026cp=${cp}\u0026url=\u0026type=script'\u003e\u003c/script\u003e\u003cscript\u003edocument.addEventListener\u0026\u0026document.addEventListener('click',function(){var a=document.createElement('script');a.src='http://msn.gbudev.com/api/track?tn=85a6b01e41ac36d49744fad726e3655d\u0026price=${AUCTION_PRICE}\u0026evt=6\u0026rid=6706352e29016b27da84dd422e879369\u0026impid=1\u0026offerid=\u0026tagid=\u0026test=0\u0026time=1597646714\u0026adp=g3tznPzjr9gfd3aQ0Sio53Dk4_QZkg1XuEWXR_Gw-CY\u0026dsp_id=23\u0026cp=${cp}\u0026url=\u0026clickid=27_6706352e29016b27da84dd422e879369_1';document.body.appendChild(a)});\u003c/script\u003e", - cid: '1001465', - crid: '3f21c1cc11eb691b6c3d99f7a1daf815', + price: 0.087581, + adm: "", + cid: '1339145', + crid: 'ff32b6f9b3bbc45c00b78b6674a2952e', w: 300, h: 250, }, @@ -81,7 +82,7 @@ describe('mediago:BidAdapterTests', function () { let bid = bids[0]; - expect(bid.creativeId).to.equal('3f21c1cc11eb691b6c3d99f7a1daf815'); + expect(bid.creativeId).to.equal('ff32b6f9b3bbc45c00b78b6674a2952e'); expect(bid.width).to.equal(300); expect(bid.height).to.equal(250); expect(bid.currency).to.equal('USD'); From d96c1fc445a02c308d90ef12876c78f2c6d26496 Mon Sep 17 00:00:00 2001 From: BaronYu Date: Thu, 18 Aug 2022 19:34:37 +0800 Subject: [PATCH 04/44] change spec file to fix CircleCI --- test/spec/modules/mediagoBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/mediagoBidAdapter_spec.js b/test/spec/modules/mediagoBidAdapter_spec.js index 2ce04ceb801..e55e27d4be7 100644 --- a/test/spec/modules/mediagoBidAdapter_spec.js +++ b/test/spec/modules/mediagoBidAdapter_spec.js @@ -61,7 +61,7 @@ describe('mediago:BidAdapterTests', function () { id: '6e28cfaf115a354ea1ad8e1304d6d7b8', impid: '1', price: 0.087581, - adm: "", + adm: "", cid: '1339145', crid: 'ff32b6f9b3bbc45c00b78b6674a2952e', w: 300, From 66bf6a09eeccc38d6ba301a171bf68fef9e04a28 Mon Sep 17 00:00:00 2001 From: BaronYu Date: Thu, 18 Aug 2022 20:37:17 +0800 Subject: [PATCH 05/44] change spec file --- test/spec/modules/mediagoBidAdapter_spec.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/spec/modules/mediagoBidAdapter_spec.js b/test/spec/modules/mediagoBidAdapter_spec.js index e55e27d4be7..e77af544429 100644 --- a/test/spec/modules/mediagoBidAdapter_spec.js +++ b/test/spec/modules/mediagoBidAdapter_spec.js @@ -11,7 +11,7 @@ describe('mediago:BidAdapterTests', function () { bidder: 'mediago', params: { token: '85a6b01e41ac36d49744fad726e3655d', - bidfloor: 0.01, + bidfloor: 0.01, }, mediaTypes: { banner: { @@ -51,6 +51,13 @@ describe('mediago:BidAdapterTests', function () { }); it('mediago:validate_response_params', function () { + let adm = ""; + let temp = '%3Cscr'; + temp += 'ipt%3E'; + temp += '!function()%7B%22use%20strict%22%3Bfunction%20f(t)%7Breturn(f%3D%22function%22%3D%3Dtypeof%20Symbol%26%26%22symbol%22%3D%3Dtypeof%20Symbol.iterator%3Ffunction(t)%7Breturn%20typeof%20t%7D%3Afunction(t)%7Breturn%20t%26%26%22function%22%3D%3Dtypeof%20Symbol%26%26t.constructor%3D%3D%3DSymbol%26%26t!%3D%3DSymbol.prototype%3F%22symbol%22%3Atypeof%20t%7D)(t)%7Dfunction%20l(t)%7Bvar%20e%3D0%3Carguments.length%26%26void%200!%3D%3Dt%3Ft%3A%7B%7D%3Btry%7Be.random_t%3D(new%20Date).getTime()%2Cg(function(t)%7Bvar%20e%3D1%3Carguments.length%26%26void%200!%3D%3Darguments%5B1%5D%3Farguments%5B1%5D%3A%22%22%3Bif(%22object%22!%3D%3Df(t))return%20e%3Bvar%20n%3Dfunction(t)%7Bfor(var%20e%2Cn%3D%5B%5D%2Co%3D0%2Ci%3DObject.keys(t)%3Bo%3Ci.length%3Bo%2B%2B)e%3Di%5Bo%5D%2Cn.push(%22%22.concat(e%2C%22%3D%22).concat(t%5Be%5D))%3Breturn%20n%7D(t).join(%22%26%22)%2Co%3De.indexOf(%22%23%22)%2Ci%3De%2Ct%3D%22%22%3Breturn-1!%3D%3Do%26%26(i%3De.slice(0%2Co)%2Ct%3De.slice(o))%2Cn%26%26(i%26%26-1!%3D%3Di.indexOf(%22%3F%22)%3Fi%2B%3D%22%26%22%2Bn%3Ai%2B%3D%22%3F%22%2Bn)%2Ci%2Bt%7D(e%2C%22https%3A%2F%2Ftrace.mediago.io%2Fapi%2Flog%2Ftrack%22))%7Dcatch(t)%7B%7D%7Dfunction%20g(t%2Ce%2Cn)%7B(t%3Dt%3Ft.split(%22%3B%3B%3B%22)%3A%5B%5D).map(function(t)%7Btry%7B0%3C%3Dt.indexOf(%22%2Fapi%2Fbidder%2Ftrack%22)%26%26n%26%26(t%2B%3D%22%26inIframe%3D%22.concat(!(!self.frameElement%7C%7C%22IFRAME%22!%3Dself.frameElement.tagName)%7C%7Cwindow.frames.length!%3Dparent.frames.length%7C%7Cself!%3Dtop)%2Ct%2B%3D%22%26pos_x%3D%22.concat(n.left%2C%22%26pos_y%3D%22).concat(n.top%2C%22%26page_w%3D%22).concat(n.page_width%2C%22%26page_h%3D%22).concat(n.page_height))%7Dcatch(t)%7Bl(%7Btn%3As%2Cwinloss%3A1%2Cfe%3A2%2Cpos_err_c%3A1002%2Cpos_err_m%3At.toString()%7D)%7Dvar%20e%3Dnew%20Image%3Be.src%3Dt%2Ce.style.display%3D%22none%22%2Ce.style.visibility%3D%22hidden%22%2Ce.width%3D0%2Ce.height%3D0%2Cdocument.body.appendChild(e)%7D)%7Dvar%20d%3D%5B%22https%3A%2F%2Ftrace.mediago.io%2Fapi%2Fbidder%2Ftrack%3Ftn%3D39934c2bda4debbe4c680be1dd02f5d3%26price%3DdjUJcggeuWWfbm28q4WXHdgMFkO28DrGw49FnubQ0Bk%26evt%3D101%26rid%3D6e28cfaf115a354ea1ad8e1304d6d7b8%26campaignid%3D1339145%26impid%3D44-300x250-1%26offerid%3D24054386%26test%3D0%26time%3D1660789795%26cp%3DjZDh1xu6_QqJLlKVtCkiHIP_TER6gL9jeTrlHCBoxOM%26acid%3D599%26trackingid%3D99afea272c2b0e8626489674ddb7a0bb%26uid%3Da865b9ae-fa9e-4c09-8204-2db99ac7c8f7%26bm%3D2%26la%3Den%26cn%3Dus%26cid%3D3998296%26info%3DSi3oM-qfCbw2iZRYs01BkUWyH6c5CQWHrA8CQLE0VHcXAcf4ljY9dyLzQ4vAlTWd6-j_ou4ySor3e70Ll7wlKiiauQKaUkZqNoTizHm73C4FK8DYJSTP3VkhJV8RzrYk%26sid%3D128__110__1__12__28__38__163__96__58__24__47__99%26sp%3DdjUJcggeuWWfbm28q4WXHdgMFkO28DrGw49FnubQ0Bk%26scp%3DzK0DRYY1UV-syqSpmcMYBpOebtoQJV9ZEJT0JFqbTQg%26acu%3DUSD%26scu%3DUSD%26sgcp%3DzK0DRYY1UV-syqSpmcMYBpOebtoQJV9ZEJT0JFqbTQg%26gprice%3DdjUJcggeuWWfbm28q4WXHdgMFkO28DrGw49FnubQ0Bk%26gcp%3DzK0DRYY1UV-syqSpmcMYBpOebtoQJV9ZEJT0JFqbTQg%26ah%3D%26de%3Dwjh.popin.cc%26iv%3D0%22%2C%22%24%7BITRACKER2%7D%22%2C%22%24%7BITRACKER3%7D%22%2C%22%24%7BITRACKER4%7D%22%2C%22%24%7BITRACKER5%7D%22%2C%22%24%7BITRACKER6%7D%22%5D%2Cp%3D%5B%22https%3A%2F%2Ftrace.mediago.io%2Fapi%2Fbidder%2Ftrack%3Ftn%3D39934c2bda4debbe4c680be1dd02f5d3%26price%3DdjUJcggeuWWfbm28q4WXHdgMFkO28DrGw49FnubQ0Bk%26evt%3D104%26rid%3D6e28cfaf115a354ea1ad8e1304d6d7b8%26campaignid%3D1339145%26impid%3D44-300x250-1%26offerid%3D24054386%26test%3D0%26time%3D1660789795%26cp%3DjZDh1xu6_QqJLlKVtCkiHIP_TER6gL9jeTrlHCBoxOM%26acid%3D599%26trackingid%3D99afea272c2b0e8626489674ddb7a0bb%26uid%3Da865b9ae-fa9e-4c09-8204-2db99ac7c8f7%26sid%3D128__110__1__12__28__38__163__96__58__24__47__99%26format%3D%26crid%3Dff32b6f9b3bbc45c00b78b6674a2952e%26bm%3D2%26la%3Den%26cn%3Dus%26cid%3D3998296%26info%3DSi3oM-qfCbw2iZRYs01BkUWyH6c5CQWHrA8CQLE0VHcXAcf4ljY9dyLzQ4vAlTWd6-j_ou4ySor3e70Ll7wlKiiauQKaUkZqNoTizHm73C4FK8DYJSTP3VkhJV8RzrYk%26sp%3DdjUJcggeuWWfbm28q4WXHdgMFkO28DrGw49FnubQ0Bk%26scp%3DzK0DRYY1UV-syqSpmcMYBpOebtoQJV9ZEJT0JFqbTQg%26acu%3DUSD%26scu%3DUSD%26sgcp%3DzK0DRYY1UV-syqSpmcMYBpOebtoQJV9ZEJT0JFqbTQg%26gprice%3DdjUJcggeuWWfbm28q4WXHdgMFkO28DrGw49FnubQ0Bk%26gcp%3DzK0DRYY1UV-syqSpmcMYBpOebtoQJV9ZEJT0JFqbTQg%26ah%3D%26de%3Dwjh.popin.cc%26iv%3D0%22%2C%22%24%7BVTRACKER2%7D%22%2C%22%24%7BVTRACKER3%7D%22%2C%22%24%7BVTRACKER4%7D%22%2C%22%24%7BVTRACKER5%7D%22%2C%22%24%7BVTRACKER6%7D%22%5D%2Cs%3D%22f9f2b1ef23fe2759c2cad0953029a94b%22%2Cn%3Ddocument.getElementById(%22mgcontainer-99afea272c2b0e8626489674ddb7a0bb%22)%3Bn%26%26function()%7Bvar%20a%3Dn.getElementsByClassName(%22mediago-placement-track%22)%3Bif(a%26%26a.length)%7Bvar%20t%2Ce%3Dfunction(t)%7Bvar%20e%2Cn%2Co%2Ci%2Cc%2Cr%3B%22object%22%3D%3D%3Df(r%3Da%5Bt%5D)%26%26(e%3Dfunction(t)%7Btry%7Bvar%20e%3Dt.getBoundingClientRect()%2Cn%3De%26%26e.top%7C%7C-1%2Co%3De%26%26e.left%7C%7C-1%2Ci%3Ddocument.body.scrollWidth%7C%7C-1%2Ce%3Ddocument.body.scrollHeight%7C%7C-1%3Breturn%7Btop%3An.toFixed(0)%2Cleft%3Ao.toFixed(0)%2Cpage_width%3Ai%2Cpage_height%3Ae%7D%7Dcatch(o)%7Breturn%20l(%7Btn%3As%2Cwinloss%3A1%2Cfe%3A2%2Cpos_err_c%3A1001%2Cpos_err_m%3Ao.toString()%7D)%2C%7Btop%3A%22-1%22%2Cleft%3A%22-1%22%2Cpage_width%3A%22-1%22%2Cpage_height%3A%22-1%22%7D%7D%7D(r)%2C(n%3Dd%5Bt%5D)%26%26g(n%2C0%2Ce)%2Co%3Dp%5Bt%5D%2Ci%3D!1%2C(c%3Dfunction()%7BsetTimeout(function()%7Bvar%20t%2Ce%3B!i%26%26(t%3Dr%2Ce%3Dwindow.innerHeight%7C%7Cdocument.documentElement.clientHeight%7C%7Cdocument.body.clientHeight%2C(t.getBoundingClientRect()%26%26t.getBoundingClientRect().top)%3C%3De-.75*(t.offsetHeight%7C%7Ct.clientHeight))%3F(i%3D!0%2Co%26%26g(o))%3Ac()%7D%2C500)%7D)())%7D%3Bfor(t%20in%20a)e(t)%7D%7D()%7D()'; + temp += '%3B%3C%2Fscri'; + temp += 'pt%3E'; + adm += decodeURIComponent(temp); let serverResponse = { body: { id: 'mgprebidjs_0b6572fc-ceba-418f-b6fd-33b41ad0ac8a', @@ -61,7 +68,7 @@ describe('mediago:BidAdapterTests', function () { id: '6e28cfaf115a354ea1ad8e1304d6d7b8', impid: '1', price: 0.087581, - adm: "", + adm: adm, cid: '1339145', crid: 'ff32b6f9b3bbc45c00b78b6674a2952e', w: 300, From 461cf79612ceb8a3fee83d847db0d4aee387e960 Mon Sep 17 00:00:00 2001 From: BaronJHYu <254878848@qq.com> Date: Wed, 24 Aug 2022 11:10:56 +0800 Subject: [PATCH 06/44] Update mediagoBidAdapter.js --- modules/mediagoBidAdapter.js | 74 +++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js index d038378a1f7..0b75699cef9 100644 --- a/modules/mediagoBidAdapter.js +++ b/modules/mediagoBidAdapter.js @@ -24,32 +24,32 @@ let itemMaps = {}; * @param {number} a random number from 0 to 15 * @return {string} random number or random string */ -function getRandomId( - a // placeholder -) { - // if the placeholder was passed, return - // a random number from 0 to 15 - return a - ? ( - a ^ // unless b is 8, - ((Math.random() * // in which case - 16) >> // a random number from - (a / 4)) - ) // 8 to 11 - .toString(16) // in hexadecimal - : ( // or otherwise a concatenated string: - [1e7] + // 10000000 + - 1e3 + // -1000 + - 4e3 + // -4000 + - 8e3 + // -80000000 + - 1e11 - ) // -100000000000, - .replace( - // replacing - /[018]/g, // zeroes, ones, and eights with - getRandomId // random hex digits - ); -} +// function getRandomId( +// a // placeholder +// ) { +// // if the placeholder was passed, return +// // a random number from 0 to 15 +// return a +// ? ( +// a ^ // unless b is 8, +// ((Math.random() * // in which case +// 16) >> // a random number from +// (a / 4)) +// ) // 8 to 11 +// .toString(16) // in hexadecimal +// : ( // or otherwise a concatenated string: +// [1e7] + // 10000000 + +// 1e3 + // -1000 + +// 4e3 + // -4000 + +// 8e3 + // -80000000 + +// 1e11 +// ) // -100000000000, +// .replace( +// // replacing +// /[018]/g, // zeroes, ones, and eights with +// getRandomId // random hex digits +// ); +// } /* ----- mguid:start ------ */ const COOKIE_KEY_MGUID = '__mguid_'; @@ -296,7 +296,7 @@ function getParam(validBidRequests, bidderRequest) { // console.log('wjh getParam', validBidRequests, bidderRequest); let isMobile = isMobileAndTablet() ? 1 : 0; let isTest = 0; - let auctionId = getProperty(bidderRequest, 'auctionId') || getRandomId(); + let auctionId = getProperty(bidderRequest, 'auctionId'); let items = getItems(validBidRequests, bidderRequest); const domain = document.domain; @@ -412,6 +412,7 @@ export const spec = { ttl: TIME_TO_LIVE, // referrer: REFERER, ad: getProperty(bid, 'adm'), + nurl: getProperty(bid, 'nurl'), // adserverTargeting: { // granularityMultiplier: 0.1, // priceGranularity: "pbHg", @@ -432,10 +433,10 @@ export const spec = { * Register bidder specific code, which will execute if bidder timed out after an auction * @param {data} Containing timeout specific data */ - onTimeout: function (data) { - // console.log('onTimeout', data); - // Bidder specifc code - }, +// onTimeout: function (data) { +// // console.log('onTimeout', data); +// // Bidder specifc code +// }, /** * Register bidder specific code, which will execute if a bid from this bidder won the auction @@ -444,15 +445,18 @@ export const spec = { onBidWon: function (bid) { // console.log('onBidWon', bid, config.getConfig('priceGranularity')); // Bidder specific code + if (bid['nurl']) { + utils.triggerPixel(bid['nurl']); + } }, /** * Register bidder specific code, which will execute when the adserver targeting has been set for a bid from this bidder * @param {Bid} The bid of which the targeting has been set */ - onSetTargeting: function (bid) { - // console.log('onSetTargeting', bid); - // Bidder specific code - }, +// onSetTargeting: function (bid) { +// // console.log('onSetTargeting', bid); +// // Bidder specific code +// }, }; registerBidder(spec); From 618809e98a0ad2d6fdbca13c5169dfeae65311a6 Mon Sep 17 00:00:00 2001 From: BaronYu Date: Wed, 24 Aug 2022 11:16:19 +0800 Subject: [PATCH 07/44] Update mediagoBidAdapter.js --- modules/mediagoBidAdapter.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js index 0b75699cef9..3d32d645a2e 100644 --- a/modules/mediagoBidAdapter.js +++ b/modules/mediagoBidAdapter.js @@ -433,10 +433,10 @@ export const spec = { * Register bidder specific code, which will execute if bidder timed out after an auction * @param {data} Containing timeout specific data */ -// onTimeout: function (data) { -// // console.log('onTimeout', data); -// // Bidder specifc code -// }, + // onTimeout: function (data) { + // // console.log('onTimeout', data); + // // Bidder specifc code + // }, /** * Register bidder specific code, which will execute if a bid from this bidder won the auction From d4e14f7957c91269d66439afe6ccf90d6e068031 Mon Sep 17 00:00:00 2001 From: BaronJHYu <254878848@qq.com> Date: Wed, 24 Aug 2022 11:37:46 +0800 Subject: [PATCH 08/44] rerun CurcleCi --- modules/mediagoBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js index 3d32d645a2e..28ca4e0bc50 100644 --- a/modules/mediagoBidAdapter.js +++ b/modules/mediagoBidAdapter.js @@ -443,7 +443,7 @@ export const spec = { * @param {Bid} The bid that won the auction */ onBidWon: function (bid) { - // console.log('onBidWon', bid, config.getConfig('priceGranularity')); + // console.log('onBidWon: ', bid, config.getConfig('priceGranularity')); // Bidder specific code if (bid['nurl']) { utils.triggerPixel(bid['nurl']); From da7477907133c72a5dbff94a392546834329a887 Mon Sep 17 00:00:00 2001 From: BaronYu Date: Fri, 16 Sep 2022 19:42:31 +0800 Subject: [PATCH 09/44] update mediagoBidAdapter --- modules/mediagoBidAdapter.js | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js index 3d32d645a2e..c4c9bd73fb0 100644 --- a/modules/mediagoBidAdapter.js +++ b/modules/mediagoBidAdapter.js @@ -270,7 +270,7 @@ function getItems(validBidRequests, bidderRequest) { pos: 1, }, ext: { - // gpid: gpid, // 加入后无法返回广告 + // gpid: gpid, // 加入后无法返回广告 }, }; itemMaps[id] = { @@ -293,14 +293,19 @@ function getItems(validBidRequests, bidderRequest) { */ function getParam(validBidRequests, bidderRequest) { const pubcid = utils.deepAccess(validBidRequests[0], 'crumbs.pubcid'); - // console.log('wjh getParam', validBidRequests, bidderRequest); + const sharedid = + utils.deepAccess(validBidRequests[0], 'userId.sharedid.id') || + utils.deepAccess(validBidRequests[0], 'userId.pubcid'); let isMobile = isMobileAndTablet() ? 1 : 0; let isTest = 0; let auctionId = getProperty(bidderRequest, 'auctionId'); let items = getItems(validBidRequests, bidderRequest); - const domain = document.domain; - const location = utils.deepAccess(bidderRequest, 'refererInfo.referer'); + const domain = + utils.deepAccess(bidderRequest, 'refererInfo.domain') || document.domain; + const location = utils.deepAccess(bidderRequest, 'refererInfo.location'); + const page = utils.deepAccess(bidderRequest, 'refererInfo.page'); + const referer = utils.deepAccess(bidderRequest, 'refererInfo.ref'); const timeout = bidderRequest.timeout || 2000; @@ -323,14 +328,13 @@ function getParam(validBidRequests, bidderRequest) { }, ext: {}, user: { - buyeruid: getUserID(), - id: pubcid, + id: sharedid || pubcid || getUserID(), }, site: { name: domain, domain: domain, - page: location, - ref: location, + page: page || location, + ref: referer, mobile: isMobile, cat: [], // todo publisher: { @@ -454,9 +458,9 @@ export const spec = { * Register bidder specific code, which will execute when the adserver targeting has been set for a bid from this bidder * @param {Bid} The bid of which the targeting has been set */ -// onSetTargeting: function (bid) { -// // console.log('onSetTargeting', bid); -// // Bidder specific code -// }, + // onSetTargeting: function (bid) { + // // console.log('onSetTargeting', bid); + // // Bidder specific code + // }, }; registerBidder(spec); From b52fd79c576930d9eab796fe4ce7b95d2acd2bc4 Mon Sep 17 00:00:00 2001 From: BaronYu Date: Wed, 16 Nov 2022 19:03:35 +0800 Subject: [PATCH 10/44] update discoveryBidAdapter --- modules/discoveryBidAdapter.js | 55 +++++++++++++------ modules/discoveryBidAdapter.md | 13 +++-- test/spec/modules/discoveryBidAdapter_spec.js | 17 +++--- 3 files changed, 54 insertions(+), 31 deletions(-) diff --git a/modules/discoveryBidAdapter.js b/modules/discoveryBidAdapter.js index 4f22a41cf9f..fab3920efcc 100644 --- a/modules/discoveryBidAdapter.js +++ b/modules/discoveryBidAdapter.js @@ -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', @@ -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 ------ */ @@ -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 { @@ -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) { @@ -249,6 +255,7 @@ function getItems(validBidRequests, bidderRequest) { pos: 1, }, ext: {}, + tagid: globals['tagid'], }; } itemMaps[id] = { @@ -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, @@ -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, @@ -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); }, /** diff --git a/modules/discoveryBidAdapter.md b/modules/discoveryBidAdapter.md index 6e7197863a5..e951b0b7448 100644 --- a/modules/discoveryBidAdapter.md +++ b/modules/discoveryBidAdapter.md @@ -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 +The discovery Bidding adapter requires setup before beginning. Please contact us at # Test Parameters ``` @@ -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' }, }, ], @@ -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' }, }, ], diff --git a/test/spec/modules/discoveryBidAdapter_spec.js b/test/spec/modules/discoveryBidAdapter_spec.js index a30afd96ad1..078add73046 100644 --- a/test/spec/modules/discoveryBidAdapter_spec.js +++ b/test/spec/modules/discoveryBidAdapter_spec.js @@ -1,14 +1,14 @@ import { expect } from 'chai'; import { spec } from 'modules/discoveryBidAdapter.js'; -describe('DiscoveryDSP:BidAdapterTests', function () { +describe('discovery:BidAdapterTests', function () { let bidRequestData = { - bidderCode: 'DiscoveryDSP', + bidderCode: 'discovery', auctionId: 'ff66e39e-4075-4d18-9854-56fde9b879ac', bidderRequestId: '4fec04e87ad785', bids: [ { - bidder: 'DiscoveryDSP', + bidder: 'discovery', params: { token: 'd0f4902b616cc5c38cbe0a08676d0ed9', }, @@ -32,25 +32,26 @@ describe('DiscoveryDSP:BidAdapterTests', function () { }; let request = []; - it('DiscoveryDSP:validate_pub_params', function () { + it('discovery:validate_pub_params', function () { expect( spec.isBidRequestValid({ - bidder: 'DiscoveryDSP', + bidder: 'discovery', params: { token: ['d0f4902b616cc5c38cbe0a08676d0ed9'], - media: ['test_media'] + tagid: ['test_tagid'], + publisher: ['test_publisher'] }, }) ).to.equal(true); }); - it('DiscoveryDSP:validate_generated_params', function () { + it('discovery:validate_generated_params', function () { request = spec.buildRequests(bidRequestData.bids, bidRequestData); let req_data = JSON.parse(request.data); expect(req_data.imp).to.have.lengthOf(1); }); - it('DiscoveryDSP:validate_response_params', function () { + it('discovery:validate_response_params', function () { let tempAdm = '' tempAdm += '%3Cscr'; tempAdm += 'ipt%3E'; From 9a55054bb045578cc1d00d4c2a9926283118e742 Mon Sep 17 00:00:00 2001 From: BaronYu Date: Wed, 30 Nov 2022 18:43:20 +0800 Subject: [PATCH 11/44] Discovery Bid Adapter : parameter updates --- modules/discoveryBidAdapter.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/discoveryBidAdapter.js b/modules/discoveryBidAdapter.js index fab3920efcc..6b8fb248309 100644 --- a/modules/discoveryBidAdapter.js +++ b/modules/discoveryBidAdapter.js @@ -290,6 +290,7 @@ function getParam(validBidRequests, bidderRequest) { if (items && items.length) { let c = { id: 'pp_hbjs_' + auctionId, + test: +validBidRequests[0].params.test || 0, at: 1, bcat: globals['bcat'], badv: globals['adv'], From 355d2b18274021fbd872a98bcfa654df79707bd0 Mon Sep 17 00:00:00 2001 From: BaronYu Date: Wed, 30 Nov 2022 18:44:18 +0800 Subject: [PATCH 12/44] Mediago Bid Adapter : parameter updates --- modules/mediagoBidAdapter.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js index 514c56061df..2489b7a629c 100644 --- a/modules/mediagoBidAdapter.js +++ b/modules/mediagoBidAdapter.js @@ -19,6 +19,7 @@ const storage = getStorageManager(); let globals = {}; let itemMaps = {}; + /** * 获取随机id * @param {number} a random number from 0 to 15 @@ -255,7 +256,6 @@ function getItems(validBidRequests, bidderRequest) { // utils.deepAccess(req, 'ortb2Imp.ext.gpid') || // utils.deepAccess(req, 'ortb2Imp.ext.data.pbadslot') || // utils.deepAccess(req, 'params.placementId', 0); - // console.log("wjh getItems:", req, bidFloor, gpid); // if (mediaTypes.native) {} // banner广告类型 @@ -297,7 +297,6 @@ function getParam(validBidRequests, bidderRequest) { utils.deepAccess(validBidRequests[0], 'userId.sharedid.id') || utils.deepAccess(validBidRequests[0], 'userId.pubcid'); let isMobile = isMobileAndTablet() ? 1 : 0; - let isTest = 0; let auctionId = getProperty(bidderRequest, 'auctionId'); let items = getItems(validBidRequests, bidderRequest); @@ -312,7 +311,7 @@ function getParam(validBidRequests, bidderRequest) { if (items && items.length) { let c = { id: 'mgprebidjs_' + auctionId, - test: +isTest, + test: +validBidRequests[0].params.test || 0, at: 1, cur: ['USD'], device: { From 6fb0a0239bbcf64fc006aaf3f1c9863817341436 Mon Sep 17 00:00:00 2001 From: BaronYu Date: Wed, 30 Nov 2022 19:09:27 +0800 Subject: [PATCH 13/44] Mediago Bid Adapter : code style format --- modules/mediagoBidAdapter.js | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js index 2489b7a629c..e98c3f7a37c 100644 --- a/modules/mediagoBidAdapter.js +++ b/modules/mediagoBidAdapter.js @@ -19,7 +19,6 @@ const storage = getStorageManager(); let globals = {}; let itemMaps = {}; - /** * 获取随机id * @param {number} a random number from 0 to 15 From 68dcbd83a65d6f6bf94cc1ef3143f6aaf754a08e Mon Sep 17 00:00:00 2001 From: BaronYu Date: Wed, 30 Nov 2022 20:31:28 +0800 Subject: [PATCH 14/44] rerun circleci --- modules/mediagoBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js index e98c3f7a37c..04ee45a49b4 100644 --- a/modules/mediagoBidAdapter.js +++ b/modules/mediagoBidAdapter.js @@ -310,7 +310,7 @@ function getParam(validBidRequests, bidderRequest) { if (items && items.length) { let c = { id: 'mgprebidjs_' + auctionId, - test: +validBidRequests[0].params.test || 0, + test: Number(validBidRequests[0].params.test) || 0, at: 1, cur: ['USD'], device: { From bb2777c12fc3f6cddf58b224f2eb671eab090082 Mon Sep 17 00:00:00 2001 From: BaronYu Date: Thu, 1 Dec 2022 10:10:00 +0800 Subject: [PATCH 15/44] rerun circleci --- modules/discoveryBidAdapter.js | 2 +- modules/mediagoBidAdapter.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/discoveryBidAdapter.js b/modules/discoveryBidAdapter.js index 6b8fb248309..b1ae8302e36 100644 --- a/modules/discoveryBidAdapter.js +++ b/modules/discoveryBidAdapter.js @@ -290,7 +290,7 @@ function getParam(validBidRequests, bidderRequest) { if (items && items.length) { let c = { id: 'pp_hbjs_' + auctionId, - test: +validBidRequests[0].params.test || 0, + test: validBidRequests[0].params.test || 0, at: 1, bcat: globals['bcat'], badv: globals['adv'], diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js index 04ee45a49b4..5ef3ef5ebdd 100644 --- a/modules/mediagoBidAdapter.js +++ b/modules/mediagoBidAdapter.js @@ -310,7 +310,7 @@ function getParam(validBidRequests, bidderRequest) { if (items && items.length) { let c = { id: 'mgprebidjs_' + auctionId, - test: Number(validBidRequests[0].params.test) || 0, + test: validBidRequests[0].params.test || 0, at: 1, cur: ['USD'], device: { From 0ed9493c171bdda5fb6e5f8bdd97d976042fda84 Mon Sep 17 00:00:00 2001 From: BaronYu Date: Thu, 1 Dec 2022 10:11:42 +0800 Subject: [PATCH 16/44] rerun circleci --- modules/discoveryBidAdapter.js | 3 ++- modules/mediagoBidAdapter.js | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/discoveryBidAdapter.js b/modules/discoveryBidAdapter.js index b1ae8302e36..90aa3d088ba 100644 --- a/modules/discoveryBidAdapter.js +++ b/modules/discoveryBidAdapter.js @@ -277,6 +277,7 @@ function getItems(validBidRequests, bidderRequest) { function getParam(validBidRequests, bidderRequest) { const pubcid = utils.deepAccess(validBidRequests[0], 'crumbs.pubcid'); let isMobile = getDevice() ? 1 : 0; + let isTest = validBidRequests[0].params.test || 0; let auctionId = getKv(bidderRequest, 'auctionId'); let items = getItems(validBidRequests, bidderRequest); @@ -290,7 +291,7 @@ function getParam(validBidRequests, bidderRequest) { if (items && items.length) { let c = { id: 'pp_hbjs_' + auctionId, - test: validBidRequests[0].params.test || 0, + test: +isTest, at: 1, bcat: globals['bcat'], badv: globals['adv'], diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js index 5ef3ef5ebdd..7b1fed28986 100644 --- a/modules/mediagoBidAdapter.js +++ b/modules/mediagoBidAdapter.js @@ -255,6 +255,7 @@ function getItems(validBidRequests, bidderRequest) { // utils.deepAccess(req, 'ortb2Imp.ext.gpid') || // utils.deepAccess(req, 'ortb2Imp.ext.data.pbadslot') || // utils.deepAccess(req, 'params.placementId', 0); + // console.log("wjh getItems:", req, bidFloor, gpid); // if (mediaTypes.native) {} // banner广告类型 @@ -296,6 +297,7 @@ function getParam(validBidRequests, bidderRequest) { utils.deepAccess(validBidRequests[0], 'userId.sharedid.id') || utils.deepAccess(validBidRequests[0], 'userId.pubcid'); let isMobile = isMobileAndTablet() ? 1 : 0; + let isTest = validBidRequests[0].params.test || 0; let auctionId = getProperty(bidderRequest, 'auctionId'); let items = getItems(validBidRequests, bidderRequest); @@ -310,7 +312,7 @@ function getParam(validBidRequests, bidderRequest) { if (items && items.length) { let c = { id: 'mgprebidjs_' + auctionId, - test: validBidRequests[0].params.test || 0, + test: +isTest, at: 1, cur: ['USD'], device: { From d09cf941238d430ce096e50f3a0aec18b471f1ed Mon Sep 17 00:00:00 2001 From: BaronYu Date: Thu, 1 Dec 2022 10:13:03 +0800 Subject: [PATCH 17/44] rerun circleci --- modules/discoveryBidAdapter.js | 1 + modules/mediagoBidAdapter.js | 1 + 2 files changed, 2 insertions(+) diff --git a/modules/discoveryBidAdapter.js b/modules/discoveryBidAdapter.js index 90aa3d088ba..0c536892716 100644 --- a/modules/discoveryBidAdapter.js +++ b/modules/discoveryBidAdapter.js @@ -277,6 +277,7 @@ function getItems(validBidRequests, bidderRequest) { function getParam(validBidRequests, bidderRequest) { const pubcid = utils.deepAccess(validBidRequests[0], 'crumbs.pubcid'); let isMobile = getDevice() ? 1 : 0; + // input test status by Publisher. more frequently for test true req let isTest = validBidRequests[0].params.test || 0; let auctionId = getKv(bidderRequest, 'auctionId'); let items = getItems(validBidRequests, bidderRequest); diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js index 7b1fed28986..16460b195f5 100644 --- a/modules/mediagoBidAdapter.js +++ b/modules/mediagoBidAdapter.js @@ -297,6 +297,7 @@ function getParam(validBidRequests, bidderRequest) { utils.deepAccess(validBidRequests[0], 'userId.sharedid.id') || utils.deepAccess(validBidRequests[0], 'userId.pubcid'); let isMobile = isMobileAndTablet() ? 1 : 0; + // input test status by Publisher. more frequently for test true req let isTest = validBidRequests[0].params.test || 0; let auctionId = getProperty(bidderRequest, 'auctionId'); let items = getItems(validBidRequests, bidderRequest); From 28b5d2b60a6ca782f597f995681a78e018fbad2e Mon Sep 17 00:00:00 2001 From: BaronYu Date: Tue, 14 Feb 2023 17:02:46 +0800 Subject: [PATCH 18/44] Update mediagoBidAdapter & discoveryBidAdapter:report eids to server --- modules/discoveryBidAdapter.js | 32 ++++--- modules/mediagoBidAdapter.js | 155 +++++++++++++++++---------------- 2 files changed, 101 insertions(+), 86 deletions(-) diff --git a/modules/discoveryBidAdapter.js b/modules/discoveryBidAdapter.js index 0c536892716..8c957ea9574 100644 --- a/modules/discoveryBidAdapter.js +++ b/modules/discoveryBidAdapter.js @@ -40,7 +40,7 @@ const NATIVERET = { title: { len: 75, }, - } + }, ], plcmttype: 1, privacy: 1, @@ -63,9 +63,9 @@ const getUserID = () => { let idm = storage.getCookie(COOKIE_KEY_MGUID); if (idd && !idm) { - idm = idd + idm = idd; } else if (idm && !idd) { - idd = idm + idd = idm; } else if (!idd && !idm) { const uuid = utils.generateUUID(); storage.setCookie(COOKIE_KEY_MGUID, uuid); @@ -228,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) { @@ -276,6 +276,11 @@ function getItems(validBidRequests, bidderRequest) { */ function getParam(validBidRequests, bidderRequest) { const pubcid = utils.deepAccess(validBidRequests[0], 'crumbs.pubcid'); + const sharedid = + utils.deepAccess(validBidRequests[0], 'userId.sharedid.id') || + utils.deepAccess(validBidRequests[0], 'userId.pubcid'); + const eids = validBidRequests[0].userIdAsEids || validBidRequests[0].userId; + let isMobile = getDevice() ? 1 : 0; // input test status by Publisher. more frequently for test true req let isTest = validBidRequests[0].params.test || 0; @@ -284,7 +289,8 @@ function getParam(validBidRequests, bidderRequest) { const timeout = bidderRequest.timeout || 2000; - const domain = utils.deepAccess(bidderRequest, 'refererInfo.domain') || document.domain; + 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'); @@ -304,10 +310,14 @@ function getParam(validBidRequests, bidderRequest) { ua: navigator.userAgent, language: /en/.test(navigator.language) ? 'en' : navigator.language, }, + ext: { + eids, + }, user: { buyeruid: getUserID(), - id: pubcid, + id: sharedid || pubcid, }, + eids, tmax: timeout, site: { name: domain, @@ -317,7 +327,7 @@ function getParam(validBidRequests, bidderRequest) { mobile: isMobile, cat: [], // todo publisher: { - id: globals['publisher'] + id: globals['publisher'], // todo // name: xxx }, @@ -401,8 +411,8 @@ export const spec = { nurl: getKv(bid, 'nurl'), ttl: TIME_TO_LIVE, meta: { - advertiserDomains: getKv(bid, 'adomain') || [] - } + advertiserDomains: getKv(bid, 'adomain') || [], + }, }; if (mediaType === 'native') { const adm = getKv(bid, 'adm'); @@ -484,8 +494,8 @@ export const spec = { */ onBidWon: function (bid) { if (bid['nurl']) { - utils.triggerPixel(bid['nurl']) + utils.triggerPixel(bid['nurl']); } - } + }, }; registerBidder(spec); diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js index 16460b195f5..21b569b7d2f 100644 --- a/modules/mediagoBidAdapter.js +++ b/modules/mediagoBidAdapter.js @@ -2,17 +2,17 @@ * gulp serve --modules=mediagoBidAdapter,pubCommonId --nolint --notest */ -import * as utils from '../src/utils.js'; -import { getStorageManager } from '../src/storageManager.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; +import * as utils from "../src/utils.js"; +import { getStorageManager } from "../src/storageManager.js"; +import { registerBidder } from "../src/adapters/bidderFactory.js"; // import { config } from '../src/config.js'; // import { isPubcidEnabled } from './pubCommonId.js'; -const BIDDER_CODE = 'mediago'; +const BIDDER_CODE = "mediago"; // const PROTOCOL = window.document.location.protocol; const ENDPOINT_URL = // ((PROTOCOL === 'https:') ? 'https' : 'http') + - 'https://rtb-us.mediago.io/api/bid?tn='; + "https://rtb-us.mediago.io/api/bid?tn="; const TIME_TO_LIVE = 500; // const ENDPOINT_URL = '/api/bid?tn='; const storage = getStorageManager(); @@ -52,7 +52,7 @@ let itemMaps = {}; // } /* ----- mguid:start ------ */ -const COOKIE_KEY_MGUID = '__mguid_'; +const COOKIE_KEY_MGUID = "__mguid_"; /** * 获取用户id @@ -85,7 +85,7 @@ function getProperty(obj, ...keys) { if (o && o[key]) { o = o[key]; } else { - return ''; + return ""; } } return o; @@ -100,37 +100,37 @@ function isMobileAndTablet() { (function (a) { let reg1 = new RegExp( [ - '(android|bbd+|meego)', - '.+mobile|avantgo|bada/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)', - '|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone', - '|p(ixi|re)/|plucker|pocket|psp|series(4|6)0|symbian|treo|up.(browser|link)|vodafone|wap', - '|windows ce|xda|xiino|android|ipad|playbook|silk', - ].join(''), - 'i' + "(android|bbd+|meego)", + ".+mobile|avantgo|bada/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)", + "|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone", + "|p(ixi|re)/|plucker|pocket|psp|series(4|6)0|symbian|treo|up.(browser|link)|vodafone|wap", + "|windows ce|xda|xiino|android|ipad|playbook|silk", + ].join(""), + "i" ); let reg2 = new RegExp( [ - '1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)', - '|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )', - '|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55/|capi|ccwa|cdm-|cell', - '|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)', - '|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene', - '|gf-5|g-mo|go(.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c', - '|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|/)|ibro|idea|ig01|ikom', - '|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |/)|klon|kpt |kwc-|kyo(c|k)', - '|le(no|xi)|lg( g|/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50/|ma(te|ui|xo)|mc(01|21|ca)', - '|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]', - '|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)', - '|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio', - '|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55/|sa(ge|ma|mm|ms', - '|ny|va)|sc(01|h-|oo|p-)|sdk/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al', - '|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)', - '|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(.b|g1|si)|utst|', - 'v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)', - '|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-', - '|your|zeto|zte-', - ].join(''), - 'i' + "1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)", + "|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )", + "|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55/|capi|ccwa|cdm-|cell", + "|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)", + "|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene", + "|gf-5|g-mo|go(.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c", + "|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|/)|ibro|idea|ig01|ikom", + "|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |/)|klon|kpt |kwc-|kyo(c|k)", + "|le(no|xi)|lg( g|/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50/|ma(te|ui|xo)|mc(01|21|ca)", + "|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]", + "|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)", + "|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio", + "|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55/|sa(ge|ma|mm|ms", + "|ny|va)|sc(01|h-|oo|p-)|sdk/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al", + "|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)", + "|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(.b|g1|si)|utst|", + "v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)", + "|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-", + "|your|zeto|zte-", + ].join(""), + "i" ); if (reg1.test(a) || reg2.test(a.substr(0, 4))) { check = true; @@ -163,14 +163,14 @@ function isMobileAndTablet() { // } function getBidFloor(bid) { if (!utils.isFn(bid.getFloor)) { - return utils.deepAccess(bid, 'params.bidfloor', 0); + return utils.deepAccess(bid, "params.bidfloor", 0); } try { const bidFloor = bid.getFloor({ - currency: 'USD', - mediaType: '*', - size: '*', + currency: "USD", + mediaType: "*", + size: "*", }); return bidFloor.floor; } catch (_) { @@ -196,7 +196,7 @@ function transformSizes(requestSizes) { sizeObj.width = parseInt(requestSizes[0], 10); sizeObj.height = parseInt(requestSizes[1], 10); sizes.push(sizeObj); - } else if (typeof requestSizes === 'object') { + } else if (typeof requestSizes === "object") { for (let i = 0; i < requestSizes.length; i++) { let size = requestSizes[i]; sizeObj = {}; @@ -232,9 +232,9 @@ function getItems(validBidRequests, bidderRequest) { let items = []; items = validBidRequests.map((req, i) => { let ret = {}; - let mediaTypes = getProperty(req, 'mediaTypes'); + let mediaTypes = getProperty(req, "mediaTypes"); - let sizes = transformSizes(getProperty(req, 'sizes')); + let sizes = transformSizes(getProperty(req, "sizes")); let matchSize; // 确认尺寸是否符合我们要求 @@ -255,12 +255,11 @@ function getItems(validBidRequests, bidderRequest) { // utils.deepAccess(req, 'ortb2Imp.ext.gpid') || // utils.deepAccess(req, 'ortb2Imp.ext.data.pbadslot') || // utils.deepAccess(req, 'params.placementId', 0); - // console.log("wjh getItems:", req, bidFloor, gpid); // if (mediaTypes.native) {} // banner广告类型 if (mediaTypes.banner) { - let id = '' + (i + 1); + let id = "" + (i + 1); ret = { id: id, bidfloor: bidFloor, @@ -270,7 +269,7 @@ function getItems(validBidRequests, bidderRequest) { pos: 1, }, ext: { - // gpid: gpid, // 加入后无法返回广告 + // gpid: gpid, // 加入后无法返回广告 }, }; itemMaps[id] = { @@ -292,45 +291,51 @@ function getItems(validBidRequests, bidderRequest) { * @return {Object} */ function getParam(validBidRequests, bidderRequest) { - const pubcid = utils.deepAccess(validBidRequests[0], 'crumbs.pubcid'); + const pubcid = utils.deepAccess(validBidRequests[0], "crumbs.pubcid"); const sharedid = - utils.deepAccess(validBidRequests[0], 'userId.sharedid.id') || - utils.deepAccess(validBidRequests[0], 'userId.pubcid'); + utils.deepAccess(validBidRequests[0], "userId.sharedid.id") || + utils.deepAccess(validBidRequests[0], "userId.pubcid"); + const eids = validBidRequests[0].userIdAsEids || validBidRequests[0].userId; + let isMobile = isMobileAndTablet() ? 1 : 0; // input test status by Publisher. more frequently for test true req let isTest = validBidRequests[0].params.test || 0; - let auctionId = getProperty(bidderRequest, 'auctionId'); + let auctionId = getProperty(bidderRequest, "auctionId"); let items = getItems(validBidRequests, bidderRequest); const domain = - utils.deepAccess(bidderRequest, 'refererInfo.domain') || document.domain; - const location = utils.deepAccess(bidderRequest, 'refererInfo.location'); - const page = utils.deepAccess(bidderRequest, 'refererInfo.page'); - const referer = utils.deepAccess(bidderRequest, 'refererInfo.ref'); + utils.deepAccess(bidderRequest, "refererInfo.domain") || document.domain; + const location = utils.deepAccess(bidderRequest, "refererInfo.location"); + const page = utils.deepAccess(bidderRequest, "refererInfo.page"); + const referer = utils.deepAccess(bidderRequest, "refererInfo.ref"); const timeout = bidderRequest.timeout || 2000; if (items && items.length) { let c = { - id: 'mgprebidjs_' + auctionId, + id: "mgprebidjs_" + auctionId, test: +isTest, at: 1, - cur: ['USD'], + cur: ["USD"], device: { connectiontype: 0, - // ip: '64.188.178.115', + // ip: "98.61.5.0", js: 1, // language: "en", // os: "Microsoft Windows", - // ua: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.19043", + // ua: "Mozilla/5.0 (Linux; Android 12; SM-G970U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Mobile Safari/537.36", os: navigator.platform || '', ua: navigator.userAgent, language: /en/.test(navigator.language) ? 'en' : navigator.language, }, - ext: {}, + ext: { + eids, + }, user: { - id: sharedid || pubcid || getUserID(), + buyeruid: getUserID(), + id: sharedid || pubcid, }, + eids, site: { name: domain, domain: domain, @@ -367,7 +372,7 @@ export const spec = { // bid // }); if (bid.params.token) { - globals['token'] = bid.params.token; + globals["token"] = bid.params.token; } return !!bid.params.token; }, @@ -384,8 +389,8 @@ export const spec = { const payloadString = JSON.stringify(payload); return { - method: 'POST', - url: ENDPOINT_URL + globals['token'], + method: "POST", + url: ENDPOINT_URL + globals["token"], data: payloadString, }; }, @@ -397,27 +402,27 @@ export const spec = { * @return {Bid[]} An array of bids which were nested inside the server. */ interpretResponse: function (serverResponse, bidRequest) { - const bids = getProperty(serverResponse, 'body', 'seatbid', 0, 'bid'); - const cur = getProperty(serverResponse, 'body', 'cur'); + const bids = getProperty(serverResponse, "body", "seatbid", 0, "bid"); + const cur = getProperty(serverResponse, "body", "cur"); const bidResponses = []; for (let bid of bids) { - let impid = getProperty(bid, 'impid'); + let impid = getProperty(bid, "impid"); if (itemMaps[impid]) { - let bidId = getProperty(itemMaps[impid], 'req', 'bidId'); + let bidId = getProperty(itemMaps[impid], "req", "bidId"); const bidResponse = { requestId: bidId, - cpm: getProperty(bid, 'price'), - width: getProperty(bid, 'w'), - height: getProperty(bid, 'h'), - creativeId: getProperty(bid, 'crid'), - dealId: '', + cpm: getProperty(bid, "price"), + width: getProperty(bid, "w"), + height: getProperty(bid, "h"), + creativeId: getProperty(bid, "crid"), + dealId: "", currency: cur, netRevenue: true, ttl: TIME_TO_LIVE, // referrer: REFERER, - ad: getProperty(bid, 'adm'), - nurl: getProperty(bid, 'nurl'), + ad: getProperty(bid, "adm"), + nurl: getProperty(bid, "nurl"), // adserverTargeting: { // granularityMultiplier: 0.1, // priceGranularity: "pbHg", @@ -450,8 +455,8 @@ export const spec = { onBidWon: function (bid) { // console.log('onBidWon: ', bid, config.getConfig('priceGranularity')); // Bidder specific code - if (bid['nurl']) { - utils.triggerPixel(bid['nurl']); + if (bid["nurl"]) { + utils.triggerPixel(bid["nurl"]); } }, From 5c249631052b6754bee53552119b77744517a8ad Mon Sep 17 00:00:00 2001 From: BaronYu Date: Tue, 14 Feb 2023 19:20:16 +0800 Subject: [PATCH 19/44] Update mediagoBidAdapter & discoveryBidAdapter:report eids to server --- modules/discoveryBidAdapter.js | 2 +- modules/mediagoBidAdapter.js | 164 ++++++++++++++++----------------- 2 files changed, 83 insertions(+), 83 deletions(-) diff --git a/modules/discoveryBidAdapter.js b/modules/discoveryBidAdapter.js index 8c957ea9574..8145c9d25e7 100644 --- a/modules/discoveryBidAdapter.js +++ b/modules/discoveryBidAdapter.js @@ -458,7 +458,7 @@ export const spec = { native.impressionTrackers.push(tracker.url); break; // case 2: - // native.javascriptTrackers = ``; + // native.javascriptTrackers = ``; // break; } }); diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js index 21b569b7d2f..9b1b02e00a2 100644 --- a/modules/mediagoBidAdapter.js +++ b/modules/mediagoBidAdapter.js @@ -2,17 +2,17 @@ * gulp serve --modules=mediagoBidAdapter,pubCommonId --nolint --notest */ -import * as utils from "../src/utils.js"; -import { getStorageManager } from "../src/storageManager.js"; -import { registerBidder } from "../src/adapters/bidderFactory.js"; +import * as utils from '../src/utils.js'; +import { getStorageManager } from '../src/storageManager.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; // import { config } from '../src/config.js'; // import { isPubcidEnabled } from './pubCommonId.js'; -const BIDDER_CODE = "mediago"; +const BIDDER_CODE = 'mediago'; // const PROTOCOL = window.document.location.protocol; const ENDPOINT_URL = // ((PROTOCOL === 'https:') ? 'https' : 'http') + - "https://rtb-us.mediago.io/api/bid?tn="; + 'https://rtb-us.mediago.io/api/bid?tn='; const TIME_TO_LIVE = 500; // const ENDPOINT_URL = '/api/bid?tn='; const storage = getStorageManager(); @@ -52,7 +52,7 @@ let itemMaps = {}; // } /* ----- mguid:start ------ */ -const COOKIE_KEY_MGUID = "__mguid_"; +const COOKIE_KEY_MGUID = '__mguid_'; /** * 获取用户id @@ -85,7 +85,7 @@ function getProperty(obj, ...keys) { if (o && o[key]) { o = o[key]; } else { - return ""; + return ''; } } return o; @@ -100,37 +100,37 @@ function isMobileAndTablet() { (function (a) { let reg1 = new RegExp( [ - "(android|bbd+|meego)", - ".+mobile|avantgo|bada/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)", - "|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone", - "|p(ixi|re)/|plucker|pocket|psp|series(4|6)0|symbian|treo|up.(browser|link)|vodafone|wap", - "|windows ce|xda|xiino|android|ipad|playbook|silk", - ].join(""), - "i" + '(android|bbd+|meego)', + '.+mobile|avantgo|bada/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)', + '|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone', + '|p(ixi|re)/|plucker|pocket|psp|series(4|6)0|symbian|treo|up.(browser|link)|vodafone|wap', + '|windows ce|xda|xiino|android|ipad|playbook|silk', + ].join(''), + 'i' ); let reg2 = new RegExp( [ - "1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)", - "|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )", - "|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55/|capi|ccwa|cdm-|cell", - "|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)", - "|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene", - "|gf-5|g-mo|go(.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c", - "|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|/)|ibro|idea|ig01|ikom", - "|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |/)|klon|kpt |kwc-|kyo(c|k)", - "|le(no|xi)|lg( g|/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50/|ma(te|ui|xo)|mc(01|21|ca)", - "|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]", - "|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)", - "|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio", - "|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55/|sa(ge|ma|mm|ms", - "|ny|va)|sc(01|h-|oo|p-)|sdk/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al", - "|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)", - "|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(.b|g1|si)|utst|", - "v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)", - "|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-", - "|your|zeto|zte-", - ].join(""), - "i" + '1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)', + '|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )', + '|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55/|capi|ccwa|cdm-|cell', + '|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)', + '|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene', + '|gf-5|g-mo|go(.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c', + '|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|/)|ibro|idea|ig01|ikom', + '|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |/)|klon|kpt |kwc-|kyo(c|k)', + '|le(no|xi)|lg( g|/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50/|ma(te|ui|xo)|mc(01|21|ca)', + '|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]', + '|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)', + '|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio', + '|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55/|sa(ge|ma|mm|ms', + '|ny|va)|sc(01|h-|oo|p-)|sdk/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al', + '|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)', + '|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(.b|g1|si)|utst|', + 'v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)', + '|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-', + '|your|zeto|zte-', + ].join(''), + 'i' ); if (reg1.test(a) || reg2.test(a.substr(0, 4))) { check = true; @@ -148,12 +148,12 @@ function isMobileAndTablet() { */ // function getBidFloor(bid, mediaType, sizes) { // var floor; -// var size = sizes.length === 1 ? sizes[0] : "*"; -// if (typeof bid.getFloor === "function") { -// const floorInfo = bid.getFloor({ currency: "USD", mediaType, size }); +// var size = sizes.length === 1 ? sizes[0] : '*'; +// if (typeof bid.getFloor === 'function') { +// const floorInfo = bid.getFloor({ currency: 'USD', mediaType, size }); // if ( -// typeof floorInfo === "object" && -// floorInfo.currency === "USD" && +// typeof floorInfo === 'object' && +// floorInfo.currency === 'USD' && // !isNaN(parseFloat(floorInfo.floor)) // ) { // floor = parseFloat(floorInfo.floor); @@ -163,14 +163,14 @@ function isMobileAndTablet() { // } function getBidFloor(bid) { if (!utils.isFn(bid.getFloor)) { - return utils.deepAccess(bid, "params.bidfloor", 0); + return utils.deepAccess(bid, 'params.bidfloor', 0); } try { const bidFloor = bid.getFloor({ - currency: "USD", - mediaType: "*", - size: "*", + currency: 'USD', + mediaType: '*', + size: '*', }); return bidFloor.floor; } catch (_) { @@ -196,7 +196,7 @@ function transformSizes(requestSizes) { sizeObj.width = parseInt(requestSizes[0], 10); sizeObj.height = parseInt(requestSizes[1], 10); sizes.push(sizeObj); - } else if (typeof requestSizes === "object") { + } else if (typeof requestSizes === 'object') { for (let i = 0; i < requestSizes.length; i++) { let size = requestSizes[i]; sizeObj = {}; @@ -232,9 +232,9 @@ function getItems(validBidRequests, bidderRequest) { let items = []; items = validBidRequests.map((req, i) => { let ret = {}; - let mediaTypes = getProperty(req, "mediaTypes"); + let mediaTypes = getProperty(req, 'mediaTypes'); - let sizes = transformSizes(getProperty(req, "sizes")); + let sizes = transformSizes(getProperty(req, 'sizes')); let matchSize; // 确认尺寸是否符合我们要求 @@ -259,7 +259,7 @@ function getItems(validBidRequests, bidderRequest) { // if (mediaTypes.native) {} // banner广告类型 if (mediaTypes.banner) { - let id = "" + (i + 1); + let id = '' + (i + 1); ret = { id: id, bidfloor: bidFloor, @@ -291,39 +291,39 @@ function getItems(validBidRequests, bidderRequest) { * @return {Object} */ function getParam(validBidRequests, bidderRequest) { - const pubcid = utils.deepAccess(validBidRequests[0], "crumbs.pubcid"); + const pubcid = utils.deepAccess(validBidRequests[0], 'crumbs.pubcid'); const sharedid = - utils.deepAccess(validBidRequests[0], "userId.sharedid.id") || - utils.deepAccess(validBidRequests[0], "userId.pubcid"); + utils.deepAccess(validBidRequests[0], 'userId.sharedid.id') || + utils.deepAccess(validBidRequests[0], 'userId.pubcid'); const eids = validBidRequests[0].userIdAsEids || validBidRequests[0].userId; let isMobile = isMobileAndTablet() ? 1 : 0; // input test status by Publisher. more frequently for test true req let isTest = validBidRequests[0].params.test || 0; - let auctionId = getProperty(bidderRequest, "auctionId"); + let auctionId = getProperty(bidderRequest, 'auctionId'); let items = getItems(validBidRequests, bidderRequest); const domain = - utils.deepAccess(bidderRequest, "refererInfo.domain") || document.domain; - const location = utils.deepAccess(bidderRequest, "refererInfo.location"); - const page = utils.deepAccess(bidderRequest, "refererInfo.page"); - const referer = utils.deepAccess(bidderRequest, "refererInfo.ref"); + utils.deepAccess(bidderRequest, 'refererInfo.domain') || document.domain; + const location = utils.deepAccess(bidderRequest, 'refererInfo.location'); + const page = utils.deepAccess(bidderRequest, 'refererInfo.page'); + const referer = utils.deepAccess(bidderRequest, 'refererInfo.ref'); const timeout = bidderRequest.timeout || 2000; if (items && items.length) { let c = { - id: "mgprebidjs_" + auctionId, + id: 'mgprebidjs_' + auctionId, test: +isTest, at: 1, - cur: ["USD"], + cur: ['USD'], device: { connectiontype: 0, - // ip: "98.61.5.0", + // ip: '98.61.5.0', js: 1, - // language: "en", - // os: "Microsoft Windows", - // ua: "Mozilla/5.0 (Linux; Android 12; SM-G970U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Mobile Safari/537.36", + // language: 'en', + // os: 'Microsoft Windows', + // ua: 'Mozilla/5.0 (Linux; Android 12; SM-G970U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Mobile Safari/537.36', os: navigator.platform || '', ua: navigator.userAgent, language: /en/.test(navigator.language) ? 'en' : navigator.language, @@ -372,7 +372,7 @@ export const spec = { // bid // }); if (bid.params.token) { - globals["token"] = bid.params.token; + globals['token'] = bid.params.token; } return !!bid.params.token; }, @@ -389,8 +389,8 @@ export const spec = { const payloadString = JSON.stringify(payload); return { - method: "POST", - url: ENDPOINT_URL + globals["token"], + method: 'POST', + url: ENDPOINT_URL + globals['token'], data: payloadString, }; }, @@ -402,35 +402,35 @@ export const spec = { * @return {Bid[]} An array of bids which were nested inside the server. */ interpretResponse: function (serverResponse, bidRequest) { - const bids = getProperty(serverResponse, "body", "seatbid", 0, "bid"); - const cur = getProperty(serverResponse, "body", "cur"); + const bids = getProperty(serverResponse, 'body', 'seatbid', 0, 'bid'); + const cur = getProperty(serverResponse, 'body', 'cur'); const bidResponses = []; for (let bid of bids) { - let impid = getProperty(bid, "impid"); + let impid = getProperty(bid, 'impid'); if (itemMaps[impid]) { - let bidId = getProperty(itemMaps[impid], "req", "bidId"); + let bidId = getProperty(itemMaps[impid], 'req', 'bidId'); const bidResponse = { requestId: bidId, - cpm: getProperty(bid, "price"), - width: getProperty(bid, "w"), - height: getProperty(bid, "h"), - creativeId: getProperty(bid, "crid"), - dealId: "", + cpm: getProperty(bid, 'price'), + width: getProperty(bid, 'w'), + height: getProperty(bid, 'h'), + creativeId: getProperty(bid, 'crid'), + dealId: '', currency: cur, netRevenue: true, ttl: TIME_TO_LIVE, // referrer: REFERER, - ad: getProperty(bid, "adm"), - nurl: getProperty(bid, "nurl"), + ad: getProperty(bid, 'adm'), + nurl: getProperty(bid, 'nurl'), // adserverTargeting: { // granularityMultiplier: 0.1, - // priceGranularity: "pbHg", - // pbMg: "0.01", + // priceGranularity: 'pbHg', + // pbMg: '0.01', // }, - // pbMg: "0.01", + // pbMg: '0.01', // granularityMultiplier: 0.1, - // priceGranularity: "pbHg", + // priceGranularity: 'pbHg', }; bidResponses.push(bidResponse); } @@ -455,8 +455,8 @@ export const spec = { onBidWon: function (bid) { // console.log('onBidWon: ', bid, config.getConfig('priceGranularity')); // Bidder specific code - if (bid["nurl"]) { - utils.triggerPixel(bid["nurl"]); + if (bid['nurl']) { + utils.triggerPixel(bid['nurl']); } }, From e103260ef4e3815617d0e6d646a15eb95152a8f4 Mon Sep 17 00:00:00 2001 From: BaronYu Date: Fri, 24 Feb 2023 17:32:59 +0800 Subject: [PATCH 20/44] update Mediago & Discovery BidAdapter:remove size filter --- modules/discoveryBidAdapter.js | 4 +++- modules/mediagoBidAdapter.js | 37 ++++------------------------------ 2 files changed, 7 insertions(+), 34 deletions(-) diff --git a/modules/discoveryBidAdapter.js b/modules/discoveryBidAdapter.js index 8145c9d25e7..52e7c38185e 100644 --- a/modules/discoveryBidAdapter.js +++ b/modules/discoveryBidAdapter.js @@ -244,7 +244,9 @@ function getItems(validBidRequests, bidderRequest) { } } if (!matchSize) { - return {}; + matchSize = sizes[0] ? + { h: sizes[0].height || 0, w: sizes[0].width || 0} : + { h: 0, w: 0}; } ret = { id: id, diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js index 9b1b02e00a2..1b953bb62f9 100644 --- a/modules/mediagoBidAdapter.js +++ b/modules/mediagoBidAdapter.js @@ -19,37 +19,6 @@ const storage = getStorageManager(); let globals = {}; let itemMaps = {}; -/** - * 获取随机id - * @param {number} a random number from 0 to 15 - * @return {string} random number or random string - */ -// function getRandomId( -// a // placeholder -// ) { -// // if the placeholder was passed, return -// // a random number from 0 to 15 -// return a -// ? ( -// a ^ // unless b is 8, -// ((Math.random() * // in which case -// 16) >> // a random number from -// (a / 4)) -// ) // 8 to 11 -// .toString(16) // in hexadecimal -// : ( // or otherwise a concatenated string: -// [1e7] + // 10000000 + -// 1e3 + // -1000 + -// 4e3 + // -4000 + -// 8e3 + // -80000000 + -// 1e11 -// ) // -100000000000, -// .replace( -// // replacing -// /[018]/g, // zeroes, ones, and eights with -// getRandomId // random hex digits -// ); -// } /* ----- mguid:start ------ */ const COOKIE_KEY_MGUID = '__mguid_'; @@ -246,8 +215,10 @@ function getItems(validBidRequests, bidderRequest) { break; } } - if (!matchSize) { - return {}; + if (!matchSize) { + matchSize = sizes[0] ? + { h: sizes[0].height || 0, w: sizes[0].width || 0} : + { h: 0, w: 0}; } const bidFloor = getBidFloor(req); From f7e7b2ad7cc3354ce30bd83f6eefa92f9b4377d2 Mon Sep 17 00:00:00 2001 From: BaronYu Date: Fri, 24 Feb 2023 17:41:23 +0800 Subject: [PATCH 21/44] update Mediago & Discovery BidAdapter:code format --- modules/discoveryBidAdapter.js | 6 +++--- modules/mediagoBidAdapter.js | 9 ++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/modules/discoveryBidAdapter.js b/modules/discoveryBidAdapter.js index 52e7c38185e..3bbb198b3c1 100644 --- a/modules/discoveryBidAdapter.js +++ b/modules/discoveryBidAdapter.js @@ -244,9 +244,9 @@ function getItems(validBidRequests, bidderRequest) { } } if (!matchSize) { - matchSize = sizes[0] ? - { h: sizes[0].height || 0, w: sizes[0].width || 0} : - { h: 0, w: 0}; + matchSize = sizes[0] + ? { h: sizes[0].height || 0, w: sizes[0].width || 0} + : { h: 0, w: 0}; } ret = { id: id, diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js index 1b953bb62f9..615c8caccbc 100644 --- a/modules/mediagoBidAdapter.js +++ b/modules/mediagoBidAdapter.js @@ -19,7 +19,6 @@ const storage = getStorageManager(); let globals = {}; let itemMaps = {}; - /* ----- mguid:start ------ */ const COOKIE_KEY_MGUID = '__mguid_'; @@ -215,10 +214,10 @@ function getItems(validBidRequests, bidderRequest) { break; } } - if (!matchSize) { - matchSize = sizes[0] ? - { h: sizes[0].height || 0, w: sizes[0].width || 0} : - { h: 0, w: 0}; + if (!matchSize) { + matchSize = sizes[0] + ? { h: sizes[0].height || 0, w: sizes[0].width || 0} + : { h: 0, w: 0}; } const bidFloor = getBidFloor(req); From 2b1d8c0fae265fab2eff0e65a5571e4246f89e00 Mon Sep 17 00:00:00 2001 From: BaronYu Date: Fri, 24 Feb 2023 17:47:40 +0800 Subject: [PATCH 22/44] update Mediago & Discovery BidAdapter:code format --- modules/discoveryBidAdapter.js | 4 ++-- modules/mediagoBidAdapter.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/discoveryBidAdapter.js b/modules/discoveryBidAdapter.js index 3bbb198b3c1..5a04fc63c15 100644 --- a/modules/discoveryBidAdapter.js +++ b/modules/discoveryBidAdapter.js @@ -245,8 +245,8 @@ function getItems(validBidRequests, bidderRequest) { } if (!matchSize) { matchSize = sizes[0] - ? { h: sizes[0].height || 0, w: sizes[0].width || 0} - : { h: 0, w: 0}; + ? { h: sizes[0].height || 0, w: sizes[0].width || 0 } + : { h: 0, w: 0 }; } ret = { id: id, diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js index 615c8caccbc..c8794b751fb 100644 --- a/modules/mediagoBidAdapter.js +++ b/modules/mediagoBidAdapter.js @@ -216,8 +216,8 @@ function getItems(validBidRequests, bidderRequest) { } if (!matchSize) { matchSize = sizes[0] - ? { h: sizes[0].height || 0, w: sizes[0].width || 0} - : { h: 0, w: 0}; + ? { h: sizes[0].height || 0, w: sizes[0].width || 0 } + : { h: 0, w: 0 }; } const bidFloor = getBidFloor(req); From d3c8806ecf6f7fb7f984ef91b4ba5733707638a8 Mon Sep 17 00:00:00 2001 From: BaronYu Date: Fri, 24 Feb 2023 18:45:04 +0800 Subject: [PATCH 23/44] update Mediago & Discovery BidAdapter:add param in banner format --- modules/discoveryBidAdapter.js | 1 + modules/mediagoBidAdapter.js | 1 + 2 files changed, 2 insertions(+) diff --git a/modules/discoveryBidAdapter.js b/modules/discoveryBidAdapter.js index 5a04fc63c15..1c146c6fa00 100644 --- a/modules/discoveryBidAdapter.js +++ b/modules/discoveryBidAdapter.js @@ -255,6 +255,7 @@ function getItems(validBidRequests, bidderRequest) { h: matchSize.h, w: matchSize.w, pos: 1, + format: sizes, }, ext: {}, tagid: globals['tagid'], diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js index c8794b751fb..6b1c75d125a 100644 --- a/modules/mediagoBidAdapter.js +++ b/modules/mediagoBidAdapter.js @@ -237,6 +237,7 @@ function getItems(validBidRequests, bidderRequest) { h: matchSize.h, w: matchSize.w, pos: 1, + format: sizes, }, ext: { // gpid: gpid, // 加入后无法返回广告 From 32492f16fd406629b100aeb4ab4cfb45d671abd5 Mon Sep 17 00:00:00 2001 From: BaronYu Date: Fri, 3 Mar 2023 10:27:39 +0800 Subject: [PATCH 24/44] update mediago & discovery:first party data --- modules/discoveryBidAdapter.js | 2 ++ modules/mediagoBidAdapter.js | 3 +++ 2 files changed, 5 insertions(+) diff --git a/modules/discoveryBidAdapter.js b/modules/discoveryBidAdapter.js index 1c146c6fa00..10656bfed75 100644 --- a/modules/discoveryBidAdapter.js +++ b/modules/discoveryBidAdapter.js @@ -297,6 +297,7 @@ function getParam(validBidRequests, bidderRequest) { const location = utils.deepAccess(bidderRequest, 'refererInfo.referer'); const page = utils.deepAccess(bidderRequest, 'refererInfo.page'); const referer = utils.deepAccess(bidderRequest, 'refererInfo.ref'); + const firstPartyData = bidderRequest.ortb2; if (items && items.length) { let c = { @@ -315,6 +316,7 @@ function getParam(validBidRequests, bidderRequest) { }, ext: { eids, + firstPartyData, }, user: { buyeruid: getUserID(), diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js index 6b1c75d125a..7ef17dbbac4 100644 --- a/modules/mediagoBidAdapter.js +++ b/modules/mediagoBidAdapter.js @@ -281,6 +281,8 @@ function getParam(validBidRequests, bidderRequest) { const referer = utils.deepAccess(bidderRequest, 'refererInfo.ref'); const timeout = bidderRequest.timeout || 2000; + + const firstPartyData = bidderRequest.ortb2; if (items && items.length) { let c = { @@ -301,6 +303,7 @@ function getParam(validBidRequests, bidderRequest) { }, ext: { eids, + firstPartyData, }, user: { buyeruid: getUserID(), From 5d9250047f6b6d1f0409a623f5c9fbf86585168a Mon Sep 17 00:00:00 2001 From: BaronYu Date: Fri, 3 Mar 2023 10:31:59 +0800 Subject: [PATCH 25/44] update mediago & discovery:first party data --- modules/discoveryBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/discoveryBidAdapter.js b/modules/discoveryBidAdapter.js index 10656bfed75..7930efc4fa8 100644 --- a/modules/discoveryBidAdapter.js +++ b/modules/discoveryBidAdapter.js @@ -316,7 +316,7 @@ function getParam(validBidRequests, bidderRequest) { }, ext: { eids, - firstPartyData, + firstPartyData, }, user: { buyeruid: getUserID(), From e897e9ab8d1c2340a75b5732d0261578e5c49876 Mon Sep 17 00:00:00 2001 From: BaronYu Date: Fri, 3 Mar 2023 10:40:52 +0800 Subject: [PATCH 26/44] update mediago & discovery:first party data --- modules/mediagoBidAdapter.js | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js index 7ef17dbbac4..d807c9b801e 100644 --- a/modules/mediagoBidAdapter.js +++ b/modules/mediagoBidAdapter.js @@ -281,7 +281,6 @@ function getParam(validBidRequests, bidderRequest) { const referer = utils.deepAccess(bidderRequest, 'refererInfo.ref'); const timeout = bidderRequest.timeout || 2000; - const firstPartyData = bidderRequest.ortb2; if (items && items.length) { From 5658450dcebef2dfb3ff0571d314f47ffcbcb83e Mon Sep 17 00:00:00 2001 From: BaronYu Date: Tue, 27 Jun 2023 16:43:49 +0800 Subject: [PATCH 27/44] fix(mediago & discovery): update param tagid --- modules/discoveryBidAdapter.js | 2 +- modules/mediagoBidAdapter.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/discoveryBidAdapter.js b/modules/discoveryBidAdapter.js index 675ede273a6..74c51a33b45 100644 --- a/modules/discoveryBidAdapter.js +++ b/modules/discoveryBidAdapter.js @@ -258,7 +258,7 @@ function getItems(validBidRequests, bidderRequest) { format: sizes, }, ext: {}, - tagid: globals['tagid'], + tagid: validBidRequests.params.tagid, }; } itemMaps[id] = { diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js index 055fef3bb39..ec5afabc089 100644 --- a/modules/mediagoBidAdapter.js +++ b/modules/mediagoBidAdapter.js @@ -242,6 +242,7 @@ function getItems(validBidRequests, bidderRequest) { ext: { // gpid: gpid, // 加入后无法返回广告 }, + tagid: validBidRequests.params.tagid, }; itemMaps[id] = { req, From c6ad1c15daf1aa56a313f20e8b552c67b98ec34c Mon Sep 17 00:00:00 2001 From: BaronYu Date: Tue, 27 Jun 2023 16:56:30 +0800 Subject: [PATCH 28/44] fix(mediago & discovery): update param tagid --- modules/discoveryBidAdapter.js | 2 +- modules/mediagoBidAdapter.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/discoveryBidAdapter.js b/modules/discoveryBidAdapter.js index 74c51a33b45..7ad75f64215 100644 --- a/modules/discoveryBidAdapter.js +++ b/modules/discoveryBidAdapter.js @@ -258,7 +258,7 @@ function getItems(validBidRequests, bidderRequest) { format: sizes, }, ext: {}, - tagid: validBidRequests.params.tagid, + tagid: req.params && req.params.tagid }; } itemMaps[id] = { diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js index ec5afabc089..756e636572d 100644 --- a/modules/mediagoBidAdapter.js +++ b/modules/mediagoBidAdapter.js @@ -242,7 +242,7 @@ function getItems(validBidRequests, bidderRequest) { ext: { // gpid: gpid, // 加入后无法返回广告 }, - tagid: validBidRequests.params.tagid, + tagid: req.params && req.params.tagid, }; itemMaps[id] = { req, From d5cb0fb8b87faf724370a00f5190fd71088ed2ae Mon Sep 17 00:00:00 2001 From: BaronYu Date: Fri, 3 Nov 2023 14:55:05 +0800 Subject: [PATCH 29/44] =?UTF-8?q?feat=EF=BC=9Aadd=20imp=20params=20for=20a?= =?UTF-8?q?nalysis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/mediagoBidAdapter.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js index 756e636572d..42b1f3d1616 100644 --- a/modules/mediagoBidAdapter.js +++ b/modules/mediagoBidAdapter.js @@ -221,10 +221,10 @@ function getItems(validBidRequests, bidderRequest) { } const bidFloor = getBidFloor(req); - // const gpid = - // utils.deepAccess(req, 'ortb2Imp.ext.gpid') || - // utils.deepAccess(req, 'ortb2Imp.ext.data.pbadslot') || - // utils.deepAccess(req, 'params.placementId', 0); + const gpid = + utils.deepAccess(req, 'ortb2Imp.ext.gpid') || + utils.deepAccess(req, 'ortb2Imp.ext.data.pbadslot') || + utils.deepAccess(req, 'params.placementId', 0); // if (mediaTypes.native) {} // banner广告类型 @@ -240,7 +240,8 @@ function getItems(validBidRequests, bidderRequest) { format: sizes, }, ext: { - // gpid: gpid, // 加入后无法返回广告 + ortb2Imp: deepAccess(bidRequest, 'ortb2Imp'), // 传入完整对象,分析日志数据 + gpid: gpid, // 加入后无法返回广告 }, tagid: req.params && req.params.tagid, }; From 96eb09a9b71f41dd50cedcb91aa0963c9974a1f1 Mon Sep 17 00:00:00 2001 From: BaronYu Date: Fri, 3 Nov 2023 15:26:42 +0800 Subject: [PATCH 30/44] =?UTF-8?q?fix=EF=BC=9Aadd=20imp=20params=20for=20an?= =?UTF-8?q?alysis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/mediagoBidAdapter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js index 42b1f3d1616..5973899395a 100644 --- a/modules/mediagoBidAdapter.js +++ b/modules/mediagoBidAdapter.js @@ -240,8 +240,8 @@ function getItems(validBidRequests, bidderRequest) { format: sizes, }, ext: { - ortb2Imp: deepAccess(bidRequest, 'ortb2Imp'), // 传入完整对象,分析日志数据 - gpid: gpid, // 加入后无法返回广告 + ortb2Imp: utils.deepAccess(req, "ortb2Imp"), // 传入完整对象,分析日志数据 + gpid: gpid, // 加入后无法返回广告 }, tagid: req.params && req.params.tagid, }; From 3833b902952f187facad83870e4a9d3d1ef6abca Mon Sep 17 00:00:00 2001 From: BaronYu Date: Fri, 3 Nov 2023 15:35:47 +0800 Subject: [PATCH 31/44] code format --- modules/mediagoBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js index 5973899395a..efd730acace 100644 --- a/modules/mediagoBidAdapter.js +++ b/modules/mediagoBidAdapter.js @@ -240,7 +240,7 @@ function getItems(validBidRequests, bidderRequest) { format: sizes, }, ext: { - ortb2Imp: utils.deepAccess(req, "ortb2Imp"), // 传入完整对象,分析日志数据 + ortb2Imp: utils.deepAccess(req, 'ortb2Imp'), // 传入完整对象,分析日志数据 gpid: gpid, // 加入后无法返回广告 }, tagid: req.params && req.params.tagid, From e2c81fbe836c494536d93c50fbd3b5302b3906f6 Mon Sep 17 00:00:00 2001 From: BaronYu Date: Mon, 6 Nov 2023 15:24:46 +0800 Subject: [PATCH 32/44] test:add test data & test --- test/spec/modules/mediagoBidAdapter_spec.js | 52 ++++++++++++++++----- 1 file changed, 41 insertions(+), 11 deletions(-) diff --git a/test/spec/modules/mediagoBidAdapter_spec.js b/test/spec/modules/mediagoBidAdapter_spec.js index e77af544429..142d97b716b 100644 --- a/test/spec/modules/mediagoBidAdapter_spec.js +++ b/test/spec/modules/mediagoBidAdapter_spec.js @@ -3,28 +3,58 @@ import { spec } from 'modules/mediagoBidAdapter.js'; describe('mediago:BidAdapterTests', function () { let bidRequestData = { - bidderCode: 'mediago', - auctionId: '7fae02a9-0195-472f-ba94-708d3bc2c0d9', - bidderRequestId: '4fec04e87ad785', + bidderCode: "mediago", + auctionId: "7fae02a9-0195-472f-ba94-708d3bc2c0d9", + bidderRequestId: "4fec04e87ad785", bids: [ { - bidder: 'mediago', + bidder: "mediago", params: { - token: '85a6b01e41ac36d49744fad726e3655d', + token: "85a6b01e41ac36d49744fad726e3655d", + siteId: "siteId_01", + zoneId: "zoneId_01", + publisher: "52", + position: "left", + referrer: "https://trace.mediago.io", bidfloor: 0.01, + ortb2Imp: { + ext: { + gpid: "adslot_gpid", + tid: "tid_01", + data: { + browsi: { + browsiViewability: "NA", + }, + adserver: { + name: "adserver_name", + adslot: "adslot_name", + }, + }, + }, + }, }, mediaTypes: { banner: { sizes: [[300, 250]], + pos: "left", + }, + }, + ortb2: { + user: { + ext: { + data: { + CxSegments: [], + }, + }, }, }, - adUnitCode: 'regular_iframe', - transactionId: '7b26fdae-96e6-4c35-a18b-218dda11397d', + adUnitCode: "regular_iframe", + transactionId: "7b26fdae-96e6-4c35-a18b-218dda11397d", sizes: [[300, 250]], - bidId: '54d73f19c9d47a', // todo - bidderRequestId: '4fec04e87ad785', // todo - auctionId: '883a346a-6d62-4adb-a600-0f3a869061d1', - src: 'client', + bidId: "54d73f19c9d47a", // todo + bidderRequestId: "4fec04e87ad785", // todo + auctionId: "883a346a-6d62-4adb-a600-0f3a869061d1", + src: "client", bidRequestsCount: 1, bidderRequestsCount: 1, bidderWinsCount: 0, From 98db0615a8de8e77fdd63cf4afaec4f1fec5933f Mon Sep 17 00:00:00 2001 From: BaronYu Date: Mon, 6 Nov 2023 15:42:04 +0800 Subject: [PATCH 33/44] format code --- test/spec/modules/mediagoBidAdapter_spec.js | 44 ++++++++++----------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/test/spec/modules/mediagoBidAdapter_spec.js b/test/spec/modules/mediagoBidAdapter_spec.js index 142d97b716b..e695c3e5d39 100644 --- a/test/spec/modules/mediagoBidAdapter_spec.js +++ b/test/spec/modules/mediagoBidAdapter_spec.js @@ -3,31 +3,31 @@ import { spec } from 'modules/mediagoBidAdapter.js'; describe('mediago:BidAdapterTests', function () { let bidRequestData = { - bidderCode: "mediago", - auctionId: "7fae02a9-0195-472f-ba94-708d3bc2c0d9", - bidderRequestId: "4fec04e87ad785", + bidderCode: 'mediago', + auctionId: '7fae02a9-0195-472f-ba94-708d3bc2c0d9', + bidderRequestId: '4fec04e87ad785', bids: [ { - bidder: "mediago", + bidder: 'mediago', params: { - token: "85a6b01e41ac36d49744fad726e3655d", - siteId: "siteId_01", - zoneId: "zoneId_01", - publisher: "52", - position: "left", - referrer: "https://trace.mediago.io", + token: '85a6b01e41ac36d49744fad726e3655d', + siteId: 'siteId_01', + zoneId: 'zoneId_01', + publisher: '52', + position: 'left', + referrer: 'https://trace.mediago.io', bidfloor: 0.01, ortb2Imp: { ext: { - gpid: "adslot_gpid", - tid: "tid_01", + gpid: 'adslot_gpid', + tid: 'tid_01', data: { browsi: { - browsiViewability: "NA", + browsiViewability: 'NA', }, adserver: { - name: "adserver_name", - adslot: "adslot_name", + name: 'adserver_name', + adslot: 'adslot_name', }, }, }, @@ -36,7 +36,7 @@ describe('mediago:BidAdapterTests', function () { mediaTypes: { banner: { sizes: [[300, 250]], - pos: "left", + pos: 'left', }, }, ortb2: { @@ -48,13 +48,13 @@ describe('mediago:BidAdapterTests', function () { }, }, }, - adUnitCode: "regular_iframe", - transactionId: "7b26fdae-96e6-4c35-a18b-218dda11397d", + adUnitCode: 'regular_iframe', + transactionId: '7b26fdae-96e6-4c35-a18b-218dda11397d', sizes: [[300, 250]], - bidId: "54d73f19c9d47a", // todo - bidderRequestId: "4fec04e87ad785", // todo - auctionId: "883a346a-6d62-4adb-a600-0f3a869061d1", - src: "client", + bidId: '54d73f19c9d47a', // todo + bidderRequestId: '4fec04e87ad785', // todo + auctionId: '883a346a-6d62-4adb-a600-0f3a869061d1', + src: 'client', bidRequestsCount: 1, bidderRequestsCount: 1, bidderWinsCount: 0, From 3c6de5b2f4fc4b5ebe0bc56ac91c399c8d54c39d Mon Sep 17 00:00:00 2001 From: BaronYu Date: Mon, 6 Nov 2023 16:46:00 +0800 Subject: [PATCH 34/44] rerun circleci --- test/spec/modules/mediagoBidAdapter_spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/spec/modules/mediagoBidAdapter_spec.js b/test/spec/modules/mediagoBidAdapter_spec.js index e695c3e5d39..5eb362893e3 100644 --- a/test/spec/modules/mediagoBidAdapter_spec.js +++ b/test/spec/modules/mediagoBidAdapter_spec.js @@ -43,7 +43,6 @@ describe('mediago:BidAdapterTests', function () { user: { ext: { data: { - CxSegments: [], }, }, }, From cc1895da1a497a2f9053fb8281b74d06e3aec60b Mon Sep 17 00:00:00 2001 From: BaronYu Date: Tue, 14 Nov 2023 15:56:35 +0800 Subject: [PATCH 35/44] feat: 1. add cookieSync 2. add gdpr --- modules/mediagoBidAdapter.js | 61 ++++++++++++++++----- test/spec/modules/mediagoBidAdapter_spec.js | 59 ++++++++++++++++++++ 2 files changed, 105 insertions(+), 15 deletions(-) diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js index efd730acace..51d318ced05 100644 --- a/modules/mediagoBidAdapter.js +++ b/modules/mediagoBidAdapter.js @@ -13,9 +13,10 @@ const BIDDER_CODE = 'mediago'; const ENDPOINT_URL = // ((PROTOCOL === 'https:') ? 'https' : 'http') + 'https://rtb-us.mediago.io/api/bid?tn='; +const COOKY_SYNC_URL = 'https://trace.mediago.io/ju/cs/eplist'; const TIME_TO_LIVE = 500; // const ENDPOINT_URL = '/api/bid?tn='; -const storage = getStorageManager({bidderCode: BIDDER_CODE}); +const storage = getStorageManager({ bidderCode: BIDDER_CODE }); let globals = {}; let itemMaps = {}; @@ -156,11 +157,7 @@ function transformSizes(requestSizes) { let sizes = []; let sizeObj = {}; - if ( - utils.isArray(requestSizes) && - requestSizes.length === 2 && - !utils.isArray(requestSizes[0]) - ) { + if (utils.isArray(requestSizes) && requestSizes.length === 2 && !utils.isArray(requestSizes[0])) { sizeObj.width = parseInt(requestSizes[0], 10); sizeObj.height = parseInt(requestSizes[1], 10); sizes.push(sizeObj); @@ -207,17 +204,13 @@ function getItems(validBidRequests, bidderRequest) { // 确认尺寸是否符合我们要求 for (let size of sizes) { - matchSize = mediagoAdSize.find( - (item) => size.width === item.w && size.height === item.h - ); + matchSize = mediagoAdSize.find(item => size.width === item.w && size.height === item.h); if (matchSize) { break; } } if (!matchSize) { - matchSize = sizes[0] - ? { h: sizes[0].height || 0, w: sizes[0].width || 0 } - : { h: 0, w: 0 }; + matchSize = sizes[0] ? { h: sizes[0].height || 0, w: sizes[0].width || 0 } : { h: 0, w: 0 }; } const bidFloor = getBidFloor(req); @@ -226,6 +219,18 @@ function getItems(validBidRequests, bidderRequest) { utils.deepAccess(req, 'ortb2Imp.ext.data.pbadslot') || utils.deepAccess(req, 'params.placementId', 0); + const gdpr_consent = {}; + if (bidderRequest && bidderRequest.gdprConsent) { + (gdpr_consent.consent = bidderRequest.gdprConsent.consentString), + (gdpr_consent.gdpr = bidderRequest.gdprConsent.gdprApplies ? 1 : 0); + // if (bidderRequest.gdprConsent.addtlConsent && bidderRequest.gdprConsent.addtlConsent.indexOf('~') !== -1) { + // let ac = bidderRequest.gdprConsent.addtlConsent; + // // pull only the ids from the string (after the ~) and convert them to an array of ints + // let acStr = ac.substring(ac.indexOf('~') + 1); + // gdpr_consent.addtl_consent = acStr.split('.').map(id => parseInt(id, 10)); + // } + } + // if (mediaTypes.native) {} // banner广告类型 if (mediaTypes.banner) { @@ -242,6 +247,8 @@ function getItems(validBidRequests, bidderRequest) { ext: { ortb2Imp: utils.deepAccess(req, 'ortb2Imp'), // 传入完整对象,分析日志数据 gpid: gpid, // 加入后无法返回广告 + adslot: deepAccess(bidRequest, 'ortb2Imp.ext.data.adserver.adslot', '', ''), + ...gdpr_consent, // gdpr }, tagid: req.params && req.params.tagid, }; @@ -268,7 +275,10 @@ function getParam(validBidRequests, bidderRequest) { const sharedid = utils.deepAccess(validBidRequests[0], 'userId.sharedid.id') || utils.deepAccess(validBidRequests[0], 'userId.pubcid'); - const eids = validBidRequests[0].userIdAsEids || validBidRequests[0].userId; + + const bidsUserIdAsEids = validBidRequests[0].userIdAsEids; + const bidsUserid = validBidRequests[0].userId; + const eids = userIdAsEids || userid; let isMobile = isMobileAndTablet() ? 1 : 0; // input test status by Publisher. more frequently for test true req @@ -276,8 +286,7 @@ function getParam(validBidRequests, bidderRequest) { let auctionId = getProperty(bidderRequest, 'auctionId'); let items = getItems(validBidRequests, bidderRequest); - const domain = - utils.deepAccess(bidderRequest, 'refererInfo.domain') || document.domain; + const domain = utils.deepAccess(bidderRequest, 'refererInfo.domain') || document.domain; const location = utils.deepAccess(bidderRequest, 'refererInfo.location'); const page = utils.deepAccess(bidderRequest, 'refererInfo.page'); const referer = utils.deepAccess(bidderRequest, 'refererInfo.ref'); @@ -305,6 +314,8 @@ function getParam(validBidRequests, bidderRequest) { }, ext: { eids, + bidsUserIdAsEids, + bidsUserid, firstPartyData, }, user: { @@ -415,6 +426,26 @@ export const spec = { return bidResponses; }, + getUserSyncs: function (syncOptions, serverResponse, gdprConsent, uspConsent, gppConsent) { + const origin = encodeURIComponent(location.origin || `https://${location.host}`); + const url = `${COOKY_SYNC_URL}?dm=${origin}&gdpr_consent=${gdprConsent.consentString}`; + if (syncOptions.iframeEnabled) { + return [ + { + type: 'iframe', + url: `https://cdn.mediago.io/js/cookieSync.html?gdpr_consent=${gdprConsent.consentString}`, + }, + ]; + } else { + return [ + { + type: 'image', + url: url, + }, + ]; + } + }, + /** * Register bidder specific code, which will execute if bidder timed out after an auction * @param {data} Containing timeout specific data diff --git a/test/spec/modules/mediagoBidAdapter_spec.js b/test/spec/modules/mediagoBidAdapter_spec.js index 5eb362893e3..439d23b1daf 100644 --- a/test/spec/modules/mediagoBidAdapter_spec.js +++ b/test/spec/modules/mediagoBidAdapter_spec.js @@ -29,6 +29,7 @@ describe('mediago:BidAdapterTests', function () { name: 'adserver_name', adslot: 'adslot_name', }, + pbadslot: '/12345/my-gpt-tag-0' }, }, }, @@ -59,6 +60,64 @@ describe('mediago:BidAdapterTests', function () { bidderWinsCount: 0, }, ], + gdprConsent: { + consentString: 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A==', + gdprApplies: true, + apiVersion: 2, + vendorData: { + purpose: { + consents: { + 1: false + } + } + } + }, + userId: { + tdid: 'sample-userid', + uid2: { id: 'sample-uid2-value' }, + criteoId: 'sample-criteo-userid', + netId: 'sample-netId-userid', + idl_env: 'sample-idl-userid', + pubProvidedId: [{ + source: 'puburl.com', + uids: [{ + id: 'pubid1', + atype: 1, + ext: { + stype: 'ppuid' + } + }] + }, { + source: 'puburl2.com', + uids: [{ + id: 'pubid2' + }, { + id: 'pubid2-123' + }] + }] + }, + userIdAsEids: [{ + source: 'adserver.org', + uids: [{ id: 'sample-userid' }] + }, { + source: 'criteo.com', + uids: [{ id: 'sample-criteo-userid' }] + }, { + source: 'netid.de', + uids: [{ id: 'sample-netId-userid' }] + }, { + source: 'liveramp.com', + uids: [{ id: 'sample-idl-userid' }] + }, { + source: 'uidapi.com', + uids: [{ id: 'sample-uid2-value' }] + }, { + source: 'puburl.com', + uids: [{ id: 'pubid1' }] + }, { + source: 'puburl2.com', + uids: [{ id: 'pubid2' }, { id: 'pubid2-123' }] + }] }; let request = []; From 5d81f7edd1f2f52fa9a9f306a26744f379ce1829 Mon Sep 17 00:00:00 2001 From: BaronYu Date: Tue, 14 Nov 2023 16:10:23 +0800 Subject: [PATCH 36/44] code format --- modules/mediagoBidAdapter.js | 12 +- test/spec/modules/mediagoBidAdapter_spec.js | 135 +++++++++++--------- 2 files changed, 82 insertions(+), 65 deletions(-) diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js index 51d318ced05..055501aaa0e 100644 --- a/modules/mediagoBidAdapter.js +++ b/modules/mediagoBidAdapter.js @@ -219,10 +219,10 @@ function getItems(validBidRequests, bidderRequest) { utils.deepAccess(req, 'ortb2Imp.ext.data.pbadslot') || utils.deepAccess(req, 'params.placementId', 0); - const gdpr_consent = {}; + const gdprConsent = {}; if (bidderRequest && bidderRequest.gdprConsent) { - (gdpr_consent.consent = bidderRequest.gdprConsent.consentString), - (gdpr_consent.gdpr = bidderRequest.gdprConsent.gdprApplies ? 1 : 0); + gdprConsent.consent = bidderRequest.gdprConsent.consentString; + gdprConsent.gdpr = bidderRequest.gdprConsent.gdprApplies ? 1 : 0; // if (bidderRequest.gdprConsent.addtlConsent && bidderRequest.gdprConsent.addtlConsent.indexOf('~') !== -1) { // let ac = bidderRequest.gdprConsent.addtlConsent; // // pull only the ids from the string (after the ~) and convert them to an array of ints @@ -247,8 +247,8 @@ function getItems(validBidRequests, bidderRequest) { ext: { ortb2Imp: utils.deepAccess(req, 'ortb2Imp'), // 传入完整对象,分析日志数据 gpid: gpid, // 加入后无法返回广告 - adslot: deepAccess(bidRequest, 'ortb2Imp.ext.data.adserver.adslot', '', ''), - ...gdpr_consent, // gdpr + adslot: utils.deepAccess(req, 'ortb2Imp.ext.data.adserver.adslot', '', ''), + ...gdprConsent, // gdpr }, tagid: req.params && req.params.tagid, }; @@ -278,7 +278,7 @@ function getParam(validBidRequests, bidderRequest) { const bidsUserIdAsEids = validBidRequests[0].userIdAsEids; const bidsUserid = validBidRequests[0].userId; - const eids = userIdAsEids || userid; + const eids = bidsUserIdAsEids || bidsUserid; let isMobile = isMobileAndTablet() ? 1 : 0; // input test status by Publisher. more frequently for test true req diff --git a/test/spec/modules/mediagoBidAdapter_spec.js b/test/spec/modules/mediagoBidAdapter_spec.js index 439d23b1daf..3576068979c 100644 --- a/test/spec/modules/mediagoBidAdapter_spec.js +++ b/test/spec/modules/mediagoBidAdapter_spec.js @@ -23,30 +23,29 @@ describe('mediago:BidAdapterTests', function () { tid: 'tid_01', data: { browsi: { - browsiViewability: 'NA', + browsiViewability: 'NA' }, adserver: { name: 'adserver_name', - adslot: 'adslot_name', + adslot: 'adslot_name' }, pbadslot: '/12345/my-gpt-tag-0' - }, - }, - }, + } + } + } }, mediaTypes: { banner: { sizes: [[300, 250]], - pos: 'left', - }, + pos: 'left' + } }, ortb2: { user: { ext: { - data: { - }, - }, - }, + data: {} + } + } }, adUnitCode: 'regular_iframe', transactionId: '7b26fdae-96e6-4c35-a18b-218dda11397d', @@ -57,67 +56,83 @@ describe('mediago:BidAdapterTests', function () { src: 'client', bidRequestsCount: 1, bidderRequestsCount: 1, - bidderWinsCount: 0, - }, + bidderWinsCount: 0 + } ], gdprConsent: { - consentString: 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A==', - gdprApplies: true, - apiVersion: 2, - vendorData: { - purpose: { - consents: { - 1: false - } + consentString: 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A==', + gdprApplies: true, + apiVersion: 2, + vendorData: { + purpose: { + consents: { + 1: false } } + } }, userId: { - tdid: 'sample-userid', - uid2: { id: 'sample-uid2-value' }, - criteoId: 'sample-criteo-userid', - netId: 'sample-netId-userid', - idl_env: 'sample-idl-userid', - pubProvidedId: [{ + tdid: 'sample-userid', + uid2: { id: 'sample-uid2-value' }, + criteoId: 'sample-criteo-userid', + netId: 'sample-netId-userid', + idl_env: 'sample-idl-userid', + pubProvidedId: [ + { source: 'puburl.com', - uids: [{ - id: 'pubid1', - atype: 1, - ext: { - stype: 'ppuid' + uids: [ + { + id: 'pubid1', + atype: 1, + ext: { + stype: 'ppuid' + } } - }] - }, { + ] + }, + { source: 'puburl2.com', - uids: [{ - id: 'pubid2' - }, { - id: 'pubid2-123' - }] - }] - }, - userIdAsEids: [{ + uids: [ + { + id: 'pubid2' + }, + { + id: 'pubid2-123' + } + ] + } + ] + }, + userIdAsEids: [ + { source: 'adserver.org', uids: [{ id: 'sample-userid' }] - }, { + }, + { source: 'criteo.com', uids: [{ id: 'sample-criteo-userid' }] - }, { + }, + { source: 'netid.de', uids: [{ id: 'sample-netId-userid' }] - }, { + }, + { source: 'liveramp.com', uids: [{ id: 'sample-idl-userid' }] - }, { + }, + { source: 'uidapi.com', uids: [{ id: 'sample-uid2-value' }] - }, { + }, + { source: 'puburl.com', uids: [{ id: 'pubid1' }] - }, { + }, + { source: 'puburl2.com', uids: [{ id: 'pubid2' }, { id: 'pubid2-123' }] - }] + } + ] }; let request = []; @@ -126,8 +141,8 @@ describe('mediago:BidAdapterTests', function () { spec.isBidRequestValid({ bidder: 'mediago', params: { - token: ['85a6b01e41ac36d49744fad726e3655d'], - }, + token: ['85a6b01e41ac36d49744fad726e3655d'] + } }) ).to.equal(true); }); @@ -139,10 +154,12 @@ describe('mediago:BidAdapterTests', function () { }); it('mediago:validate_response_params', function () { - let adm = ""; + let adm = + ''; let temp = '%3Cscr'; temp += 'ipt%3E'; - temp += '!function()%7B%22use%20strict%22%3Bfunction%20f(t)%7Breturn(f%3D%22function%22%3D%3Dtypeof%20Symbol%26%26%22symbol%22%3D%3Dtypeof%20Symbol.iterator%3Ffunction(t)%7Breturn%20typeof%20t%7D%3Afunction(t)%7Breturn%20t%26%26%22function%22%3D%3Dtypeof%20Symbol%26%26t.constructor%3D%3D%3DSymbol%26%26t!%3D%3DSymbol.prototype%3F%22symbol%22%3Atypeof%20t%7D)(t)%7Dfunction%20l(t)%7Bvar%20e%3D0%3Carguments.length%26%26void%200!%3D%3Dt%3Ft%3A%7B%7D%3Btry%7Be.random_t%3D(new%20Date).getTime()%2Cg(function(t)%7Bvar%20e%3D1%3Carguments.length%26%26void%200!%3D%3Darguments%5B1%5D%3Farguments%5B1%5D%3A%22%22%3Bif(%22object%22!%3D%3Df(t))return%20e%3Bvar%20n%3Dfunction(t)%7Bfor(var%20e%2Cn%3D%5B%5D%2Co%3D0%2Ci%3DObject.keys(t)%3Bo%3Ci.length%3Bo%2B%2B)e%3Di%5Bo%5D%2Cn.push(%22%22.concat(e%2C%22%3D%22).concat(t%5Be%5D))%3Breturn%20n%7D(t).join(%22%26%22)%2Co%3De.indexOf(%22%23%22)%2Ci%3De%2Ct%3D%22%22%3Breturn-1!%3D%3Do%26%26(i%3De.slice(0%2Co)%2Ct%3De.slice(o))%2Cn%26%26(i%26%26-1!%3D%3Di.indexOf(%22%3F%22)%3Fi%2B%3D%22%26%22%2Bn%3Ai%2B%3D%22%3F%22%2Bn)%2Ci%2Bt%7D(e%2C%22https%3A%2F%2Ftrace.mediago.io%2Fapi%2Flog%2Ftrack%22))%7Dcatch(t)%7B%7D%7Dfunction%20g(t%2Ce%2Cn)%7B(t%3Dt%3Ft.split(%22%3B%3B%3B%22)%3A%5B%5D).map(function(t)%7Btry%7B0%3C%3Dt.indexOf(%22%2Fapi%2Fbidder%2Ftrack%22)%26%26n%26%26(t%2B%3D%22%26inIframe%3D%22.concat(!(!self.frameElement%7C%7C%22IFRAME%22!%3Dself.frameElement.tagName)%7C%7Cwindow.frames.length!%3Dparent.frames.length%7C%7Cself!%3Dtop)%2Ct%2B%3D%22%26pos_x%3D%22.concat(n.left%2C%22%26pos_y%3D%22).concat(n.top%2C%22%26page_w%3D%22).concat(n.page_width%2C%22%26page_h%3D%22).concat(n.page_height))%7Dcatch(t)%7Bl(%7Btn%3As%2Cwinloss%3A1%2Cfe%3A2%2Cpos_err_c%3A1002%2Cpos_err_m%3At.toString()%7D)%7Dvar%20e%3Dnew%20Image%3Be.src%3Dt%2Ce.style.display%3D%22none%22%2Ce.style.visibility%3D%22hidden%22%2Ce.width%3D0%2Ce.height%3D0%2Cdocument.body.appendChild(e)%7D)%7Dvar%20d%3D%5B%22https%3A%2F%2Ftrace.mediago.io%2Fapi%2Fbidder%2Ftrack%3Ftn%3D39934c2bda4debbe4c680be1dd02f5d3%26price%3DdjUJcggeuWWfbm28q4WXHdgMFkO28DrGw49FnubQ0Bk%26evt%3D101%26rid%3D6e28cfaf115a354ea1ad8e1304d6d7b8%26campaignid%3D1339145%26impid%3D44-300x250-1%26offerid%3D24054386%26test%3D0%26time%3D1660789795%26cp%3DjZDh1xu6_QqJLlKVtCkiHIP_TER6gL9jeTrlHCBoxOM%26acid%3D599%26trackingid%3D99afea272c2b0e8626489674ddb7a0bb%26uid%3Da865b9ae-fa9e-4c09-8204-2db99ac7c8f7%26bm%3D2%26la%3Den%26cn%3Dus%26cid%3D3998296%26info%3DSi3oM-qfCbw2iZRYs01BkUWyH6c5CQWHrA8CQLE0VHcXAcf4ljY9dyLzQ4vAlTWd6-j_ou4ySor3e70Ll7wlKiiauQKaUkZqNoTizHm73C4FK8DYJSTP3VkhJV8RzrYk%26sid%3D128__110__1__12__28__38__163__96__58__24__47__99%26sp%3DdjUJcggeuWWfbm28q4WXHdgMFkO28DrGw49FnubQ0Bk%26scp%3DzK0DRYY1UV-syqSpmcMYBpOebtoQJV9ZEJT0JFqbTQg%26acu%3DUSD%26scu%3DUSD%26sgcp%3DzK0DRYY1UV-syqSpmcMYBpOebtoQJV9ZEJT0JFqbTQg%26gprice%3DdjUJcggeuWWfbm28q4WXHdgMFkO28DrGw49FnubQ0Bk%26gcp%3DzK0DRYY1UV-syqSpmcMYBpOebtoQJV9ZEJT0JFqbTQg%26ah%3D%26de%3Dwjh.popin.cc%26iv%3D0%22%2C%22%24%7BITRACKER2%7D%22%2C%22%24%7BITRACKER3%7D%22%2C%22%24%7BITRACKER4%7D%22%2C%22%24%7BITRACKER5%7D%22%2C%22%24%7BITRACKER6%7D%22%5D%2Cp%3D%5B%22https%3A%2F%2Ftrace.mediago.io%2Fapi%2Fbidder%2Ftrack%3Ftn%3D39934c2bda4debbe4c680be1dd02f5d3%26price%3DdjUJcggeuWWfbm28q4WXHdgMFkO28DrGw49FnubQ0Bk%26evt%3D104%26rid%3D6e28cfaf115a354ea1ad8e1304d6d7b8%26campaignid%3D1339145%26impid%3D44-300x250-1%26offerid%3D24054386%26test%3D0%26time%3D1660789795%26cp%3DjZDh1xu6_QqJLlKVtCkiHIP_TER6gL9jeTrlHCBoxOM%26acid%3D599%26trackingid%3D99afea272c2b0e8626489674ddb7a0bb%26uid%3Da865b9ae-fa9e-4c09-8204-2db99ac7c8f7%26sid%3D128__110__1__12__28__38__163__96__58__24__47__99%26format%3D%26crid%3Dff32b6f9b3bbc45c00b78b6674a2952e%26bm%3D2%26la%3Den%26cn%3Dus%26cid%3D3998296%26info%3DSi3oM-qfCbw2iZRYs01BkUWyH6c5CQWHrA8CQLE0VHcXAcf4ljY9dyLzQ4vAlTWd6-j_ou4ySor3e70Ll7wlKiiauQKaUkZqNoTizHm73C4FK8DYJSTP3VkhJV8RzrYk%26sp%3DdjUJcggeuWWfbm28q4WXHdgMFkO28DrGw49FnubQ0Bk%26scp%3DzK0DRYY1UV-syqSpmcMYBpOebtoQJV9ZEJT0JFqbTQg%26acu%3DUSD%26scu%3DUSD%26sgcp%3DzK0DRYY1UV-syqSpmcMYBpOebtoQJV9ZEJT0JFqbTQg%26gprice%3DdjUJcggeuWWfbm28q4WXHdgMFkO28DrGw49FnubQ0Bk%26gcp%3DzK0DRYY1UV-syqSpmcMYBpOebtoQJV9ZEJT0JFqbTQg%26ah%3D%26de%3Dwjh.popin.cc%26iv%3D0%22%2C%22%24%7BVTRACKER2%7D%22%2C%22%24%7BVTRACKER3%7D%22%2C%22%24%7BVTRACKER4%7D%22%2C%22%24%7BVTRACKER5%7D%22%2C%22%24%7BVTRACKER6%7D%22%5D%2Cs%3D%22f9f2b1ef23fe2759c2cad0953029a94b%22%2Cn%3Ddocument.getElementById(%22mgcontainer-99afea272c2b0e8626489674ddb7a0bb%22)%3Bn%26%26function()%7Bvar%20a%3Dn.getElementsByClassName(%22mediago-placement-track%22)%3Bif(a%26%26a.length)%7Bvar%20t%2Ce%3Dfunction(t)%7Bvar%20e%2Cn%2Co%2Ci%2Cc%2Cr%3B%22object%22%3D%3D%3Df(r%3Da%5Bt%5D)%26%26(e%3Dfunction(t)%7Btry%7Bvar%20e%3Dt.getBoundingClientRect()%2Cn%3De%26%26e.top%7C%7C-1%2Co%3De%26%26e.left%7C%7C-1%2Ci%3Ddocument.body.scrollWidth%7C%7C-1%2Ce%3Ddocument.body.scrollHeight%7C%7C-1%3Breturn%7Btop%3An.toFixed(0)%2Cleft%3Ao.toFixed(0)%2Cpage_width%3Ai%2Cpage_height%3Ae%7D%7Dcatch(o)%7Breturn%20l(%7Btn%3As%2Cwinloss%3A1%2Cfe%3A2%2Cpos_err_c%3A1001%2Cpos_err_m%3Ao.toString()%7D)%2C%7Btop%3A%22-1%22%2Cleft%3A%22-1%22%2Cpage_width%3A%22-1%22%2Cpage_height%3A%22-1%22%7D%7D%7D(r)%2C(n%3Dd%5Bt%5D)%26%26g(n%2C0%2Ce)%2Co%3Dp%5Bt%5D%2Ci%3D!1%2C(c%3Dfunction()%7BsetTimeout(function()%7Bvar%20t%2Ce%3B!i%26%26(t%3Dr%2Ce%3Dwindow.innerHeight%7C%7Cdocument.documentElement.clientHeight%7C%7Cdocument.body.clientHeight%2C(t.getBoundingClientRect()%26%26t.getBoundingClientRect().top)%3C%3De-.75*(t.offsetHeight%7C%7Ct.clientHeight))%3F(i%3D!0%2Co%26%26g(o))%3Ac()%7D%2C500)%7D)())%7D%3Bfor(t%20in%20a)e(t)%7D%7D()%7D()'; + temp += + '!function()%7B%22use%20strict%22%3Bfunction%20f(t)%7Breturn(f%3D%22function%22%3D%3Dtypeof%20Symbol%26%26%22symbol%22%3D%3Dtypeof%20Symbol.iterator%3Ffunction(t)%7Breturn%20typeof%20t%7D%3Afunction(t)%7Breturn%20t%26%26%22function%22%3D%3Dtypeof%20Symbol%26%26t.constructor%3D%3D%3DSymbol%26%26t!%3D%3DSymbol.prototype%3F%22symbol%22%3Atypeof%20t%7D)(t)%7Dfunction%20l(t)%7Bvar%20e%3D0%3Carguments.length%26%26void%200!%3D%3Dt%3Ft%3A%7B%7D%3Btry%7Be.random_t%3D(new%20Date).getTime()%2Cg(function(t)%7Bvar%20e%3D1%3Carguments.length%26%26void%200!%3D%3Darguments%5B1%5D%3Farguments%5B1%5D%3A%22%22%3Bif(%22object%22!%3D%3Df(t))return%20e%3Bvar%20n%3Dfunction(t)%7Bfor(var%20e%2Cn%3D%5B%5D%2Co%3D0%2Ci%3DObject.keys(t)%3Bo%3Ci.length%3Bo%2B%2B)e%3Di%5Bo%5D%2Cn.push(%22%22.concat(e%2C%22%3D%22).concat(t%5Be%5D))%3Breturn%20n%7D(t).join(%22%26%22)%2Co%3De.indexOf(%22%23%22)%2Ci%3De%2Ct%3D%22%22%3Breturn-1!%3D%3Do%26%26(i%3De.slice(0%2Co)%2Ct%3De.slice(o))%2Cn%26%26(i%26%26-1!%3D%3Di.indexOf(%22%3F%22)%3Fi%2B%3D%22%26%22%2Bn%3Ai%2B%3D%22%3F%22%2Bn)%2Ci%2Bt%7D(e%2C%22https%3A%2F%2Ftrace.mediago.io%2Fapi%2Flog%2Ftrack%22))%7Dcatch(t)%7B%7D%7Dfunction%20g(t%2Ce%2Cn)%7B(t%3Dt%3Ft.split(%22%3B%3B%3B%22)%3A%5B%5D).map(function(t)%7Btry%7B0%3C%3Dt.indexOf(%22%2Fapi%2Fbidder%2Ftrack%22)%26%26n%26%26(t%2B%3D%22%26inIframe%3D%22.concat(!(!self.frameElement%7C%7C%22IFRAME%22!%3Dself.frameElement.tagName)%7C%7Cwindow.frames.length!%3Dparent.frames.length%7C%7Cself!%3Dtop)%2Ct%2B%3D%22%26pos_x%3D%22.concat(n.left%2C%22%26pos_y%3D%22).concat(n.top%2C%22%26page_w%3D%22).concat(n.page_width%2C%22%26page_h%3D%22).concat(n.page_height))%7Dcatch(t)%7Bl(%7Btn%3As%2Cwinloss%3A1%2Cfe%3A2%2Cpos_err_c%3A1002%2Cpos_err_m%3At.toString()%7D)%7Dvar%20e%3Dnew%20Image%3Be.src%3Dt%2Ce.style.display%3D%22none%22%2Ce.style.visibility%3D%22hidden%22%2Ce.width%3D0%2Ce.height%3D0%2Cdocument.body.appendChild(e)%7D)%7Dvar%20d%3D%5B%22https%3A%2F%2Ftrace.mediago.io%2Fapi%2Fbidder%2Ftrack%3Ftn%3D39934c2bda4debbe4c680be1dd02f5d3%26price%3DdjUJcggeuWWfbm28q4WXHdgMFkO28DrGw49FnubQ0Bk%26evt%3D101%26rid%3D6e28cfaf115a354ea1ad8e1304d6d7b8%26campaignid%3D1339145%26impid%3D44-300x250-1%26offerid%3D24054386%26test%3D0%26time%3D1660789795%26cp%3DjZDh1xu6_QqJLlKVtCkiHIP_TER6gL9jeTrlHCBoxOM%26acid%3D599%26trackingid%3D99afea272c2b0e8626489674ddb7a0bb%26uid%3Da865b9ae-fa9e-4c09-8204-2db99ac7c8f7%26bm%3D2%26la%3Den%26cn%3Dus%26cid%3D3998296%26info%3DSi3oM-qfCbw2iZRYs01BkUWyH6c5CQWHrA8CQLE0VHcXAcf4ljY9dyLzQ4vAlTWd6-j_ou4ySor3e70Ll7wlKiiauQKaUkZqNoTizHm73C4FK8DYJSTP3VkhJV8RzrYk%26sid%3D128__110__1__12__28__38__163__96__58__24__47__99%26sp%3DdjUJcggeuWWfbm28q4WXHdgMFkO28DrGw49FnubQ0Bk%26scp%3DzK0DRYY1UV-syqSpmcMYBpOebtoQJV9ZEJT0JFqbTQg%26acu%3DUSD%26scu%3DUSD%26sgcp%3DzK0DRYY1UV-syqSpmcMYBpOebtoQJV9ZEJT0JFqbTQg%26gprice%3DdjUJcggeuWWfbm28q4WXHdgMFkO28DrGw49FnubQ0Bk%26gcp%3DzK0DRYY1UV-syqSpmcMYBpOebtoQJV9ZEJT0JFqbTQg%26ah%3D%26de%3Dwjh.popin.cc%26iv%3D0%22%2C%22%24%7BITRACKER2%7D%22%2C%22%24%7BITRACKER3%7D%22%2C%22%24%7BITRACKER4%7D%22%2C%22%24%7BITRACKER5%7D%22%2C%22%24%7BITRACKER6%7D%22%5D%2Cp%3D%5B%22https%3A%2F%2Ftrace.mediago.io%2Fapi%2Fbidder%2Ftrack%3Ftn%3D39934c2bda4debbe4c680be1dd02f5d3%26price%3DdjUJcggeuWWfbm28q4WXHdgMFkO28DrGw49FnubQ0Bk%26evt%3D104%26rid%3D6e28cfaf115a354ea1ad8e1304d6d7b8%26campaignid%3D1339145%26impid%3D44-300x250-1%26offerid%3D24054386%26test%3D0%26time%3D1660789795%26cp%3DjZDh1xu6_QqJLlKVtCkiHIP_TER6gL9jeTrlHCBoxOM%26acid%3D599%26trackingid%3D99afea272c2b0e8626489674ddb7a0bb%26uid%3Da865b9ae-fa9e-4c09-8204-2db99ac7c8f7%26sid%3D128__110__1__12__28__38__163__96__58__24__47__99%26format%3D%26crid%3Dff32b6f9b3bbc45c00b78b6674a2952e%26bm%3D2%26la%3Den%26cn%3Dus%26cid%3D3998296%26info%3DSi3oM-qfCbw2iZRYs01BkUWyH6c5CQWHrA8CQLE0VHcXAcf4ljY9dyLzQ4vAlTWd6-j_ou4ySor3e70Ll7wlKiiauQKaUkZqNoTizHm73C4FK8DYJSTP3VkhJV8RzrYk%26sp%3DdjUJcggeuWWfbm28q4WXHdgMFkO28DrGw49FnubQ0Bk%26scp%3DzK0DRYY1UV-syqSpmcMYBpOebtoQJV9ZEJT0JFqbTQg%26acu%3DUSD%26scu%3DUSD%26sgcp%3DzK0DRYY1UV-syqSpmcMYBpOebtoQJV9ZEJT0JFqbTQg%26gprice%3DdjUJcggeuWWfbm28q4WXHdgMFkO28DrGw49FnubQ0Bk%26gcp%3DzK0DRYY1UV-syqSpmcMYBpOebtoQJV9ZEJT0JFqbTQg%26ah%3D%26de%3Dwjh.popin.cc%26iv%3D0%22%2C%22%24%7BVTRACKER2%7D%22%2C%22%24%7BVTRACKER3%7D%22%2C%22%24%7BVTRACKER4%7D%22%2C%22%24%7BVTRACKER5%7D%22%2C%22%24%7BVTRACKER6%7D%22%5D%2Cs%3D%22f9f2b1ef23fe2759c2cad0953029a94b%22%2Cn%3Ddocument.getElementById(%22mgcontainer-99afea272c2b0e8626489674ddb7a0bb%22)%3Bn%26%26function()%7Bvar%20a%3Dn.getElementsByClassName(%22mediago-placement-track%22)%3Bif(a%26%26a.length)%7Bvar%20t%2Ce%3Dfunction(t)%7Bvar%20e%2Cn%2Co%2Ci%2Cc%2Cr%3B%22object%22%3D%3D%3Df(r%3Da%5Bt%5D)%26%26(e%3Dfunction(t)%7Btry%7Bvar%20e%3Dt.getBoundingClientRect()%2Cn%3De%26%26e.top%7C%7C-1%2Co%3De%26%26e.left%7C%7C-1%2Ci%3Ddocument.body.scrollWidth%7C%7C-1%2Ce%3Ddocument.body.scrollHeight%7C%7C-1%3Breturn%7Btop%3An.toFixed(0)%2Cleft%3Ao.toFixed(0)%2Cpage_width%3Ai%2Cpage_height%3Ae%7D%7Dcatch(o)%7Breturn%20l(%7Btn%3As%2Cwinloss%3A1%2Cfe%3A2%2Cpos_err_c%3A1001%2Cpos_err_m%3Ao.toString()%7D)%2C%7Btop%3A%22-1%22%2Cleft%3A%22-1%22%2Cpage_width%3A%22-1%22%2Cpage_height%3A%22-1%22%7D%7D%7D(r)%2C(n%3Dd%5Bt%5D)%26%26g(n%2C0%2Ce)%2Co%3Dp%5Bt%5D%2Ci%3D!1%2C(c%3Dfunction()%7BsetTimeout(function()%7Bvar%20t%2Ce%3B!i%26%26(t%3Dr%2Ce%3Dwindow.innerHeight%7C%7Cdocument.documentElement.clientHeight%7C%7Cdocument.body.clientHeight%2C(t.getBoundingClientRect()%26%26t.getBoundingClientRect().top)%3C%3De-.75*(t.offsetHeight%7C%7Ct.clientHeight))%3F(i%3D!0%2Co%26%26g(o))%3Ac()%7D%2C500)%7D)())%7D%3Bfor(t%20in%20a)e(t)%7D%7D()%7D()'; temp += '%3B%3C%2Fscri'; temp += 'pt%3E'; adm += decodeURIComponent(temp); @@ -160,13 +177,13 @@ describe('mediago:BidAdapterTests', function () { cid: '1339145', crid: 'ff32b6f9b3bbc45c00b78b6674a2952e', w: 300, - h: 250, - }, - ], - }, + h: 250 + } + ] + } ], - cur: 'USD', - }, + cur: 'USD' + } }; let bids = spec.interpretResponse(serverResponse); From fca52d6182ac5e9ec8a0d4c216a3ceffa234ef42 Mon Sep 17 00:00:00 2001 From: BaronYu Date: Tue, 14 Nov 2023 16:38:14 +0800 Subject: [PATCH 37/44] rerun circleci --- test/spec/modules/mediagoBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/mediagoBidAdapter_spec.js b/test/spec/modules/mediagoBidAdapter_spec.js index 3576068979c..4e73c490c38 100644 --- a/test/spec/modules/mediagoBidAdapter_spec.js +++ b/test/spec/modules/mediagoBidAdapter_spec.js @@ -82,7 +82,7 @@ describe('mediago:BidAdapterTests', function () { source: 'puburl.com', uids: [ { - id: 'pubid1', + id: 'pubid2', atype: 1, ext: { stype: 'ppuid' From ace0549a8548c604c33e282c0e13c6b5191b9a07 Mon Sep 17 00:00:00 2001 From: BaronYu Date: Thu, 16 Nov 2023 14:48:39 +0800 Subject: [PATCH 38/44] add gvlid --- modules/mediagoBidAdapter.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js index 055501aaa0e..3426aed54a5 100644 --- a/modules/mediagoBidAdapter.js +++ b/modules/mediagoBidAdapter.js @@ -15,6 +15,7 @@ const ENDPOINT_URL = 'https://rtb-us.mediago.io/api/bid?tn='; const COOKY_SYNC_URL = 'https://trace.mediago.io/ju/cs/eplist'; const TIME_TO_LIVE = 500; +const GVLID = 1020; // const ENDPOINT_URL = '/api/bid?tn='; const storage = getStorageManager({ bidderCode: BIDDER_CODE }); let globals = {}; @@ -347,6 +348,7 @@ function getParam(validBidRequests, bidderRequest) { export const spec = { code: BIDDER_CODE, + gvlid: GVLID, // aliases: ['ex'], // short code /** * Determines whether or not the given bid request is valid. From 1847dcf6fe57bed156ec8cc544f21e63718174f1 Mon Sep 17 00:00:00 2001 From: BaronYu Date: Fri, 1 Dec 2023 18:09:41 +0800 Subject: [PATCH 39/44] feat:add param 1.ppuid 2.content 3.cat 4.reqtime --- modules/mediagoBidAdapter.js | 12 +++++++++++- test/spec/modules/mediagoBidAdapter_spec.js | 8 ++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js index 3426aed54a5..1afe8074eb4 100644 --- a/modules/mediagoBidAdapter.js +++ b/modules/mediagoBidAdapter.js @@ -23,6 +23,8 @@ let itemMaps = {}; /* ----- mguid:start ------ */ const COOKIE_KEY_MGUID = '__mguid_'; +const STORE_MAX_AGE = 1000*60*60*24*365; +let reqTimes = 0; /** * 获取用户id @@ -33,7 +35,7 @@ const getUserID = () => { if (i === null) { const uuid = utils.generateUUID(); - storage.setCookie(COOKIE_KEY_MGUID, uuid); + storage.setCookie(COOKIE_KEY_MGUID, uuid, STORE_MAX_AGE); return uuid; } return i; @@ -280,6 +282,10 @@ function getParam(validBidRequests, bidderRequest) { const bidsUserIdAsEids = validBidRequests[0].userIdAsEids; const bidsUserid = validBidRequests[0].userId; const eids = bidsUserIdAsEids || bidsUserid; + const ppuid = bidsUserid && bidsUserid.pubProvidedId; + const content = utils.deepAccess(bidderRequest, 'ortb2.site.content', config.getAnyConfig('ortb2.site.content')); + const cat = utils.deepAccess(bidderRequest, 'ortb2.site.cat'); + reqTimes +=1; let isMobile = isMobileAndTablet() ? 1 : 0; // input test status by Publisher. more frequently for test true req @@ -317,7 +323,11 @@ function getParam(validBidRequests, bidderRequest) { eids, bidsUserIdAsEids, bidsUserid, + ppuid, firstPartyData, + content, + cat, + reqTimes }, user: { buyeruid: getUserID(), diff --git a/test/spec/modules/mediagoBidAdapter_spec.js b/test/spec/modules/mediagoBidAdapter_spec.js index 4e73c490c38..601bcff527a 100644 --- a/test/spec/modules/mediagoBidAdapter_spec.js +++ b/test/spec/modules/mediagoBidAdapter_spec.js @@ -41,6 +41,14 @@ describe('mediago:BidAdapterTests', function () { } }, ortb2: { + site: { + cat: ['IAB2'], + keywords: 'power tools, drills, tools=industrial', + content: { + keywords: 'video, source=streaming' + }, + + }, user: { ext: { data: {} From 10f546a47e43554a53e120710f144f0a0cad1266 Mon Sep 17 00:00:00 2001 From: BaronYu Date: Fri, 1 Dec 2023 18:30:47 +0800 Subject: [PATCH 40/44] fix: getUserSyncs param fixed --- modules/mediagoBidAdapter.js | 68 ++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 27 deletions(-) diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js index 1afe8074eb4..e5571b43b0f 100644 --- a/modules/mediagoBidAdapter.js +++ b/modules/mediagoBidAdapter.js @@ -14,6 +14,8 @@ const ENDPOINT_URL = // ((PROTOCOL === 'https:') ? 'https' : 'http') + 'https://rtb-us.mediago.io/api/bid?tn='; const COOKY_SYNC_URL = 'https://trace.mediago.io/ju/cs/eplist'; +const COOKY_SYNC_IFRAME_URL = 'https://cdn.mediago.io/js/cookieSync.html'; + const TIME_TO_LIVE = 500; const GVLID = 1020; // const ENDPOINT_URL = '/api/bid?tn='; @@ -23,7 +25,7 @@ let itemMaps = {}; /* ----- mguid:start ------ */ const COOKIE_KEY_MGUID = '__mguid_'; -const STORE_MAX_AGE = 1000*60*60*24*365; +const STORE_MAX_AGE = 1000 * 60 * 60 * 24 * 365; let reqTimes = 0; /** @@ -76,7 +78,7 @@ function isMobileAndTablet() { '.+mobile|avantgo|bada/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)', '|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone', '|p(ixi|re)/|plucker|pocket|psp|series(4|6)0|symbian|treo|up.(browser|link)|vodafone|wap', - '|windows ce|xda|xiino|android|ipad|playbook|silk', + '|windows ce|xda|xiino|android|ipad|playbook|silk' ].join(''), 'i' ); @@ -100,7 +102,7 @@ function isMobileAndTablet() { '|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(.b|g1|si)|utst|', 'v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)', '|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-', - '|your|zeto|zte-', + '|your|zeto|zte-' ].join(''), 'i' ); @@ -142,7 +144,7 @@ function getBidFloor(bid) { const bidFloor = bid.getFloor({ currency: 'USD', mediaType: '*', - size: '*', + size: '*' }); return bidFloor.floor; } catch (_) { @@ -187,7 +189,7 @@ const mediagoAdSize = [ { w: 160, h: 600 }, { w: 320, h: 180 }, { w: 320, h: 100 }, - { w: 336, h: 280 }, + { w: 336, h: 280 } ]; /** @@ -245,19 +247,19 @@ function getItems(validBidRequests, bidderRequest) { h: matchSize.h, w: matchSize.w, pos: 1, - format: sizes, + format: sizes }, ext: { ortb2Imp: utils.deepAccess(req, 'ortb2Imp'), // 传入完整对象,分析日志数据 gpid: gpid, // 加入后无法返回广告 adslot: utils.deepAccess(req, 'ortb2Imp.ext.data.adserver.adslot', '', ''), - ...gdprConsent, // gdpr + ...gdprConsent // gdpr }, - tagid: req.params && req.params.tagid, + tagid: req.params && req.params.tagid }; itemMaps[id] = { req, - ret, + ret }; } @@ -285,7 +287,7 @@ function getParam(validBidRequests, bidderRequest) { const ppuid = bidsUserid && bidsUserid.pubProvidedId; const content = utils.deepAccess(bidderRequest, 'ortb2.site.content', config.getAnyConfig('ortb2.site.content')); const cat = utils.deepAccess(bidderRequest, 'ortb2.site.cat'); - reqTimes +=1; + reqTimes += 1; let isMobile = isMobileAndTablet() ? 1 : 0; // input test status by Publisher. more frequently for test true req @@ -317,21 +319,21 @@ function getParam(validBidRequests, bidderRequest) { // ua: 'Mozilla/5.0 (Linux; Android 12; SM-G970U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Mobile Safari/537.36', os: navigator.platform || '', ua: navigator.userAgent, - language: /en/.test(navigator.language) ? 'en' : navigator.language, + language: /en/.test(navigator.language) ? 'en' : navigator.language }, ext: { eids, bidsUserIdAsEids, bidsUserid, - ppuid, + ppuid, firstPartyData, - content, - cat, - reqTimes + content, + cat, + reqTimes }, user: { buyeruid: getUserID(), - id: sharedid || pubcid, + id: sharedid || pubcid }, eids, site: { @@ -344,11 +346,11 @@ function getParam(validBidRequests, bidderRequest) { publisher: { // todo id: domain, - name: domain, - }, + name: domain + } }, imp: items, - tmax: timeout, + tmax: timeout }; return c; } else { @@ -390,7 +392,7 @@ export const spec = { return { method: 'POST', url: ENDPOINT_URL + globals['token'], - data: payloadString, + data: payloadString }; }, @@ -421,7 +423,7 @@ export const spec = { ttl: TIME_TO_LIVE, // referrer: REFERER, ad: getProperty(bid, 'adm'), - nurl: getProperty(bid, 'nurl'), + nurl: getProperty(bid, 'nurl') // adserverTargeting: { // granularityMultiplier: 0.1, // priceGranularity: 'pbHg', @@ -440,20 +442,32 @@ export const spec = { getUserSyncs: function (syncOptions, serverResponse, gdprConsent, uspConsent, gppConsent) { const origin = encodeURIComponent(location.origin || `https://${location.host}`); - const url = `${COOKY_SYNC_URL}?dm=${origin}&gdpr_consent=${gdprConsent.consentString}`; + let syncParamUrl = `dm=${origin}`; + + if (gdprConsent && gdprConsent.consentString) { + if (typeof gdprConsent.gdprApplies === 'boolean') { + syncParamUrl += `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`; + } else { + syncParamUrl += `&gdpr=0&gdpr_consent=${gdprConsent.consentString}`; + } + } + if (uspConsent && uspConsent.consentString) { + syncParamUrl += `&ccpa_consent=${uspConsent.consentString}`; + } + if (syncOptions.iframeEnabled) { return [ { type: 'iframe', - url: `https://cdn.mediago.io/js/cookieSync.html?gdpr_consent=${gdprConsent.consentString}`, - }, + url: `${COOKY_SYNC_IFRAME_URL}?${syncParamUrl}` + } ]; } else { return [ { type: 'image', - url: url, - }, + url: `${COOKY_SYNC_URL}?${syncParamUrl}` + } ]; } }, @@ -477,7 +491,7 @@ export const spec = { if (bid['nurl']) { utils.triggerPixel(bid['nurl']); } - }, + } /** * Register bidder specific code, which will execute when the adserver targeting has been set for a bid from this bidder From 4377fc29a03a7fa31ce3d002d24130eeffea255e Mon Sep 17 00:00:00 2001 From: BaronYu Date: Fri, 1 Dec 2023 18:35:50 +0800 Subject: [PATCH 41/44] fix: getUserSyncs param fixed --- modules/mediagoBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js index e5571b43b0f..275873af8a9 100644 --- a/modules/mediagoBidAdapter.js +++ b/modules/mediagoBidAdapter.js @@ -285,7 +285,7 @@ function getParam(validBidRequests, bidderRequest) { const bidsUserid = validBidRequests[0].userId; const eids = bidsUserIdAsEids || bidsUserid; const ppuid = bidsUserid && bidsUserid.pubProvidedId; - const content = utils.deepAccess(bidderRequest, 'ortb2.site.content', config.getAnyConfig('ortb2.site.content')); + const content = utils.deepAccess(bidderRequest, 'ortb2.site.content'); const cat = utils.deepAccess(bidderRequest, 'ortb2.site.cat'); reqTimes += 1; From 486e88eef696041e29e585571d450c89992a4631 Mon Sep 17 00:00:00 2001 From: BaronYu Date: Mon, 4 Dec 2023 10:07:59 +0800 Subject: [PATCH 42/44] feat: add param 1. adUnitCode 2. referrer --- modules/mediagoBidAdapter.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js index 275873af8a9..72b06dfe7ed 100644 --- a/modules/mediagoBidAdapter.js +++ b/modules/mediagoBidAdapter.js @@ -250,6 +250,8 @@ function getItems(validBidRequests, bidderRequest) { format: sizes }, ext: { + adUnitCode: req.adUnitCode, + referrer: getReferrer(req, bidderRequest), ortb2Imp: utils.deepAccess(req, 'ortb2Imp'), // 传入完整对象,分析日志数据 gpid: gpid, // 加入后无法返回广告 adslot: utils.deepAccess(req, 'ortb2Imp.ext.data.adserver.adslot', '', ''), @@ -268,6 +270,21 @@ function getItems(validBidRequests, bidderRequest) { return items; } +/** + * @param {BidRequest} bidRequest + * @param bidderRequest + * @returns {string} + */ +function getReferrer(bidRequest = {}, bidderRequest = {}) { + let pageUrl; + if (bidRequest.params && bidRequest.params.referrer) { + pageUrl = bidRequest.params.referrer; + } else { + pageUrl = utils.deepAccess(bidderRequest, 'refererInfo.page'); + } + return pageUrl; +} + /** * 获取rtb请求参数 * From a34f57fd74a9fb47941fbbf15ecf612c8e6a4a62 Mon Sep 17 00:00:00 2001 From: BaronYu Date: Wed, 13 Dec 2023 11:35:08 +0800 Subject: [PATCH 43/44] feat: Switch domain --- modules/mediagoBidAdapter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js index 72b06dfe7ed..b04800df431 100644 --- a/modules/mediagoBidAdapter.js +++ b/modules/mediagoBidAdapter.js @@ -12,8 +12,8 @@ const BIDDER_CODE = 'mediago'; // const PROTOCOL = window.document.location.protocol; const ENDPOINT_URL = // ((PROTOCOL === 'https:') ? 'https' : 'http') + - 'https://rtb-us.mediago.io/api/bid?tn='; -const COOKY_SYNC_URL = 'https://trace.mediago.io/ju/cs/eplist'; + 'https://gbid.mediago.io/api/bid?tn='; +const COOKY_SYNC_URL = 'https://gtrace.mediago.io/ju/cs/eplist'; const COOKY_SYNC_IFRAME_URL = 'https://cdn.mediago.io/js/cookieSync.html'; const TIME_TO_LIVE = 500; From 86547136a9fe7ab20e2727b7223f2441ad470f6e Mon Sep 17 00:00:00 2001 From: BaronYu Date: Wed, 13 Dec 2023 11:49:03 +0800 Subject: [PATCH 44/44] rerun circle ci --- modules/mediagoBidAdapter.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js index b04800df431..a9c670f35d8 100644 --- a/modules/mediagoBidAdapter.js +++ b/modules/mediagoBidAdapter.js @@ -10,9 +10,7 @@ import { registerBidder } from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'mediago'; // const PROTOCOL = window.document.location.protocol; -const ENDPOINT_URL = - // ((PROTOCOL === 'https:') ? 'https' : 'http') + - 'https://gbid.mediago.io/api/bid?tn='; +const ENDPOINT_URL = 'https://gbid.mediago.io/api/bid?tn='; const COOKY_SYNC_URL = 'https://gtrace.mediago.io/ju/cs/eplist'; const COOKY_SYNC_IFRAME_URL = 'https://cdn.mediago.io/js/cookieSync.html';