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

Kargo Bid Adapter: Removing Salesforce partner support #8140

Merged
merged 8 commits into from
Mar 3, 2022
25 changes: 1 addition & 24 deletions modules/kargoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,28 +172,6 @@ export const spec = {
return spec._getCrbFromCookie();
Copy link
Collaborator

@patmmccann patmmccann Mar 3, 2022

Choose a reason for hiding this comment

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

you should not be writing cookies in the first party domain. I know it is out of scope of this PR, but this type of behavior will be imminently disallowed. Local storage is much more palatable to publishers. Writing your cookie in their domain without their awareness breaks many many sites.

},

_getKruxUserId() {
return spec._getLocalStorageSafely('kxkar_user');
},

_getKruxSegments() {
return spec._getLocalStorageSafely('kxkar_segs');
},

_getKrux() {
const segmentsStr = spec._getKruxSegments();
let segments = [];

if (segmentsStr) {
segments = segmentsStr.split(',');
}

return {
userID: spec._getKruxUserId(),
segments: segments
};
},

_getLocalStorageSafely(key) {
try {
return storage.getDataFromLocalStorage(key);
Copy link
Collaborator

Choose a reason for hiding this comment

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

fyi, bidders will be disabled from accessing local storage by default in prebid 7

Expand All @@ -205,7 +183,7 @@ export const spec = {
_getUserIds(tdid, usp, gdpr) {
const crb = spec._getCrb();
const userIds = {
kargoID: crb.userId,
kargoID: crb.lexId,
clientID: crb.clientId,
crbIDs: crb.syncIds || {},
optOut: crb.optOut,
Expand Down Expand Up @@ -235,7 +213,6 @@ export const spec = {
_getAllMetadata(tdid, usp, gdpr) {
return {
userIDs: spec._getUserIds(tdid, usp, gdpr),
krux: spec._getKrux(),
pageURL: window.location.href,
rawCRB: spec._readCookie('krg_crb'),
rawCRBLocalStorage: spec._getLocalStorageSafely('krg_crb')
Expand Down
87 changes: 19 additions & 68 deletions test/spec/modules/kargoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,20 +149,12 @@ describe('kargo adapter tests', function () {
};
}

function initializeKruxUser() {
setLocalStorageItem('kxkar_user', 'rsgr9pnij');
}

function initializeKruxSegments() {
setLocalStorageItem('kxkar_segs', 'qv9v984dy,rpx2gy365,qrd5u4axv,rnub9nmtd,reha00jnu');
}

function getKrgCrb() {
return 'eyJzeW5jSWRzIjp7IjIiOiI4MmZhMjU1NS01OTY5LTQ2MTQtYjRjZS00ZGNmMTA4MGU5ZjkiLCIxNiI6IlZveElrOEFvSnowQUFFZENleUFBQUFDMiY1MDIiLCIyMyI6ImQyYTg1NWE1LTFiMWMtNDMwMC05NDBlLWE3MDhmYTFmMWJkZSIsIjI0IjoiVm94SWs4QW9KejBBQUVkQ2V5QUFBQUMyJjUwMiIsIjI1IjoiNWVlMjQxMzgtNWUwMy00YjlkLWE5NTMtMzhlODMzZjI4NDlmIiwiMl84MCI6ImQyYTg1NWE1LTFiMWMtNDMwMC05NDBlLWE3MDhmYTFmMWJkZSIsIjJfOTMiOiI1ZWUyNDEzOC01ZTAzLTRiOWQtYTk1My0zOGU4MzNmMjg0OWYifSwidXNlcklkIjoiNWYxMDg4MzEtMzAyZC0xMWU3LWJmNmItNDU5NWFjZDNiZjZjIiwiY2xpZW50SWQiOiIyNDEwZDhmMi1jMTExLTQ4MTEtODhhNS03YjVlMTkwZTQ3NWYiLCJvcHRPdXQiOmZhbHNlLCJleHBpcmVUaW1lIjoxNDk3NDQ5MzgyNjY4LCJsYXN0U3luY2VkQXQiOjE0OTczNjI5NzkwMTJ9';
return 'eyJzeW5jSWRzIjp7IjIiOiI4MmZhMjU1NS01OTY5LTQ2MTQtYjRjZS00ZGNmMTA4MGU5ZjkiLCIxNiI6IlZveElrOEFvSnowQUFFZENleUFBQUFDMiY1MDIiLCIyMyI6ImQyYTg1NWE1LTFiMWMtNDMwMC05NDBlLWE3MDhmYTFmMWJkZSIsIjI0IjoiVm94SWs4QW9KejBB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3NDQ5MzgyNjY4LCJsYXN0U3luY2VkQXQiOjE0OTczNjI5NzkwMTJ9%22%7D';
return '%7B%22v%22%3A%22eyJzeW5jSWRzIjp7IjIiOiI4MmZhMjU1NS01OTY5LTQ2MTQtYjRjZS00ZGNmMTA4MGU5ZjkiLCIxNiI6IlZveElrOEFvSnowQUFFZENleUFBQUFDMiY1MDIiLCIyMyI6ImQyYTg1NWE1LTFiMWMtNDMwMC05NDBlLWE3MDhmYTFmMWJkZSIsIjI0IjoiVm94SWs4QW9KejBBQUVkQ2V5QUFBQUMyJjUwMiIsIjI1IjoiNWVlMjQxMzgtNWUwMy00YjlkLWE5NTMtMzhlODMzZjI4NDlmIiwiMl84MCI6ImQyYTg1NWE1LTFiMWMtNDMwMC05NDBlLWE3MDhmYTFmMWJkZSIsIjJfOTMiOiI1ZWUyNDEzOC01ZTAzLTRiOWQtYTk1My0zOGU4MzNmMjg0OWYifSwibGV4SWQiOiI1ZjEwODgzMS0zMDJkLTExZTctYmY2Yi00NTk1YWNkM2JmNmMiLCJjbGllbnRJZCI6IjI0MTBkOGYyLWMxMTEtNDgxMS04OGE1LTdiNWUxOTBlNDc1ZiIsIm9wdE91dCI6ZmFsc2UsImV4cGlyZVRpbWUiOjE0OTc0NDkzODI2NjgsImxhc3RTeW5jZWRBdCI6MTQ5NzM2Mjk3OTAxMn0=%22%7D';
}

function initializeKrgCrb(cookieOnly) {
Expand Down Expand Up @@ -236,7 +228,7 @@ describe('kargo adapter tests', function () {
return spec._getSessionId();
}

function getExpectedKrakenParams(excludeUserIds, excludeKrux, expectedRawCRB, expectedRawCRBCookie, expectedGDPR) {
function getExpectedKrakenParams(excludeUserIds, expectedRawCRB, expectedRawCRBCookie, expectedGDPR) {
var base = {
timeout: 200,
requestCount: requestCount++,
Expand Down Expand Up @@ -273,16 +265,6 @@ describe('kargo adapter tests', function () {
optOut: false,
usp: '1---'
},
krux: {
userID: 'rsgr9pnij',
segments: [
'qv9v984dy',
'rpx2gy365',
'qrd5u4axv',
'rnub9nmtd',
'reha00jnu'
]
},
pageURL: window.location.href,
prebidRawBidRequests: [
{
Expand Down Expand Up @@ -326,13 +308,6 @@ describe('kargo adapter tests', function () {
delete base.prebidRawBidRequests[0].userId.tdid;
}

if (excludeKrux) {
base.krux = {
userID: null,
segments: []
};
}

return base;
}

Expand Down Expand Up @@ -367,101 +342,77 @@ describe('kargo adapter tests', function () {
}

it('works when all params and localstorage and cookies are correctly set', function() {
initializeKruxUser();
initializeKruxSegments();
initializeKrgCrb();
testBuildRequests(false, getExpectedKrakenParams(undefined, undefined, getKrgCrb(), getKrgCrbOldStyle()));
testBuildRequests(false, getExpectedKrakenParams(undefined, getKrgCrb(), getKrgCrbOldStyle()));
});

it('works when all params and cookies are correctly set but no localstorage', function() {
initializeKruxUser();
initializeKruxSegments();
initializeKrgCrb(true);
testBuildRequests(false, getExpectedKrakenParams(undefined, undefined, null, getKrgCrbOldStyle()));
testBuildRequests(false, getExpectedKrakenParams(undefined, null, getKrgCrbOldStyle()));
});

it('gracefully handles nothing being set', function() {
testBuildRequests(true, getExpectedKrakenParams(true, true, null, null));
testBuildRequests(true, getExpectedKrakenParams(true, null, null));
});

it('gracefully handles browsers without localStorage', function() {
simulateNoLocalStorage();
testBuildRequests(true, getExpectedKrakenParams(true, true, null, null));
testBuildRequests(true, getExpectedKrakenParams(true, null, null));
});

it('handles empty yet valid Kargo CRB', function() {
initializeKruxUser();
initializeKruxSegments();
initializeEmptyKrgCrb();
initializeEmptyKrgCrbCookie();
testBuildRequests(true, getExpectedKrakenParams(true, undefined, getEmptyKrgCrb(), getEmptyKrgCrbOldStyle()));
testBuildRequests(true, getExpectedKrakenParams(true, getEmptyKrgCrb(), getEmptyKrgCrbOldStyle()));
});

it('handles broken Kargo CRBs where base64 encoding is invalid', function() {
initializeKruxUser();
initializeKruxSegments();
initializeInvalidKrgCrbType1();
testBuildRequests(true, getExpectedKrakenParams(true, undefined, getInvalidKrgCrbType1(), null));
testBuildRequests(true, getExpectedKrakenParams(true, getInvalidKrgCrbType1(), null));
});

it('handles broken Kargo CRBs where top level JSON is invalid on cookie', function() {
initializeKruxUser();
initializeKruxSegments();
initializeInvalidKrgCrbType1Cookie();
testBuildRequests(true, getExpectedKrakenParams(true, undefined, null, getInvalidKrgCrbType1()));
testBuildRequests(true, getExpectedKrakenParams(true, null, getInvalidKrgCrbType1()));
});

it('handles broken Kargo CRBs where decoded JSON is invalid', function() {
initializeKruxUser();
initializeKruxSegments();
initializeInvalidKrgCrbType2();
testBuildRequests(true, getExpectedKrakenParams(true, undefined, getInvalidKrgCrbType2(), null));
testBuildRequests(true, getExpectedKrakenParams(true, getInvalidKrgCrbType2(), null));
});

it('handles broken Kargo CRBs where inner base 64 is invalid on cookie', function() {
initializeKruxUser();
initializeKruxSegments();
initializeInvalidKrgCrbType2Cookie();
testBuildRequests(true, getExpectedKrakenParams(true, undefined, null, getInvalidKrgCrbType2OldStyle()));
testBuildRequests(true, getExpectedKrakenParams(true, null, getInvalidKrgCrbType2OldStyle()));
});

it('handles broken Kargo CRBs where inner JSON is invalid on cookie', function() {
initializeKruxUser();
initializeKruxSegments();
initializeInvalidKrgCrbType3Cookie();
testBuildRequests(true, getExpectedKrakenParams(true, undefined, null, getInvalidKrgCrbType3OldStyle()));
testBuildRequests(true, getExpectedKrakenParams(true, null, getInvalidKrgCrbType3OldStyle()));
});

it('handles broken Kargo CRBs where inner JSON is falsey', function() {
initializeKruxUser();
initializeKruxSegments();
initializeInvalidKrgCrbType4Cookie();
testBuildRequests(true, getExpectedKrakenParams(true, undefined, null, getInvalidKrgCrbType4OldStyle()));
testBuildRequests(true, getExpectedKrakenParams(true, null, getInvalidKrgCrbType4OldStyle()));
});

it('handles a non-existant currency object on the config', function() {
simulateNoCurrencyObject();
initializeKruxUser();
initializeKruxSegments();
initializeKrgCrb();
testBuildRequests(false, getExpectedKrakenParams(undefined, undefined, getKrgCrb(), getKrgCrbOldStyle()));
testBuildRequests(false, getExpectedKrakenParams(undefined, getKrgCrb(), getKrgCrbOldStyle()));
});

it('handles no ad server currency being set on the currency object in the config', function() {
simulateNoAdServerCurrency();
initializeKruxUser();
initializeKruxSegments();
initializeKrgCrb();
testBuildRequests(false, getExpectedKrakenParams(undefined, undefined, getKrgCrb(), getKrgCrbOldStyle()));
testBuildRequests(false, getExpectedKrakenParams(undefined, getKrgCrb(), getKrgCrbOldStyle()));
});

it('sends gdpr consent', function () {
initializeKruxUser();
initializeKruxSegments();
initializeKrgCrb();
testBuildRequests(false, getExpectedKrakenParams(undefined, undefined, getKrgCrb(), getKrgCrbOldStyle(), generateGDPRExpect(true, true)), generateGDPR(true, true));
testBuildRequests(false, getExpectedKrakenParams(undefined, undefined, getKrgCrb(), getKrgCrbOldStyle(), generateGDPRExpect(false, true)), generateGDPR(false, true));
testBuildRequests(false, getExpectedKrakenParams(undefined, undefined, getKrgCrb(), getKrgCrbOldStyle(), generateGDPRExpect(false, false)), generateGDPR(false, false));
testBuildRequests(false, getExpectedKrakenParams(undefined, getKrgCrb(), getKrgCrbOldStyle(), generateGDPRExpect(true, true)), generateGDPR(true, true));
testBuildRequests(false, getExpectedKrakenParams(undefined, getKrgCrb(), getKrgCrbOldStyle(), generateGDPRExpect(false, true)), generateGDPR(false, true));
testBuildRequests(false, getExpectedKrakenParams(undefined, getKrgCrb(), getKrgCrbOldStyle(), generateGDPRExpect(false, false)), generateGDPR(false, false));
});
});

Expand Down