Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.

Commit 2852ab2

Browse files
authored
ID5 Analytics: redaction process skips 'ext' on ID5 ID (prebid#7141)
* #26 id5analytics redactin process skips 'ext' on ID5 ID * #26 stop using startsWith because IE11 doesn't like it Co-authored-by: Marco Cosentino <[email protected]>
1 parent 3cfbf9d commit 2852ab2

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

modules/id5AnalyticsAdapter.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,14 @@ function deepTransformingClone(obj, transform, currentPath = []) {
243243
// takes (obj, prop) and transforms property "prop" in object "obj".
244244
// The "match" is an array of path parts. Each part is either a string or an array.
245245
// In case of array, it represents alternatives which all would match.
246-
// Special path part '*' matches any subproperty
246+
// Special path part '*' matches any subproperty or array index.
247+
// Prefixing a part with "!" makes it negative match (doesn't work with multiple alternatives)
247248
const CLEANUP_RULES = {};
248249
CLEANUP_RULES[AUCTION_END] = [{
249-
match: [['adUnits', 'bidderRequests'], '*', 'bids', '*', ['userId', 'crumbs'], '*'],
250+
match: [['adUnits', 'bidderRequests'], '*', 'bids', '*', ['userId', 'crumbs'], '!id5id'],
251+
apply: 'redact'
252+
}, {
253+
match: [['adUnits', 'bidderRequests'], '*', 'bids', '*', ['userId', 'crumbs'], 'id5id', 'uid'],
250254
apply: 'redact'
251255
}, {
252256
match: [['adUnits', 'bidderRequests'], '*', 'bids', '*', 'userIdAsEids', '*', 'uids', '*', ['id', 'ext']],
@@ -288,7 +292,10 @@ function transformFnFromCleanupRules(eventType) {
288292
}
289293
for (let fragment = 0; fragment < ruleMatcher.length && match; fragment++) {
290294
const choices = makeSureArray(ruleMatcher[fragment]);
291-
match = !choices.every((choice) => choice !== '*' && path[fragment] !== choice);
295+
match = !choices.every((choice) => choice !== '*' &&
296+
(choice.charAt(0) === '!'
297+
? path[fragment] === choice.substring(1)
298+
: path[fragment] !== choice));
292299
}
293300
if (match) {
294301
const transformfn = TRANSFORM_FUNCTIONS[transformation];

test/spec/modules/id5AnalyticsAdapter_spec.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -322,12 +322,22 @@ describe('ID5 analytics adapter', () => {
322322
expect(body.event).to.equal('auctionEnd');
323323
expect(body.payload.adUnits[0].bids[0].userId).to.eql({
324324
'criteoId': '__ID5_REDACTED__',
325-
'id5id': '__ID5_REDACTED__',
325+
'id5id': {
326+
'uid': '__ID5_REDACTED__',
327+
'ext': {
328+
'linkType': 1
329+
}
330+
},
326331
'tdid': '__ID5_REDACTED__'
327332
});
328333
expect(body.payload.bidderRequests[0].bids[0].userId).to.eql({
329334
'sharedid': '__ID5_REDACTED__',
330-
'id5id': '__ID5_REDACTED__',
335+
'id5id': {
336+
'uid': '__ID5_REDACTED__',
337+
'ext': {
338+
'linkType': 1
339+
}
340+
},
331341
'tdid': '__ID5_REDACTED__'
332342
});
333343
body.payload.adUnits[0].bids[0].userIdAsEids.forEach((userId) => {

0 commit comments

Comments
 (0)