diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e1640b..4ee0fe7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ # Changelog +## 6.13.0 +### New +- [browser] New configuration `enableExtendedOptout` to enable enhanced tracking of optout visitors (`false` by default) + ## 6.12.2 ### Fixes - - [browser] Cookie `_pcus` being created by mistake diff --git a/package.json b/package.json index bb6a925..eef42be 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "piano-analytics-js", "description": "JavaScript library for Piano Analytics", - "version": "6.12.2", + "version": "6.13.0", "main": "dist/browserless/piano-analytics.cjs.js", "module": "dist/browserless/piano-analytics.esm.js", "browser": "dist/browser/piano-analytics.umd.js", diff --git a/src/business/ext/data-layer/data-layer.js b/src/business/ext/data-layer/data-layer.js index 6458a78..0ac127e 100644 --- a/src/business/ext/data-layer/data-layer.js +++ b/src/business/ext/data-layer/data-layer.js @@ -1,6 +1,6 @@ /** * @license - * Piano Browser SDK-DataLayer@2.9.3. + * Piano Browser SDK-DataLayer@2.9.4. * Copyright 2010-2022 Piano Software Inc. */ import { cookie } from '@piano-sdk/storage'; @@ -2801,10 +2801,25 @@ var DataLayer = function (paramsArgs, cookiesArgs, onInit) { }; }; -var getCookieProhibition = function () { return ({ - _pprv: !getGlobalConfig$1().requireConsent -}); }; +var isPAConsentOnly = function (con) { + var _a, _b; + var conf = getGlobalConfig$1(); + var products = ((_a = conf.consent) === null || _a === void 0 ? void 0 : _a.products) || []; + var paOnly = products.length === 1 && products[0] === 'PA'; + var isOptOut = ((_b = con === null || con === void 0 ? void 0 : con.PA) === null || _b === void 0 ? void 0 : _b.mode) === 'opt-out'; + return !!conf.requireConsent && paOnly && isOptOut; +}; +var getCookieProhibition = function (con) { + var prohibitForPaProducts = isPAConsentOnly(con); + return { + _pprv: !getGlobalConfig$1().requireConsent, + _pctx: prohibitForPaProducts, + _pcid: prohibitForPaProducts, + _pcus: prohibitForPaProducts, + }; +}; var checkConsent = function (_private) { + var _a; var items = keys(cookieEncoders).reduce(function (res, cookieName) { res[cookieName] = cookieEncoders[cookieName].consent; return res; @@ -2815,10 +2830,11 @@ var checkConsent = function (_private) { type: 'cookie', getConsent: getConsent }); - var prevValueConsent = getConsent(); - var checkCookieWrappers = function (con) { + var prevValueDlConsent = getConsent(); + var prevValuePAConsent = ((_a = _private.get('consent')) === null || _a === void 0 ? void 0 : _a.PA) || null; + var checkCookieWrappers = function (con, allConsents) { var _a; - var prohibition = getCookieProhibition(); + var prohibition = getCookieProhibition(allConsents); var cookieWrapperMap = (_a = _private.getConnection()) === null || _a === void 0 ? void 0 : _a.registeredCookiesWrapper; if (cookieWrapperMap) { var names = keys(cookieWrapperMap).map(function (key) { return cookieWrapperMap[key].cookieName; }); @@ -2831,13 +2847,15 @@ var checkConsent = function (_private) { } }; _private.addChangeListener('consent', function (data) { - var newValue = (data === null || data === void 0 ? void 0 : data.DL) || null; - if ((prevValueConsent === null || prevValueConsent === void 0 ? void 0 : prevValueConsent.mode) !== (newValue === null || newValue === void 0 ? void 0 : newValue.mode)) { - prevValueConsent = newValue; - checkCookieWrappers(newValue); + var newDLValue = (data === null || data === void 0 ? void 0 : data.DL) || null; + var newPAValue = (data === null || data === void 0 ? void 0 : data.PA) || null; + if ((prevValueDlConsent === null || prevValueDlConsent === void 0 ? void 0 : prevValueDlConsent.mode) !== (newDLValue === null || newDLValue === void 0 ? void 0 : newDLValue.mode) || (prevValuePAConsent === null || prevValuePAConsent === void 0 ? void 0 : prevValuePAConsent.mode) !== (newPAValue === null || newPAValue === void 0 ? void 0 : newPAValue.mode)) { + prevValueDlConsent = newDLValue; + prevValuePAConsent = newPAValue; + checkCookieWrappers(newDLValue, data); } }); - checkCookieWrappers(prevValueConsent); + checkCookieWrappers(prevValueDlConsent, _private.get('consent')); }; var log = function (product, mode, type) { diff --git a/src/business/privacy/dl-privacy.js b/src/business/privacy/dl-privacy.js index 0a07565..bcdb1ab 100644 --- a/src/business/privacy/dl-privacy.js +++ b/src/business/privacy/dl-privacy.js @@ -25,7 +25,7 @@ function DlPrivacy(pa) { }, 'opt-out': { 'visitor_privacy_consent': false, - 'visitor_privacy_mode': 'optout' + 'visitor_privacy_mode': pa.getConfiguration('enableExtendedOptout') === true ? 'extended-optout' : 'optout' }, 'essential': { 'visitor_privacy_consent': false, @@ -100,9 +100,15 @@ function DlPrivacy(pa) { return this.consentItems; }; this.isPropAllowed = (function (propertyName) { + if (pa.getConfiguration('enableExtendedOptout') === true && this.getMode() === 'opt-out') { + return true; + } return this.propertyConsent.check(propertyName).allowed; }).bind(this); this.isEventAllowed = (function (eventName) { + if (pa.getConfiguration('enableExtendedOptout') === true && this.getMode() === 'opt-out') { + return true; + } return this.eventConsent.check(eventName).allowed; }).bind(this); this.isKeyAllowed = (function (storageKey) { diff --git a/src/config.js b/src/config.js index ef91cf6..847de5b 100644 --- a/src/config.js +++ b/src/config.js @@ -23,7 +23,7 @@ export default { ], 'storageVisitor': 'pa_vid', 'storageUser': 'pa_user', - 'version': '6.12.2', + 'version': '6.13.0', 'minHeartbeat': 5, 'minBufferingHeartbeat': 1, 'queueVarName': '_paq', @@ -31,6 +31,7 @@ export default { 'enableAutomaticPageRefresh': true, 'allowHighEntropyClientHints': true, 'sendEmptyProperties': true, + 'enableExtendedOptout': false, 'privacy': { 'storageKey': 'pa_privacy', 'legacyKeys': {