Skip to content

adWMG adapter: add new parameter, fix minor bugs #6265

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

Merged
merged 11 commits into from
Feb 4, 2021
Merged
8 changes: 6 additions & 2 deletions modules/adWMGBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,18 @@ export const spec = {
return bidResponses;
},
getUserSyncs: (syncOptions, serverResponses, gdprConsent, uspConsent) => {
if (gdprConsent) {
if (gdprConsent && SYNC_ENDPOINT.indexOf('gdpr') === -1) {
SYNC_ENDPOINT = utils.tryAppendQueryString(SYNC_ENDPOINT, 'gdpr', (gdprConsent.gdprApplies ? 1 : 0));
}

if (gdprConsent && typeof gdprConsent.consentString === 'string') {
if (gdprConsent && typeof gdprConsent.consentString === 'string' && SYNC_ENDPOINT.indexOf('gdpr_consent') === -1) {
SYNC_ENDPOINT = utils.tryAppendQueryString(SYNC_ENDPOINT, 'gdpr_consent', gdprConsent.consentString);
}

if (SYNC_ENDPOINT.slice(-1) === '&') {
SYNC_ENDPOINT = SYNC_ENDPOINT.slice(0, -1);
}

/* if (uspConsent) {
SYNC_ENDPOINT = utils.tryAppendQueryString(SYNC_ENDPOINT, 'us_privacy', uspConsent);
} */
Expand Down
9 changes: 5 additions & 4 deletions modules/adWMGBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ Module that connects to adWMG demand sources to fetch bids. Supports 'banner' ad

# Bid Parameters

| Key | Required | Example | Description |
| --- | -------- | ------- | ----------- |
| `publisherId` | yes | `'5cebea3c9eea646c7b623d5e'` | publisher ID from WMG Dashboard |
| `IABCategories` | no | `['IAB1', 'IAB5']` | IAB ad categories for adUnit |
| Key | Required | Example | Description |
| --------------- | -------- | -----------------------------| ------------------------------- |
| `publisherId` | yes | `'5cebea3c9eea646c7b623d5e'` | publisher ID from WMG Dashboard |
| `IABCategories` | no | `['IAB1', 'IAB5']` | IAB ad categories for adUnit |
| `floorCPM` | no | `0.5` | Floor price for adUnit |


# Test Parameters
Expand Down
40 changes: 40 additions & 0 deletions test/spec/modules/adWMGBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,5 +288,45 @@ describe('adWMGBidAdapter', function () {
expect(syncs[0].url).includes('gdpr=1');
expect(syncs[0].url).includes(`gdpr_consent=${gdprConsent.consentString}`);
});

it('should not add GDPR consent params twice', function() {
const syncOptions = {
'iframeEnabled': true,
'pixelEnabled': true
};
const gdprConsent = {
consentString: 'CO9rhBTO9rhBTAcABBENBCCsAP_AAH_AACiQHItf_X_fb3_j-_59_9t0eY1f9_7_v20zjgeds-8Nyd_X_L8X42M7vB36pq4KuR4Eu3LBIQdlHOHcTUmw6IkVqTPsbk2Mr7NKJ7PEinMbe2dYGH9_n9XTuZKY79_s___z__-__v__7_f_r-3_3_vp9V---3YHIgEmGpfARZiWOBJNGlUKIEIVxIdACACihGFomsICVwU7K4CP0EDABAagIwIgQYgoxZBAAAAAElEQEgB4IBEARAIAAQAqQEIACNAEFgBIGAQACgGhYARQBCBIQZHBUcpgQESLRQTyVgCUXexhhCGUUANAg4AA.YAAAAAAAAAAA',
vendorData: {},
gdprApplies: true,
apiVersion: 2
};
const gdprConsent2 = {
consentString: 'CO9rhBTO9rhBTAcABBENBCCsAP_AAH_AACiQHItf_7_fb3_j-_59_9t0eY1f9_7_v20zjgeds-8Nyd_X_L8X42M7vB36pq4KuR4Eu3LBIQdlHOHcTUmw6IkVqTPsbk2Mr7NKJ7PEinMbe2dYGH9_n9XTuZKY79_s___z__-__v__7_f_r-3_3_vp9V---3YHIgEmGpfARZiWOBJNGlUKIEIVxIdACACihGFomsICVwU7K4CP0EDABAagIwIgQYgoxZBAAAAAElEQEgB4IBEARAIAAQAqQEIACNAEFgBIGAQACgGhYARQBCBIQZHBUcpgQESLRQTyVgCUXexhhCGUUANAg4AA.YAAAAAAAAAAA',
vendorData: {},
gdprApplies: true,
apiVersion: 2
};
const serverResponse = {};
let syncs = spec.getUserSyncs(syncOptions, serverResponse, gdprConsent);
syncs = spec.getUserSyncs(syncOptions, serverResponse, gdprConsent2);
expect(syncs[0].url.match(/gdpr/g).length).to.equal(2); // gdpr + gdpr_consent
expect(syncs[0].url.match(/gdpr_consent/g).length).to.equal(1);
});

it('should delete \'&\' symbol at the end of usersync URL', function() {
const syncOptions = {
'iframeEnabled': true,
'pixelEnabled': true
};
const gdprConsent = {
consentString: 'CO9rhBTO9rhBTAcABBENBCCsAP_AAH_AACiQHItf_X_fb3_j-_59_9t0eY1f9_7_v20zjgeds-8Nyd_X_L8X42M7vB36pq4KuR4Eu3LBIQdlHOHcTUmw6IkVqTPsbk2Mr7NKJ7PEinMbe2dYGH9_n9XTuZKY79_s___z__-__v__7_f_r-3_3_vp9V---3YHIgEmGpfARZiWOBJNGlUKIEIVxIdACACihGFomsICVwU7K4CP0EDABAagIwIgQYgoxZBAAAAAElEQEgB4IBEARAIAAQAqQEIACNAEFgBIGAQACgGhYARQBCBIQZHBUcpgQESLRQTyVgCUXexhhCGUUANAg4AA.YAAAAAAAAAAA',
vendorData: {},
gdprApplies: true,
apiVersion: 2
};
const serverResponse = {};
let syncs = spec.getUserSyncs(syncOptions, serverResponse, gdprConsent);
expect(syncs[0].url.slice(-1)).to.not.equal('&');
});
});
});