Skip to content

Commit

Permalink
parrableIdSystem: Add an optional timezone and timezone offset allow/…
Browse files Browse the repository at this point in the history
…block filter (#5569)

* Add unit coverage for parrableIdSystem getId callback

* PBID-14: Pass uspString to Parrable as us_privacy query parameter

* PBID-14: Simplify parrableIdSystem us_privacy test

* PBID-14: Only send us_privacy to Parrable when a value exists

* PBID-11: Read new Parrable compound cookie _parrable_id

Migrating from legacy _parrable_eid cookie. The new cookie contains ibaOptout and ccpaOptout status fields

* Remove path check from parrableIdSystem url test

* PBID-11: Integrate Parrable compound cookie, consolidating old cookies

* PBID-11: Update parrableIdSystem requestBids hook test to support compound cookie value

* PBID-11: Small refactor to parrableIdSystem spec to support compound cookie

* PBID-11: Handle legacy ibaOptout as truthy value when migrating to compound cookie

* PBID-11: Add parrableIdSystem spec tests covering migration of legacy cookies

* PBID-11: Remove storage documentation from test pages and userId module docs

* PBID-11: Remove SUBMODULES_THAT_ALWAYS_REFRESH_ID feature from userId system

* PBID-11: Use better serialize implementation for Parrable compound cookie

* PBID-11: Update parrableIdSystem interface documentation

* Add missing extension to mock xhr import

* PBID-11: Try to access eid property only when parrableId object exists

* PBID-11: Construct parrableId from legacy cookies in same manner as compound cookie

* Use hardcoded expiration date for legacy cookies

* PBID-39: Return full parrableId object in decode method

* PBID-39: Update all adapters to use parrableId.eid for userId value

* PBID-39: Update config for ORTB EIDs to extract parrableId.eid as User UID value

* PBID-39: Pass Parrable IBA and CCPA optout status into ORTB EIDs list through UID extensions

* PBID-39: Pass a true CCPA optout status to adapters when the EID has been suppressed

The userId/eids module will not consider our ID system for inclusion in the EIDs object if our ID value is not a string.
Unfortunately when we write our cookie without an EID (in the case where CCPA optout is true) then the deserialized EID value is undefined, to save space in the cookie.

So this is a hack that will return an empty string when Prebid is building the EIDs object so that we can still pass our optout status to those that require it to understand why our ID may be missing.

* parrableIdSystem: Relocate new unit test from upstream

* PBID-39: Fallback to cookie values when backend response is missing components

Also handle another missed callback scenario if the response object parses to nothing

* PBID-39: Avoid breaking openx bid adapter when renaming our id system

* PBID-39: Use array find

* Use supported array find method in parrableIdSystem_spec

* Restore backwards-compatible parrableId passing to OpenxBidAdapter

* PBID-25: Add time zone and offset filtering of impressions to parrableIdSystem

* PBID-25: Better group existing getId tests

* PBID-25: Add unit tests covering time zone and offset filtering functionality

* PBID-25: Remove parrable .only test scope
  • Loading branch information
icflournoy authored Sep 3, 2020
1 parent e783c75 commit deb7d5b
Show file tree
Hide file tree
Showing 2 changed files with 314 additions and 87 deletions.
49 changes: 49 additions & 0 deletions modules/parrableIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,51 @@ function migrateLegacyCookies(parrableId) {
}
}

function shouldFilterImpression(configParams, parrableId) {
const config = configParams.timezoneFilter;

if (!config) {
return false;
}

if (parrableId) {
return false;
}

const offset = (new Date()).getTimezoneOffset() / 60;
const zone = Intl.DateTimeFormat().resolvedOptions().timeZone;

function isAllowed() {
if (utils.isEmpty(config.allowedZones) &&
utils.isEmpty(config.allowedOffsets)) {
return true;
}
if (utils.contains(config.allowedZones, zone)) {
return true;
}
if (utils.contains(config.allowedOffsets, offset)) {
return true;
}
return false;
}

function isBlocked() {
if (utils.isEmpty(config.blockedZones) &&
utils.isEmpty(config.blockedOffsets)) {
return false;
}
if (utils.contains(config.blockedZones, zone)) {
return true;
}
if (utils.contains(config.blockedOffsets, offset)) {
return true;
}
return false;
}

return !isAllowed() || isBlocked();
}

function fetchId(configParams) {
if (!isValidConfig(configParams)) return;

Expand All @@ -122,6 +167,10 @@ function fetchId(configParams) {
migrateLegacyCookies(parrableId);
}

if (shouldFilterImpression(configParams, parrableId)) {
return null;
}

const eid = (parrableId) ? parrableId.eid : null;
const refererInfo = getRefererInfo();
const uspString = uspDataHandler.getConsentData();
Expand Down
Loading

0 comments on commit deb7d5b

Please sign in to comment.