saltfish
Version:
An interactive video-guided tour system for web applications
76 lines • 3.12 kB
TypeScript
import type { ABTestConfig, ABTestAssignment, PlaylistPathInfo } from '../types';
import type { EventManager } from './EventManager';
import { EventSubscriberManager } from './EventSubscriberManager';
/**
* Manager class for handling A/B testing functionality
*
* This class handles:
* - User assignment to A/B tests based on percentage allocation
* - Playlist filtering based on test assignments
* - Test assignment persistence for identified users
* - Local-only assignments for anonymous users
*/
export declare class ABTestManager extends EventSubscriberManager {
/**
* Creates a new ABTestManager
* @param eventManager - Optional event manager to subscribe to events
*/
constructor(eventManager?: EventManager);
/**
* Subscribe to relevant events for A/B testing
*/
protected subscribeToEvents(): void;
/**
* Initialize A/B tests with configurations from backend
* @param abTests - A/B test configurations from validate-token response
*/
initializeTests(abTests: ABTestConfig[]): void;
/**
* Assign a user to A/B tests based on their ID and test percentages
* @param userId - User ID for consistent assignment
* @param existingAssignments - Existing assignments from backend (for identified users)
* @param userListAssignments - Assignments from backend for user list tests
* @returns Record of test assignments
*/
assignUserToTests(userId: string, existingAssignments?: Record<string, ABTestAssignment>, userListAssignments?: Record<string, boolean>): Record<string, ABTestAssignment>;
/**
* Determine if a user should be included in a percentage-based test using consistent hashing
* @param userId - User ID
* @param test - A/B test configuration
* @returns true if user should be in test
*/
private isUserInTest;
/**
* Get playlists that the user should see based on A/B test assignments
* @param allPlaylists - All available playlists
* @returns Filtered playlists based on A/B test assignments
*/
getFilteredPlaylists(allPlaylists: PlaylistPathInfo[]): PlaylistPathInfo[];
/**
* Track when a user participates in an A/B test (playlist starts)
* @param playlistId - ID of the playlist that started
*/
private trackTestParticipation;
/**
* Get assignments for identified users to send to backend
* @returns A/B test assignments that should be stored in backend
*/
getAssignmentsForBackend(): Record<string, ABTestAssignment>;
/**
* Check if a specific playlist is available for the current user
* @param playlistId - Playlist ID to check
* @returns true if playlist is available based on A/B test assignments
*/
isPlaylistAvailable(playlistId: string): boolean;
/**
* Get active A/B test information for analytics
* @returns Array of active test information
*/
getActiveTestInfo(): Array<{
testId: string;
testName: string;
testType: string;
assigned: boolean;
}>;
}
//# sourceMappingURL=ABTestManager.d.ts.map