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

@storepecker/storefront-analytics

v1.3.1

Published

Storefront analytics client — tracks page views and e-commerce events to /spa/cad/

Readme

@storepecker/storefront-analytics

TypeScript client for the storefront analytics API. Tracks pages and events in storefront.


Install

npm install @yourorg/storefront-analytics

Setup

import { createAnalytics } from '@yourorg/storefront-analytics';

export const analytics = createAnalytics({
  baseUrl: 'https://mystore.com',
  token: getUserJwt(), // optional — include when the user is logged in
});

When token is provided, events are automatically linked to the customer's account (identity stitching). Pass undefined for anonymous visitors.

Update the token after login:

analytics.setToken(jwt);   // on login
analytics.setToken(undefined); // on logout

Page Views

Fire on every SPA route change:

// Basic
analytics.pageView({ path: '/shop/classic-cotton-tee' });

// With UTM params (read from URL query string)
analytics.pageView({
  path: '/',
});

Cart Events

// Add to cart
analytics.addToCart({ product_variant_id: 42, quantity: 2 });

// Remove from cart
analytics.removeFromCart({ product_variant_id: 42, quantity: 1 });

quantity defaults to 1 if omitted.


Checkout Funnel

Fire these in order as the customer progresses through checkout:

// 1. User arrives on checkout page
analytics.checkoutStarted({ event_value: 2500.00, item_count: 3 });

// 2. User fills in shipping address
analytics.addressEntered({ event_value: 2500.00 });

// 3. User picks a shipping method
analytics.shippingSelected({ event_value: 2500.00, shipping_method: 'standard' });

// 4. User selects payment method
analytics.paymentSelected({ event_value: 2500.00, payment_method: 'razorpay' });

// 5. User clicks "Pay Now"
analytics.paymentInitiated({ event_value: 2500.00, payment_method: 'razorpay' });

// ✓ "Order completed" is recorded server-side — no frontend call needed.

All event_value and item_count fields are optional and default to 0.

Supported payment_method values: razorpay, phonepe, stripe, cod.


API Reference

| Method | Description | |---|---| | pageView({ path, utm_params? }) | Page view on every route change | | addToCart({ product_variant_id, quantity? }) | Item added to cart | | removeFromCart({ product_variant_id, quantity? }) | Item removed from cart | | checkoutStarted({ event_value?, item_count? }) | Checkout page visited | | addressEntered({ event_value? }) | Shipping address completed | | shippingSelected({ event_value?, shipping_method? }) | Shipping method chosen | | paymentSelected({ event_value?, payment_method? }) | Payment method chosen | | paymentInitiated({ event_value?, payment_method? }) | "Pay Now" clicked | | setToken(token) | Update JWT after login/logout |

All methods return Promise<void> and throw on non-2xx responses.