@hashicorp/react-consent-manager

9.2.0 • Public • Published

Consent Manager

A GDPR-compliant consent manager.

Props

  • version (integer) - version number, bump up to override previous consent preferences
  • container (string) - id of container where the consent manager should live
  • companyName (string) - your company name to be inserted in various copy
  • privacyPolicyLink (string) - link to your company's privacy policy
  • segmentWriteKey (string) - your production segment write key
  • segmentServices (array of objects) - use this to override the category or description of a service provided by Segment
    • name - name of the Segment integration, must match the integration you are overriding
    • category [optional] - new category name
    • description [optional] - new description
  • categories (array) - State of toggle
    • name - name of category
    • description - description for the category
  • additionalServices (array of objects) - additional integrations outside of Segment that you wish to include in the consent manager
    • name - name of service
    • description - description of service
    • category - category of service
    • body [optional] - javascript body associated with service If present, overrides url below
    • url [optional] - url of js file associated with service
    • async (bool) [optional] - add async property to script element
    • addToBody (bool) [optional] - inject script before closing <body> tag
    • dataAttrs (arr) [optional] - array of data- attributes to add to script tag
      • name (str) - name of data attribute (data-name)
      • value (str) - value of data attribute to set

Upgrading from v8 to v9

npm install @hashicorp/react-consent-manager@latest

Warning: v9 is technically not a breaking change, but there are some significant changes to be aware of with regards to our analytics.

As of v9.0.0, the Segment CDN hostname has been replace with a HashiCorp hostname via analytics._cdn. A custom Segment Analytics.js URL is also being used. There is no breaking change to the react component API.

SegmentPreloadScript

In v9.0.0, ConsentManager now exports a SegmentPreloadScript component. Why? ConsentManager uses a very similar Segment script to the current preloading script that we use in our _document.tsx/js files.

Now that we're updating both with a custom Segment AJS URL and CDN hostname, it makes sense for the two to be co-located.

Expect the new change to look like the following:

// pages/_document.tsx


  import Document, { Html, Head, Main, NextScript } from 'next/document'
  import HashiHead from '@hashicorp/react-head'
+ import { SegmentPreloadScript } from '@hashicorp/react-consent-manager/scripts/segment'
  // other imports

  export default class MyDocument extends Document {
    static async getInitialProps(ctx) {
      const initialProps = await Document.getInitialProps(ctx)
      return { ...initialProps }
    }

    render() {
      return (
        <Html lang="en">
          <Head>
            <HashiHead />
          </Head>
          <body>
-           <script
-             dangerouslySetInnerHTML={{
-               __html: `!function(){var analytics=window... ... ...`
-             }}
-           />
+           <SegmentPreloadScript />

// etc...

No additional updates are necessary!

Readme

Keywords

none

Package Sidebar

Install

npm i @hashicorp/react-consent-manager

Weekly Downloads

3,948

Version

9.2.0

License

MPL-2.0

Unpacked Size

71.7 kB

Total Files

22

Last publish

Collaborators

  • abhishek-hashicorp
  • dstaley
  • cameronperera
  • alexju
  • consul-ui-services
  • wenincode-hashicorp
  • hashicb
  • britt.lindgren
  • paulhcp
  • nandereck
  • tstormk
  • hashibot-hds
  • lackeyjb1
  • youriwims
  • jpogran
  • _natmegs
  • thrashr888
  • melsumner
  • mwickett
  • didoo
  • zchsh
  • hcitsec
  • gregone
  • meirish
  • enmod
  • kaxcode
  • anubhavmishra-hashicorp
  • hashibot-web
  • cstitt-hashi
  • kstraut
  • mocohen
  • dhaulagiri