/** * * Copyright 2020-2026 Splunk Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ import { InstrumentationBase } from '@opentelemetry/instrumentation'; import { SplunkOtelWebConfig } from '../../types'; import { EventName, UserInteractionInstrumentationConfig } from './types'; /** * This class represents a UserInteraction plugin for auto instrumentation. * If zone.js is available then it patches the zone otherwise it patches * addEventListener of Element */ export declare class UserInteractionInstrumentation extends InstrumentationBase { private otelConfig; readonly moduleName: string; readonly version = "0.34.0"; private _eventNames; private _eventsSpanMap; private _shouldPreventSpanCreation; private _spansData; private _wrappedListeners; private _zonePatched?; constructor(config: T, otelConfig: SplunkOtelWebConfig); /** * Patches the history api */ _patchHistoryApi(): void; /** * Patches the certain history api method */ _patchHistoryMethod(): (original: any) => (this: History, ...args: unknown[]) => any; /** * unpatch the history api methods */ _unpatchHistoryApi(): void; /** * Updates interaction span name * @param url */ _updateInteractionName(url: string): void; /** * implements unpatch function */ disable(): void; /** * implements enable function */ enable(): void; /** * returns Zone */ getZoneWithPrototype(): undefined; init(): void; /** * Controls whether or not to create a span, based on the event type. */ protected _allowEventName(eventName: EventName): boolean; /** * Creates a new span * @param element * @param eventName * @param parentSpan */ private _createSpan; /** * Most browser provide event listener api via EventTarget in prototype chain. * Exception to this is IE 11 which has it on the prototypes closest to EventTarget: * * * - has addEventListener in IE * ** - has addEventListener in all other browsers * ! - missing in IE * * Element -> Node * -> EventTarget **! -> Object * Document -> Node * -> EventTarget **! -> Object * Window * -> WindowProperties ! -> EventTarget **! -> Object */ private _getPatchableEventTargets; private _invokeListener; private _isInteractiveElement; /** * This patches the addEventListener of Element to be able to * auto instrument the click events * This is done when zone is not available */ private _patchAddEventListener; /** * This patches the removeEventListener of Element to handle the fact that * we patched the original callbacks * This is done when zone is not available */ private _patchRemoveEventListener; /** * Returns true if we should use the patched callback; false if it's already been patched */ private addPatchedListener; /** * Returns the patched version of the callback (or undefined) */ private removePatchedListener; }