Skip to content

Commit

Permalink
removes idx and loop to create 5 syncs (#37) (#11968)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickllerandi authored Jul 12, 2024
1 parent af742ce commit 85e6ef1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
25 changes: 11 additions & 14 deletions modules/kargoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const SUA_ATTRIBUTES = [

const CERBERUS = Object.freeze({
KEY: 'krg_crb',
SYNC_URL: 'https://crb.kargo.com/api/v1/initsyncrnd/{UUID}?seed={SEED}&idx={INDEX}&gdpr={GDPR}&gdpr_consent={GDPR_CONSENT}&us_privacy={US_PRIVACY}&gpp={GPP_STRING}&gpp_sid={GPP_SID}',
SYNC_URL: 'https://crb.kargo.com/api/v1/initsyncrnd/{UUID}?seed={SEED}&gdpr={GDPR}&gdpr_consent={GDPR_CONSENT}&us_privacy={US_PRIVACY}&gpp={GPP_STRING}&gpp_sid={GPP_SID}',
SYNC_COUNT: 5,
PAGE_VIEW_ID: 'pageViewId',
PAGE_VIEW_TIMESTAMP: 'pageViewTimestamp',
Expand Down Expand Up @@ -274,19 +274,16 @@ function getUserSyncs(syncOptions, _, gdprConsent, usPrivacy, gppConsent) {
return syncs;
}
if (syncOptions.iframeEnabled && seed && clientId) {
for (let i = 0; i < CERBERUS.SYNC_COUNT; i++) {
syncs.push({
type: 'iframe',
url: CERBERUS.SYNC_URL.replace('{UUID}', clientId)
.replace('{SEED}', seed)
.replace('{INDEX}', i)
.replace('{GDPR}', gdpr)
.replace('{GDPR_CONSENT}', gdprConsentString)
.replace('{US_PRIVACY}', usPrivacy || '')
.replace('{GPP_STRING}', gppString)
.replace('{GPP_SID}', gppApplicableSections)
});
}
syncs.push({
type: 'iframe',
url: CERBERUS.SYNC_URL.replace('{UUID}', clientId)
.replace('{SEED}', seed)
.replace('{GDPR}', gdpr)
.replace('{GDPR_CONSENT}', gdprConsentString)
.replace('{US_PRIVACY}', usPrivacy || '')
.replace('{GPP_STRING}', gppString)
.replace('{GPP_SID}', gppApplicableSections)
})
}
return syncs;
}
Expand Down
15 changes: 7 additions & 8 deletions test/spec/modules/kargoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1885,16 +1885,15 @@ describe('kargo adapter tests', function() {
describe('getUserSyncs', function() {
let crb = {};
const clientId = 'random-client-id-string';
const baseUrl = 'https://crb.kargo.com/api/v1/initsyncrnd/random-client-id-string?seed=3205e885-8d37-4139-b47e-f82cff268000&idx=0&gdpr=0&gdpr_consent=&us_privacy=&gpp=&gpp_sid=';
const baseUrl = 'https://crb.kargo.com/api/v1/initsyncrnd/random-client-id-string?seed=3205e885-8d37-4139-b47e-f82cff268000&gdpr=0&gdpr_consent=&us_privacy=&gpp=&gpp_sid=';

function buildSyncUrls(baseUrl = 'https://crb.kargo.com/api/v1/initsyncrnd/random-client-id-string?seed=3205e885-8d37-4139-b47e-f82cff268000&idx=0&gdpr=0&gdpr_consent=&us_privacy=&gpp=&gpp_sid=') {
function buildSyncUrls(baseUrl = 'https://crb.kargo.com/api/v1/initsyncrnd/random-client-id-string?seed=3205e885-8d37-4139-b47e-f82cff268000&gdpr=0&gdpr_consent=&us_privacy=&gpp=&gpp_sid=') {
let syncs = [];
for (let i = 0; i < 5; i++) {
syncs.push({
type: 'iframe',
url: baseUrl.replace(/idx=\d+&/, `idx=${i}&`),
});
}

syncs.push({
type: 'iframe',
url: baseUrl
});

return syncs;
}
Expand Down

0 comments on commit 85e6ef1

Please sign in to comment.