Skip to content

Commit

Permalink
ID5 Analytics: redaction process skips 'ext' on ID5 ID (#7141)
Browse files Browse the repository at this point in the history
* #26 id5analytics redactin process skips 'ext' on ID5 ID

* #26 stop using startsWith because IE11 doesn't like it

Co-authored-by: Marco Cosentino <mcosentino@id5.io>
  • Loading branch information
cosenmarco and cosenmarco committed Jul 13, 2021
1 parent 3cfbf9d commit 2852ab2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
13 changes: 10 additions & 3 deletions modules/id5AnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,14 @@ function deepTransformingClone(obj, transform, currentPath = []) {
// takes (obj, prop) and transforms property "prop" in object "obj".
// The "match" is an array of path parts. Each part is either a string or an array.
// In case of array, it represents alternatives which all would match.
// Special path part '*' matches any subproperty
// Special path part '*' matches any subproperty or array index.
// Prefixing a part with "!" makes it negative match (doesn't work with multiple alternatives)
const CLEANUP_RULES = {};
CLEANUP_RULES[AUCTION_END] = [{
match: [['adUnits', 'bidderRequests'], '*', 'bids', '*', ['userId', 'crumbs'], '*'],
match: [['adUnits', 'bidderRequests'], '*', 'bids', '*', ['userId', 'crumbs'], '!id5id'],
apply: 'redact'
}, {
match: [['adUnits', 'bidderRequests'], '*', 'bids', '*', ['userId', 'crumbs'], 'id5id', 'uid'],
apply: 'redact'
}, {
match: [['adUnits', 'bidderRequests'], '*', 'bids', '*', 'userIdAsEids', '*', 'uids', '*', ['id', 'ext']],
Expand Down Expand Up @@ -288,7 +292,10 @@ function transformFnFromCleanupRules(eventType) {
}
for (let fragment = 0; fragment < ruleMatcher.length && match; fragment++) {
const choices = makeSureArray(ruleMatcher[fragment]);
match = !choices.every((choice) => choice !== '*' && path[fragment] !== choice);
match = !choices.every((choice) => choice !== '*' &&
(choice.charAt(0) === '!'
? path[fragment] === choice.substring(1)
: path[fragment] !== choice));
}
if (match) {
const transformfn = TRANSFORM_FUNCTIONS[transformation];
Expand Down
14 changes: 12 additions & 2 deletions test/spec/modules/id5AnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,12 +322,22 @@ describe('ID5 analytics adapter', () => {
expect(body.event).to.equal('auctionEnd');
expect(body.payload.adUnits[0].bids[0].userId).to.eql({
'criteoId': '__ID5_REDACTED__',
'id5id': '__ID5_REDACTED__',
'id5id': {
'uid': '__ID5_REDACTED__',
'ext': {
'linkType': 1
}
},
'tdid': '__ID5_REDACTED__'
});
expect(body.payload.bidderRequests[0].bids[0].userId).to.eql({
'sharedid': '__ID5_REDACTED__',
'id5id': '__ID5_REDACTED__',
'id5id': {
'uid': '__ID5_REDACTED__',
'ext': {
'linkType': 1
}
},
'tdid': '__ID5_REDACTED__'
});
body.payload.adUnits[0].bids[0].userIdAsEids.forEach((userId) => {
Expand Down

0 comments on commit 2852ab2

Please sign in to comment.