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

@walkeros/web-source-session

v2.0.1

Published

Session source for walkerOS

Readme

@walkeros/web-source-session

Standalone session detection and management for walkerOS.

Source Code | NPM | Documentation

Quick Start

import { startFlow } from '@walkeros/collector';
import { sourceBrowser } from '@walkeros/web-source-browser';
import { sourceSession } from '@walkeros/web-source-session';

const { collector, elb } = await startFlow({
  sources: {
    browser: sourceBrowser,
    session: {
      code: sourceSession,
      config: {
        settings: {
          storage: true, // Enable persistent session storage
        },
      },
    },
  },
});

Features

  • Session detection: Automatic detection of new sessions based on navigation, referrer, and marketing parameters
  • Device tracking: Persistent device ID across sessions (with consent)
  • Consent-aware: Switches between window-only and storage-based sessions based on user consent
  • Composable: Works alongside any source (browser, dataLayer, custom)

Installation

npm install @walkeros/web-source-session

Why Separate Session Source?

The session source was extracted from the browser source to enable:

  1. Composability: Use session detection with any source, not just browser
  2. Single responsibility: Browser source focuses on DOM events, session source on identity
  3. Flexibility: Configure session independently from event capture
  4. Server-side ready: Session logic can work with server sources too

Configuration Reference

| Name | Type | Description | Default | | ---------------- | -------------------------- | ------------------------------------------------ | ---------------- | | storage | boolean | Enable persistent storage for session/device IDs | false | | consent | string \| string[] | Consent key(s) required to enable storage mode | - | | length | number | Session timeout in minutes | 30 | | pulse | boolean | Keep session alive on each event | false | | sessionKey | string | Storage key for session ID | 'elbSessionId' | | sessionStorage | 'local' \| 'session' | Storage type for session | 'local' | | deviceKey | string | Storage key for device ID | 'elbDeviceId' | | deviceStorage | 'local' \| 'session' | Storage type for device | 'local' | | cb | SessionCallback \| false | Custom callback or disable default | - |

Examples

Basic (Window-only)

No persistent storage, session detected per page load:

const { elb } = await startFlow({
  sources: {
    browser: sourceBrowser,
    session: sourceSession, // Defaults to window-only mode
  },
});

With Persistent Storage

Store session and device IDs in localStorage:

const { elb } = await startFlow({
  sources: {
    browser: sourceBrowser,
    session: {
      code: sourceSession,
      config: {
        settings: {
          storage: true,
          length: 30, // 30-minute session timeout
        },
      },
    },
  },
});

Consent-Aware

Switch to storage mode only when user grants consent:

const { elb } = await startFlow({
  sources: {
    browser: sourceBrowser,
    session: {
      code: sourceSession,
      config: {
        settings: {
          consent: 'analytics', // Wait for analytics consent
          storage: true,
        },
      },
    },
  },
});

// Later, when user grants consent:
elb('walker consent', { analytics: true });
// Session source automatically switches to storage mode

Session Start Event

When a new session is detected, the source pushes a session start event:

{
  name: 'session start',
  data: {
    isStart: true,
    id: 'abc123',      // Session ID
    device: 'xyz789',  // Device ID (if storage enabled)
    storage: true,     // Whether storage mode is active
    // ... additional session metadata
  }
}

Migration from Browser Source

If you were using the browser source with session enabled:

// Before (browser source with built-in session)
const { elb } = await startFlow({
  sources: {
    browser: {
      code: sourceBrowser,
      config: { settings: { session: true } },
    },
  },
});

// After (separate session source)
const { elb } = await startFlow({
  sources: {
    browser: sourceBrowser,
    session: {
      code: sourceSession,
      config: { settings: { storage: true } },
    },
  },
});

Exported Functions

The session source exports session functions for direct usage:

import {
  // Session functions
  sessionStart,
  sessionWindow,
  sessionStorage,
} from '@walkeros/web-source-session';

// Use sessionStart directly (advanced usage)
const session = sessionStart({
  storage: true,
  collector: collectorInstance,
});

Storage utilities are available from @walkeros/web-core:

import { storageRead, storageWrite, storageDelete } from '@walkeros/web-core';

storageWrite('key', 'value', 30); // 30-minute expiration
const value = storageRead('key');
storageDelete('key');

Type Definitions

See src/types/index.ts for TypeScript interfaces.

Related