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. + + + +