diff --git a/CHANGELOG.md b/CHANGELOG.md index e8f1ef9..354d5dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Added fields `Integration > CMP API > Default environment` and `Integration > CMP API > Environment code` in the GTM template. +- Added option `evironment` in the `CmpApiOptions`. The environment is taken into account in the integration with CMP. +- Added getter `CookieConsentWrapper.consentCookieData` that returns data from the consent cookie (`cc-settings` by default) as an object or null if the consent doesn't exists. + +### Changed + +- Credentials are now omitted in CPM integration requests. + ## [0.4.7] - 2023-10-04 ### Added diff --git a/package-lock.json b/package-lock.json index 25b68d3..f3641c9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "68publishers-cookie-consent", - "version": "0.4.8-beta.1", + "version": "0.4.8-beta.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "68publishers-cookie-consent", - "version": "0.4.8-beta.1", + "version": "0.4.8-beta.2", "license": "MIT", "dependencies": { "crypto-js": "^4.1.1", diff --git a/package.json b/package.json index ae30cb6..3cfd32f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "68publishers-cookie-consent", - "version": "0.4.8-beta.1", + "version": "0.4.8-beta.2", "description": "Cookie consent wrapper based on orestbida/cookieconsent with GTM integration.", "homepage": "http://www.68publishers.io/", "main": "index.js", diff --git a/src/CookieConsentWrapper.js b/src/CookieConsentWrapper.js index e81775e..3492921 100644 --- a/src/CookieConsentWrapper.js +++ b/src/CookieConsentWrapper.js @@ -69,6 +69,28 @@ class CookieConsentWrapper { return this._cookieTables; } + get consentCookieData() { + const cookieName = this._config.pluginOptions.cookie_name; + let cookieValue = document.cookie.match("(^|;)\\s*" + cookieName + "\\s*=\\s*([^;]+)"); + cookieValue = cookieValue ? cookieValue.pop() : null; + + if (null === cookieValue) { + return null; + } + + try{ + cookieValue = JSON.parse(cookieValue) + } catch (e) { + try { + cookieValue = JSON.parse(decodeURIComponent(cookieValue)) + } catch (e) { + cookieValue = null; + } + } + + return cookieValue; + } + setStaticUserIdentity(id) { this._user = this.user.withStaticIdentity(id); }