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

Send GDPR data in analytics request #5653

Merged
merged 45 commits into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
1beaa7c
Livewrapped bid and analytics adapter
bjorn-lw Sep 25, 2018
250fca3
Merge remote-tracking branch 'upstream/master'
bjorn-lw Oct 4, 2018
c47dd60
Fixed some tests for browser compatibility
bjorn-lw Oct 4, 2018
5c0a354
Fixed some tests for browser compatibility
bjorn-lw Oct 4, 2018
f02ada1
Changed analytics adapter code name
bjorn-lw Oct 5, 2018
b2f72e1
Merge remote-tracking branch 'upstream/master'
bjorn-lw Oct 5, 2018
4792245
Fix double quote in debug message
bjorn-lw Oct 9, 2018
02a6e5a
modified how gdpr is being passed
bjorn-lw Nov 2, 2018
a26936a
Merge remote-tracking branch 'upstream/master'
bjorn-lw Nov 2, 2018
e799957
Merge remote-tracking branch 'upstream/master'
bjorn-lw Jan 16, 2019
176ea08
Added support for Publisher Common ID Module
bjorn-lw Jan 17, 2019
e20d9e7
Merge remote-tracking branch 'upstream/master'
bjorn-lw Jan 17, 2019
5f1951a
Corrections for ttr in analytics
bjorn-lw Feb 18, 2019
efe678c
Merge remote-tracking branch 'upstream/master'
bjorn-lw Feb 18, 2019
e959425
ANalytics updates
bjorn-lw Feb 18, 2019
43f2f07
Auction start time stamp changed
bjorn-lw Feb 22, 2019
18bfbbf
Merge remote-tracking branch 'upstream/master'
bjorn-lw Apr 11, 2019
87ebc8b
Detect recovered ad blocked requests
bjorn-lw Apr 15, 2019
f5f1e64
Merge branch 'master' of https://github.com/prebid/Prebid.js
bjorn-lw Aug 16, 2019
332b500
Collect info on ad units receiving any valid bid
bjorn-lw Aug 16, 2019
bda0fff
Merge branch 'master' of https://github.com/prebid/Prebid.js
bjorn-lw Oct 1, 2019
5f09e2a
Support for ID5
bjorn-lw Oct 22, 2019
728be38
Typo in test + eids on wrong level
bjorn-lw Oct 22, 2019
55d4448
Merge remote-tracking branch 'upstream/master'
bjorn-lw Dec 3, 2019
26c35ad
Merge remote-tracking branch 'upstream/master'
bjorn-lw Dec 12, 2019
531365e
Fix for Prebid 3.0
bjorn-lw Dec 12, 2019
6603c59
Fix get referer
bjorn-lw Dec 12, 2019
0ea76e4
http -> https in tests
bjorn-lw Dec 18, 2019
aa1a01d
Native support
bjorn-lw Dec 22, 2019
80b1079
Read sizes from mediatype.banner
bjorn-lw Jan 20, 2020
2114e29
Merge remote-tracking branch 'upstream/master'
bjorn-lw Jan 20, 2020
4c2db42
Revert accidental commit
bjorn-lw Jan 20, 2020
59c9ed2
Merge remote-tracking branch 'upstream/master'
bjorn-lw Jan 27, 2020
52903d5
Support native data collection + minor refactorings
bjorn-lw Jan 31, 2020
7bf4d26
Set analytics endpoint
bjorn-lw Feb 1, 2020
06cba0f
Support for app parameters
bjorn-lw Apr 7, 2020
2cdd237
Merge remote-tracking branch 'upstream/master'
bjorn-lw Apr 7, 2020
a9f204c
Fix issue where adunits with bids were not counted on reload
bjorn-lw Apr 7, 2020
559624d
Merge remote-tracking branch 'upstream/master'
bjorn-lw Apr 21, 2020
8171a22
Send debug info from adapter to external debugger
bjorn-lw Apr 22, 2020
0ea9dcd
Merge remote-tracking branch 'upstream/master'
bjorn-lw May 6, 2020
00b7642
Merge remote-tracking branch 'upstream/master'
bjorn-lw May 19, 2020
ef490e1
SChain support
bjorn-lw May 20, 2020
9db844d
Merge remote-tracking branch 'upstream/master'
bjorn-lw Aug 21, 2020
e951ade
Send GDPR data in analytics request
bjorn-lw Aug 23, 2020
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
27 changes: 23 additions & 4 deletions modules/livewrappedAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ let livewrappedAnalyticsAdapter = Object.assign(adapter({EMPTYURL, ANALYTICSTYPE
cache.auctions[args.auctionId].timeStamp = args.start;

args.bids.forEach(function(bidRequest) {
cache.auctions[args.auctionId].gdprApplies = args.gdprConsent ? args.gdprConsent.gdprApplies : undefined;
cache.auctions[args.auctionId].gdprConsent = args.gdprConsent ? args.gdprConsent.consentString : undefined;

cache.auctions[args.auctionId].bids[bidRequest.bidId] = {
bidder: bidRequest.bidder,
adUnit: bidRequest.adUnitCode,
Expand Down Expand Up @@ -116,9 +119,11 @@ livewrappedAnalyticsAdapter.enableAnalytics = function (config) {
};

livewrappedAnalyticsAdapter.sendEvents = function() {
var sentRequests = getSentRequests();
var events = {
publisherId: initOptions.publisherId,
requests: getSentRequests(),
gdpr: sentRequests.gdpr,
requests: sentRequests.sentRequests,
responses: getResponses(),
wins: getWins(),
timeouts: getTimeouts(),
Expand All @@ -144,24 +149,38 @@ function getAdblockerRecovered() {

function getSentRequests() {
var sentRequests = [];
var gdpr = [];

Object.keys(cache.auctions).forEach(auctionId => {
let auction = cache.auctions[auctionId];
var gdprPos = 0;
for (gdprPos = 0; gdprPos < gdpr.length; gdprPos++) {
if (gdpr[gdprPos].gdprApplies == auction.gdprApplies &&
gdpr[gdprPos].gdprConsent == auction.gdprConsent) {
break;
}
}

if (gdprPos == gdpr.length) {
gdpr[gdprPos] = {gdprApplies: auction.gdprApplies, gdprConsent: auction.gdprConsent};
}

Object.keys(cache.auctions[auctionId].bids).forEach(bidId => {
let auction = cache.auctions[auctionId];
let bid = auction.bids[bidId];
if (!(bid.sendStatus & REQUESTSENT)) {
bid.sendStatus |= REQUESTSENT;

sentRequests.push({
timeStamp: auction.timeStamp,
adUnit: bid.adUnit,
bidder: bid.bidder
bidder: bid.bidder,
gdpr: gdprPos
});
}
});
});

return sentRequests;
return {gdpr: gdpr, sentRequests: sentRequests};
}

function getResponses() {
Expand Down
52 changes: 49 additions & 3 deletions test/spec/modules/livewrappedAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ const MOCK = {

const ANALYTICS_MESSAGE = {
publisherId: 'CC411485-42BC-4F92-8389-42C503EE38D7',
gdpr: [{}],
bidAdUnits: [
{
adUnit: 'panorama_d_1',
Expand All @@ -134,17 +135,20 @@ const ANALYTICS_MESSAGE = {
{
adUnit: 'panorama_d_1',
bidder: 'livewrapped',
timeStamp: 1519149562216
timeStamp: 1519149562216,
gdpr: 0
},
{
adUnit: 'box_d_1',
bidder: 'livewrapped',
timeStamp: 1519149562216
timeStamp: 1519149562216,
gdpr: 0
},
{
adUnit: 'box_d_2',
bidder: 'livewrapped',
timeStamp: 1519149562216
timeStamp: 1519149562216,
gdpr: 0
}
],
responses: [
Expand Down Expand Up @@ -321,6 +325,48 @@ describe('Livewrapped analytics adapter', function () {

expect(message.rcv).to.equal(true);
});

it('should forward GDPR data', function () {
events.emit(AUCTION_INIT, MOCK.AUCTION_INIT);
events.emit(BID_REQUESTED, {
'bidder': 'livewrapped',
'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa',
'bidderRequestId': '1be65d7958826a',
'bids': [
{
'bidder': 'livewrapped',
'adUnitCode': 'panorama_d_1',
'bidId': '2ecff0db240757',
},
{
'bidder': 'livewrapped',
'adUnitCode': 'box_d_1',
'bidId': '3ecff0db240757',
}
],
'start': 1519149562216,
'gdprConsent': {
'gdprApplies': true,
'consentString': 'consentstring'
}
},
);
events.emit(BID_TIMEOUT, MOCK.BID_TIMEOUT);
events.emit(AUCTION_END, MOCK.AUCTION_END);

clock.tick(BID_WON_TIMEOUT + 1000);

expect(server.requests.length).to.equal(1);
let request = server.requests[0];
let message = JSON.parse(request.requestBody);

expect(message.gdpr.length).to.equal(1);
expect(message.gdpr[0].gdprApplies).to.equal(true);
expect(message.gdpr[0].gdprConsent).to.equal('consentstring');
expect(message.requests.length).to.equal(2);
expect(message.requests[0].gdpr).to.equal(0);
expect(message.requests[1].gdpr).to.equal(0);
});
});

describe('when given other endpoint', function () {
Expand Down