Skip to content

Commit

Permalink
Magnite Analytics: Minor fix for default rule name (#11791)
Browse files Browse the repository at this point in the history
* minor fix for default rule name

* delete comment - fix spelling
  • Loading branch information
robertrmartinez committed Jun 13, 2024
1 parent 19131b9 commit 8466868
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
7 changes: 4 additions & 3 deletions modules/magniteAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ const pbsErrorMap = {
4: 'request-error',
999: 'generic-error'
}
let cookieless;

let browser;
let pageReferer;
let auctionIndex = 0; // count of auctions on page
let accountId;
let endpoint;
let cookieless;

let prebidGlobal = getGlobal();
const {
Expand Down Expand Up @@ -334,9 +334,9 @@ const getTopLevelDetails = () => {

// Add DM wrapper details
if (rubiConf.wrapperName) {
let rule;
let rule = rubiConf.rule_name;
if (cookieless) {
rule = rubiConf.rule_name ? rubiConf.rule_name.concat('_cookieless') : 'cookieless';
rule = rule ? rule.concat('_cookieless') : 'cookieless';
}
payload.wrapper = {
name: rubiConf.wrapperName,
Expand Down Expand Up @@ -703,6 +703,7 @@ magniteAdapter.disableAnalytics = function () {
magniteAdapter._oldEnable = enableMgniAnalytics;
endpoint = undefined;
accountId = undefined;
cookieless = undefined;
auctionIndex = 0;
resetConfs();
getHook('callPrebidCache').getHooks({ hook: callPrebidCacheHook }).remove();
Expand Down
30 changes: 23 additions & 7 deletions test/spec/modules/magniteAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1758,16 +1758,32 @@ describe('magnite analytics adapter', function () {
});
});
describe('cookieless', () => {
beforeEach(() => {
magniteAdapter.enableAnalytics({
options: {
cookieles: undefined
}
});
})
afterEach(() => {
magniteAdapter.disableAnalytics();
})
it('should not add cookieless and preserve original rule name', () => {
// Set the confs
config.setConfig({
rubicon: {
wrapperName: '1001_general',
wrapperFamily: 'general',
rule_name: 'desktop-magnite.com',
}
});
performStandardAuction();

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

expect(request.url).to.match(/\/\/localhost:9999\/event/);

let message = JSON.parse(request.requestBody);
expect(message.wrapper).to.deep.equal({
name: '1001_general',
family: 'general',
rule: 'desktop-magnite.com',
});
})
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({
Expand Down

0 comments on commit 8466868

Please sign in to comment.