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
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-sensitiveattributes - Ignores elements with
pt-ignoreclass - Blocks elements with
pt-blockclass
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
- Initialize Early: Start the tracker as early as possible in your application lifecycle.
- Tag Important Events: Use
addTag()to mark significant user actions. - Handle Errors: Implement error tagging to track and analyze issues.
- Respect Privacy: Use the provided classes to exclude or mask sensitive information.
- 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.