Skip to content

Commit

Permalink
Feat: Generate and store consent UUID on accept #CCM-35
Browse files Browse the repository at this point in the history
  • Loading branch information
OndraM committed Nov 18, 2021
1 parent 6801656 commit 519182d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
},
"dependencies": {
"@lmc-eu/spirit-design-tokens": "^0.4.0",
"nanoid": "^3.1.30",
"vanilla-cookieconsent": "^2.6.1"
},
"devDependencies": {
Expand Down
9 changes: 9 additions & 0 deletions src/LmcCookieConsentManager.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'vanilla-cookieconsent';
import { nanoid } from 'nanoid';

import { config as configCs } from './languages/cs';
import { config as configDe } from './languages/de';
Expand Down Expand Up @@ -91,6 +92,14 @@ const LmcCookieConsentManager = (serviceName, args) => {
onAccept(cookie, cookieConsent);

if (isFirstTimeAccept) {
const cookieData = cookieConsent.get('data');
if (cookieData === null || !('uid' in cookieData)) {
cookieConsent.set('data', {
value: { serviceName: serviceName, uid: nanoid() },
mode: 'update',
});
}

onFirstAccept(cookie, cookieConsent);
acceptedOnlyNecessary
? onFirstAcceptOnlyNecessary(cookie, cookieConsent)
Expand Down

0 comments on commit 519182d

Please sign in to comment.