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: Minor fix for default rule name #11791

Merged
merged 2 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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
37 changes: 30 additions & 7 deletions test/spec/modules/magniteAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1758,16 +1758,39 @@ describe('magnite analytics adapter', function () {
});
});
describe('cookieless', () => {
beforeEach(() => {
magniteAdapter.enableAnalytics({
options: {
cookieles: undefined
}
});
})
// beforeEach(() => {
// magniteAdapter.enableAnalytics({
// options: {
// cookieles: undefined
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is on the comment now, but was spelling causing an issue?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no it was something else (mot initializing the variable), this bit of code just does not even do anything so I commented out while testing and forgot to remove, I deleted now.

// }
// });
// })
afterEach(() => {
magniteAdapter.disableAnalytics();
})
it('should not add cokieless and preserve original rule name', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cookieless

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed!

// 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