From 3763921848d142e34282a66721041a9e557c8897 Mon Sep 17 00:00:00 2001 From: nkloeber Date: Thu, 24 Feb 2022 09:59:53 +0100 Subject: [PATCH 1/3] YL-4121 Add user matching to prebid --- modules/yieldlabBidAdapter.js | 33 +++++++++++++++++- test/spec/modules/yieldlabBidAdapter_spec.js | 36 ++++++++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-) diff --git a/modules/yieldlabBidAdapter.js b/modules/yieldlabBidAdapter.js index c2f2b79a3b7..66ef9239e81 100644 --- a/modules/yieldlabBidAdapter.js +++ b/modules/yieldlabBidAdapter.js @@ -1,4 +1,4 @@ -import { _each, isPlainObject, isArray, deepAccess } from '../src/utils.js'; +import {_each, isPlainObject, isArray, deepAccess, timestamp} from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js' import find from 'core-js-pure/features/array/find.js' import { VIDEO, BANNER, NATIVE } from '../src/mediaTypes.js' @@ -174,6 +174,37 @@ export const spec = { } }) return bidResponses + }, + + /** + * Register the user sync pixels which should be dropped after the auction. + * + * @param {SyncOptions} syncOptions Which user syncs are allowed? + * @param {ServerResponse[]} serverResponses List of server's responses. + * @param {Object} gdprConsent Is the GDPR Consent object wrapping gdprApplies {boolean} and consentString {string} attributes. + * @param {string} uspConsent Is the US Privacy Consent string. + * @return {UserSync[]} The user syncs which should be dropped. + */ + getUserSyncs: function (syncOptions, serverResponses, gdprConsent, uspConsent) { + const syncs = []; + + if (syncOptions.iframeEnabled) { + let params = []; + params.push(`ts=${timestamp()}`); + params.push(`type=h`) + if (gdprConsent && (typeof gdprConsent.gdprApplies === 'boolean')) { + params.push(`gdpr=${gdprConsent.gdprApplies ? '1' : '0'}`); + } + if (gdprConsent && (typeof gdprConsent.consentString === 'string')) { + params.push(`consent=${gdprConsent.consentString}`); + } + syncs.push({ + type: 'iframe', + url: `https://ad.yieldlab.net/d/6846326/766/2x2?${params.join('&')}` + }); + } + + return syncs; } }; diff --git a/test/spec/modules/yieldlabBidAdapter_spec.js b/test/spec/modules/yieldlabBidAdapter_spec.js index f80cad46d50..a96ef1bb0f2 100644 --- a/test/spec/modules/yieldlabBidAdapter_spec.js +++ b/test/spec/modules/yieldlabBidAdapter_spec.js @@ -414,4 +414,40 @@ describe('yieldlabBidAdapter', function () { expect(result[0].vastUrl).to.include('&iab_content=id%3Afoo_id%2Cepisode%3A99%2Ctitle%3Afoo_title%252Cbar_title%2Cseries%3Afoo_series%2Cseason%3As1%2Cartist%3Afoo%2520bar%2Cgenre%3Abaz%2Cisrc%3ACC-XXX-YY-NNNNN%2Curl%3Ahttp%253A%252F%252Ffoo_url.de%2Ccat%3Acat1%7Ccat2%252Cppp%7Ccat3%257C%257C%257C%252F%252F%2Ccontext%3A7%2Ckeywords%3Ak1%252C%7Ck2..%2Clive%3A0') }) }) + + describe('getUserSyncs', function () { + const syncOptions = { + iframeEnabled: true, + pixelEnabled: false + }; + const expectedUrlSnippets = ['https://ad.yieldlab.net/d/6846326/766/2x2?', 'ts=', 'type=h']; + + it('should return user sync as expected', function () { + const bidRequest = { + gdprConsent: { + consentString: 'BN5lERiOMYEdiAKAWXEND1AAAAE6DABACMA', + gdprApplies: true + }, + uspConsent: '1YYY' + }; + const sync = spec.getUserSyncs(syncOptions, [], bidRequest.gdprConsent, bidRequest.uspConsent); + expect(expectedUrlSnippets.every(urlSnippet => sync[0].url.includes(urlSnippet))); + expect(sync[0].url).to.have.string('gdpr=' + Number(bidRequest.gdprConsent.gdprApplies)); + expect(sync[0].url).to.have.string('consent=' + bidRequest.gdprConsent.consentString); + // USP consent should be ignored + expect(sync[0].url).not.have.string('usp_consent='); + expect(sync[0].type).to.have.string('iframe'); + }); + + it('should return user sync even without gdprApplies in gdprConsent', function () { + const gdprConsent = { + consentString: 'BN5lERiOMYEdiAKAWXEND1AAAAE6DABACMA' + } + const sync = spec.getUserSyncs(syncOptions, [], gdprConsent, undefined); + expect(expectedUrlSnippets.every(urlSnippet => sync[0].url.includes(urlSnippet))); + expect(sync[0].url).to.have.string('consent=' + gdprConsent.consentString); + expect(sync[0].url).not.have.string('gdpr='); + expect(sync[0].type).to.have.string('iframe'); + }); + }); }) From 7e2211705d9208a5ce02fed81b4f1ef7f17e7c5b Mon Sep 17 00:00:00 2001 From: nkloeber Date: Thu, 24 Feb 2022 10:35:55 +0100 Subject: [PATCH 2/3] YL-4121 using a constad instead of hardcoded string as endpoint --- modules/yieldlabBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/yieldlabBidAdapter.js b/modules/yieldlabBidAdapter.js index 66ef9239e81..ef2427f94c0 100644 --- a/modules/yieldlabBidAdapter.js +++ b/modules/yieldlabBidAdapter.js @@ -200,7 +200,7 @@ export const spec = { } syncs.push({ type: 'iframe', - url: `https://ad.yieldlab.net/d/6846326/766/2x2?${params.join('&')}` + url: `${ENDPOINT}/d/6846326/766/2x2?${params.join('&')}` }); } From b4136913bf9b114c8b8588f997f15f9124f1a1a6 Mon Sep 17 00:00:00 2001 From: nkloeber Date: Wed, 2 Mar 2022 13:27:11 +0100 Subject: [PATCH 3/3] YL-4121 improvements as requested in pr --- modules/yieldlabBidAdapter.js | 4 ++-- test/spec/modules/yieldlabBidAdapter_spec.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/yieldlabBidAdapter.js b/modules/yieldlabBidAdapter.js index ef2427f94c0..55083720dab 100644 --- a/modules/yieldlabBidAdapter.js +++ b/modules/yieldlabBidAdapter.js @@ -193,10 +193,10 @@ export const spec = { params.push(`ts=${timestamp()}`); params.push(`type=h`) if (gdprConsent && (typeof gdprConsent.gdprApplies === 'boolean')) { - params.push(`gdpr=${gdprConsent.gdprApplies ? '1' : '0'}`); + params.push(`gdpr=${Number(gdprConsent.gdprApplies)}`); } if (gdprConsent && (typeof gdprConsent.consentString === 'string')) { - params.push(`consent=${gdprConsent.consentString}`); + params.push(`gdpr_consent=${gdprConsent.consentString}`); } syncs.push({ type: 'iframe', diff --git a/test/spec/modules/yieldlabBidAdapter_spec.js b/test/spec/modules/yieldlabBidAdapter_spec.js index a96ef1bb0f2..e4d258ecdea 100644 --- a/test/spec/modules/yieldlabBidAdapter_spec.js +++ b/test/spec/modules/yieldlabBidAdapter_spec.js @@ -433,7 +433,7 @@ describe('yieldlabBidAdapter', function () { const sync = spec.getUserSyncs(syncOptions, [], bidRequest.gdprConsent, bidRequest.uspConsent); expect(expectedUrlSnippets.every(urlSnippet => sync[0].url.includes(urlSnippet))); expect(sync[0].url).to.have.string('gdpr=' + Number(bidRequest.gdprConsent.gdprApplies)); - expect(sync[0].url).to.have.string('consent=' + bidRequest.gdprConsent.consentString); + expect(sync[0].url).to.have.string('gdpr_consent=' + bidRequest.gdprConsent.consentString); // USP consent should be ignored expect(sync[0].url).not.have.string('usp_consent='); expect(sync[0].type).to.have.string('iframe'); @@ -445,7 +445,7 @@ describe('yieldlabBidAdapter', function () { } const sync = spec.getUserSyncs(syncOptions, [], gdprConsent, undefined); expect(expectedUrlSnippets.every(urlSnippet => sync[0].url.includes(urlSnippet))); - expect(sync[0].url).to.have.string('consent=' + gdprConsent.consentString); + expect(sync[0].url).to.have.string('gdpr_consent=' + gdprConsent.consentString); expect(sync[0].url).not.have.string('gdpr='); expect(sync[0].type).to.have.string('iframe'); });