Skip to content

Sessions

The Sessions module provides functionality to track and analyze user interactions while respecting privacy and optimizing performance.

Overview

The Session Tracker allows you to capture and analyze user interactions with your application, helping you understand user behavior and identify potential issues.

Basic Usage

typescript
import { SessionTracker } from '@your-sdk/core';

// Initialize the tracker
const sessionTracker = new SessionTracker();

// Start recording a session
sessionTracker.start();

// Add custom tags for important events
sessionTracker.addTag('pageView', { page: 'checkout' });

// Stop recording when done
sessionTracker.stop();

Key Features

Event Tracking

  • Captures user interactions and navigation
  • Tracks custom events and tags
  • Optimized for performance with smart sampling

Privacy Protection

  • Automatically masks sensitive information
  • Respects data-sensitive attributes
  • Ignores elements with pt-ignore class
  • Blocks elements with pt-block class

Performance Optimization

  • Efficient data collection with configurable sampling
  • Smart buffering to minimize memory usage
  • Configurable event collection intervals

Methods

start(): void

Starts the session recording. No parameters required.

stop(): void

Stops the current recording session.

addTag(type: string, data?: Record<string, any>): void

Adds a custom tag to the current session.

addErrorTag(error: TrackedError): void

Adds an error event to the session.

addRageClickTag(count: number): void

Marks a rage click event in the session.

addConversionTag(step: string): void

Tracks conversion steps in the session.

isRecording(): boolean

Returns true if a session is currently being recorded.

Best Practices

  1. Initialize Early: Start the tracker as early as possible in your application lifecycle.
  2. Tag Important Events: Use addTag() to mark significant user actions.
  3. Handle Errors: Implement error tagging to track and analyze issues.
  4. Respect Privacy: Use the provided classes to exclude or mask sensitive information.
  5. Clean Up: Always call stop() when the session ends to free resources.

Configuration

You can customize the session tracking behavior by passing a configuration object when initializing the tracker. See the Configuration Guide for more details.

Troubleshooting

If you encounter any issues with session tracking, please refer to the Troubleshooting Guide or contact support.


Note: All session data is collected and processed in compliance with our privacy policy and data protection regulations.