Skip to content

TrueReach Bidder Adapter: Added User Sync Support #5846

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 12 commits into from
Oct 13, 2020
20 changes: 20 additions & 0 deletions modules/truereachBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,26 @@ export const spec = {

return bidResponses;
},
getUserSyncs: function(syncOptions, serverResponses, gdprConsent, uspConsent) {
const syncs = []

var gdprParams = '';
if (gdprConsent) {
if (typeof gdprConsent.gdprApplies === 'boolean') {
gdprParams = `?gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`;
} else {
gdprParams = `?gdpr_consent=${gdprConsent.consentString}`;
}
}

if (syncOptions.iframeEnabled) {
syncs.push({
type: 'iframe',
url: 'http://ads.momagic.com/jsp/usersync.jsp' + gdprParams
});
}
return syncs;
}

};

Expand Down
21 changes: 21 additions & 0 deletions test/spec/modules/truereachBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,25 @@ describe('truereachBidAdapterTests', function () {
expect(bid.netRevenue).to.equal(false);
expect(bid.meta.advertiserDomains[0]).to.equal('https://www.momagic.com/');
});

describe('user_sync', function() {
const user_sync_url = 'http://ads.momagic.com/jsp/usersync.jsp';
it('register_iframe_pixel_if_iframeEnabled_is_true', function() {
let syncs = spec.getUserSyncs(
{iframeEnabled: true}
);
expect(syncs).to.be.an('array');
expect(syncs.length).to.equal(1);
expect(syncs[0].type).to.equal('iframe');
expect(syncs[0].url).to.equal(user_sync_url);
});

it('if_pixelEnabled_is_true', function() {
let syncs = spec.getUserSyncs(
{pixelEnabled: true}
);
expect(syncs).to.be.an('array');
expect(syncs.length).to.equal(0);
});
});
});