13.0.1 • Published 7 months ago

@wikia/tracking-opt-in v13.0.1

Weekly downloads
11
License
Apache-2.0
Repository
github
Last release
7 months ago

tracking-opt-in

FANDOM's gdpr opt-in dialog prompt.

Installation

Using yarn:

yarn add @wikia/tracking-opt-in

Access npmjs

Access the npmjs.com UI through vault key vault read secret/app/npmjs.

Usage

The library exports one function that can be invoked to kickoff the process of showing the modal, or calling the appropriate callbacks if the user has already accepted or rejected tracking. The library is built using webpack's libraryTarget: "umd" option, so it should be usable in any of our projects.

Integration Test

  • An integration test can be run for any client by adding a additional build to their pipeline: Pipeline Syntax
  • If you do not integrate with with Jenkins you can ping a url http://jenkins:8080/view/CAKE/view/tracking-opt-in/job/external%20test/buildWithParameters?token=tracking-opt-in-external-test&testUrl=<url>&slackChannel=<slack channel>&projectName=<your app>
  • Params
    • token = tracking-opt-in-external-test (no need to change)
    • testUrl = publicly accessible url where the selenium tests will target
    • projectName = A unique per app name to organize each integration test
    • testIE = (Optional - defaults to true) Enable ie11 tests

Examples

As es6 module:

import main from '@wikia/tracking-opt-in'
...
const optIn = main(options)

As script tag:

<script src="..."></script>
...
<script>
var optIn = trackingOptIn.main(options)
</script>

Invocation of the exported function returns an instance of ConsentManagementPlatform. See below for the available functions.

Options

