Hacker News new | ask | show | jobs
by kfkdjajgjic 386 days ago
if (cookies.accepted) { trackUser(); } else { trackUserAnyway(); }
2 comments

I recently looked at how websites handled these simple "accept cookies" buttons - turns out lots of them did them like your example but more like {trackUser(); } else {trackUser(); } The only effect was to close the popup.

Even some (most?) off the shelf cookie consent libraries don't handle the turning the actual cookies off.

else { trackUserCovertly(); }
if (cookies.accepted) { trackUser(); } else { isAbTestEnabled() ? trackUserCovertly() : trackUserAnyway(); }
simplify

if (true) { trackUser(); }

trackUser();
lgtm. Ship it
trackUser()