Skip to content

Commit

Permalink
Merge pull request #251 from as-ideas/OIL-336-poi-write-soi
Browse files Browse the repository at this point in the history
removes poi_subscriber_set_cookie
  • Loading branch information
rbuer committed May 6, 2019
2 parents b521003 + fd574bb commit b131a4c
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 71 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion docs/src/docs/03-configuration.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
| <<preview_mode,preview_mode>> | 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 <<Language label configuration>> for details. | false
Expand Down
4 changes: 0 additions & 4 deletions src/scripts/core/core_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/scripts/core/core_constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/core/core_optin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
35 changes: 17 additions & 18 deletions src/scripts/userview/userview_modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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());
Expand All @@ -99,8 +99,8 @@ export function oilShowPreferenceCenter() {
currentPrivacySettings = getAdvancedSettingsPurposesDefault() ? getPurposeIds() : [];
}
applyPrivacySettings(currentPrivacySettings);
})
})
});
});
})
.catch((error) => logError(error));
}
Expand All @@ -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);
Expand Down Expand Up @@ -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();
}
}
Expand All @@ -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();
}
}
Expand All @@ -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 => {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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(() => {
Expand All @@ -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 {
Expand All @@ -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);
}
Expand Down
11 changes: 3 additions & 8 deletions src/scripts/userview/userview_optin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -61,7 +57,6 @@ export function oilPowerOptIn(privacySettings, powerOnly = false) {
});
}


/**
* Oil SOI optIn
*
Expand Down
19 changes: 0 additions & 19 deletions test/specs/optin.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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'});
}));
Expand Down
4 changes: 2 additions & 2 deletions test/specs/userview/userview_handle-optin.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},
Expand All @@ -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();
},
Expand Down
17 changes: 1 addition & 16 deletions test/specs/userview/userview_optin.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit b131a4c

Please sign in to comment.