Skip to content
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
60 changes: 6 additions & 54 deletions modules/asoBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { deepAccess, deepSetValue } from '../src/utils.js';
import { deepAccess } from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { tryAppendQueryString } from '../libraries/urlUtils/urlUtils.js';
import { ortbConverter } from '../libraries/ortbConverter/converter.js';
import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js';

const BIDDER_CODE = 'aso';
const BIDDER_GVLID = 1621;
const DEFAULT_SERVER_URL = 'https://srv.aso1.net';
const DEFAULT_SERVER_PATH = '/prebid/bidder';
const DEFAULT_CURRENCY = 'USD';
Expand All @@ -14,11 +14,12 @@ const TTL = 300;
export const spec = {

code: BIDDER_CODE,
gvlid: BIDDER_GVLID,
supportedMediaTypes: [BANNER, VIDEO, NATIVE],
aliases: [
{ code: 'bcmint' },
{ code: 'bidgency' },
{ code: 'kuantyx' },
{ code: 'bidgency', gvlid: 1403 },
{ code: 'kuantyx', gvlid: 1374 },
{ code: 'cordless' },
{ code: 'adklip' }
],
Expand Down Expand Up @@ -53,28 +54,10 @@ export const spec = {
return [];
},

getUserSyncs: function (syncOptions, serverResponses, gdprConsent, uspConsent) {
getUserSyncs: function (syncOptions, serverResponses) {
const urls = [];

if (serverResponses && serverResponses.length !== 0) {
let query = '';
if (gdprConsent) {
query = tryAppendQueryString(query, 'gdpr', (gdprConsent.gdprApplies ? 1 : 0));
query = tryAppendQueryString(query, 'consents_str', gdprConsent.consentString);
const consentsIds = getConsentsIds(gdprConsent);
if (consentsIds) {
query = tryAppendQueryString(query, 'consents', consentsIds);
}
}

if (uspConsent) {
query = tryAppendQueryString(query, 'us_privacy', uspConsent);
}

if (query.slice(-1) === '&') {
query = query.slice(0, -1);
}

serverResponses.forEach(resp => {
const userSyncs = deepAccess(resp, 'body.ext.user_syncs');
if (!userSyncs) {
Expand All @@ -83,9 +66,6 @@ export const spec = {

userSyncs.forEach(us => {
let url = us.url;
if (query) {
url = url + (url.indexOf('?') === -1 ? '?' : '&') + query;
}

urls.push({
type: us.type,
Expand Down Expand Up @@ -116,13 +96,6 @@ const converter = ortbConverter({
request(buildRequest, imps, bidderRequest, context) {
const request = buildRequest(imps, bidderRequest, context);

if (bidderRequest.gdprConsent) {
const consentsIds = getConsentsIds(bidderRequest.gdprConsent);
if (consentsIds) {
deepSetValue(request, 'user.ext.consents', consentsIds);
}
}

if (!request.cur) {
request.cur = [DEFAULT_CURRENCY];
}
Expand All @@ -133,14 +106,6 @@ const converter = ortbConverter({
bidResponse(buildBidResponse, bid, context) {
context.mediaType = deepAccess(bid, 'ext.prebid.type');
return buildBidResponse(bid, context);
},

overrides: {
request: {
// We don't need extra data
gdprAddtlConsent(setAddtlConsent, ortbRequest, bidderRequest) {
}
}
}
});

Expand All @@ -149,17 +114,4 @@ function getEndpoint(bidRequest) {
return serverUrl + DEFAULT_SERVER_PATH + '?zid=' + bidRequest.params.zone + '&pbjs=' + VERSION;
}

function getConsentsIds(gdprConsent) {
const consents = deepAccess(gdprConsent, 'vendorData.purpose.consents', []);
const consentsIds = [];

Object.keys(consents).forEach(key => {
if (consents[key] === true) {
consentsIds.push(key);
}
});

return consentsIds.join(',');
}

registerBidder(spec);
16 changes: 12 additions & 4 deletions test/spec/modules/asoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ describe('Adserver.Online bidding adapter', function () {
ext: {
user_syncs: [
{
url: 'sync_url',
url: 'sync_url?gdpr=1&gdpr_consent=consentString&us_privacy=usp_consent',
type: 'iframe'
}
]
Expand Down Expand Up @@ -394,7 +394,15 @@ describe('Adserver.Online bidding adapter', function () {
}
]
}],
cur: 'USD'
cur: 'USD',
ext: {
user_syncs: [
{
url: 'sync_url?us_privacy=usp_consent',
type: 'iframe'
}
]
}
},
};

Expand Down Expand Up @@ -471,12 +479,12 @@ describe('Adserver.Online bidding adapter', function () {
expect(syncs).to.have.lengthOf(1);
expect(syncs[0].type).to.equal('iframe');
expect(syncs[0].url).to.equal(
'sync_url?gdpr=1&consents_str=consentString&consents=1%2C2&us_privacy=usp_consent'
'sync_url?gdpr=1&gdpr_consent=consentString&us_privacy=usp_consent'
);
});

it('should return iframe sync option - gdpr not applies', function () {
const syncs = spec.getUserSyncs(syncOptions, [bannerResponse], gdprNotApplies, uspConsent);
const syncs = spec.getUserSyncs(syncOptions, [nativeResponse], gdprNotApplies, uspConsent);
expect(syncs).to.have.lengthOf(1);

expect(syncs[0].url).to.equal(
Expand Down
Loading