Skip to content

Commit dac32df

Browse files
mefjushPedro López Jiménez
authored and
Pedro López Jiménez
committed
Fix Adhese bid adapter user sync (prebid#3453)
1 parent 2750673 commit dac32df

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

modules/adheseBidAdapter.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,19 @@ export const spec = {
5252
.map(item => adResponse(item.bid, item.ad));
5353
},
5454

55-
getUserSyncs: function(syncOptions, serverResponse, gdprConsent) {
56-
const account = serverResponse.account || '';
57-
if (syncOptions.iframeEnabled) {
58-
let syncurl = USER_SYNC_BASE_URL + '?account=' + account;
59-
if (gdprConsent) {
60-
syncurl += '&gdpr=' + (gdprConsent.gdprApplies ? 1 : 0);
61-
syncurl += '&consentString=' + encodeURIComponent(gdprConsent.consentString || '');
55+
getUserSyncs: function(syncOptions, serverResponses, gdprConsent) {
56+
if (syncOptions.iframeEnabled && serverResponses.length > 0) {
57+
const account = serverResponses[0].account;
58+
if (account) {
59+
let syncurl = USER_SYNC_BASE_URL + '?account=' + account;
60+
if (gdprConsent) {
61+
syncurl += '&gdpr=' + (gdprConsent.gdprApplies ? 1 : 0);
62+
syncurl += '&consentString=' + encodeURIComponent(gdprConsent.consentString || '');
63+
}
64+
return [{type: 'iframe', url: syncurl}];
6265
}
63-
return [{ type: 'iframe', url: syncurl }];
6466
}
67+
return [];
6568
}
6669
};
6770

test/spec/modules/adheseBidAdapter_spec.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,24 @@ let bidWithParams = function(data) {
2525

2626
describe('AdheseAdapter', function () {
2727
describe('getUserSyncs', function () {
28-
const serverResponse = {
28+
const serverResponses = [{
2929
account: 'demo'
30-
};
30+
}];
3131
const gdprConsent = {
3232
gdprApplies: true,
3333
consentString: 'CONSENT_STRING'
3434
};
3535
it('should return empty when iframe disallowed', function () {
36-
expect(spec.getUserSyncs({ iframeEnabled: false }, serverResponse, gdprConsent)).to.be.empty;
36+
expect(spec.getUserSyncs({ iframeEnabled: false }, serverResponses, gdprConsent)).to.be.empty;
37+
});
38+
it('should return empty when no serverResponses present', function () {
39+
expect(spec.getUserSyncs({ iframeEnabled: true }, [], gdprConsent)).to.be.empty;
40+
});
41+
it('should return empty when no account info present in the response', function () {
42+
expect(spec.getUserSyncs({ iframeEnabled: true }, [{}], gdprConsent)).to.be.empty;
3743
});
3844
it('should return usersync url when iframe allowed', function () {
39-
expect(spec.getUserSyncs({ iframeEnabled: true }, serverResponse, gdprConsent)).to.deep.equal([{ type: 'iframe', url: 'https://user-sync.adhese.com/iframe/user_sync.html?account=demo&gdpr=1&consentString=CONSENT_STRING' }]);
45+
expect(spec.getUserSyncs({ iframeEnabled: true }, serverResponses, gdprConsent)).to.deep.equal([{ type: 'iframe', url: 'https://user-sync.adhese.com/iframe/user_sync.html?account=demo&gdpr=1&consentString=CONSENT_STRING' }]);
4046
});
4147
});
4248

0 commit comments

Comments
 (0)