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

Rubicon Analytics Adapter: Move wrapper details into wrapper object #6184

Merged
merged 2 commits into from
Jan 20, 2021
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
8 changes: 6 additions & 2 deletions modules/rubiconAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,17 @@ function sendMessage(auctionId, bidWonId) {
let message = {
eventTimeMillis: Date.now(),
integration: rubiConf.int_type || DEFAULT_INTEGRATION,
ruleId: rubiConf.rule_name,
version: '$prebid.version$',
referrerUri: referrer,
referrerHostname: rubiconAdapter.referrerHostname || getHostNameFromReferer(referrer),
channel: 'web',
wrapperName: rubiConf.wrapperName
};
if (rubiConf.wrapperName || rubiConf.rule_name) {
message.wrapper = {
name: rubiConf.wrapperName,
rule: rubiConf.rule_name
}
}
if (auctionCache && !auctionCache.sent) {
let adUnitMap = Object.keys(auctionCache.bids).reduce((adUnits, bidId) => {
let bid = auctionCache.bids[bidId];
Expand Down
32 changes: 31 additions & 1 deletion test/spec/modules/rubiconAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,9 @@ const ANALYTICS_MESSAGE = {
'bidwonStatus': 'success'
}
],
'wrapperName': '10000_fakewrapper_test'
'wrapper': {
'name': '10000_fakewrapper_test'
}
};

function performStandardAuction(gptEvents) {
Expand Down Expand Up @@ -1678,6 +1680,34 @@ describe('rubicon analytics adapter', function () {
});
});

describe('wrapper details passed in', () => {
it('should correctly pass in the wrapper details if provided', () => {
config.setConfig({rubicon: {
wrapperName: '1001_wrapperName',
rule_name: 'na-mobile'
}});

rubiconAnalyticsAdapter.enableAnalytics({
options: {
endpoint: '//localhost:9999/event',
accountId: 1001
}
});

performStandardAuction();

expect(server.requests.length).to.equal(1);
const request = server.requests[0];
const message = JSON.parse(request.requestBody);
expect(message.wrapper).to.deep.equal({
name: '1001_wrapperName',
rule: 'na-mobile'
});

rubiconAnalyticsAdapter.disableAnalytics();
});
});

it('getHostNameFromReferer correctly grabs hostname from an input URL', function () {
let inputUrl = 'https://www.prebid.org/some/path?pbjs_debug=true';
expect(getHostNameFromReferer(inputUrl)).to.equal('www.prebid.org');
Expand Down