import Message, { CustomEvent, JSException, MouseClick, NetworkRequest, SetPageLocation } from '../../common/messages.gen.js'; import App, { StartOptions } from '../app/index.js'; export interface IFeatureFlag { key: string; is_persist: boolean; value: string | boolean; payload: string; } interface Filter { filters: { operator: string; value: string[]; type: string; source?: string; }[]; operator: string; value: string[]; type: string; source?: string; } export default class ConditionsManager { private readonly app; private readonly startParams; conditions: Condition[]; hasStarted: boolean; constructor(app: App, startParams: StartOptions); setConditions(conditions: Condition[]): void; fetchConditions(projectId: string, token: string): Promise; createConditionFromFilter: (filter: Filter) => Condition | undefined; trigger(conditionName: string): void; processMessage(message: Message): void; processFlags(flag: IFeatureFlag[]): void; durationInt: ReturnType | null; processDuration(durationMs: number, condName: string): void; networkRequest(message: NetworkRequest): void; customEvent(message: CustomEvent): void; clickEvent(message: MouseClick): void; pageLocationEvent(message: SetPageLocation): void; jsExceptionEvent(message: JSException): void; } type CommonCondition = { type: 'visited_url' | 'click' | 'custom_event'; operator: keyof typeof operators; value: string[]; name: string; }; type ExceptionCondition = { type: 'exception'; operator: 'contains' | 'startsWith' | 'endsWith'; value: string[]; name: string; }; type FeatureFlagCondition = { type: 'feature_flag'; operator: 'is'; value: string[]; name: string; }; type SessionDurationCondition = { type: 'session_duration'; value: number[]; name: string; }; type SubCondition = { type: 'network_request'; key: 'url' | 'status' | 'method' | 'duration'; operator: keyof typeof operators; value: string[]; }; type NetworkRequestCondition = { type: 'network_request'; subConditions: SubCondition[]; name: string; }; type Condition = CommonCondition | ExceptionCondition | FeatureFlagCondition | SessionDurationCondition | NetworkRequestCondition; declare const operators: { is: (val: string, target: string[]) => boolean; isAny: () => boolean; isNot: (val: string, target: string[]) => boolean; contains: (val: string, target: string[]) => boolean; notContains: (val: string, target: string[]) => boolean; startsWith: (val: string, target: string[]) => boolean; endsWith: (val: string, target: string[]) => boolean; greaterThan: (val: number, target: number) => boolean; greaterOrEqual: (val: number, target: number) => boolean; lessOrEqual: (val: number, target: number) => boolean; lessThan: (val: number, target: number) => boolean; }; export {};