The following options are accepted:

  • beaconCookieName - The name of the beacon cookie that will be added to tracking calls
  • cookieName - The name of the cookie used for the user's tracking consent status. Should only be changed for development purposes. defaults to tracking-opt-in-status.
  • cookieExpiration - How long the consent cookie should last when the user accepts consent. Defaults to 50 years.
  • cookieRejectExpiration - How long the reject cookie should last when the user rejects. Defaults to 1 days.
  • country - Override the country code for determining the country the user is visiting from. Defaults to reading from the Geo cookie that should be available in all of our web apps.
  • countriesRequiringPrompt - Array of country codes that require tracking opt-in. See GeoManager for the defaults.
  • disableConsentQueue - If true then CMP will return fully opted-out consent string before user accept or reject the modal without queuing the commands
  • enabledVendorPurposes - Array of purpose IDs to be allowed on opt-in. See the IAB CMP specification for details. Defaults to all standard purposes.
  • enabledVendors - Array of vendor IDs to be allowed on opt-in. See the IAB CMP specification for details. Defaults to a list of all of Fandom's vendors who are partnered with IAB.
  • isSubjectToCcpa - Used to opt-out of sale users who are below 16 y.o.
  • isSubjectToCoppa - Same as isSubjectToCcpa. Takes precendence over isSubjectToCcpa. Left for backwards compatibility.
  • language - Override the language used to display the dialog text. Defaults to window.navigator.language if available, otherwise to en.
  • preventScrollOn - Prevent scrolling on the specified element when the dialog is shown. Can be either an element or query selector passed to document.querySelector. Defaults to 'body', set to null to prevent this behavior.
  • queryParam - The name of the query param to forcefully set the accepted status. Defaults to tracking-opt-in-status and accepts the string values true or false (e.g http://starwars.wikia.com/?tracking-opt-in-status=true)
  • track - Whether to track impressions and user consent/rejections. Defaults to true.
  • zIndex - Useful if elements on the app are appearing above the overlay/modal. Defaults to 1000.
  • onAcceptTracking - The callback fired when:
    • the user's geo does not require tracking consent
    • the user accepts non-IAB vendor tracking
    • the user has already accepted tracking (subsequent page load)
  • onRejectTracking - The callback fired when:
    • the user rejects non-IAB vendor tracking
    • the user has already rejected tracking (subsequent page load)
  • isCurse - Optional boolean that generates a different privacy link on curse products

Notes

  • onAcceptTracking and onRejectTracking are the key options that should be overridden by each app to either initialize their respective trackers or to somehow react to the user's rejection of tracking.
  • As of v2.0.0, accepting or rejecting vendor tracking should not affect any GA or internal tracking unrelated to advertising.
  • Country codes are in ISO 3166-1 format.

ConsentManagementPlatform class

Calling the exported function returns an instance of the ConsentManagementPlatform class. The class has the following functions:

  • hasUserConsented() - Returns true if the user has accepted non-IAB vendor tracking (or does not need to based on their geo), false if they have explicitly rejected tracking, and undefined if the user has neither accepted nor rejected tracking.
  • geoRequiresTrackingConsent() - Returns true if the user's geo requires consent, false otherwise.
  • reset() - Clears the opt-in cookie and runs through the rendering rules again.
  • clear() - Clears the opt-in cookie
  • render() - Runs through the rendering rules and either renders the opt-in prompt or calls the appropriate onAcceptTracking/onRejectTracking callbacks.

Local Development

Installation

$> yarn install

Running demo site

$> yarn start:dev

Open up http://localhost:3000. Webpack HMR should update the app as you develop.

The main entry point is src/index.js.

Running Tests

To run a single pass over the tests:

$> yarn test

To run the tests in watch mode so that changes re-run the tests:

$> yarn test:watch

Selenium Testing

FANDOM uses BrowserStack to assist our automated testing efforts. BrowserStack Status

To run the selenium tests locally first run yarn start:prod in one terminal then, in a separate terminal, run BROWSERSTACK_KEY=<browser-stack> BROWSERSTACK_USERNAME=<username> USE_TUNNEL=true yarn test:selenium

12.0.0

9 months ago

12.0.1

9 months ago

13.0.0

7 months ago

13.0.1

7 months ago

12.2.1

8 months ago

12.2.2

7 months ago

12.2.3

7 months ago

12.2.4

7 months ago

12.1.1

9 months ago

10.2.2

11 months ago

11.0.0

11 months ago

11.2.0

11 months ago

11.1.0

11 months ago

9.5.2

1 year ago

9.4.6

2 years ago

9.4.3

2 years ago

9.4.2

2 years ago

9.4.1

2 years ago

9.4.0

2 years ago

9.4.9

1 year ago

9.4.8

1 year ago

9.4.7

1 year ago

9.4.16-alpha

1 year ago

9.4.19-alpha-2

1 year ago

9.4.21-alpha

1 year ago

8.2.0

2 years ago

0.0.0

1 year ago

9.0.0

2 years ago

9.2.3

2 years ago

9.2.2

2 years ago

9.2.1

2 years ago

8.4.1

2 years ago

8.4.0

2 years ago

8.4.3

2 years ago

8.4.2

2 years ago

9.4.15

1 year ago

9.4.14

1 year ago

9.4.13

1 year ago

8.3.0

2 years ago

9.4.12

1 year ago

9.4.19

1 year ago

9.4.18

1 year ago

9.4.17

1 year ago

9.4.16

1 year ago

9.4.11

1 year ago

9.4.10

1 year ago

9.1.0

2 years ago

9.4.19-alpha

1 year ago

9.3.4

2 years ago

9.3.3

2 years ago

9.3.2

2 years ago

9.3.1

2 years ago

9.3.0

2 years ago

9.4.23

1 year ago

9.4.22

1 year ago

9.4.21

1 year ago

9.4.20

1 year ago

9.2.0

2 years ago

7.3.0

2 years ago

7.4.1

2 years ago

6.13.2

2 years ago

6.13.1

2 years ago

6.13.0

2 years ago

8.1.0

2 years ago

7.0.0

2 years ago

7.4.0

2 years ago

7.0.1

2 years ago

6.12.0

2 years ago

7.5.2

2 years ago

7.5.1

2 years ago

7.5.0

2 years ago

6.7.1

3 years ago

7.1.0

2 years ago

6.11.0

2 years ago

7.6.0

2 years ago

6.8.0

3 years ago

7.2.1

2 years ago

7.2.0

2 years ago

6.10.1

2 years ago

6.10.0

3 years ago

8.0.1

2 years ago

8.0.0

2 years ago

8.0.2

2 years ago

6.9.0

3 years ago

6.5.0

3 years ago

6.6.0

3 years ago

6.7.0

3 years ago

6.3.0

3 years ago

6.4.0

3 years ago

6.2.5

3 years ago

6.2.4

3 years ago

6.2.3

3 years ago

6.2.2

3 years ago

6.2.1

3 years ago

6.2.0

3 years ago

6.1.2

3 years ago

6.1.1

3 years ago

6.1.0

3 years ago

6.0.8

3 years ago

6.0.7

3 years ago

6.0.6

3 years ago

6.0.3

3 years ago

6.0.2

3 years ago

6.0.5

3 years ago

6.0.4

3 years ago

6.0.1

3 years ago

6.0.0

3 years ago

5.3.0

3 years ago

5.2.0

3 years ago

5.1.1

4 years ago

5.1.0

4 years ago

5.0.0

4 years ago

4.5.1

4 years ago

4.4.0

4 years ago

4.5.0

4 years ago

4.3.0

4 years ago

4.2.3

4 years ago

4.2.2

4 years ago

4.2.1

4 years ago

4.2.0

4 years ago

4.0.18

4 years ago

4.1.0

4 years ago

4.0.17

4 years ago

4.0.16

4 years ago

4.0.15

4 years ago

4.0.14

4 years ago

4.0.12

4 years ago

4.0.13

4 years ago

4.0.11

4 years ago

4.0.10

4 years ago

4.0.9

4 years ago

4.0.8

4 years ago

4.0.7

4 years ago

4.0.6

4 years ago

4.0.5

4 years ago

4.0.4

4 years ago

4.0.3

4 years ago

4.0.2

4 years ago

4.0.1

4 years ago

4.0.0

4 years ago

3.0.6

4 years ago

3.0.5

4 years ago

3.0.4

4 years ago

3.0.3

4 years ago

3.0.2

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.3.0

4 years ago

2.2.0

4 years ago

2.1.2

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.6

5 years ago

2.0.6-pre2

5 years ago

2.0.6-pre1

5 years ago

2.0.5

5 years ago

2.0.4

5 years ago

2.0.4-pre1

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

2.0.0-pre7

5 years ago

2.0.0-pre6

5 years ago

2.0.0-pre5

5 years ago

2.0.0-pre4

5 years ago

2.0.0-pre3.11

5 years ago

1.0.41

5 years ago

1.0.40

5 years ago

1.0.39

6 years ago

1.0.38

6 years ago

1.0.37

6 years ago

1.0.36

6 years ago

1.0.35

6 years ago

1.0.34

6 years ago

1.0.33

6 years ago

1.0.32

6 years ago

1.0.31

6 years ago

1.0.30

6 years ago

1.0.29

6 years ago

1.0.28

6 years ago

1.0.27

6 years ago

1.0.26

6 years ago

1.0.25

6 years ago

1.0.24

6 years ago

1.0.23

6 years ago

1.0.22

6 years ago

1.0.21

6 years ago

1.0.20

6 years ago

1.0.19

6 years ago

1.0.18

6 years ago

1.0.17

6 years ago

1.0.16

6 years ago

1.0.15

6 years ago

1.0.14

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago