Skip to content

Commit

Permalink
6.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
piano-analytics committed Nov 6, 2023
1 parent 33310ec commit 3557c36
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
42 changes: 30 additions & 12 deletions src/business/ext/data-layer/data-layer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @license
* Piano Browser [email protected].3.
* Piano Browser [email protected].4.
* Copyright 2010-2022 Piano Software Inc.
*/
import { cookie } from '@piano-sdk/storage';
Expand Down Expand Up @@ -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;
Expand All @@ -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; });
Expand All @@ -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) {
Expand Down
8 changes: 7 additions & 1 deletion src/business/privacy/dl-privacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ export default {
],
'storageVisitor': 'pa_vid',
'storageUser': 'pa_user',
'version': '6.12.2',
'version': '6.13.0',
'minHeartbeat': 5,
'minBufferingHeartbeat': 1,
'queueVarName': '_paq',
'globalVarName': 'pa',
'enableAutomaticPageRefresh': true,
'allowHighEntropyClientHints': true,
'sendEmptyProperties': true,
'enableExtendedOptout': false,
'privacy': {
'storageKey': 'pa_privacy',
'legacyKeys': {
Expand Down

0 comments on commit 3557c36

Please sign in to comment.