Skip to content

Commit

Permalink
Smaato: Add UserSyncs (#11932)
Browse files Browse the repository at this point in the history
  • Loading branch information
el-chuck authored Jul 9, 2024
1 parent e8964d4 commit c4360d3
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 2 deletions.
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}`
}
]
)
})
})
});

0 comments on commit c4360d3

Please sign in to comment.