From 6d2e4095dad472c55310ddd437936cc055a8cbeb Mon Sep 17 00:00:00 2001 From: Netto Farah Date: Tue, 8 Oct 2019 14:25:49 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=99=85=F0=9F=8F=BB=E2=80=8D=E2=99=80?= =?UTF-8?q?=EF=B8=8FNo=20longer=20imply=20consent=20on=20interaction=20(#4?= =?UTF-8?q?7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * No longer imply consent on interaction * Add example --- README.md | 2 +- package.json | 2 +- .../consent-manager-builder/index.todo.js | 20 ++++++ src/consent-manager/index.tsx | 12 ++-- stories/0-consent-manager.stories.tsx | 8 +-- stories/ImplyConsentOnInteraction.tsx | 62 +++++++++++++++++++ stories/common-react.tsx | 56 +++++++++++++++++ stories/standalone-custom.html | 1 - stories/standalone.html | 1 - yarn.lock | 58 +++++++++++++---- 10 files changed, 196 insertions(+), 26 deletions(-) create mode 100644 stories/ImplyConsentOnInteraction.tsx create mode 100644 stories/common-react.tsx diff --git a/README.md b/README.md index 9452e75c..d70640c8 100644 --- a/README.md +++ b/README.md @@ -177,7 +177,7 @@ Callback function that determines if consent is required before tracking can beg ##### implyConsentOnInteraction Type: `boolean`
-Default: `true` +Default: `false` Whether or not consent should be implied if the user interacts with the website (clicks anywhere outside the consent manager banner or dialogs). diff --git a/package.json b/package.json index f645884c..efd4fabf 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,7 @@ "@typescript-eslint/parser": "^2.3.3", "babel-loader": "^8.0.6", "concurrently": "^3.5.1", - "enzyme": "^3.3.0", + "enzyme": "^3.10.0", "enzyme-adapter-react-16": "^1.1.1", "eslint": "^6.5.1", "eslint-config-prettier": "^6.4.0", diff --git a/src/__tests__/consent-manager-builder/index.todo.js b/src/__tests__/consent-manager-builder/index.todo.js index 9b53f7fa..b972a307 100644 --- a/src/__tests__/consent-manager-builder/index.todo.js +++ b/src/__tests__/consent-manager-builder/index.todo.js @@ -149,6 +149,26 @@ describe('ConsentManagerBuilder', () => { ) }) + test('does not imply consent on interacation', done => { + nock('https://cdn.segment.com') + .get('/v1/projects/123/integrations') + .reply(200, [ + { + name: 'Amplitude', + creationName: 'Amplitude' + } + ]) + + shallow( + + {({ preferences }) => { + expect(preferences).toMatchObject({}) + done() + }} + + ) + }) + test.todo('loads analytics.js normally when consent isn՚t required') test.todo('still applies preferences when consent isn՚t required') test.todo('provides a setPreferences() function for setting the preferences') diff --git a/src/consent-manager/index.tsx b/src/consent-manager/index.tsx index da678003..b8d712e6 100644 --- a/src/consent-manager/index.tsx +++ b/src/consent-manager/index.tsx @@ -16,7 +16,7 @@ export default class ConsentManager extends PureComponent true, - implyConsentOnInteraction: true, + implyConsentOnInteraction: false, onError: undefined, cookieDomain: undefined, bannerTextColor: '#fff', @@ -62,8 +62,8 @@ export default class ConsentManager extends PureComponent ( - { + return - )} + }} ) } diff --git a/stories/0-consent-manager.stories.tsx b/stories/0-consent-manager.stories.tsx index 91820f54..b602f492 100644 --- a/stories/0-consent-manager.stories.tsx +++ b/stories/0-consent-manager.stories.tsx @@ -3,6 +3,7 @@ import cookies from 'js-cookie' import { Pane, Heading, Button } from 'evergreen-ui' import { ConsentManager, openConsentManager } from '../src' import { storiesOf } from '@storybook/react' +import { ImplyConsentOnInteraction } from './ImplyConsentOnInteraction' const bannerContent = ( @@ -67,7 +68,6 @@ const ConsentManagerExample = () => { otherWriteKeys={['vMRS7xbsjH97Bb2PeKbEKvYDvgMm5T3l']} bannerContent={bannerContent} bannerSubContent={bannerSubContent} - implyConsentOnInteraction={false} preferencesDialogTitle={preferencesDialogTitle} preferencesDialogContent={preferencesDialogContent} cancelDialogTitle={cancelDialogTitle} @@ -112,6 +112,6 @@ const ConsentManagerExample = () => { ) } -storiesOf('React ConsentManager', module).add(`Basic React Component`, () => ( - -)) +storiesOf('React ConsentManager', module) + .add(`Basic React Component`, () => ) + .add(`Basic React Component with implied consent`, () => ) diff --git a/stories/ImplyConsentOnInteraction.tsx b/stories/ImplyConsentOnInteraction.tsx new file mode 100644 index 00000000..0935ad16 --- /dev/null +++ b/stories/ImplyConsentOnInteraction.tsx @@ -0,0 +1,62 @@ +import React from 'react' +import cookies from 'js-cookie' +import { Pane, Heading, Button, Paragraph } from 'evergreen-ui' +import { ConsentManager, openConsentManager } from '../src' +import { + bannerContent, + bannerSubContent, + preferencesDialogContent, + preferencesDialogTitle, + cancelDialogContent, + cancelDialogTitle +} from './common-react' + +export const ImplyConsentOnInteraction = () => { + return ( + + + + + Your website content + + Clicking anywhere on this page will cause the Consent Manager to imply consent. + + + +