Skip to content

Commit

Permalink
EMX: Add CCPA Suport (#147)
Browse files Browse the repository at this point in the history
* Add US CCPA Support

* fix tests

* target ccpa string
  • Loading branch information
ncolletti committed Feb 28, 2020
1 parent 0a25f2c commit b5add47
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
3 changes: 3 additions & 0 deletions emx-digital/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# 1.1.0
- Adds support for CCPA (US Privacy)

# 1.0.0
- Bidder added to support latest EMX Exchange.
9 changes: 8 additions & 1 deletion emx-digital/emx-digital-htb-system-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ function validateTargetingWithDeal(targetingMap) {
}));
}

function validateBidRequestWithPrivacy(request) {
var req = JSON.parse(request.body);
expect(req.regs.ext.gdpr).toBe(1);
expect(req.user.ext.consent).toBe('TEST_GDPR_CONSENT_STRING');
}

function getPassResponse(request) {
var response = { request: request };

Expand All @@ -203,5 +209,6 @@ module.exports = {
getValidResponse: getValidResponse,
getPassResponse: getPassResponse,
getValidResponseWithDeal: getValidResponseWithDeal,
validateTargetingWithDeal: validateTargetingWithDeal
validateTargetingWithDeal: validateTargetingWithDeal,
validateBidRequestWithPrivacy: validateBidRequestWithPrivacy
};
14 changes: 10 additions & 4 deletions emx-digital/emx-digital-htb.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function BRealTimeHtb(configs) {
*/
function __generateRequestObj(returnParcels) {
var timeout = SpaceCamp.globalTimeout || 1500;
var version = '1.0.0';
var version = '1.1.0';

var timestamp = System.now();
var baseUrl = Browser.getProtocol() + __endpoint + ('?t=' + timeout + '&ts=' + timestamp);
Expand All @@ -102,8 +102,9 @@ function BRealTimeHtb(configs) {
var pageUrl = Browser.getPageUrl();
var pageHost = Browser.getHostname();
var callbackId = System.generateUniqueId();
var privacyEnabled = ComplianceService.isPrivacyEnabled();
var gdprStatus = ComplianceService.gdpr.getConsent();
var gdprPrivacyEnabled = ComplianceService.isPrivacyEnabled();
var ccpaStatus = ComplianceService.usp && ComplianceService.usp.getConsent();

/* =============================================================================
* STEP 2 | Generate Request URL
Expand Down Expand Up @@ -151,7 +152,7 @@ function BRealTimeHtb(configs) {
}
};

if (gdprPrivacyEnabled) {
if (privacyEnabled) {
/* eslint-disable camelcase */
if (gdprStatus.hasOwnProperty('consentString')) {
__emxData.user = {
Expand All @@ -160,7 +161,6 @@ function BRealTimeHtb(configs) {
}
};
}
/* eslint-enable camelcase */

if (gdprStatus.hasOwnProperty('applies')) {
__emxData.regs = {
Expand All @@ -169,6 +169,12 @@ function BRealTimeHtb(configs) {
}
};
}

if (ccpaStatus && ccpaStatus.hasOwnProperty('uspString')) {
__emxData.us_privacy = ccpaStatus.uspString;
}

/* eslint-enable camelcase */
}

/* -------------------------------------------------------------------------- */
Expand Down

0 comments on commit b5add47

Please sign in to comment.