Skip to content

Commit db4b7c8

Browse files
committed
Smaato: Add UserSyncs
1 parent 8f817bd commit db4b7c8

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

modules/smaatoBidAdapter.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const SMAATO_CLIENT = 'prebid_js_$prebid.version$_3.1'
2323
const TTL = 300;
2424
const CURRENCY = 'USD';
2525
const SUPPORTED_MEDIA_TYPES = [BANNER, VIDEO, NATIVE];
26+
const SYNC_URL = 'https://s.ad.smaato.net/c/?adExInit=p'
2627

2728
export const spec = {
2829
code: BIDDER_CODE,
@@ -196,6 +197,22 @@ export const spec = {
196197
* @return {UserSync[]} The user syncs which should be dropped.
197198
*/
198199
getUserSyncs: (syncOptions, serverResponses, gdprConsent, uspConsent) => {
200+
if (syncOptions && syncOptions.pixelEnabled) {
201+
let gdprParams = '';
202+
if (gdprConsent && gdprConsent.consentString) {
203+
if (typeof gdprConsent.gdprApplies === 'boolean') {
204+
gdprParams = `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`;
205+
} else {
206+
gdprParams = `&gdpr_consent=${gdprConsent.consentString}`;
207+
}
208+
}
209+
210+
return [{
211+
type: 'image',
212+
url: SYNC_URL + gdprParams
213+
}];
214+
}
215+
199216
return [];
200217
}
201218
}

test/spec/modules/smaatoBidAdapter_spec.js

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import 'modules/consentManagementTcf.js';
1212
import 'modules/consentManagementUsp.js';
1313
import 'modules/schain.js';
1414

15+
const SYNC_URL = 'https://s.ad.smaato.net/c/?adExInit=p'
16+
1517
const ADTYPE_IMG = 'Img';
1618
const ADTYPE_VIDEO = 'Video';
1719
const ADTYPE_NATIVE = 'Native';
@@ -1667,8 +1669,41 @@ describe('smaatoBidAdapterTest', () => {
16671669
});
16681670

16691671
describe('getUserSyncs', () => {
1670-
it('returns no pixels', () => {
1672+
it('when pixelEnabled false then returns no pixels', () => {
16711673
expect(spec.getUserSyncs()).to.be.empty
16721674
})
1675+
1676+
it('when pixelEnabled true then returns pixel', () => {
1677+
expect(spec.getUserSyncs({pixelEnabled: true})).to.deep.equal(
1678+
[
1679+
{
1680+
type: 'image',
1681+
url: SYNC_URL
1682+
}
1683+
]
1684+
)
1685+
})
1686+
1687+
it('when pixelEnabled true and gdprConsent then returns pixel with gdpr params', () => {
1688+
expect(spec.getUserSyncs({pixelEnabled: true}, null, {gdprApplies:true, consentString: CONSENT_STRING})).to.deep.equal(
1689+
[
1690+
{
1691+
type: 'image',
1692+
url: `${SYNC_URL}&gdpr=1&gdpr_consent=${CONSENT_STRING}`
1693+
}
1694+
]
1695+
)
1696+
})
1697+
1698+
it('when pixelEnabled true and gdprConsent without gdpr then returns pixel with gdpr_consent', () => {
1699+
expect(spec.getUserSyncs({pixelEnabled: true}, null, {consentString: CONSENT_STRING})).to.deep.equal(
1700+
[
1701+
{
1702+
type: 'image',
1703+
url: `${SYNC_URL}&gdpr_consent=${CONSENT_STRING}`
1704+
}
1705+
]
1706+
)
1707+
})
16731708
})
16741709
});

0 commit comments

Comments
 (0)