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 🙏

© 2026 – Pkg Stats / Ryan Hefner

consent-tracker

v3.1.2

Published

The consent management library that doesn't fight your design system

Readme

consent-tracker

Law requirements

According to Swedish law (lagen om elektronisk kommunikation) when a webbsite wants to store non-essential information (not strictly necessary for the website's basic functionality) on that user's browser, the user must give consent before such data is stored. GDPR further regulates how personal information must be handled and protected and require wwebsite owners to provide prof of specific user's consents.

Purpose of consent-tracker

The aim of the module is to provide a simple interface for managing user's consents alowing developers full design customization posibility for their banner. Simply put, a consent manager that doesn't fight design choices.

Functionality and limitations

This module does only provide the underlying logic for storing, retrieving and updating the consents trough simple function calls.

Providing proof of users consents is made possible trough a webhook that sends a POST request containg the user's consents and their IP at the provided webhook URL.

This module does not provide the visual banner that would get rendered in the viewport.

The module is using local storage to store the users consents.

If consents are set to false, the value won't be stored on user's machine since the user didn't consent to that.

The user's consents are valid for 12 months and automatically removed after that.

Installation

npm i consent-tracker

Then import and use the module as:

import ConsentTracker from 'consent-tracker'

const consentTracker = new ConsentTracker()

consentTracker.uppdateConsent('analytics', true)

Public API's

All methods that return or send consent data use the following structure:

{
  essential: boolean
  analytics: boolean
  marketing: boolean
  consentDate: Date
}
  • onConsentChange(callbackFunction) - Registers a callback that runs when the consent state changes. The callback receives the current consents as an object:

  • getConsents() - Returns the consents in object format or throws an error if no consent is found

  • setWebhook(endpoint) - Registers API endpoint for the webhook and sends the current consents each time they update. The sent data is POST:en as:

{
essential: boolean
analytics: boolean
marketing: boolean
consentDate: Date
userIP: string
}

[!NOTE] The user's ip is discovered trough the dependency ipify

  • setDeveloperMode() - Allows more permissive logs when seting up the webhooks. Helpful in debugging.

  • setConsents(consents) - Updates consents in bulk. The method takes an object argument as:

{
  essential: boolean
  analytics: boolean
  marketing: boolean
}
  • uppdateConsent(category, value) - Updates single category
uppdateConsent('analytics', boolean)
  • acceptAll() - Accept all the consent categories (essential, analytics, marketing) and stores them

  • declineAll() - Removes/ deletes the consent object in storage

  • hasConsents() - Returns true if there are valid consents stored otherwise returns false

Dependencyes

The module is using ipify to fetch the IP of the user leaving consents (if you are implementing webhook)

Reflections

Reflections are provided in reflections.md

Testing

Manual tests are provided in testingGuide.md

Test report is provided in testReport.md

Contributing

Found a bug or want to improve the code?