Skip to content

Commit f04c5a7

Browse files
committed
Fix opt-out cookie check (close #604)
1 parent 0ed0909 commit f04c5a7

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/js/tracker.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,10 @@
456456
function sendRequest(request, delay) {
457457
var now = new Date();
458458

459-
if (!(configDoNotTrack || !!getSnowplowCookieValue(configOptOutCookie))) {
459+
// Set to true if Opt-out cookie is defined
460+
var toOptoutByCookie = !!cookie.cookie(configOptOutCookie);
461+
462+
if (!(configDoNotTrack || toOptoutByCookie)) {
460463
outQueueManager.enqueueRequest(request.build(), configCollectorUrl);
461464
mutSnowplowState.expireDateTime = now.getTime() + delay;
462465
}
@@ -705,7 +708,9 @@
705708
lastVisitTs = id[5],
706709
sessionIdFromCookie = id[6];
707710

708-
if ((configDoNotTrack || !!getSnowplowCookieValue(configOptOutCookie)) &&
711+
var toOptoutByCookie = !!cookie.cookie(configOptOutCookie);
712+
713+
if ((configDoNotTrack || toOptoutByCookie) &&
709714
configStateStorageStrategy != 'none') {
710715
if (configStateStorageStrategy == 'localStorage') {
711716
helpers.attemptWriteLocalStorage(idname, '');
@@ -1929,7 +1934,6 @@
19291934
*/
19301935
setOptOutCookie: function (name) {
19311936
configOptOutCookie = name;
1932-
setCookie(name, '*', 1800);
19331937
},
19341938

19351939
/**

0 commit comments

Comments
 (0)