Skip to content

Commit

Permalink
geoedge rtd module: support site override (prebid#12213)
Browse files Browse the repository at this point in the history
* Add ability to override site from a global object

* Add test for overrides

---------

Co-authored-by: daniel manan <[email protected]>
  • Loading branch information
GeoEdge-r-and-d and mmndaniel authored Sep 9, 2024
1 parent 4eb7515 commit 72bf1cf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
9 changes: 6 additions & 3 deletions modules/geoedgeRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ export let wrapper
let wrapperReady;
/** @type {boolean} */;
let preloaded;
/** @type {object} */;
let refererInfo = getRefererInfo();
/** @type {object} */;
let overrides = window.grumi?.overrides;

/**
* fetches the creative wrapper
Expand All @@ -75,9 +79,8 @@ export function setWrapper(responseText) {
}

export function getInitialParams(key) {
let refererInfo = getRefererInfo();
let params = {
wver: 'pbjs',
wver: '1.1.1',
wtype: 'pbjs-module',
key,
meta: {
Expand Down Expand Up @@ -141,7 +144,7 @@ export function getMacros(bid, key) {
'%_hbcid!': bid.creativeId || '',
'%_hbadomains': bid.meta && bid.meta.advertiserDomains,
'%%PATTERN:hb_pb%%': bid.pbHg,
'%%SITE%%': location.hostname,
'%%SITE%%': overrides?.site || refererInfo.domain,
'%_pimp%': PV_ID,
'%_hbCpm!': bid.cpm,
'%_hbCurrency!': bid.currency
Expand Down
8 changes: 8 additions & 0 deletions test/spec/modules/geoedgeRtdProvider_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ describe('Geoedge RTD module', function () {
const hasCurrency = dict['%_hbCurrency!'] === bid.currency;
expect(hasCpm && hasCurrency);
});
it('return a dictionary of macros replaced with values from overrides object if provided', function () {
const bid = mockBid('testBidder');
window.grumi.overrides = { site: 'test-overrides' };
const overrides = window.grumi.overrides;
const dict = getMacros(bid, key);
const siteOveridden = dict['%%SITE%%'] === overrides.site;
expect(siteOveridden);
});
});
describe('onBidResponseEvent', function () {
const bidFromA = mockBid('bidderA');
Expand Down

0 comments on commit 72bf1cf

Please sign in to comment.