Skip to content

Commit

Permalink
6.8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
piano-analytics committed Jan 27, 2023
1 parent 2f79e29 commit 4aaadb0
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 27 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 6.8.2
### Fixes
- Fixed an issue preventing various cookies from being deposited when not using Consent

## 6.8.1
### Fixes
- Consent management was crashing in rare case where no `window.pdl` was set beforehand
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.8.1",
"version": "6.8.2",
"main": "dist/browserless/piano-analytics.cjs.js",
"module": "dist/browserless/piano-analytics.esm.js",
"browser": "dist/browser/piano-analytics.umd.js",
Expand Down
10 changes: 9 additions & 1 deletion src/business/privacy/dl-privacy-configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@ const baseConfig = {
'device_timestamp_utc': 'mandatory',
'visitor_privacy_consent': 'mandatory',
'visitor_privacy_mode': 'mandatory',
'ch_ua*': 'mandatory',
'ch_ua': 'mandatory',
'ch_ua_arch': 'mandatory',
'ch_ua_bitness': 'mandatory',
'ch_ua_full_version': 'mandatory',
'ch_ua_full_version_list': 'mandatory',
'ch_ua_mobile': 'mandatory',
'ch_ua_model': 'mandatory',
'ch_ua_platform': 'mandatory',
'ch_ua_platform_version': 'mandatory',
'app_crash': 'essential',
'app_crash_class': 'essential',
'app_crash_screen': 'essential',
Expand Down
31 changes: 12 additions & 19 deletions src/business/privacy/dl-privacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {dataLayer} from '../data-layer/data-layer';
import {getConsentItems} from './dl-privacy-configuration';

function DlPrivacy(pa) {
const DEFAULT_MODE = 'opt-in';
this.storageKeys = [
'pa_vid',
'pa_user',
Expand Down Expand Up @@ -54,40 +55,39 @@ function DlPrivacy(pa) {
items: this.consentItems.cookieItems
});
if(!pa.getConfiguration('isLegacyPrivacy')){
this.initMode();
this.filterKeys();
}
};

this.initMode = function () {
if (dataLayer.get('consent') === null) {
if (window.pdl.consent && window.pdl.consent.defaultPreset) {
dataLayer.set('consent', 0);
} else {
this.setMode(DEFAULT_MODE);
}
}
};
/* public */
this.setMode = function (mode) {
_switchToDl();
dataLayer.set('consent', {
PA: {mode: mode}
});
this.filterKeys();
};
this.setPresets = function (presets) {
_switchToDl();
dataLayer.set('consent', presets);
this.filterKeys();
};
this.getMode = function () {
_switchToDl();
let consent = 'opt-in';
let consent = DEFAULT_MODE;
const dlConsent = dataLayer.get('consent');
if (dlConsent && dlConsent['PA'] && dlConsent['PA'].mode) {
consent = dataLayer.get('consent')['PA'].mode;
} else if (dlConsent === null) {
if (window.pdl.consent && window.pdl.consent.defaultPreset) {
dataLayer.set('consent', 0);
} else {
this.setMode(consent);
}
}
return consent;
};
this.setCustomModeMetadata = function (consentValue, modeName) {
_switchToDl();
this.modeMetadata['custom'].visitor_privacy_mode = modeName || 'custom';
this.modeMetadata['custom'].visitor_privacy_consent = consentValue;
};
Expand Down Expand Up @@ -139,13 +139,6 @@ function DlPrivacy(pa) {
}
};

function _switchToDl() {
if (pa.getConfiguration('isLegacyPrivacy')) {
pa.setConfiguration('isLegacyPrivacy', false);
pa.consent.filterKeys();
}
}

this.dl = dataLayer;

this.init();
Expand Down
2 changes: 1 addition & 1 deletion src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default {
],
'storageVisitor': 'pa_vid',
'storageUser': 'pa_user',
'version': '6.8.1',
'version': '6.8.2',
'minHeartbeat': 5,
'minBufferingHeartbeat': 1,
'queueVarName': '_paq',
Expand Down
6 changes: 1 addition & 5 deletions src/core/PianoAnalytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ function _initPrivacy(pa) {
if (BUILD_BROWSER) {
if (typeof window.pdl === 'undefined') {
window.pdl = {
requireConsent: true,
migration: {
browserId: {
source: 'PA'
Expand All @@ -59,10 +58,7 @@ function _initPrivacy(pa) {
storageMode: 'fixed'
}
};
} else {
if (!window.pdl.requireConsent) {
window.pdl.requireConsent = true;
}
} else if (window.pdl && window.pdl.requireConsent) {
pa.setConfiguration('isLegacyPrivacy', false);
}
dataLayer.init({
Expand Down

0 comments on commit 4aaadb0

Please sign in to comment.