Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
rmi22186 committed Jan 6, 2025
1 parent c66ec58 commit 7681164
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
36 changes: 17 additions & 19 deletions src/cookieSyncManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,22 +110,15 @@ export default function CookieSyncManager(
redirectUrl
);

// reset shouldPerformCookieSync to false
let shouldPerformCookieSync = false;
if (previousMPID && previousMPID !== mpid) {
if (persistence && persistence[mpid]) {
if (!persistence[mpid].csd) {
persistence[mpid].csd = {};
}
self.performCookieSync(
urlWithRedirect,
moduleId,
mpid,
persistence[mpid].csd,
filteringConsentRuleValues,
mpidIsNotInCookies,
requiresConsent
);
shouldPerformCookieSync = true;
}
return;
} else {
if (!persistence || !persistence[mpid]) {
return;
Expand All @@ -139,17 +132,22 @@ export default function CookieSyncManager(

// Check to see if we need to refresh cookieSync
if (hasFrequencyCapExpired(frequencyCap, lastSyncDateForModule)) {
self.performCookieSync(
urlWithRedirect,
moduleId,
mpid,
persistence[mpid].csd,
filteringConsentRuleValues,
mpidIsNotInCookies,
requiresConsent
);
shouldPerformCookieSync = true;
}
}

if (shouldPerformCookieSync) {
self.performCookieSync(
urlWithRedirect,
moduleId,
mpid,
persistence[mpid].csd,
filteringConsentRuleValues,
mpidIsNotInCookies,
requiresConsent
);
}

});
};

Expand Down
2 changes: 1 addition & 1 deletion test/src/tests-cookie-syncing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ declare global {

const mParticle = window.mParticle;

describe('cookie syncing', function() {
describe.only('cookie syncing', function() {
const timeout = 100;
// Have a reference to createElement function to reset after all cookie sync
// tests have run
Expand Down

0 comments on commit 7681164

Please sign in to comment.