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

@session-services/sdk

v0.1.33

Published

Official Session Services API SDK for JavaScript/TypeScript

Readme

@session-services/sdk

Official JavaScript/TypeScript SDK for the Session Services API.

Installation

npm install @session-services/sdk

Browser Bundlers

Bundlers that honor the package browser export condition automatically use the browser-safe build for the root import. The explicit browser entry point is also available when you want to guarantee that selection:

import { createClient } from '@session-services/sdk/browser';

CDN Usage

Use directly in browsers via unpkg:

<script type="module">
  import { createClient } from 'https://unpkg.com/@session-services/sdk@latest/dist/browser.mjs';

  const client = createClient({
    environment: 'prod',
    tenantId: 'your-tenant-id'
  });

  const { event } = await client.event.get({ key: 'event-slug' });
</script>

Pin @latest to an exact SDK version in production.

Quick Start

import { createClient } from '@session-services/sdk';

const client = createClient({
  environment: 'sandbox',
  tenantId: 'your-tenant-id'
});

const { event } = await client.event.get({ key: 'event-slug' });

Configuration

| Option | Type | Description | |--------|------|-------------| | environment | 'sandbox' \| 'prod' \| string | API environment or custom URL | | tenantId | string | Tenant ID (defaults to Session Services) | | headers | Record<string, string> | Additional request headers |

const client = createClient({
  environment: 'prod',
  tenantId: 'your-tenant-id',
  headers: { 'X-Custom-Header': 'value' }
});

API Reference

Full API documentation: https://api.session.services/docs

The client provides typed methods matching the API structure:

// Pattern: client.{resource}.{method}({ ...params })
await client.event.get({ key: 'event-id' });
await client.event.list({});
await client.order.get({ key: 'order-id' });

React Query Integration

import { createQueryClient } from '@session-services/sdk';
import { QueryClientProvider, QueryClient } from '@tanstack/react-query';

const queryClient = new QueryClient();
const api = createQueryClient({
  environment: 'prod',
  tenantId: 'your-tenant-id'
});

function App() {
  return (
    <QueryClientProvider client={queryClient}>
      <EventList />
    </QueryClientProvider>
  );
}

function EventList() {
  const { data } = api.event.list.useQuery({});
  return <ul>{data?.items.map(e => <li key={e.id}>{e.name}</li>)}</ul>;
}

Analytics

The SDK includes analytics for tracking events to Session Services and third-party pixels (Facebook, Google Analytics, TikTok).

Analytics monetary fields (price, value, total, revenue, and product price) use major currency units, not minor units. For example, send 99.00 for USD 99.00. The formatPrice utility below is for display and accepts minor units.

Vanilla JavaScript

import { createClient } from '@session-services/sdk';
import { createAnalytics } from '@session-services/sdk/analytics';

const client = createClient({ environment: 'prod', tenantId: '...' });
const analytics = createAnalytics({ client, debug: true });

// Track events
analytics.track('Product Viewed', {
  promoter_id: 'prm_123',
  event_id: 'evt_456',
  product_id: 'tkt_abc',
  name: 'VIP Ticket',
  price: 99.00,
  currency: 'USD'
});

// Page views
analytics.page('Event Page', { promoter_id: 'prm_123' });

// Identify users
analytics.identify('user_123', { promoter_id: 'prm_123' });

// Reset session (e.g., on logout)
analytics.reset();

React Hooks

import { createClient } from '@session-services/sdk';
import { AnalyticsProvider } from '@session-services/sdk/analytics/react';

const client = createClient({ environment: 'prod', tenantId: '...' });

function App() {
  return (
    <AnalyticsProvider client={client} debug={false}>
      <TicketPage />
    </AnalyticsProvider>
  );
}

useTrack

Track custom events:

import { useTrack } from '@session-services/sdk/analytics/react';

function AddToCartButton() {
  const track = useTrack();

  const handleClick = () => {
    track('Product Added', {
      promoter_id: 'prm_123',
      event_id: 'evt_456',
      product_id: 'tkt_abc',
      price: 99.00
    });
  };

  return <button onClick={handleClick}>Add to Cart</button>;
}

