@hashicorp/react-consent-manager
v9.3.0
Published
A GDPR-compliant Consent Manager
Downloads
1,270
Maintainers
Keywords
Readme
Consent Manager
A GDPR-compliant consent manager.
Props
version
(integer) - version number, bump up to override previous consent preferencescontainer
(string) - id of container where the consent manager should livecompanyName
(string) - your company name to be inserted in various copyprivacyPolicyLink
(string) - link to your company's privacy policysegmentWriteKey
(string) - your production segment write keysegmentServices
(array of objects) - use this to override the category or description of a service provided by Segmentname
- name of the Segment integration, must match the integration you are overridingcategory
[optional] - new category namedescription
[optional] - new description
categories
(array) - State of togglename
- name of categorydescription
- description for the category
additionalServices
(array of objects) - additional integrations outside of Segment that you wish to include in the consent managername
- name of servicedescription
- description of servicecategory
- category of servicebody
[optional] - javascript body associated with service If present, overridesurl
belowurl
[optional] - url of js file associated with serviceasync
(bool) [optional] - addasync
property to script elementaddToBody
(bool) [optional] - inject script before closing<body>
tagdataAttrs
(arr) [optional] - array ofdata-
attributes to add to script tagname
(str) - name of data attribute (data-name
)value
(str) - value ofdata
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!