Skip to content
Draft
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
19 changes: 18 additions & 1 deletion modules/smaatoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ import {ortbConverter} from '../libraries/ortbConverter/converter.js';

const BIDDER_CODE = 'smaato';
const SMAATO_ENDPOINT = 'https://prebid.ad.smaato.net/oapi/prebid';
const SMAATO_CLIENT = 'prebid_js_$prebid.version$_3.1'
const SMAATO_CLIENT = 'prebid_js_$prebid.version$_3.2'
const TTL = 300;
const CURRENCY = 'USD';
const SUPPORTED_MEDIA_TYPES = [BANNER, VIDEO, NATIVE];
const SYNC_URL = 'https://s.ad.smaato.net/c/?adExInit=p'

export const spec = {
code: BIDDER_CODE,
Expand Down Expand Up @@ -196,6 +197,22 @@ export const spec = {
* @return {UserSync[]} The user syncs which should be dropped.
*/
getUserSyncs: (syncOptions, serverResponses, gdprConsent, uspConsent) => {
if (syncOptions && syncOptions.pixelEnabled) {
let gdprParams = '';
if (gdprConsent && gdprConsent.consentString) {
if (typeof gdprConsent.gdprApplies === 'boolean') {
gdprParams = `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`;
} else {
gdprParams = `&gdpr_consent=${gdprConsent.consentString}`;
}
}

return [{
type: 'image',
url: SYNC_URL + gdprParams
}];
}

return [];
}
}
Expand Down
37 changes: 36 additions & 1 deletion test/spec/modules/smaatoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import 'modules/consentManagementTcf.js';
import 'modules/consentManagementUsp.js';
import 'modules/schain.js';

const SYNC_URL = 'https://s.ad.smaato.net/c/?adExInit=p'

const ADTYPE_IMG = 'Img';
const ADTYPE_VIDEO = 'Video';
const ADTYPE_NATIVE = 'Native';
Expand Down Expand Up @@ -1667,8 +1669,41 @@ describe('smaatoBidAdapterTest', () => {
});

describe('getUserSyncs', () => {
it('returns no pixels', () => {
it('when pixelEnabled false then returns no pixels', () => {
expect(spec.getUserSyncs()).to.be.empty
})

it('when pixelEnabled true then returns pixel', () => {
expect(spec.getUserSyncs({pixelEnabled: true}, null, null, null)).to.deep.equal(
[
{
type: 'image',
url: SYNC_URL
}
]
)
})

it('when pixelEnabled true and gdprConsent then returns pixel with gdpr params', () => {
expect(spec.getUserSyncs({pixelEnabled: true}, null, {gdprApplies: true, consentString: CONSENT_STRING}, null)).to.deep.equal(
[
{
type: 'image',
url: `${SYNC_URL}&gdpr=1&gdpr_consent=${CONSENT_STRING}`
}
]
)
})

it('when pixelEnabled true and gdprConsent without gdpr then returns pixel with gdpr_consent', () => {
expect(spec.getUserSyncs({pixelEnabled: true}, null, {consentString: CONSENT_STRING}, null), null).to.deep.equal(
[
{
type: 'image',
url: `${SYNC_URL}&gdpr_consent=${CONSENT_STRING}`
}
]
)
})
})
});