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

@86d-app/social-proof

v0.0.25

Published

Social proof and trust signals module for 86d commerce platform

Readme

[!WARNING] This project is under active development and is not ready for production use. Please proceed with caution. Use at your own risk.

Social Proof Module

Social proof and trust signals module for driving conversions. Track and display aggregate product activity — purchase counts, viewer counts, trending indicators, and recent purchase notifications. Configure trust badges (secure checkout, money-back guarantee, free shipping) to build customer confidence.

Installation

npm install @86d-app/social-proof

Usage

import socialProof from "@86d-app/social-proof";

const module = socialProof({
  maxEventsPerProduct: "5000",
  defaultPeriod: "24h",
});

Configuration

| Option | Type | Default | Description | |---|---|---|---| | maxEventsPerProduct | string | "10000" | Maximum activity events to retain per product | | defaultPeriod | string | "24h" | Default time period for activity queries |

Store Endpoints

| Method | Path | Description | |---|---|---| | POST | /social-proof/track | Record a product activity event | | GET | /social-proof/activity/:productId | Get aggregated activity stats for a product | | GET | /social-proof/trending | Get trending products by activity volume | | GET | /social-proof/badges | List active trust badges | | GET | /social-proof/recent | Get recent activity feed |

Response shapes

Track event:

{ event: ActivityEvent }

Product activity:

{
  activity: {
    productId: string;
    viewCount: number;
    purchaseCount: number;
    cartAddCount: number;
    wishlistAddCount: number;
    totalEvents: number;
    recentPurchases: Array<{
      region?: string;
      city?: string;
      country?: string;
      quantity?: number;
      createdAt: Date;
    }>;
  }
}

Trending products:

{ products: TrendingProduct[] }

Trust badges:

{ badges: TrustBadge[] }

Recent activity:

{ events: ActivityEvent[] }

Admin Endpoints

| Method | Path | Description | |---|---|---| | GET | /admin/social-proof/events | List activity events (paginated, filterable) | | GET | /admin/social-proof/summary | Activity dashboard summary | | POST | /admin/social-proof/events/cleanup | Remove events older than N days | | GET | /admin/social-proof/badges | List all trust badges | | POST | /admin/social-proof/badges/create | Create a trust badge | | POST | /admin/social-proof/badges/:id/update | Update a trust badge | | POST | /admin/social-proof/badges/:id/delete | Delete a trust badge |

Controller API

interface SocialProofController {
  /** Record a product activity event. */
  recordEvent(params: {
    productId: string;
    productName: string;
    productSlug: string;
    productImage?: string;
    eventType: ActivityEventType;
    region?: string;
    country?: string;
    city?: string;
    quantity?: number;
  }): Promise<ActivityEvent>;

  /** Get aggregated activity stats for a product within a time period. */
  getProductActivity(productId: string, params?: {
    period?: ActivityPeriod;
  }): Promise<ProductActivity>;

  /** Get recent activity events, optionally filtered by type. */
  getRecentActivity(params?: {
    eventType?: ActivityEventType;
    take?: number;
    skip?: number;
  }): Promise<ActivityEvent[]>;

  /** Get trending products ranked by activity volume. */
  getTrendingProducts(params?: {
    period?: ActivityPeriod;
    take?: number;
    skip?: number;
  }): Promise<TrendingProduct[]>;

  /** Create a trust badge. */
  createBadge(params: {
    name: string;
    description?: string;
    icon: string;
    url?: string;
    position: BadgePosition;
    priority?: number;
    isActive?: boolean;
  }): Promise<TrustBadge>;

  /** Get a trust badge by ID. */
  getBadge(id: string): Promise<TrustBadge | null>;

  /** Update a trust badge. Pass null to clear optional fields. */
  updateBadge(id: string, params: {
    name?: string;
    description?: string | null;
    icon?: string;
    url?: string | null;
    position?: BadgePosition;
    priority?: number;
    isActive?: boolean;
  }): Promise<TrustBadge | null>;

  /** Delete a trust badge. */
  deleteBadge(id: string): Promise<boolean>;

  /** List trust badges with optional filters. Sorted by priority descending. */
  listBadges(params?: {
    position?: BadgePosition;
    isActive?: boolean;
    take?: number;
    skip?: number;
  }): Promise<TrustBadge[]>;

  /** Count badges matching filters. */
  countBadges(params?: {
    position?: BadgePosition;
    isActive?: boolean;
  }): Promise<number>;

  /** Admin: list all activity events with filters. */
  listEvents(params?: {
    productId?: string;
    eventType?: ActivityEventType;
    take?: number;
    skip?: number;
  }): Promise<ActivityEvent[]>;

  /** Admin: count events matching filters. */
  countEvents(params?: {
    productId?: string;
    eventType?: ActivityEventType;
  }): Promise<number>;

  /** Admin: remove events older than N days. Returns deleted count. */
  cleanupEvents(olderThanDays: number): Promise<number>;

  /** Admin: dashboard summary with aggregated stats and top products. */
  getActivitySummary(params?: {
    period?: ActivityPeriod;
  }): Promise<ActivitySummary>;
}

Types

type ActivityEventType = "purchase" | "view" | "cart_add" | "wishlist_add";
type BadgePosition = "header" | "footer" | "product" | "checkout" | "cart";
type ActivityPeriod = "1h" | "24h" | "7d" | "30d";

interface ActivityEvent {
  id: string;
  productId: string;
  productName: string;
  productSlug: string;
  productImage?: string;
  eventType: ActivityEventType;
  region?: string;
  country?: string;
  city?: string;
  quantity?: number;
  createdAt: Date;
}

interface TrustBadge {
  id: string;
  name: string;
  description?: string;
  icon: string;
  url?: string;
  position: BadgePosition;
  priority: number;
  isActive: boolean;
  createdAt: Date;
  updatedAt: Date;
}

interface TrendingProduct {
  productId: string;
  productName: string;
  productSlug: string;
  productImage?: string;
  eventCount: number;
  purchaseCount: number;
}

interface ActivitySummary {
  totalEvents: number;
  totalPurchases: number;
  totalViews: number;
  totalCartAdds: number;
  uniqueProducts: number;
  topProducts: TrendingProduct[];
}

Store Components

<ProductActivity productId="..." period="24h" />

Displays social proof indicators on product pages: "X bought recently", "Y viewing", "Z added to cart". Only renders when there is activity data.

<TrustBadges position="product" />

Renders configurable trust badges (secure checkout, money-back guarantee, etc.) filtered by position. Uses emoji icons with optional links.

<RecentPurchases take={5} />

Shows a feed of recent purchase events with product name, location, and relative time. Each item links to the product page.

Notes

  • Events are anonymous — no customer or session IDs are stored for visitor privacy
  • Activity is aggregated in time-based periods (1h, 24h, 7d, 30d)
  • Use cleanupEvents to prevent unbounded data growth — delete events older than a retention period
  • Store badge endpoint only returns active badges; admin returns all badges
  • Trust badges support 5 positions: header, footer, product, checkout, cart
  • Recent purchases in product activity are limited to 10 most recent
  • Text inputs on admin endpoints use sanitizeText to prevent XSS