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

@meowwolf/cookie-consent-utils

v1.2.0

Published

A collection of utilities for managing cookie consent. Used to manage cookie consent across meow wolf sites.

Readme

Cookie Consent Utils

A lightweight collection of TypeScript utility functions for managing privacy consent across Meow Wolf sites, built around Cloudflare Zaraz's Consent API, the Global Privacy Control (GPC) signal, and Segment.

Features

  • Integrates with Segment (@segment/analytics-next and @segment/analytics-consent-tools) to delay loading until Zaraz consent is resolved
  • Automatically synchronizes consent category preferences with Segment tracking calls
  • Displays the Zaraz privacy consent modal on demand
  • Honors the browser's Global Privacy Control (GPC) signal, opting users out automatically when enabled
  • Synchronizes consent state with the Zaraz Consent API on page load
  • Automatically reloads the page on consent choice updates so changes take effect immediately

Installation

npm install @meowwolf/cookie-consent-utils

This package is published as compiled JavaScript with bundled type declarations (dist/index.d.ts), so no separate @types package is needed.

Quick start

import {
  handlePrivacyOnClick,
  loadSegmentWithConsent,
} from '@meowwolf/cookie-consent-utils';

// Initialize Segment tracking with Zaraz consent management.
window.analytics = loadSegmentWithConsent('YOUR_SEGMENT_WRITE_KEY');

// Wire up a "Privacy Settings" link/button to open the Zaraz consent modal.
document
  .querySelector('#privacy-settings-link')
  ?.addEventListener('click', handlePrivacyOnClick);

// Track page views or events as usual; outgoing calls are buffered and
// dispatched according to user consent once Zaraz is ready.
window.analytics.page();

How it works

  • Segment integration: loadSegmentWithConsent creates an AnalyticsBrowser instance wrapped with Zaraz consent management using @segment/analytics-consent-tools. Segment loading is delayed until the Zaraz Consent API is ready (zarazConsentAPIReady).
  • Consent synchronization: When Zaraz is ready, the library synchronizes consent state with Zaraz (opting users in by default if no choices exist yet, or denying consent if GPC is active).
  • Consent cookie & categories: Zaraz stores the user's consent choices in a cookie named zaraz-consent. Category preferences are extracted from this cookie and automatically attached to Segment's consent context.
  • GPC takes precedence: Whenever navigator.globalPrivacyControl is true, the library treats the user as opted out, regardless of what is stored in the consent cookie.
  • Consent updates: When the user updates their choices in the Zaraz modal (zarazConsentChoicesUpdated), the new category preferences are saved and the page is reloaded so changes take effect immediately.
  • window.zaraz: The Zaraz Consent API (window.zaraz) is injected at runtime by the Cloudflare Zaraz script and is not bundled with this package. Functions that touch window.zaraz no-op safely if it is not present yet.

API Reference

loadSegmentWithConsent(writeKeyOrSettings: string | AnalyticsBrowserSettings, options?: InitOptions, consentOptions?: ConsentOptions): AnalyticsBrowser

Creates an AnalyticsBrowser instance wrapped with Zaraz consent management and begins loading Segment:

  • Delays Segment and device-mode destination initialization until Zaraz is ready.
  • Automatically stamps outgoing events with the user's consent category preferences.
  • Honors GPC signals and listens for consent preference changes.
  • Safe to use synchronously in React components/hooks as well as vanilla JS (buffered pre-initialization calls are preserved and dispatched once consent resolves).
  • If Zaraz doesn't report ready within 3 seconds, loads Segment with JaAU: false (required cookies only) and calls consentOptions.onZarazUnavailable({ timeoutMs, zarazDefined }) once, so the site can report it to error monitoring:
window.analytics = loadSegmentWithConsent('YOUR_SEGMENT_WRITE_KEY', undefined, {
  onZarazUnavailable: (details) => Sentry.captureMessage('Zaraz consent API not ready', { level: 'warning', extra: details }),
})

handlePrivacyOnClick(e: Event): void

Click handler for privacy-related elements (e.g. a "Privacy Settings" link). Prevents the default action and opens the Zaraz consent modal (window.zaraz.consent.modal = true).

<a href="/privacy" onClick={handlePrivacyOnClick}>Privacy Settings</a>

Requirements

  • These utilities are designed to run in a browser context (they read document.cookie and window/navigator globals) and assume the Cloudflare Zaraz script is loaded on the page for consent-modal and consent-sync features to take effect.

Development

This project uses pnpm. Common scripts:

pnpm install       # install dependencies
pnpm run build     # compile TypeScript to dist/
pnpm run lint      # lint with ESLint
pnpm test          # run the test suite (Vitest)
pnpm run test:watch     # run tests in watch mode
pnpm run test:coverage  # run tests with coverage
pnpm release       # interactively bump version and create a release branch

See CONTRIBUTING.md for local setup, branching model, and the release process, and DEPLOYMENT.md for details on the CI/publish pipeline.

License

ISC