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

Smaato Bid Adapter: Add UserSyncs #11932

Merged
merged 1 commit into from
Jul 9, 2024
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
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) {
Copy link
Collaborator

@patmmccann patmmccann Jul 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you forgot about gpp? Also, why not import

export const getUserSyncs = (syncUrl) => (syncOptions, serverResponses, gdprConsent, uspConsent, gppConsent) => {
or
export function createUserSyncGetter(options = {
?

I'm hoping these generic user sync implementations can develop common patterns for many bidders to import

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the changes are sufficient for now, but thank you for checking.

regarding the generic implementation: both options currently don't fit our use case. if those should be used, i can of course rework one of them to make it fit. is there some preference which one should be worked on for a generic implementation?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No preference, I'll merge this and keep we'll study some more adapters before starting a generic implementation

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}`
}
]
)
})
})
});