From fd574bbf1b547c77137d3a3b834e10b3fe999b1f Mon Sep 17 00:00:00 2001 From: Rene Buechner Date: Mon, 6 May 2019 14:20:01 +0200 Subject: [PATCH] removes poi_subscriber_set_cookie OIL-336 --- README.md | 1 - docs/src/docs/03-configuration.adoc | 1 - src/scripts/core/core_config.js | 4 --- src/scripts/core/core_constants.js | 1 - src/scripts/core/core_optin.js | 2 +- src/scripts/userview/userview_modal.js | 35 +++++++++---------- src/scripts/userview/userview_optin.js | 11 ++---- test/specs/optin.spec.js | 19 ---------- .../userview/userview_handle-optin.spec.js | 4 +-- test/specs/userview/userview_optin.spec.js | 17 +-------- 10 files changed, 24 insertions(+), 71 deletions(-) diff --git a/README.md b/README.md index e972b682..2d27777e 100755 --- a/README.md +++ b/README.md @@ -167,7 +167,6 @@ For detailed explanations, please visit the [documentation](https://oil.axelspri | poi_group_name | POI group name. POI only affects those sites with the same group name (mandatory if POI is activated). The group name must be valid (existing). | None | poi_hub_origin | The origin of the hub.js installation | `https://unpkg.com` | poi_hub_path | The path to the hub.html installation on the origin, if any. | `/@ideasio/oil.js@{oilVersion}/release/current/hub.html` -| poi_subscriber_set_cookie | Whether to set the SOI cookie on POI opt-ins or not. | true | preview_mode | The preview mode is useful when testing OIL in a production or live environment. When value is `true`, the layer remains hidden until you manually trigger `window.AS_OIL.previewModeOn()` in your console. Reload, and the layer is displayed. You can hide it again with `window.AS_OIL.previewModeOff()`. | false | publicPath | The server path from which all chunks and ressources will be loaded. You should upload all released files there and configure it. | `//unpkg.com/@ideasio/oil.js@{oilVersion}/release/current/` | require_optout_confirm | Flag to activate the opt-out confirmation dialog within the CPC. If set to `true`, additional label definitions (with prefix `label_cpc_purpose_optout`) are required. See the label configuration section in the documentation for details. | false diff --git a/docs/src/docs/03-configuration.adoc b/docs/src/docs/03-configuration.adoc index 2e55494a..e3317476 100644 --- a/docs/src/docs/03-configuration.adoc +++ b/docs/src/docs/03-configuration.adoc @@ -135,7 +135,6 @@ This is a full list of configurable options. | poi_group_name | POI group name. POI only affects those sites with the same group name (mandatory if POI is activated). | None | poi_hub_origin | The origin of the hub.js installation | `https://unpkg.com` | poi_hub_path | The path to the hub.html installation on the origin, if any. | `/@ideasio/oil.js@{version}/release/current/hub.html` -| poi_subscriber_set_cookie | Whether to set the SOI cookie on POI opt-ins or not. | true | <> | The preview mode is useful when testing OIL in a production or live environment. As a dev you can trigger the overlay by setting a cookie named "oil_preview" with the value "true". This will show the OIL layer on your client. | false | publicPath | The server path from which all chunks and resources will be loaded. You should upload all released files there and configure it. | `https://unpkg.com/@ideasio/oil.js@{version}/release/current/` | require_optout_confirm | Flag to activate the opt-out confirmation dialog within Cookie Preference Center. If set to `true`, addition label definitions (for labels with prefix `label_cpc_purpose_optout_confirm`) are required. See section <> for details. | false diff --git a/src/scripts/core/core_config.js b/src/scripts/core/core_config.js index 448c94ac..c6df8951 100644 --- a/src/scripts/core/core_config.js +++ b/src/scripts/core/core_config.js @@ -109,10 +109,6 @@ export function isPoiActive() { return getConfigValue(OIL_CONFIG.ATTR_ACTIVATE_POI, false); } -export function isSubscriberSetCookieActive() { - return getConfigValue(OIL_CONFIG.ATTR_SUB_SET_COOKIE, true); -} - /** * Get the hub iFrame domain with protocol prefix for the current location * @returns {string, null} domain iframe orgin diff --git a/src/scripts/core/core_constants.js b/src/scripts/core/core_constants.js index 1464ed95..75d06527 100644 --- a/src/scripts/core/core_constants.js +++ b/src/scripts/core/core_constants.js @@ -11,7 +11,6 @@ export const OIL_CONFIG = { ATTR_HUB_PATH: 'poi_hub_path', ATTR_PUBLIC_PATH: 'publicPath', ATTR_HUB_LOCATION: 'poi_hub_location', // complete hub location, gets generated - ATTR_SUB_SET_COOKIE: 'poi_subscriber_set_cookie', ATTR_PREVIEW_MODE: 'preview_mode', ATTR_COOKIE_EXPIRES_IN_DAYS: 'cookie_expires_in_days', ATTR_TIMESTAMP: 'timestamp', diff --git a/src/scripts/core/core_optin.js b/src/scripts/core/core_optin.js index ca97ce22..0814e79d 100644 --- a/src/scripts/core/core_optin.js +++ b/src/scripts/core/core_optin.js @@ -32,7 +32,7 @@ export function checkOptIn() { logPreviewOptInInfo(soiOptIn, powerOptIn.power_opt_in); if (powerOptIn.power_opt_in) { resultOptIn = powerOptIn.power_opt_in; - if (isSubscriberSetCookieActive() && !soiOptIn) { + if (!soiOptIn) { setSoiCookieWithPoiCookieData(powerOptIn) .then(() => resolve(resultOptIn)) .catch(error => reject(error)); diff --git a/src/scripts/userview/userview_modal.js b/src/scripts/userview/userview_modal.js index 09432dde..35d8d120 100644 --- a/src/scripts/userview/userview_modal.js +++ b/src/scripts/userview/userview_modal.js @@ -25,7 +25,7 @@ import * as AdvancedSettingsStandard from './view/oil.advanced.settings.standard import * as AdvancedSettingsTabs from './view/oil.advanced.settings.tabs'; import { logError, logInfo } from '../core/core_log'; import { getCpcType, getTheme, getTimeOutValue, isOptoutConfirmRequired, isPersistMinimumTracking } from './userview_config'; -import { gdprApplies, getAdvancedSettingsPurposesDefault, isPoiActive, isSubscriberSetCookieActive } from '../core/core_config'; +import { gdprApplies, getAdvancedSettingsPurposesDefault, isPoiActive } from '../core/core_config'; import { applyPrivacySettings, getPrivacySettings, getSoiConsentData } from './userview_privacy'; import { activateOptoutConfirm } from './userview_optout_confirm'; import { getPurposeIds, loadVendorListAndCustomVendorList } from '../core/core_vendor_lists'; @@ -83,7 +83,7 @@ export function oilShowPreferenceCenter() { let wrapper = document.querySelector('.as-oil'); let entryNode = document.querySelector('#oil-preference-center'); if (wrapper) { - renderOil({advancedSettings: true}); + renderOil({ advancedSettings: true }); } else if (entryNode) { entryNode.innerHTML = findAdvancedSettingsInlineTemplate(); addOilHandlers(getOilDOMNodes()); @@ -99,8 +99,8 @@ export function oilShowPreferenceCenter() { currentPrivacySettings = getAdvancedSettingsPurposesDefault() ? getPurposeIds() : []; } applyPrivacySettings(currentPrivacySettings); - }) - }) + }); + }); }) .catch((error) => logError(error)); } @@ -110,7 +110,7 @@ export function handleOptIn() { import('../poi-list/poi.group.list.js').then(poi_group_list => { poi_group_list.getGroupList().then(() => { (handlePoiOptIn()).then(onOptInComplete); - }) + }); }); } else { (handleSoiOptIn()).then(onOptInComplete); @@ -151,7 +151,7 @@ function findAdvancedSettingsTemplate() { case OIL_CONFIG_CPC_TYPES.CPC_TYPE_TABS: return AdvancedSettingsTabs.oilAdvancedSettingsTemplate(); default: - logError(`Found unknown CPC type '${cpcType}'! Falling back to CPC type '${OIL_CONFIG_CPC_TYPES.CPC_TYPE_STANDARD}'!`); + logError(`Found unknown CPC type '${ cpcType }'! Falling back to CPC type '${ OIL_CONFIG_CPC_TYPES.CPC_TYPE_STANDARD }'!`); return AdvancedSettingsStandard.oilAdvancedSettingsTemplate(); } } @@ -164,7 +164,7 @@ function findAdvancedSettingsInlineTemplate() { case OIL_CONFIG_CPC_TYPES.CPC_TYPE_TABS: return AdvancedSettingsTabs.oilAdvancedSettingsInlineTemplate(); default: - logError(`Found unknown CPC type '${cpcType}'! Falling back to CPC type '${OIL_CONFIG_CPC_TYPES.CPC_TYPE_STANDARD}'!`); + logError(`Found unknown CPC type '${ cpcType }'! Falling back to CPC type '${ OIL_CONFIG_CPC_TYPES.CPC_TYPE_STANDARD }'!`); return AdvancedSettingsStandard.oilAdvancedSettingsInlineTemplate(); } } @@ -183,13 +183,12 @@ function attachCpcEventHandlers() { AdvancedSettingsTabs.attachCpcHandlers(); break; default: - logError(`Found unknown CPC type '${cpcType}'! Falling back to CPC type '${OIL_CONFIG_CPC_TYPES.CPC_TYPE_STANDARD}'!`); + logError(`Found unknown CPC type '${ cpcType }'! Falling back to CPC type '${ OIL_CONFIG_CPC_TYPES.CPC_TYPE_STANDARD }'!`); AdvancedSettingsStandard.attachCpcHandlers(); break; } } - function oilShowCompanyList() { import('../poi-list/poi-info.js') .then(poiList => { @@ -217,7 +216,7 @@ function oilShowThirdPartyList() { function defineOilWrapper() { let oilWrapper = document.createElement('div'); // Set some attributes as CSS classes and attributes for testing - oilWrapper.setAttribute('class', `as-oil ${getTheme()}`); + oilWrapper.setAttribute('class', `as-oil ${ getTheme() }`); oilWrapper.setAttribute('data-qa', 'oil-Layer'); return oilWrapper; } @@ -258,13 +257,13 @@ function injectOilWrapperInDOM(wrapper) { function getOilDOMNodes() { return { oilWrapper: document.querySelectorAll('.as-oil'), - btnOptIn: document.querySelectorAll(`.${JS_CLASS_BUTTON_OPTIN}`), + btnOptIn: document.querySelectorAll(`.${ JS_CLASS_BUTTON_OPTIN }`), btnPoiOptIn: document.querySelectorAll('.as-js-optin-poi'), companyList: document.querySelectorAll('.as-js-companyList'), thirdPartyList: document.querySelectorAll('.as-js-thirdPartyList'), - btnAdvancedSettings: document.querySelectorAll(`.${JS_CLASS_BUTTON_ADVANCED_SETTINGS}`), - btnBack: document.querySelectorAll(`.${JS_CLASS_BUTTON_OILBACK}`) - } + btnAdvancedSettings: document.querySelectorAll(`.${ JS_CLASS_BUTTON_ADVANCED_SETTINGS }`), + btnBack: document.querySelectorAll(`.${ JS_CLASS_BUTTON_OILBACK }`) + }; } function handleBackToMainDialog() { @@ -296,7 +295,7 @@ function handleThirdPartyList() { } function animateOptInButton() { - let optInButton = document.querySelector(`.${JS_CLASS_BUTTON_OPTIN}`); + let optInButton = document.querySelector(`.${ JS_CLASS_BUTTON_OPTIN }`); if (optInButton) { optInButton.className += ' as-oil__btn-optin-clicked'; window.setTimeout(() => { @@ -313,7 +312,7 @@ function handleSoiOptIn() { if (shouldPrivacySettingBeStored(privacySetting)) { return oilOptIn(privacySetting).then(() => { // FIXME should remove Wrapper - renderOil({optIn: true}); + renderOil({ optIn: true }); sendEventToHostSite(EVENT_NAME_SOI_OPT_IN); }); } else { @@ -330,9 +329,9 @@ function handlePoiOptIn() { trackPrivacySettings(privacySetting); if (shouldPrivacySettingBeStored(privacySetting)) { - return oilPowerOptIn(privacySetting, !isSubscriberSetCookieActive()).then(() => { + return oilPowerOptIn(privacySetting).then(() => { // FIXME should remove Wrapper - renderOil({optIn: true}); + renderOil({ optIn: true }); if (isPoiActive()) { sendEventToHostSite(EVENT_NAME_POI_OPT_IN); } diff --git a/src/scripts/userview/userview_optin.js b/src/scripts/userview/userview_optin.js index fe16e071..637437af 100644 --- a/src/scripts/userview/userview_optin.js +++ b/src/scripts/userview/userview_optin.js @@ -21,15 +21,11 @@ import { isPoiActive } from '../core/core_config'; * @param powerOnly - only set Power Opt In (POI), no local site cookie (SOI) * @return Promise with updated cookie value */ -export function oilPowerOptIn(privacySettings, powerOnly = false) { +export function oilPowerOptIn(privacySettings) { return new Promise((resolve, reject) => { let soiCookiePromise; - if (!powerOnly) { - // Update Oil cookie (site - SOI) - soiCookiePromise = setSoiCookie(privacySettings) - } else { - soiCookiePromise = buildSoiCookie(privacySettings); - } + // Update Oil cookie (site - SOI) + soiCookiePromise = setSoiCookie(privacySettings); soiCookiePromise.then((cookie) => { let payload = { [OIL_PAYLOAD_PRIVACY]: cookie.consentString, @@ -61,7 +57,6 @@ export function oilPowerOptIn(privacySettings, powerOnly = false) { }); } - /** * Oil SOI optIn * diff --git a/test/specs/optin.spec.js b/test/specs/optin.spec.js index 82cfc661..a2a5602a 100644 --- a/test/specs/optin.spec.js +++ b/test/specs/optin.spec.js @@ -48,7 +48,6 @@ describe('Opt-In', () => { let powerOptIn = true; const poiCookieJson = {power_opt_in: powerOptIn, consentData: 'aConsentDataObject'}; spyOn(CoreCookies, 'getSoiCookie').and.returnValue({opt_in: singleOptIn}); - spyOn(CoreConfig, 'isSubscriberSetCookieActive').and.returnValue(true); spyOn(CorePoi, 'verifyPowerOptIn').and.returnValue(new Promise(resolve => resolve(poiCookieJson))); checkOptIn().then(resultOptIn => { @@ -75,28 +74,10 @@ describe('Opt-In', () => { }); }); - it('should not try to set single opt-in if power opt-in can be verified but subscriberSetCookie is not active', (done) => { - let singleOptIn = false; - let powerOptIn = true; - spyOn(CoreCookies, 'getSoiCookie').and.returnValue({opt_in: singleOptIn}); - spyOn(CoreConfig, 'isSubscriberSetCookieActive').and.returnValue(false); - spyOn(CorePoi, 'verifyPowerOptIn').and.returnValue(new Promise(resolve => { - resolve({power_opt_in: powerOptIn, consentData: 'aConsentDataObject'}); - })); - - checkOptIn().then(resultOptIn => { - expect(resultOptIn).toBe(powerOptIn); - expect(CorePoi.verifyPowerOptIn).toHaveBeenCalled(); - expect(CoreCookies.setSoiCookieWithPoiCookieData).not.toHaveBeenCalled(); - done(); - }); - }); - it('should not try to set single opt-in if power opt-in can be verified but single opt-in is already set', (done) => { let singleOptIn = true; let powerOptIn = true; spyOn(CoreCookies, 'getSoiCookie').and.returnValue({opt_in: singleOptIn}); - spyOn(CoreConfig, 'isSubscriberSetCookieActive').and.returnValue(true); spyOn(CorePoi, 'verifyPowerOptIn').and.returnValue(new Promise(resolve => { resolve({power_opt_in: powerOptIn, consentData: 'aConsentDataObject'}); })); diff --git a/test/specs/userview/userview_handle-optin.spec.js b/test/specs/userview/userview_handle-optin.spec.js index 18664116..5b43b580 100644 --- a/test/specs/userview/userview_handle-optin.spec.js +++ b/test/specs/userview/userview_handle-optin.spec.js @@ -129,7 +129,7 @@ describe('the user view modal handles opt-in clicks on', () => { () => { expect(CoreUtils.sendEventToHostSite.calls.count()).toBe(1); expect(CoreUtils.sendEventToHostSite.calls.argsFor(0)[0]).toEqual(EVENT_NAME_POI_OPT_IN); - expect(UserviewOptIn.oilPowerOptIn).toHaveBeenCalledWith(PRIVACY_FULL_TRACKING, false); + expect(UserviewOptIn.oilPowerOptIn).toHaveBeenCalledWith(PRIVACY_FULL_TRACKING); thenOilLayerIsHidden(); done(); }, @@ -149,7 +149,7 @@ describe('the user view modal handles opt-in clicks on', () => { () => { expect(CoreUtils.sendEventToHostSite.calls.count()).toBe(1); expect(CoreUtils.sendEventToHostSite.calls.argsFor(0)[0]).toEqual(EVENT_NAME_POI_OPT_IN); - expect(UserviewOptIn.oilPowerOptIn).toHaveBeenCalledWith(PRIVACY_MINIMUM_TRACKING, false); + expect(UserviewOptIn.oilPowerOptIn).toHaveBeenCalledWith(PRIVACY_MINIMUM_TRACKING); thenOilLayerIsHidden(); done(); }, diff --git a/test/specs/userview/userview_optin.spec.js b/test/specs/userview/userview_optin.spec.js index f7009be6..175c879b 100644 --- a/test/specs/userview/userview_optin.spec.js +++ b/test/specs/userview/userview_optin.spec.js @@ -52,27 +52,12 @@ describe('user view opt-in handler', () => { }); it('should set single opt-in too if it is not prohibited', (done) => { - oilPowerOptIn(PRIVACY_SETTINGS, false).then(() => { + oilPowerOptIn(PRIVACY_SETTINGS).then(() => { expect(CoreCookies.setSoiCookie).toHaveBeenCalledWith(PRIVACY_SETTINGS); done(); }); }); - it('should not set single opt-in too if it is prohibited', (done) => { - spyOn(CoreConfig, 'isPoiActive').and.returnValue(true); - - oilPowerOptIn(PRIVACY_SETTINGS, true).then(() => { - expect(CoreCookies.setSoiCookie).not.toHaveBeenCalled(); - expect(CoreCookies.buildSoiCookie).toHaveBeenCalledWith(PRIVACY_SETTINGS); - - let payload = UserViewPoi.activatePowerOptInWithIFrame.calls.argsFor(0)[0]; - verifyThatPayloadForPowerOptInActivationIsCorrect(payload, EXPECTED_COOKIE); - - expect(CoreUtils.sendEventToHostSite).toHaveBeenCalledWith(EVENT_NAME_OPT_IN); - done(); - }); - }); - it('should activate power opt-in with iframe', (done) => { spyOn(CoreConfig, 'isPoiActive').and.returnValue(true);