npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hashicorp/react-consent-manager

v9.3.0

Published

A GDPR-compliant Consent Manager

Downloads

2,160

Readme

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!