import { FetchContext } from './request'; import type { EventData, SplunkEvent } from './strategy'; export { FetchContext }; export interface Config { /** * Whether or not to automatically flush batched events * after calling {@link SplunkEvent#logEvent}. * * Turned on by default. This option will also be turned * on when using `useExponentialBackoff`, regardless of the * value passed the the configuration. */ autoFlush?: boolean; /** * Whether or not to automatically retry failed flushes. */ autoRetryFlush?: boolean; /** * Timeout, in milliseconds, used to batch events together in one single request. */ debounceTime?: number; /** * Wether or not to enable debugging of the {@link SplunkEvent} class * itself. */ debug?: boolean; /** * Endpoint of your Splunk server. */ endpoint: string; /** * Host of your Splunk server. */ host?: string; /** * Whether or not to inject additional information about the user's * device and browser in the Splunk event. */ injectAdditionalInfo?: boolean; /** * @deprecated Use `injectAdditionalInfo` instead */ injectAditionalInfo?: boolean; /** * Whether or not to automatically add the timestamp to the Splunk event. */ injectTimestamp?: boolean; /** * Path of the Splunk server endpoint. */ path?: string; /** * Custom request function to use in environments where {@link window.fetch} * is not available. */ request?: (fetchContext: FetchContext) => Promise; /** * Whether or not to parse the event data in {@link SplunkEvent#logEvent}. */ shouldParseEventData?: boolean; /** * Source of the Splunk event. */ source?: string; /** * Token used to authenticate with the Splunk server. */ token: string; /** * Custom headers to be added in the request */ headers?: HeadersInit; /** * Configures the {@link SplunkEvent#flush} method to use an * exponential backoff algorithm instead of a fixed debounce time. * * Turned off by default. */ useExponentialBackoff?: boolean; /** * Maximum time, in milliseconds, to use for the exponential backoff * algorithm. * * The default limit is 60_000 milliseconds. */ exponentialBackoffLimit?: number; /** * Maximum number of retries of failed requests before dropping the events. */ maxNumberOfRetries?: number; } export default class SplunkEvents { private _requestImpl; private autoFlush; private debug; private endpoint?; private headers?; private host; private injectAdditionalInfo; private injectTimestamp; private path; private shouldParseEventData; private source; private token?; private configured; private flushStrategy; constructor(config?: Config); /** * Configure this Splunk Event instance. */ config(config: Partial): void; /** * Logs an event to Splunk. * * This method will send the data to the Splunk endpoint configured * in the {@link SplunkEvent#config} method. For now, you can only * send primitive types such as string, numbers and booleans in the * event data object. * * @argument level Level of criticity of this log, use values such as * "Critical", "Important" or "Debug" * @argument type Type of this log, use values such as "Error", "Warn" * or "Info" * @argument workflowType Type of this "workflow", you can use something * related to your application domain, such as "checkout" for events happening * in the Checkout page. * @argument workflowInstance A more fine-grained level of information * regarding the workflow, use values such as "checkout-cart" for events * that happened in the Cart page of Checkout for example. * @argument eventData Any custom event data you may find useful to log * together that can provide more information. * @argument account In multi-tenant environment it can be useful to know * the exact account this event is happening in. */ logEvent: (level: string, type: string, workflowType: string, workflowInstance: string, eventData?: EventData | null | undefined, account?: string) => void; /** * Exposes the implementation for the request function * used to send the events to the Splunk API. */ request(fetchContext: FetchContext): Promise; private parseEventData; private validateEvent; getAdditionalInfo(): "" | { additional_info: string; }; /** * Flushes pending events into one single request. * * You won't need to use this function unless you configured * this instance to not auto flush the events. */ flush: (events?: SplunkEvent[] | undefined) => Promise; private formatEventsForSplunkBatch; private validateConfig; } //# sourceMappingURL=splunk-events.d.ts.map