usePageView

Automatic page view tracking:

import { usePageView } from '@session-services/sdk/analytics/react';

function EventPage() {
  usePageView('Event Page', { promoter_id: 'prm_123', event_id: 'evt_456' });

  return <div>Event content...</div>;
}

useIdentify

Identify users after login:

import { useIdentify } from '@session-services/sdk/analytics/react';

function LoginSuccess({ userId }) {
  const identify = useIdentify();

  useEffect(() => {
    identify(userId, { promoter_id: 'prm_123', email: '[email protected]' });
  }, [userId]);
}

useReset

Reset session on logout:

import { useReset } from '@session-services/sdk/analytics/react';

function LogoutButton() {
  const reset = useReset();
  return <button onClick={reset}>Logout</button>;
}

useAnalytics

Direct access to all analytics methods:

import { useAnalytics } from '@session-services/sdk/analytics/react';

function MyComponent() {
  const analytics = useAnalytics();

  // Access all methods: track, page, screen, identify, reset, group, alias
  analytics?.track('Custom Event', { promoter_id: 'prm_123' });
}

Standard Events

| Event | Description | Required Properties | |-------|-------------|---------------------| | Product Viewed | User viewed a ticket/product | promoter_id, product_id, name, price | | Product Added | Added to cart | promoter_id, product_id, price, quantity | | Checkout Started | Began checkout flow | promoter_id, products, total, currency | | Order Completed | Purchase complete | promoter_id, order_id, total, currency, products |

All events require promoter_id to route analytics to the correct destinations. Use major currency units for monetary analytics properties. Use minor units only with formatPrice and internal ticketing price breakdown fields such as price_base and price_booking_fee.

Pixel Integrations

Analytics automatically routes events to third-party pixels based on promoter configuration:

  1. Session Services - All events are sent to the Session Services analytics backend
  2. Facebook Pixel - If promoter has fbId configured
  3. Google Analytics - If promoter has gaId configured
  4. TikTok Pixel - If promoter has tikTokId configured

The SDK fetches promoter pixel configuration automatically using the promoter_id in your event properties. No additional setup required.

Utilities

formatPrice

Format prices from minor units to localized currency strings:

import { formatPrice } from '@session-services/sdk/analytics';

formatPrice(9900, 'USD');  // "$99.00"
formatPrice(9900, 'EUR');  // "99,00 €"
formatPrice(9900, 'GBP');  // "£99.00"
formatPrice(9900, 'AUD');  // "$99.00"

Error Handling

import { safe, isDefinedError } from '@session-services/sdk';

const [error, result] = await safe(client.event.get({ key: 'event-id' }));

if (isDefinedError(error)) {
  console.error(`API Error [${error.code}]:`, error.message);
} else if (error) {
  console.error('Network error:', error.message);
} else {
  console.log(result.event.name);
}

Entry Points

| Import | Description | |--------|-------------| | @session-services/sdk | Client creation, error utilities | | @session-services/sdk/browser | Explicit browser-safe client build | | @session-services/sdk/analytics | Vanilla analytics (createAnalytics, formatPrice) | | @session-services/sdk/analytics/react | React hooks (AnalyticsProvider, useTrack, usePageView, useIdentify, useReset, useAnalytics) | | @session-services/sdk/schemas | Public Zod schemas for validation | | @session-services/sdk/contract | Public oRPC contract |

TypeScript

The package includes declarations, declaration maps, and their matching source files so editor navigation can inspect the underlying contract and schemas. API inputs and responses are inferred directly from the contract:

import type { AppClient, AppContract } from '@session-services/sdk';
import type { Analytics, EventProperties } from '@session-services/sdk/analytics';

Use @session-services/sdk/schemas to inspect or import the curated public Zod schema surface, and @session-services/sdk/contract when integrating directly with oRPC tooling. Internal service routes and schemas are intentionally not part of the published SDK contract.

Runtime Support

ES modules and CommonJS are supported on Node.js 20.19 or newer in the Node 20 line, and Node.js 22.12 or newer. Browser applications should use a modern bundler or the explicit browser/CDN entry points above.

License

MIT