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-pinpoint

v0.4.0

Published

A browser-based AWS Pinpoint client for analytics and engagement

Readme

PinpointClient Usage Guide

A general TypeScript class for AWS Amplify Pinpoint configuration using AWS Amplify v6.

Features

  • 🎯 Singleton Pattern: Ensures a single instance across your application
  • 🔒 Type-Safe: Full TypeScript support with proper type definitions
  • 🔌 Proxy Access: Direct access to all AWS Amplify methods through the client instance
  • 📊 Auto-enrichment: Automatically adds common browser attributes to events
  • 🎨 Simple API: Clean, intuitive methods for common Pinpoint operations

Installation

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

Basic Usage

import { PinpointClient } from "@luminpdf/browser-pinpoint";

// Use the static factory method to get the singleton instance
// All AWS Amplify members are exposed through the proxied instance
const pinpointClient = PinpointClient.create({
  region: "us-east-1",
  identityPoolId: process.env.IDENTITY_POOL_ID,
  pinpointAppId: process.env.PINPOINT_APP_ID,
  disableInDevelopment: true,
  allowGuestAccess: true,
});

// Configure page view tracking
pinpointClient.configurePageViewTracking({
  enable: true,
  eventName: "pageView",
  attributes: () => {
    // Your custom attributes (can be sync or async)
    return {
      page: globalThis.location.pathname,
      // ... other attributes
    };
  },
  onAttributesGenerated: (attributes) => {
    // Optional: Integrate with other services (e.g., Braze)
    // braze.logCustomEvent('pageView', attributes);
  },
});

// Configure session tracking
pinpointClient.configureSessionTracking({
  enable: true,
});

// Configure event tracking
pinpointClient.configureEventTracking({
  enable: true,
});

// Access all aws-amplify members directly from the client instance
// All members from 'aws-amplify' and 'aws-amplify/analytics' are exposed
pinpointClient.Amplify.configure(/* ... */);
pinpointClient.configureAutoTrack(/* ... */);
pinpointClient.record(/* ... */);
// Any other AWS Amplify method is also available

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

Advanced Usage

Recording Custom Events

// Record a custom event
await pinpointClient.recordEvent("buttonClicked", {
  buttonId: "submit-button",
  page: "/checkout",
});

Resetting the Instance (Testing Only)

For testing purposes, you can reset the singleton instance:

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

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

API Reference

Static Methods

PinpointClient.create(config: PinpointClientConfig): PinpointClientType

Returns the singleton instance of PinpointClient wrapped in a Proxy that exposes all AWS Amplify members. Subsequent calls return the same instance.

PinpointClient.resetInstance(): void

Resets the singleton instance. Useful for testing purposes only.

Instance Methods

configurePageViewTracking(config?: PageViewTrackingConfig): void

Configures automatic page view tracking.

configureSessionTracking(config?: SessionTrackingConfig): void

Configures automatic session tracking.

configureEventTracking(config?: EventTrackingConfig): void

Configures automatic event tracking.

recordEvent(eventName: string, attributes?: Record<string, string>): Promise<void>

Records a custom event with optional attributes. Automatically includes common attributes.

getConfig(): Readonly<Required<PinpointClientConfig>>

Returns the current configuration.

isClientConfigured(): boolean

Returns whether the client has been configured.

Configuration Options

PinpointClientConfig

| Option | Type | Default | Description | | ---------------------- | --------- | ------------- | -------------------------------- | | region | string | 'us-east-1' | AWS Region | | identityPoolId | string | '' | Cognito Identity Pool ID | | pinpointAppId | string | '' | Pinpoint App ID | | disableInDevelopment | boolean | true | Disable analytics in development | | allowGuestAccess | boolean | true | Allow guest access |

PageViewTrackingConfig

| Option | Type | Default | Description | | ----------------------- | ---------- | ------------ | ----------------------------------------------------- | | enable | boolean | true | Enable/disable tracking | | eventName | string | 'pageView' | Custom event name | | attributes | function | undefined | Function to get attributes (can return sync or async) | | getUrl | function | default | Function to get current URL | | immediate | boolean | true | Track immediately on load | | onAttributesGenerated | function | undefined | Callback for integrations (e.g., Braze) |

Exposed AWS Amplify Members

When using PinpointClient.create(), the returned instance is a Proxy that exposes all members from both aws-amplify and aws-amplify/analytics namespaces, in addition to the PinpointClient methods.

This means you can access any AWS Amplify method directly from the client instance:

const client = PinpointClient.create({
  /* ... */
});

// PinpointClient methods
client.configurePageViewTracking({
  /* ... */
});
client.recordEvent("eventName", {
  /* ... */
});

// All AWS Amplify members are also available
client.Amplify.configure(/* ... */);
client.configureAutoTrack(/* ... */);
client.record(/* ... */);
// Any other method from aws-amplify or aws-amplify/analytics

The Proxy pattern ensures that:

  • PinpointClient methods take precedence
  • All AWS Amplify members are accessible
  • Function bindings are preserved correctly
  • Singleton pattern maintains a single instance across the application

Migration Examples

From bananasign-web/pinpoint.js

// Before
import { Amplify } from "aws-amplify";
import { configureAutoTrack } from "aws-amplify/analytics";

const amplifyConfig = {
  Auth: {
    Cognito: {
      identityPoolId: process.env.IDENTITY_POOL_ID,
      allowGuestAccess: true,
    },
  },
  Analytics: {
    disabled: process.env.NODE_ENV === "development",
    Pinpoint: {
      appId: process.env.PINPOINT_APP_ID,
      region: "us-east-1",
      mandatorySignIn: false,
    },
  },
};

Amplify.configure(amplifyConfig);
configureAutoTrack({
  type: "pageView",
  eventName: "pageView",
  attributes: () => getPageViewAttributes(),
  getUrl: () => window.location.origin + window.location.pathname,
  immediate: true,
});

// After
import { PinpointClient } from "@luminpdf/browser-pinpoint";

const client = PinpointClient.create({
  region: "us-east-1",
  identityPoolId: process.env.IDENTITY_POOL_ID,
  pinpointAppId: process.env.PINPOINT_APP_ID,
  disableInDevelopment: process.env.NODE_ENV === "development",
  allowGuestAccess: true,
});
client.configurePageViewTracking({
  enable: true,
  eventName: "pageView",
  attributes: () => getPageViewAttributes(),
  immediate: true,
});

License

MIT