diff --git a/integrationExamples/gpt/hello_world.html b/integrationExamples/gpt/hello_world.html index 03a2356f0ef..2167a6337fb 100644 --- a/integrationExamples/gpt/hello_world.html +++ b/integrationExamples/gpt/hello_world.html @@ -23,15 +23,13 @@ sizes: [[300, 250]], } }, - // Replace this object to test a new Adapter! bids: [{ - bidder: 'appnexus', + bidder: 'greenbids', params: { - placementId: 13144370 + placementId: 4242 } }] - }]; var pbjs = pbjs || {}; @@ -48,7 +46,20 @@ pbjs.que.push(function () { pbjs.addAdUnits(adUnits); - + pbjs.setConfig({ + bidResponseFilter: { + cat: { + blockUnknown: false // setting only one of parameters will keep the other one as default + }, + adv: { + enforce: false + }, + attr: { + enforce: false, + blockUnknown: false + } + } + }); pbjs.requestBids({ bidsBackHandler: sendAdserverRequest, timeout: PREBID_TIMEOUT diff --git a/libraries/timeToFirstBytesUtils/timeToFirstBytesUtils.js b/libraries/timeToFirstBytesUtils/timeToFirstBytesUtils.js new file mode 100644 index 00000000000..5d5330d8127 --- /dev/null +++ b/libraries/timeToFirstBytesUtils/timeToFirstBytesUtils.js @@ -0,0 +1,37 @@ +/** + * Calculates the Time to First Byte (TTFB) for the given window object. + * + * This function attempts to use the Navigation Timing Level 2 API first, and falls back to + * the Navigation Timing Level 1 API if the former is not available. + * + * @param {Window} win - The window object from which to retrieve performance timing information. + * @returns {string} The TTFB in milliseconds as a string, or an empty string if the TTFB cannot be determined. + */ +export function getTimeToFirstByte(win) { + const performance = win.performance || win.webkitPerformance || win.msPerformance || win.mozPerformance; + + const ttfbWithTimingV2 = performance && + typeof performance.getEntriesByType === 'function' && + Object.prototype.toString.call(performance.getEntriesByType) === '[object Function]' && + performance.getEntriesByType('navigation')[0] && + performance.getEntriesByType('navigation')[0].responseStart && + performance.getEntriesByType('navigation')[0].requestStart && + performance.getEntriesByType('navigation')[0].responseStart > 0 && + performance.getEntriesByType('navigation')[0].requestStart > 0 && + Math.round( + performance.getEntriesByType('navigation')[0].responseStart - performance.getEntriesByType('navigation')[0].requestStart + ); + + if (ttfbWithTimingV2) { + return ttfbWithTimingV2.toString(); + } + + const ttfbWithTimingV1 = performance && + performance.timing.responseStart && + performance.timing.requestStart && + performance.timing.responseStart > 0 && + performance.timing.requestStart > 0 && + performance.timing.responseStart - performance.timing.requestStart; + + return ttfbWithTimingV1 ? ttfbWithTimingV1.toString() : ''; +} diff --git a/modules/greenbidsBidAdapter.js b/modules/greenbidsBidAdapter.js index fa5c7049c6f..c72f2a622c8 100644 --- a/modules/greenbidsBidAdapter.js +++ b/modules/greenbidsBidAdapter.js @@ -2,6 +2,7 @@ import { getValue, logError, deepAccess, parseSizesInput, getBidIdParameter, log import { registerBidder } from '../src/adapters/bidderFactory.js'; import { getStorageManager } from '../src/storageManager.js'; import { getDM, getHC, getHLen } from '../libraries/navigatorData/navigatorData.js'; +import { getTimeToFirstByte } from '../libraries/timeToFirstBytesUtils/timeToFirstBytesUtils.js'; /** * @typedef {import('../src/adapters/bidderFactory.js').BidRequest} BidRequest @@ -10,7 +11,7 @@ import { getDM, getHC, getHLen } from '../libraries/navigatorData/navigatorData. const BIDDER_CODE = 'greenbids'; const GVL_ID = 1232; -const ENDPOINT_URL = 'https://d.greenbids.ai/hb/bid-request'; +const ENDPOINT_URL = 'https://hb.greenbids.ai'; export const storage = getStorageManager({ bidderCode: BIDDER_CODE }); export const spec = { @@ -211,44 +212,6 @@ function getConnectionDownLink(nav) { return nav && nav.connection && nav.connection.downlink >= 0 ? nav.connection.downlink.toString() : ''; } -/** - * Calculates the Time to First Byte (TTFB) for the given window object. - * - * This function attempts to use the Navigation Timing Level 2 API first, and falls back to - * the Navigation Timing Level 1 API if the former is not available. - * - * @param {Window} win - The window object from which to retrieve performance timing information. - * @returns {string} The TTFB in milliseconds as a string, or an empty string if the TTFB cannot be determined. - */ -function getTimeToFirstByte(win) { - const performance = win.performance || win.webkitPerformance || win.msPerformance || win.mozPerformance; - - const ttfbWithTimingV2 = performance && - typeof performance.getEntriesByType === 'function' && - Object.prototype.toString.call(performance.getEntriesByType) === '[object Function]' && - performance.getEntriesByType('navigation')[0] && - performance.getEntriesByType('navigation')[0].responseStart && - performance.getEntriesByType('navigation')[0].requestStart && - performance.getEntriesByType('navigation')[0].responseStart > 0 && - performance.getEntriesByType('navigation')[0].requestStart > 0 && - Math.round( - performance.getEntriesByType('navigation')[0].responseStart - performance.getEntriesByType('navigation')[0].requestStart - ); - - if (ttfbWithTimingV2) { - return ttfbWithTimingV2.toString(); - } - - const ttfbWithTimingV1 = performance && - performance.timing.responseStart && - performance.timing.requestStart && - performance.timing.responseStart > 0 && - performance.timing.requestStart > 0 && - performance.timing.responseStart - performance.timing.requestStart; - - return ttfbWithTimingV1 ? ttfbWithTimingV1.toString() : ''; -} - /** * Converts the sizes from the bid object to the required format. * diff --git a/modules/greenbidsBidAdapter.md b/modules/greenbidsBidAdapter.md index 18e9840fe44..df536294f47 100644 --- a/modules/greenbidsBidAdapter.md +++ b/modules/greenbidsBidAdapter.md @@ -16,7 +16,7 @@ Use `greenbids` as bidder. bids: [{ bidder: 'greenbids', params: { - gbPlacementId: 12345, + placementId: 12345, } }] },{ @@ -25,7 +25,7 @@ Use `greenbids` as bidder. bids: [{ bidder: 'greenbids', params: { - gbPlacementId: 12345, + placementId: 12345, } }] }];