Skip to content

Commit

Permalink
Removes GA measurement API integration from banner (#265)
Browse files Browse the repository at this point in the history
* Removes GA measreument API form banner

* remove mention of tid in docs

---------

Co-authored-by: Sarah Richards <[email protected]>
  • Loading branch information
mjbp and sarah-storm authored Sep 26, 2024
1 parent bded3b2 commit 83e7890
Show file tree
Hide file tree
Showing 25 changed files with 33 additions and 594 deletions.
2 changes: 0 additions & 2 deletions docs/cookie-banner.html
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ <h2 id="usage">Usage</h2>
<pre><code>import banner from '@stormid/cookie-banner';

const cookieBanner = banner({
tid: 'UA-XXXXXXXX-X',
types: {
'performance': {
suggested: true, //set as pre-checked on consent form as a suggested response
Expand Down Expand Up @@ -255,7 +254,6 @@ <h2 id="usage">Usage</h2>
<h2 id="options">Options</h2>
<pre><code>{
name: '.CookiePreferences', //name of the cookie set to record user consent
tid: '', // Google Analytics tracking id for Measurement API event tracking
path: '/', //path of the preferences cookie
domain: window.location.hostname === 'localhost' ? '' : `.${removeSubdomain(window.location.hostname)}`, //domain of the preferences cookie, defaults to .&lt;root-domain&gt;
secure: true, //preferences cookie secure
Expand Down
4 changes: 0 additions & 4 deletions packages/cookie-banner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ GDPR compliant cookie banner and consent form.

Renders a cookie banner and a consent form based on configuration settings, and conditionally invokes cookie-reliant functionality based on user consent.

Optionally send anonymous [predefined cookie banner and consent form interaction measurements](./measurements.md) to a specified Google Analytics using the Google Measurement API.

---

## Usage
Expand Down Expand Up @@ -38,7 +36,6 @@ Initialise the module (example configuration shown below)
import banner from '@stormid/cookie-banner';
const cookieBanner = banner({
tid: 'UA-XXXXXXXX-X',
types: {
'performance': {
suggested: true, //set as pre-checked on consent form as a suggested response
Expand Down Expand Up @@ -78,7 +75,6 @@ const cookieBanner = banner({
```
{
name: '.CookiePreferences', //name of the cookie set to record user consent
tid: '', // Google Analytics tracking id for Measurement API event tracking
path: '/', //path of the preferences cookie
domain: window.location.hostname === 'localhost' ? '' : `.${removeSubdomain(window.location.hostname)}`, //domain of the preferences cookie, defaults to .<root-domain>
secure: true, //preferences cookie secure
Expand Down
2 changes: 0 additions & 2 deletions packages/cookie-banner/__tests__/banner/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const init = () => {
cookieBanner({
secure: false,
hideBannerOnFormPage: false,
tid: 'UA-XXXXX-Y',
types: {
test: {
title: 'Test title',
Expand Down Expand Up @@ -51,7 +50,6 @@ describe(`Cookie banner > DOM > not render`, () => {
cookieBanner({
secure: false,
hideBannerOnFormPage: true,
tid: 'UA-XXXXX-Y',
types: {
test: {
title: 'Test title',
Expand Down
1 change: 0 additions & 1 deletion packages/cookie-banner/__tests__/banner/showBanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const init = () => {
document.body.innerHTML = `<main></main>`;
instance = cookieBanner({
secure: false,
tid: 'UA-XXXXX-Y',
types: {
test: {
title: 'Test title',
Expand Down
2 changes: 1 addition & 1 deletion packages/cookie-banner/__tests__/consent.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe(`Cookie banner > consent > callback`, () => {
}
};

const state = { settings: {tid: 'UA-XXXXX-Y', types}, consent: { test: 1, test2: 0 }};
const state = { settings: { types }, consent: { test: 1, test2: 0 }};
applyEffects(state);
expect(document.getElementById('test').textContent).toEqual("Consent given");
expect(document.getElementById('test2').textContent).toEqual("");
Expand Down
7 changes: 2 additions & 5 deletions packages/cookie-banner/__tests__/cookies.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const init = () => {
window.__cb__ = cookieBanner({
secure: false,
hideBannerOnFormPage: false,
tid: 'UA-141774857-1',
types: {
test: {
title: 'Test title',
Expand Down Expand Up @@ -41,15 +40,13 @@ describe(`Cookie banner > cookies > update`, () => {

it('Sets a cookie based on preferences form', async () => {
document.querySelector(`.${defaults.classNames.acceptBtn}`).click();
//get the cid from state
const cid = window.__cb__.getState().persistentMeasurementParams.cid;
expect(document.cookie).toEqual(`${defaults.name}=${btoa(`{"consent":{"test":1,"performance":1},"cid":"${cid}"}`)}`);
expect(document.cookie).toEqual(`${defaults.name}=${btoa(`{"consent":{"test":1,"performance":1}}`)}`);

const fields = Array.from(document.querySelectorAll(`.${defaults.classNames.field}`));
fields[1].checked = true;
fields[3].checked = true;
document.querySelector(`.${defaults.classNames.submitBtn}`).click();
expect(document.cookie).toEqual(`${defaults.name}=${btoa(`{"consent":{"test":0,"performance":0},"cid":"${cid}"}`)}`);
expect(document.cookie).toEqual(`${defaults.name}=${btoa(`{"consent":{"test":0,"performance":0}}`)}`);
});

});
Expand Down
1 change: 0 additions & 1 deletion packages/cookie-banner/__tests__/form/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ describe(`Cookie banner > DOM > form > render by api`, () => {
const instance = cookieBanner({
secure: false,
hideBannerOnFormPage: false,
tid: 'UA-XXXXX-Y',
types: {
test: {
suggested: true,
Expand Down
5 changes: 1 addition & 4 deletions packages/cookie-banner/__tests__/form/interactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ describe(`Cookie banner > DOM > form interactions`, () => {
window.__cb__ = cookieBanner({
secure: false,
hideBannerOnFormPage: false,
tid: 'UA-141774857-1',
types: {
test: {
title: 'Test title',
Expand Down Expand Up @@ -59,9 +58,7 @@ describe(`Cookie banner > DOM > form interactions`, () => {

it('Submit button should set the cookie and hide the banner', async () => {
document.querySelector(`.${defaults.classNames.acceptBtn}`).click();
//get the cid from state
const cid = window.__cb__.getState().persistentMeasurementParams.cid;
expect(document.cookie).toEqual(`${defaults.name}=${btoa(`{"consent":{"test":1,"performance":1},"cid":"${cid}"}`)}`);
expect(document.cookie).toEqual(`${defaults.name}=${btoa(`{"consent":{"test":1,"performance":1}}`)}`);
expect(document.querySelector(`.${defaults.classNames.banner}`)).toBeNull();
});
});
1 change: 0 additions & 1 deletion packages/cookie-banner/__tests__/form/not-render.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import defaults from '../../src/lib/defaults';
describe(`Cookie banner > DOM > form > not render`, () => {
document.body.innerHTML = `<div></div>`;
cookieBanner({
tid: 'UA-XXXXX-Y',
types: {
test: {
title: 'Test title',
Expand Down
1 change: 0 additions & 1 deletion packages/cookie-banner/__tests__/form/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ describe(`Cookie banner > DOM > form > render`, () => {
cookieBanner({
secure: false,
hideBannerOnFormPage: false,
tid: 'UA-XXXXX-Y',
types: {
test: {
suggested: true,
Expand Down
53 changes: 0 additions & 53 deletions packages/cookie-banner/__tests__/measure/init.js

This file was deleted.

This file was deleted.

47 changes: 0 additions & 47 deletions packages/cookie-banner/__tests__/measure/measurements/options.js

This file was deleted.

Loading

0 comments on commit 83e7890

Please sign in to comment.