@financial-times/privacy-utils
v2.0.4
Published
A set of utilities to help with managing a user's privacy preferences
Downloads
1,499
Maintainers
Keywords
Readme
Privacy Utils
What it is
A module that exports a set of useful helper functions and types for working with privacy legislations and framework
Functions will generally be available for both server-side and client-side code
Usage
Example usage to check consent for a particular custom purpose:
- Make sure you have created/updated the custom purpose in
src/packages/privacy-utils/src/custom-purposes.ts
- Install, import and use helper function
import { checkConsentFor } from "@financial-times/privacy-utils";
const cookieConsent = getCookieValue("FTConsentV2");
const { gdpr, ccpa, leg: activeLegislation } = cookieConsent;
const consentState = {
gdpr,
ccpa,
activeLegislation,
};
const canRunPermutive = checkConsentFor("permutive", consentState); // boolean
CMP footer link util function
This package exposes a simple util function that is designed to work the FT.com footer. This function will use a querySelector to find and update the legacy 'Manage Cookie' link so that it works with the new CMP behavior. The new behavior will open the CMP Modal; whereas the legacy behavior is to take the user to the Manage Cookies Page.
Example usage
import { updateFooterLinkCMP } from "@financial-times/privacy-utils";
...
if (flagsClient.get('adsDisableInternalCMP')) {
updateFooterLinkCMP();
}