2.24.0 • Published 11 months ago

@transferwise/cookie-consent v2.24.0

Weekly downloads
1,404
License
UNLICENSED
Repository
github
Last release
11 months ago

Cookie consent

npm

This repo contains helper functions to make your application compliant with ICO regulations. How to make your application compliant with ICO regulations

Install

yarn add @transferwise/cookie-consent

Use

hasValidConsent()

import { hasValidConsent } from "@transferwise/cookie-consent";

if (hasValidConsent()) {
  mixpanel.opt_in_tracking();
}

hasValidConsent() checks the cookie consent from document.cookie. If consent cookie is not there or document is undefined then it will return false.

cookie.write(string, object(optional))

import { cookie } from "@transferwise/cookie-consent";

cookie.write(
  "username=John Doe; expires=Thu, 18 Dec 2013 12:00:00 UTC; path=/"
);

cookie.write(string, object) takes 2 arguments:

  1. cookie name, value and params you want to write to document.cookie
  2. Optional: object that contains value if the cookie is essential - if it's true then we will add it to document.cookie even when we don't have consent How to know if my cookie is essential?

Adding essential cookie:

import { cookie } from "@transferwise/cookie-consent";

cookie.write(
  "username=John Doe; expires=Thu, 18 Dec 2013 12:00:00 UTC; path=/",
  { essential: true }
);

Test

yarn test

Constants & cookie policy

The package also includes the constants used when creating the consent cookie, and a JSON representation of the cookie policy.

These are typically utilised by the consent mechansim, audit tooling (e.g., cookie monster).

Releasing a new version

  1. Make your changes and write tests for it
  2. Bump the version (We follow semver) and update CHANGELOG.md
  3. Create a PR and ask for a code review in #marketing-platform-dev
  4. Merge to master after it's approved
  5. Enjoy your new version in NPM
2.24.0

11 months ago

2.23.1

2 years ago

2.21.0

2 years ago

2.23.0

2 years ago

2.20.0

2 years ago

2.22.0

2 years ago

2.21.1

2 years ago

2.19.0

2 years ago

2.18.1

2 years ago

2.18.0

2 years ago

2.17.0

3 years ago

2.15.2

4 years ago

2.16.0

3 years ago

2.15.0

4 years ago

2.15.1

4 years ago

2.14.0

4 years ago

2.15.1-alpha.1

4 years ago

2.13.0

4 years ago

2.12.0

4 years ago

2.11.0

4 years ago

2.10.0

4 years ago

2.9.0

4 years ago

2.8.0

5 years ago

2.7.0

5 years ago

2.6.0

5 years ago

2.5.1

5 years ago

2.5.0

5 years ago

2.4.1

5 years ago

2.4.0

5 years ago

2.3.0

5 years ago

2.2.1

5 years ago

2.2.0

5 years ago

2.1.0

5 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.0

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago