@analytics/session-utils

0.2.0 • Public • Published

Session Utilities

A tiny session utility library in 775 bytes.

  • Persisted Sessions - saved as cookie for 30min
    • getSession
    • setSession
  • Tab Sessions - saved until tab/window closed
    • getTabSession
    • setTabSession
  • Page Sessions - saved until page changes
    • getPageSession
    • setPageSession

See live demo.

Example

import { getSession, setSession } from '@analytics/session-utils'

const currentSession = getSession()
console.log('currentSession', currentSession)

// Update session
const newSessionInfo = setSession()
console.log('newSessionInfo', newSessionInfo)

About

┌─────────────────────────────────────────────────────────────────┐
│                        Persisted Session                        │
│                                                                 │
│   ┌──────────────────────────┐    ┌──────────────────────────┐  │
│   │       Tab Session        │    │       Tab Session        │  │
│   │                          │    │                          │  │
│   │  ┌────────────────────┐  │    │  ┌────────────────────┐  │  │
│   │  │    Page Session    │  │    │  │    Page Session    │  │  │
│   │  │                    │  │    │  │                    │  │  │
│   │  │                    │  │    │  │                    │  │  │
│   │  │                    │  │    │  │                    │  │  │
│   │  │                    │  │    │  │                    │  │  │
│   │  │                    │  │    │  │                    │  │  │
│   │  │                    │  │    │  │                    │  │  │
│   │  │                    │  │    │  │                    │  │  │
│   │  │                    │  │    │  │                    │  │  │
│   │  └────────────────────┘  │    │  └────────────────────┘  │  │
│   └──────────────────────────┘    └──────────────────────────┘  │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Package Sidebar

Install

npm i @analytics/session-utils

Weekly Downloads

6,256

Version

0.2.0

License

MIT

Unpacked Size

109 kB

Total Files

21

Last publish

Collaborators

  • davidwells