Skip to main content

SoluteClient

The main client class for the Solute SDK. Create an instance to start tracking events and using feature flags.

Constructor

config
SoluteConfig
required
Configuration object for the SDK. See Configuration for all options.

Example

import { SoluteClient } from '@solute-ai/sdk';

const solute = new SoluteClient({
  apiKey: 'your_api_key',
  host: 'https://api.solute.dev',
  debug: false,
});

Methods

Event Tracking

track
(event: string, properties?: EventProperties) => void
Track a custom event. See Event Tracking Methods.
identify
(userId: string, traits?: UserTraits) => void
Identify a user. See Event Tracking Methods.
page
(name?: string, properties?: EventProperties, category?: string) => void
Track a page view. See Event Tracking Methods.
group
(groupId: string, traits?: GroupTraits) => void
Associate a user with a group. See Event Tracking Methods.
alias
(newId: string, previousId?: string) => void
Alias user identities. See Event Tracking Methods.

Feature Flags

getFeatureFlag
<T>(key: string, options?: FlagOptions) => T | undefined
Get a feature flag value. See Feature Flag Methods.
isFeatureEnabled
(key: string, options?: FlagOptions) => boolean
Check if a feature is enabled. See Feature Flag Methods.
getExperimentVariant
(key: string, options?: FlagOptions) => string | undefined
Get an experiment variant. See Feature Flag Methods.
getAllFlags
() => Record<string, FeatureFlag>
Get all feature flags. See Feature Flag Methods.
reloadFeatureFlags
(userProperties?: Record<string, any>) => Promise<void>
Reload feature flags from the server. See Feature Flag Methods.

User Management

getUserId
() => string | undefined
Get the current user ID. See User Management Methods.
getAnonymousId
() => string
Get the anonymous ID. See User Management Methods.
getSessionId
() => string
Get the current session ID. See User Management Methods.
reset
() => void
Reset user identity and start a new session. See User Management Methods.

Utilities

flush
() => Promise<void>
Flush all queued events immediately. See Event Tracking Methods.

Example

import { SoluteClient } from '@solute-ai/sdk';

// Initialize
const solute = new SoluteClient({
  apiKey: 'your_api_key',
  host: 'https://api.solute.dev',
  debug: process.env.NODE_ENV === 'development',
});

// Track events
solute.track('Button Clicked', {
  button_id: 'signup-cta',
});

// Identify user
solute.identify('user_123', {
  email: '[email protected]',
});

// Check feature flags
if (solute.isFeatureEnabled('new-checkout')) {
  // Show new checkout
}

// Get experiment variant
const variant = solute.getExperimentVariant('pricing-test');