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

Magnite Analytics Adapter: add indication of cookieless traffic #11241

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
16 changes: 15 additions & 1 deletion modules/magniteAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const pbsErrorMap = {
4: 'request-error',
999: 'generic-error'
}
let cookieless;

let prebidGlobal = getGlobal();
const {
Expand Down Expand Up @@ -332,10 +333,14 @@ const getTopLevelDetails = () => {

// Add DM wrapper details
if (rubiConf.wrapperName) {
let rule;
if (cookieless) {
rule = rubiConf.rule_name ? rubiConf.rule_name.concat('_cookieless') : 'cookieless';
}
payload.wrapper = {
name: rubiConf.wrapperName,
family: rubiConf.wrapperFamily,
rule: rubiConf.rule_name
rule
}
}

Expand Down Expand Up @@ -823,6 +828,15 @@ magniteAdapter.track = ({ eventType, args }) => {
auctionData.floors = addFloorData(floorData);
}

// Identify chrome cookieless trafic
if (!cookieless) {
const cdep = deepAccess(args, 'bidderRequests.0.ortb2.device.ext.cdep');
if (cdep && (cdep.indexOf('treatment') !== -1 || cdep.indexOf('control_2') !== -1)) {
cookieless = 1;
auctionData.cdep = 1;
}
}

// GDPR info
const gdprData = deepAccess(args, 'bidderRequests.0.gdprConsent');
if (gdprData) {
Expand Down
73 changes: 73 additions & 0 deletions test/spec/modules/magniteAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1741,6 +1741,79 @@ describe('magnite analytics adapter', function () {
expect(message1.bidsWon).to.deep.equal([expectedMessage1]);
});
});
describe('cookieless', () => {
beforeEach(() => {
magniteAdapter.enableAnalytics({
options: {
cookieles: undefined
}
});
})
afterEach(() => {
magniteAdapter.disableAnalytics();
})
it('should add sufix _cookieless to the wrapper.rule if ortb2.device.ext.cdep start with "treatment" or "control_2"', () => {
// Set the confs
config.setConfig({
rubicon: {
wrapperName: '1001_general',
wrapperFamily: 'general',
rule_name: 'desktop-magnite.com',
}
});
const auctionId = MOCK.AUCTION_INIT.auctionId;

let auctionInit = utils.deepClone(MOCK.AUCTION_INIT);
auctionInit.bidderRequests[0].ortb2.device.ext = { cdep: 'treatment' };
// Run auction
events.emit(AUCTION_INIT, auctionInit);
events.emit(BID_REQUESTED, MOCK.BID_REQUESTED);
events.emit(BID_RESPONSE, MOCK.BID_RESPONSE);
events.emit(BIDDER_DONE, MOCK.BIDDER_DONE);
events.emit(AUCTION_END, MOCK.AUCTION_END);
[gptSlotRenderEnded0].forEach(gptEvent => mockGpt.emitEvent(gptEvent.eventName, gptEvent.params));
events.emit(BID_WON, { ...MOCK.BID_WON, auctionId });
clock.tick(rubiConf.analyticsEventDelay);
expect(server.requests.length).to.equal(1);
let request = server.requests[0];
let message = JSON.parse(request.requestBody);
expect(message.wrapper).to.deep.equal({
name: '1001_general',
family: 'general',
rule: 'desktop-magnite.com_cookieless',
});
})
it('should add cookieless to the wrapper.rule if ortb2.device.ext.cdep start with "treatment" or "control_2"', () => {
// Set the confs
config.setConfig({
rubicon: {
wrapperName: '1001_general',
wrapperFamily: 'general',
}
});
const auctionId = MOCK.AUCTION_INIT.auctionId;

let auctionInit = utils.deepClone(MOCK.AUCTION_INIT);
auctionInit.bidderRequests[0].ortb2.device.ext = { cdep: 'control_2' };
// Run auction
events.emit(AUCTION_INIT, auctionInit);
events.emit(BID_REQUESTED, MOCK.BID_REQUESTED);
events.emit(BID_RESPONSE, MOCK.BID_RESPONSE);
events.emit(BIDDER_DONE, MOCK.BIDDER_DONE);
events.emit(AUCTION_END, MOCK.AUCTION_END);
[gptSlotRenderEnded0].forEach(gptEvent => mockGpt.emitEvent(gptEvent.eventName, gptEvent.params));
events.emit(BID_WON, { ...MOCK.BID_WON, auctionId });
clock.tick(rubiConf.analyticsEventDelay);
expect(server.requests.length).to.equal(1);
let request = server.requests[0];
let message = JSON.parse(request.requestBody);
expect(message.wrapper).to.deep.equal({
family: 'general',
name: '1001_general',
rule: 'cookieless',
});
});
});
});

describe('billing events integration', () => {
Expand Down