https://github.com/envato/cookie-consent
Some helper functions to deal with cookie-consent
https://github.com/envato/cookie-consent
Last synced: about 1 year ago
JSON representation
Some helper functions to deal with cookie-consent
- Host: GitHub
- URL: https://github.com/envato/cookie-consent
- Owner: envato
- License: mit
- Created: 2019-02-21T03:16:43.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2024-05-01T15:59:29.000Z (about 2 years ago)
- Last Synced: 2024-05-02T11:32:58.405Z (about 2 years ago)
- Language: TypeScript
- Size: 316 KB
- Stars: 11
- Watchers: 46
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# cookie-consent
## Overview
The npm package for cookie consent helpers. These functions are tighly coupled to using the cookiebot api at the moment.
## Usage
### Installation
```sh
npm install @envato/cookie-consent --save
# or using `yarn`
yarn add @envato/cookie-consent
```
### Examples
```js
import { Consent, consented, deferRun } from '@envato/cookie-consent'
// Check for consent inline (note that on the initial page load this function may return false)
if (consented(Consent.statistics)) {
// Do something..
}
// Manually parse and check the consent type in the CookieConsent cookie
checkCookieConsent(Cookies.get('CookieConsent'), Consent.statistics)
// Run function after consent
deferRun(() => {
doSomething()
}, Consent.marketing)
// Types of consent we support:
Consent.marketing
Consent.statistics
Consent.preferences
Consent.necessary
```
### Override CSS
There is a `cookiebot.css` in the module, you can include it to partially override the default Cookiebot style.
## Publishing
Publishing is automated via GitHub Actions. Trigger with the following steps:
1. Ensure the latest version is committed in the `package.json`. eg. `"version": "1.1.1"`
1. Ensure the latest version is tagged from `main`. eg. `git tag v1.1.1 && git push origin v1.1.1`
1. Create a release via the [Github Releases](https://github.com/envato/cookie-consent/releases)
1. Verify the build in [Github Actions](https://github.com/envato/cookie-consent/actions)
1. Verify the package published to [Github Packages](https://github.com/envato/cookie-consent/pkgs/npm/cookie-consent)
1. Verify the package published to [NPM](https://www.npmjs.com/package/@envato/cookie-consent?activeTab=versions)