Skip to main content

Overview

The MentiQ Analytics SDK is initialized with an AnalyticsConfig object that controls its behavior, tracking features, and performance characteristics.

Basic Configuration

Configuration Options

Required Parameters

string
required
Your MentiQ API key for authentication
string
required
Your MentiQ project identifier

Endpoint Configuration

string
default:"https://api.mentiq.io"
Custom API endpoint URL for self-hosted or regional deployments

User Identification

string
Initial user ID to set on initialization. Can also be set later using identify()

Session Management

number
default:"1800000"
Session timeout in milliseconds. Default is 30 minutes (30 * 60 * 1000)

Event Batching

number
default:"20"
Number of events to batch before automatic flush
number
default:"10000"
Interval in milliseconds to automatically flush events. Default is 10 seconds
number
default:"1000"
Maximum number of events to queue before dropping oldest events

Retry Configuration

number
default:"3"
Number of times to retry failed event sends
number
default:"1000"
Initial delay in milliseconds before retry (uses exponential backoff)

Automatic Tracking

boolean
default:"true"
Automatically track page views, including SPA navigation (pushState/replaceState)
boolean
default:"false"
Automatically track page performance metrics (load time, FCP, LCP, etc.)
boolean
default:"false"
Enable heatmap tracking for clicks, mouse movements, and scrolls
boolean
default:"false"
Enable session recording functionality
boolean
default:"false"
Automatically track JavaScript errors and unhandled promise rejections

A/B Testing

boolean
default:"false"
Enable A/B testing features
ABTestConfig
Additional A/B testing configuration options

Debugging

boolean
default:"false"
Enable debug logging to console

Advanced Configuration Examples

Minimal Configuration

Performance-Optimized Configuration

Development Configuration

Accessing Configuration

You can access the current configuration using the config property:

Runtime Updates

Most configuration options are set at initialization and cannot be changed at runtime. To change configuration, create a new Analytics instance:

Best Practices

Use environment variables for sensitive configuration like API keys:
Be cautious with enableHeatmapTracking and enableSessionRecording as they can generate large amounts of data and impact performance.
Enable debug mode during development to see detailed logs of SDK operations.