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

@luminpdf/browser-braze

v0.4.0

Published

A browser-based Braze client for user engagement and messaging

Readme

@luminpdf/browser-braze

A TypeScript wrapper around the Braze Web SDK that provides a simplified, type-safe interface for integrating Braze analytics into your web applications.

Features

  • Singleton Pattern: Ensures a single instance across your application
  • Type-Safe: Full TypeScript support with proper type definitions
  • Auto-enrichment: Automatically adds common browser attributes to events
  • Simple API: Clean, intuitive methods for common Braze operations

Installation

npm install @luminpdf/browser-braze
# or
yarn add @luminpdf/browser-braze
# or
pnpm add @luminpdf/browser-braze

Basic Usage

import { BrazeClient } from "@luminpdf/browser-braze";

// Use the static factory method to get the singleton instance
const brazeClient = BrazeClient.create({
  apiKey: "YOUR_API_KEY",
  options: {
    baseUrl: "YOUR_SDK_ENDPOINT",
    enableLogging: true,
    // other Braze initialization options
  },
});

// Set user information
brazeClient.setUserInfo({
  id: "user-123",
  email: "[email protected]",
  name: "John Doe",
});

// Send an event
await brazeClient.sendEvent({
  eventName: "button_clicked",
  attributes: {
    button_name: "signup",
    page: "homepage",
  },
});

Note: Calling BrazeClient.create() multiple times will always return the same singleton instance, ensuring consistent configuration across your application.

Advanced Usage

Send Events

// Send event with immediate data flush (default behavior)
await brazeClient.sendEvent({
  eventName: "button_clicked",
  attributes: {
    button_name: "signup",
    page: "homepage",
  },
});

// Send event without immediate flush (useful for batching)
await brazeClient.sendEvent({
  eventName: "page_viewed",
  attributes: {
    page: "dashboard",
  },
  flushAll: true, // skip immediate flush
});

Manage Client Attributes

Set custom attributes that will be included with all events:

// Set client attributes
brazeClient.setClientAttributes({
  app_version: "1.2.3",
  environment: "production",
});

// Get current client attributes
const attributes = brazeClient.getClientAttributes();
console.log(attributes);

Resetting the Instance (Testing Only)

For testing purposes, you can reset the singleton instance:

// Reset the singleton (typically only used in tests)
BrazeClient.resetInstance();

// Now you can create a new instance with different config
const newClient = BrazeClient.create({
  /* different config */
});

API Reference

Static Methods

BrazeClient.create(config: BrazeClientConfig): BrazeClient

Returns the singleton instance of BrazeClient. Subsequent calls return the same instance.

BrazeClient.resetInstance(): void

Resets the singleton instance. Useful for testing purposes only.

Instance Methods

sendEvent(params): Promise<boolean>

Sends a custom event to Braze with optional attributes.

Parameters:

  • eventName (string) - Name of the event
  • attributes (TAttributes) - Custom attributes for the event
  • flushAll (boolean, optional) - If true, skips immediate data flush. Default is false, which triggers an immediate flush after logging the event.

Returns: Promise that resolves to true on success

setUserInfo(user: BrazeUser): void

Sets the current user information in Braze.

Parameters:

  • user (object)
    • id (string) - Unique user identifier
    • email (string) - User's email address
    • name (string) - User's name

setClientAttributes(attributes: Record<string, unknown>): void

Sets custom attributes that will be automatically included with all events.

getClientAttributes(): Record<string, unknown>

Returns a copy of the current client attributes.

getCommonAttributesForClient(): Record<string, unknown>

Returns common attributes including both client attributes and browser attributes.

getConfig(): Readonly<BrazeClientConfig>

Returns the current configuration.

isClientConfigured(): boolean

Returns whether the client has been configured.

Configuration Options

BrazeClientConfig

| Option | Type | Description | | --------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | | apiKey | string | Your Braze API key | | options | InitializationOptions | Braze initialization options (see Braze documentation) |

Types

BrazeUser

interface BrazeUser {
  id: string;
  email: string;
  name: string;
}

BrazeClientConfig

interface BrazeClientConfig {
  apiKey: string;
  options: InitializationOptions;
}

Dependencies

  • @braze/web-sdk - Official Braze Web SDK
  • @luminpdf/signing-miscellaneous - Utility functions for common attributes
  • lodash - Utility library

License

ISC