import { ElementInteractionsOptions, ActionType, IDiagnosticsClient } from '@amplitude/analytics-core'; import type { DataSource } from '@amplitude/analytics-core/lib/esm/types/element-interactions'; import type { BaseTimestampedEvent, ElementBasedTimestampedEvent, TimestampedEvent, JSONValue } from './helpers'; import { Hierarchy } from './typings/autocapture'; import { type ElementSelectorRemoteConfig, type ElementSelectorLogger } from '@amplitude/element-selector'; import { type ShadowGate, type ShadowMode } from './shadow-mode'; export declare class DataExtractor { private readonly additionalMaskTextPatterns; diagnosticsClient?: IDiagnosticsClient; /** * Shared element-selector engine. This is the single place autocapture turns * an element into a selector string ({@link getElementPath}), so it's the * seam where the legacy `cssPath` walker is swapped for the configurable * engine. It ships dormant: with the default config (`enabled: false`) the * engine routes through the byte-identical legacy walker, so behavior is * unchanged until remote config flips an org onto the new algorithm via * {@link updateSelectorConfig}. * * The engine is shared across all DataExtractor instances to ensure * consistent selector output when both autocapture-plugin and * frustration-plugin are active. */ private readonly selectorEngine; /** * The page-scoped shadow-DOM gate. Exposed because the plugins pass it to the * observables, which both read it per callback and subscribe to its arming to * run their shadow discovery scan. See `shadow-mode.ts`. */ readonly shadowGate: ShadowGate; constructor(options: ElementInteractionsOptions, context?: { diagnosticsClient: IDiagnosticsClient; }); /** * Wrapper method to replace sensitive strings using the helper function * @param text - The text to search for sensitive data * @returns The text with sensitive data replaced by masked text */ replaceSensitiveString: (text: string | null) => string; getHierarchy: (element: Element | null) => Hierarchy; getNearestLabel: (element: Element) => string; getElementPath: (element: Element | null) => string; /** * Apply an element-selector remote-config payload to the shared engine. * Ignores `null`/absent deliveries and partial payloads that omit both * `enabled` and `shadowDomEnabled` (incomplete cache/remote handoffs must * not reset a live engine). Shadow piercing is latched via {@link ShadowGate}; * the engine's shadow fields always mirror the gate so selectors stay in * lockstep with capture. */ updateSelectorConfig: (remote?: ElementSelectorRemoteConfig | null, logger?: ElementSelectorLogger) => void; /** * The shadow-DOM mode for this page. Callable from anywhere and as often as * needed: the gate holds one value once armed, so repeated reads within a * single event resolve identically. */ getShadowMode: () => ShadowMode; getEventProperties: (actionType: ActionType, element: Element, dataAttributePrefix: string) => { [key: string]: unknown; }; addTypeAndTimestamp: (event: T, type: "error" | "navigate" | "change" | "click" | "rage" | "mutation") => BaseTimestampedEvent | ElementBasedTimestampedEvent; addAdditionalEventProperties: (event: T, type: "error" | "navigate" | "change" | "click" | "rage" | "mutation", selectorAllowlist: string[], dataAttributePrefix: string, isCapturingCursorPointer?: boolean) => TimestampedEvent; extractDataFromDataSource: (dataSource: DataSource, contextElement: HTMLElement) => string | null | undefined; private getTextWithMaskedDescendants; /** * Whether `element` or any ancestor carries the text-mask attribute. * * `Element.closest` stops at the top of the element's own tree, so it cannot * see a mask attribute on a shadow host or on a light-DOM ancestor above one. * When the mode is enabled the check uses the composed ancestor walk instead. * * The disabled path stays on `closest()` rather than the walk because * `getAncestors` stops below ``, so the walk would miss a mask attribute * set on the root element. */ private hasMaskedAncestor; getText: (element: Element) => string; getEventTagProps: (element: Element) => Record; } //# sourceMappingURL=data-extractor.d.ts.map