UNPKG

@trlogic/tracker-web

Version:
26 lines (25 loc) 1.22 kB
import { DataCollector } from "src/core/contract/DataCollector"; import { ConfigItem } from "src/core/model/TrackerConfig"; import { TrackerVariableType } from "src/core/model/TrackerVariableType"; /** * Base collector with lazy evaluation and variable mapping. * Mirrors Android BaseDataCollector. * * Collectors only evaluate a variable if it is mapped in the backend config. */ export declare abstract class BaseDataCollector implements DataCollector { abstract collect(): Map<TrackerVariableType, unknown>; /** * Only call the supplier if the variable is actually mapped in at least one config. * This is the "lazy evaluation" pattern from Android. */ protected collectIfNeeded(data: Map<TrackerVariableType, unknown>, variableType: TrackerVariableType, supplier: () => unknown, configs?: ConfigItem[]): void; /** * Maps collected TrackerVariableType → backend field names using config variableMappings. */ static mapVariablesToBackend(config: ConfigItem, variables: Map<TrackerVariableType, unknown>): Record<string, unknown>; /** * Check if a variable type is mapped in any config's variableMappings. */ private static isVariableMapped; }