Skip to content

Commit

Permalink
Updated the package version and CHANGELOG
Browse files Browse the repository at this point in the history
  • Loading branch information
tg666 committed May 10, 2024
1 parent 118f7f9 commit 7672661
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 9 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.5.3] - 2024-05-10

### Added

- Added field `User RFC cookie` into the GTM template.
- Added property `CookieConsentWrapper.consentCookieValue` that returns raw consent value as a string or null if no consent exists.

## [0.5.2] - 2024-04-04

### Fixed
Expand Down
17 changes: 13 additions & 4 deletions gtm_template.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,14 @@ ___TEMPLATE_PARAMETERS___
],
"help": "One name per line.",
"lineCount": 3
},
{
"type": "CHECKBOX",
"name": "use_rfc_cookie",
"checkboxText": "Use RFC cookie",
"simpleValueType": true,
"defaultValue": false,
"help": "The cookie value will be encoded using the \u003ccode\u003eencodeURIComponent\u003c/code\u003e function (so the cookie value will be RFC compliant) if the option is enabled. Otherwise, the cookie will contain plain JSON."
}
]
},
Expand Down Expand Up @@ -2073,12 +2081,12 @@ const temporaryWrapper = (function () {

setInWindow('CookieConsentWrapper', temporaryWrapper, false);

// parse consents from cookies
let consentCookie = getCookieValues(data.cookie_name)[0] || null;
// parse consents from cookies, values are automatically decoded using decodeURIComponent function if the second argument is true
let consentCookie = getCookieValues(data.cookie_name, true)[0] || null;

if (null !== consentCookie) {
consentCookie = JSON.parse(consentCookie);
consentCookie = consentCookie.hasOwnProperty('level') && consentCookie.level.length ? consentCookie.level : [];
consentCookie = consentCookie && consentCookie.hasOwnProperty('categories') && consentCookie.categories.length ? consentCookie.categories : [];
}

// build storage pool & event triggers
Expand Down Expand Up @@ -2274,7 +2282,8 @@ const pluginOptions = {
revision: makeInteger(data.revision),
delay: makeInteger(data.delay),
auto_language: 'disabled' !== data.locale_detection_strategy ? data.locale_detection_strategy : null,
page_scripts: data.page_scripts
page_scripts: data.page_scripts,
use_rfc_cookie: data.use_rfc_cookie
};

if (data.hasOwnProperty('current_locale')) {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "68publishers-cookie-consent",
"version": "0.5.2",
"version": "0.5.3-beta.0",
"description": "Cookie consent wrapper based on orestbida/cookieconsent with GTM integration.",
"homepage": "http://www.68publishers.io/",
"main": "index.js",
Expand Down
4 changes: 2 additions & 2 deletions src/Config/PluginOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ class PluginOptions extends require('./AbstractOptions') {
this.auto_language = 'document';
this.page_scripts = false;
this.script_selector = 'data-cookiecategory';
this.cookie_domain = window.location.hostname;
this.use_rfc_cookie = false;

// another options for the original plugin
this.cookie_path = '/';
this.cookie_domain = window.location.hostname;
this.cookie_same_site = 'Lax';
this.use_rfc_cookie = false;
this.remove_cookie_tables = false;

// unsupported options (custom reimplementation)
Expand Down
11 changes: 11 additions & 0 deletions src/CookieConsentWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ class CookieConsentWrapper {
return this._cookieTables;
}

get consentCookieValue() {
if (!this._cookieConsent.validConsent()) {
return null;
}

const cookieName = this._config.pluginOptions.cookie_name;
let cookieValue = document.cookie.match("(^|;)\\s*" + cookieName + "\\s*=\\s*([^;]+)");

return cookieValue ? cookieValue.pop() : null;
}

get consentCookieData() {
const cookieName = this._config.pluginOptions.cookie_name;
let cookieValue = document.cookie.match("(^|;)\\s*" + cookieName + "\\s*=\\s*([^;]+)");
Expand Down

0 comments on commit 7672661

Please sign in to comment.