/** * * 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 { Context, ContextManager } from '@opentelemetry/api'; import { ContextManagerConfig } from './types'; /** * Extends otel-web stack context manager. * Due to privates being unaccessible in subclasses (_enabled) need to copy-paste everything */ export declare class SplunkContextManager implements ContextManager { protected _config: ContextManagerConfig; /** * Keeps the reference to current context */ _currentContext: Context; /** * Event listeners wrapped to resume context from event registration * * _contextResumingListeners.get(Target).get(EventType).get(origListener) */ protected _contextResumingListeners: WeakMap>>; /** * whether the context manager is enabled or not */ protected _enabled: boolean; protected _hashChangeContext: Context | null; protected _messagePorts: WeakMap; constructor(_config?: ContextManagerConfig); /** * Returns the active context */ active(): Context; /** * Binds the certain context or the active one to the target function and then returns the target * @param context A context (span) to be bind to target * @param target a function or event emitter. When target or one of its callbacks is called, * the provided context will be used as the active context for the duration of the call. */ bind(context: Context, target: T): T; /** * Disable the context manager (clears the current context) */ disable(): this; /** * Enables the context manager and creates a default(root) context */ enable(): this; /** * Calls the callback function [fn] with the provided [context]. If [context] is undefined then it will use the window. * The context will be set as active * @param context * @param fn Callback function * @param thisArg optional receiver to be used for calling fn * @param args optional arguments forwarded to fn */ with ReturnType>(context: Context | null, fn: F, thisArg?: ThisParameterType, ...args: A): ReturnType; /** * * @param target Function to be executed within the context * @param context */ protected _bindFunction unknown>(target: T, context?: Context): T; protected _getListenersMap(target: EventTarget, type: string): WeakMap | undefined; protected _getWrappedEventListener(orig: E, contextGetter: () => Context | null): E; protected _patchEvents(): void; protected _patchMessageChannel(): void; protected _patchMutationObserver(): void; protected _patchPromise(): void; protected _patchTimeouts(): void; protected _unpatchEvents(): void; protected _unpatchMessageChannel(): void; protected _unpatchMutationObserver(): void; protected _unpatchPromise(): void; protected _unpatchTimeouts(): void; /** * Bind current zone to function given in arguments * * @param args Arguments array * @param index Argument index to patch */ protected bindActiveToArgument(args: unknown[], index: number): void; }