Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adgrid Bid Adapter: support userSync feature #12714

Merged
merged 2 commits into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion modules/adgridBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,28 @@ function getBidData(bid) {
return bidData;
}

/**
* Register the user sync pixels/iframe which should be dropped after the auction.
*/
function getUserSyncs(syncOptions, response, gdprConsent, uspConsent) {
if (typeof response !== 'object' || response === null || response.length === 0) {
return [];
}

if (response[0]?.body?.ext?.cookies && typeof response[0].body.ext.cookies === 'object') {
return response[0].body.ext.cookies.slice(0, 5);
} else {
return [];
}
};

export const spec = {
code: BIDDER.CODE,
isBidRequestValid,
buildRequests,
interpretResponse,
supportedMediaTypes: BIDDER.SUPPORTED_MEDIA_TYPES
supportedMediaTypes: BIDDER.SUPPORTED_MEDIA_TYPES,
getUserSyncs
};

registerBidder(spec);
40 changes: 40 additions & 0 deletions test/spec/modules/adgridBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ const globalConfig = {
endPoint: 'https://api-prebid.adgrid.io/api/v1/auction'
};

const userConfig = {
gdprConsent: {
gdprApplies: true,
consentString: 'COwK6gaOwK6gaFmAAAENAPCAAAAAAAAAAAAAAAAAAAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw',
vendorData: {}
},
uspConsent: '123456'
};

describe('AdGrid Bid Adapter', function () {
const bannerRequest = [{
bidId: 123456,
Expand Down Expand Up @@ -128,4 +137,35 @@ describe('AdGrid Bid Adapter', function () {
expect(bid.currency).to.equal(receivedBid.currency);
});
});

describe('getUserSyncs', function () {
const response = { body: { cookies: [] } };

it('Validate the user sync without cookie', function () {
var syncs = spec.getUserSyncs({}, [response], userConfig.gdprConsent, userConfig.uspConsent);
expect(syncs).to.have.lengthOf(0);
});

it('Validate the user sync with cookie', function () {
response.body.ext = {
cookies: [{ 'type': 'image', 'url': 'https://cookie-sync.org/' }]
};
var syncs = spec.getUserSyncs({}, [response], userConfig.gdprConsent);
expect(syncs).to.have.lengthOf(1);
expect(syncs[0]).to.have.property('type').and.to.equal('image');
expect(syncs[0]).to.have.property('url').and.to.equal('https://cookie-sync.org/');
});

it('Validate the user sync with no bid', function () {
var syncs = spec.getUserSyncs({}, null, userConfig.gdprConsent, userConfig.uspConsent);
expect(syncs).to.have.lengthOf(0);
});

it('Validate the user sync with no bid body', function () {
var syncs = spec.getUserSyncs({}, [], userConfig.gdprConsent, userConfig.uspConsent);
expect(syncs).to.have.lengthOf(0);
var syncs = spec.getUserSyncs({}, [{}], userConfig.gdprConsent, userConfig.uspConsent);
expect(syncs).to.have.lengthOf(0);
});
});
});