Skip to content

Commit

Permalink
Merge pull request #14 from mbrtargeting/add-meta-tag-retrieval
Browse files Browse the repository at this point in the history
add metatag version info to the payload
  • Loading branch information
Need-less authored Dec 12, 2023
2 parents 9e17b6c + e0412f7 commit 7dfb2d2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
5 changes: 2 additions & 3 deletions modules/stroeerCoreBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import {BANNER, VIDEO} from '../src/mediaTypes.js'
import * as utils from '../src/utils.js'
import {getGlobal} from '../src/prebidGlobal.js'



// Do not import POLYFILLS from core-js. Most likely until next major update (v4).
// Prebid.js committers updated core-js to version 3 on v3.19.0 release (9/5/2020).
// This broke imports. We need to be backwards compatible since this adapter is copied into
Expand Down Expand Up @@ -157,7 +155,8 @@ function getVersionValues (win) {
const pbjs = getGlobal();
return {
yl: win.YLHH?.bidder?.settings?.version,
pb: pbjs.version
pb: pbjs.version,
mt: win?.SDG?.version && win.SDG.version()
};
}

Expand Down
33 changes: 28 additions & 5 deletions test/spec/modules/stroeerCoreBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -871,39 +871,62 @@ describe('stroeerCore bid adapter', function () {
describe('optional fields', () => {
describe('version fields', () => {
let pbVerStub
let mtVersion

beforeEach(() => {
pbVerStub = sinon.stub(prebidGlobal, 'getGlobal')
win.SDG = {version: () => mtVersion};
});

afterEach(() => {
pbVerStub.restore()
});

it('gets version variables', () => {
mtVersion = '1.8';
pbVerStub.returns({version: '1.2'});
win.YLHH.bidder.settings = {version: '1.1'};
const bidReq = buildBidderRequest();
const serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq)[0];
assert.deepEqual(serverRequestInfo.data.ver, {'yl': '1.1', 'pb': '1.2'})
})
assert.deepEqual(serverRequestInfo.data.ver, {'yl': '1.1', 'pb': '1.2', 'mt': '1.8'});
});
it('functions with no pb value', () => {
mtVersion = '1.8';
pbVerStub.returns({version: undefined});
win.YLHH.bidder.settings = {version: '1.1'};
const bidReq = buildBidderRequest();
const serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq)[0];
assert.deepEqual(serverRequestInfo.data.ver, {'yl': '1.1', 'pb': undefined})
assert.deepEqual(serverRequestInfo.data.ver, {'yl': '1.1', 'pb': undefined, 'mt': '1.8'});
});
it('functions with no yl value', () => {
mtVersion = '1.8';
pbVerStub.returns({version: '2'});
const bidReq = buildBidderRequest();
const serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq)[0];
assert.deepEqual(serverRequestInfo.data.ver, {'pb': '2', 'yl': undefined})
assert.deepEqual(serverRequestInfo.data.ver, {'pb': '2', 'yl': undefined, 'mt': '1.8'});
});
it('functions with no mt value', () => {
mtVersion = undefined;
pbVerStub.returns({version: '1.2'});
win.YLHH.bidder.settings = {version: '1.1'};
const bidReq = buildBidderRequest();
const serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq)[0];
assert.deepEqual(serverRequestInfo.data.ver, {'yl': '1.1', 'pb': '1.2', 'mt': undefined});
});
it('functions with no mt version function', () => {
win.SDG = {};
pbVerStub.returns({version: '1.2'});
win.YLHH.bidder.settings = {version: '1.1'};
const bidReq = buildBidderRequest();
const serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq)[0];
assert.deepEqual(serverRequestInfo.data.ver, {'yl': '1.1', 'pb': '1.2', 'mt': undefined});
});
it('functions with no values', () => {
mtVersion = undefined;
pbVerStub.returns({version: undefined});
const bidReq = buildBidderRequest();
const serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq)[0];
assert.deepEqual(serverRequestInfo.data.ver, {'yl': undefined, 'pb': undefined})
assert.deepEqual(serverRequestInfo.data.ver, {'yl': undefined, 'pb': undefined, 'mt': undefined});
});
});
it('should use ssat value from config', () => {
Expand Down

0 comments on commit 7dfb2d2

Please sign in to comment.