Skip to content
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

ID5 Analytics: redaction process skips 'ext' on ID5 ID #7141

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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