UNPKG

@safaricom-mxl/core

Version:

MXL Javascript agent core

979 lines (941 loc) 34.8 kB
interface ApiConfig { baseUrl: string; defaultHeaders?: Record<string, string | Promise<string | null>>; maxRetries?: number; initialRetryDelay?: number; } interface FetchOptions extends RequestInit { retries?: number; } declare class Api { private baseUrl; private headers; private maxRetries; private initialRetryDelay; private retryAttempts; constructor(config: ApiConfig); addHeader(key: string, value: string | Promise<string | null>): void; onSuccess(): void; onError(): void; fetch<ReqBody, ResBody>({ path, data, options, useBeacon, }: { path: string; data: ReqBody; options?: FetchOptions; useBeacon?: boolean; }): Promise<ResBody | null>; private resolveHeaders; private retry; private fallbackRequest; } /** * Given a child DOM element, returns a query-selector statement describing that * and its ancestors * e.g. [HTMLElement] => body > div > input#foo.btn[name=baz] * @returns generated a DOM path */ declare function htmlTreeAsString(elem: unknown, options?: string[] | { keyAttrs?: string[]; maxStringLength?: number; }): string; /** * A safe form of location.href */ declare function getLocationHref(): string; /** * Given a DOM element, traverses up the tree until it finds the first ancestor node * that has the `data-mxl-component` or `data-mxl-element` attribute with `data-mxl-component` taking * precedence. This attribute is added at build-time by projects that have the component name annotation plugin installed. * * @returns a string representation of the component for the provided DOM element, or `null` if not found */ declare function getComponentName(elem: unknown): string | null; type SdkSource = 'npm' | 'cdn' | 'loader'; /** * Figures out if we're building a browser bundle. * * @returns true if this is a browser bundle build. */ declare function isBrowserBundle(): boolean; /** * Get source of SDK. */ declare function getSDKSource(): SdkSource; /** * NOTE: In order to avoid circular dependencies, if you add a function to this module and it needs to print something, * you must either a) use `console.log` rather than the logger, or b) put your function elsewhere. * * Note: This file was originally called `global.ts`, but was changed to unblock users which might be doing * string replaces with bundlers like Vite for `global` (would break imports that rely on importing from utils/src/global). * * Why worldwide? * * Why not? */ /** Internal global with common properties and MXL extensions */ type InternalGlobal = { navigator?: { userAgent?: string; maxTouchPoints?: number; }; console: Console; PerformanceObserver?: any; MXL?: any; onerror?: { (event: object | string, source?: string, lineno?: number, colno?: number, error?: Error): any; __MXL_INSTRUMENTED__?: true; }; onunhandledrejection?: { (event: unknown): boolean; __MXL_INSTRUMENTED__?: true; }; MXL_ENVIRONMENT?: string; MXL_DSN?: string; MXL_RELEASE?: { id?: string; }; MXL_SDK_SOURCE?: SdkSource; /** * Debug IDs are indirectly injected by Sentry CLI or bundler plugins to directly reference a particular source map * for resolving of a source file. The injected code will place an entry into the record for each loaded bundle/JS * file. */ _mxlDebugIds?: Record<string, string>; /** * Raw module metadata that is injected by bundler plugins. * * Keys are `error.stack` strings, values are the metadata. */ _mxlModuleMetadata?: Record<string, any>; _mxlEsmLoaderHookRegistered?: boolean; }; /** Get's the global object for the current JavaScript runtime */ declare const GLOBAL_OBJ: InternalGlobal; interface StackFrame { filename?: string; function?: string; module?: string; platform?: string; lineno?: number; colno?: number; abs_path?: string; context_line?: string; pre_context?: string[]; post_context?: string[]; in_app?: boolean; instruction_addr?: string; addr_mode?: string; vars?: { [key: string]: any; }; debug_id?: string; module_metadata?: any; } /** JSDoc */ interface Stacktrace { frames?: StackFrame[]; frames_omitted?: [number, number]; } type StackParser = (stack: string, skipFirstLines?: number, framesToPop?: number) => StackFrame[]; type StackLineParserFn = (line: string) => StackFrame | undefined; type StackLineParser = [number, StackLineParserFn]; type Primitive = number | string | boolean | bigint | symbol | null | undefined; type HttpHeaderValue = string | string[] | number | null; /** * Event-like interface that's usable in browser and node. * * Note: Here we mean the kind of events handled by event listeners, not our `Event` type. * * Property availability taken from https://developer.mozilla.org/en-US/docs/Web/API/Event#browser_compatibility */ interface PolymorphicEvent { readonly type: string; readonly target?: unknown; readonly currentTarget?: unknown; [key: string]: unknown; } /** A `Request` type compatible with Node, Express, browser, etc., because everything is optional */ type PolymorphicRequest = BaseRequest & BrowserRequest & NodeRequest & ExpressRequest & KoaRequest & NextjsRequest; type BaseRequest = { method?: string; url?: string; }; type BrowserRequest = BaseRequest; type NodeRequest = BaseRequest & { headers?: { [key: string]: string | string[] | undefined; }; protocol?: string; socket?: { encrypted?: boolean; remoteAddress?: string; }; }; type KoaRequest = NodeRequest & { host?: string; hostname?: string; ip?: string; originalUrl?: string; }; type NextjsRequest = NodeRequest & { cookies?: { [key: string]: string; }; query?: { [key: string]: any; }; }; type ExpressRequest = NodeRequest & { baseUrl?: string; body?: string | { [key: string]: any; }; host?: string; hostname?: string; ip?: string; originalUrl?: string; route?: { path: string; stack: [ { name: string; } ]; }; query?: { [key: string]: any; }; user?: { [key: string]: any; }; _reconstructedRoute?: string; }; type ParameterizedString = string & { __mxl_template_string__?: string; __mxl_template_values__?: string[]; }; /** * A function that MXL possibly wraps. */ type WrappedFunction<T extends Function = Function> = T & { __mxl_wrapped__?: WrappedFunction<T>; __mxl_original__?: T; }; type SeverityLevel = 'fatal' | 'error' | 'warning' | 'log' | 'info' | 'debug'; /** * Holds meta-information to customize the behavior of server-side event processing. **/ interface DebugMeta { images?: Array<DebugImage>; } type DebugImage = WasmDebugImage | SourceMapDebugImage | MachoDebugImage; interface WasmDebugImage { type: 'wasm'; debug_id: string; code_id?: string | null; code_file: string; debug_file?: string | null; } interface SourceMapDebugImage { type: 'sourcemap'; code_file: string; debug_id: string; } interface MachoDebugImage { type: 'macho'; debug_id: string; image_addr: string; image_size?: number; code_file?: string; } /** * Metadata about a captured exception, intended to provide a hint as to the means by which it was captured. */ interface Mechanism { /** * For now, restricted to `onerror`, `onunhandledrejection` (both obvious), `instrument` (the result of * auto-instrumentation), and `generic` (everything else). Converted to a tag on ingest. */ type: string; /** * In theory, whether or not the exception has been handled by the user. In practice, whether or not we see it before * it hits the global error/rejection handlers, whether through explicit handling by the user or auto instrumentation. * Converted to a tag on ingest and used in various ways in the UI. */ handled?: boolean; /** * Arbitrary data to be associated with the mechanism (for example, errors coming from event handlers include the * handler name and the event target. Will show up in the UI directly above the stacktrace. */ data?: { [key: string]: string | boolean; }; /** * True when `captureException` is called with anything other than an instance of `Error` (or, in the case of browser, * an instance of `ErrorEvent`, `DOMError`, or `DOMException`). causing us to create a synthetic error in an attempt * to recreate the stacktrace. */ synthetic?: boolean; /** * Describes the source of the exception, in the case that this is a derived (linked or aggregate) error. * * This should be populated with the name of the property where the exception was found on the parent exception. * E.g. "cause", "errors[0]", "errors[1]" */ source?: string; /** * Indicates whether the exception is an `AggregateException`. */ is_exception_group?: boolean; /** * An identifier for the exception inside the `event.exception.values` array. This identifier is referenced to via the * `parent_id` attribute to link and aggregate errors. */ exception_id?: number; /** * References another exception via the `exception_id` field to indicate that this exception is a child of that * exception in the case of aggregate or linked errors. */ parent_id?: number; } /** JSDoc */ interface Exception { type?: string; value?: string; mechanism?: Mechanism; module?: string; thread_id?: number; stacktrace?: Stacktrace; } type AttachmentType = 'event.attachment' | 'event.minidump' | 'event.applecrashreport' | 'unreal.context' | 'unreal.logs' | 'event.view_hierarchy'; /** * An attachment to an event. This is used to upload arbitrary data to Sentry. * * Please take care to not add sensitive information in attachments. */ interface Attachment { /** * The attachment data. Can be a string or a binary data (byte array) */ data: string | Uint8Array; /** * The name of the uploaded file without a path component */ filename: string; /** * The content type of the attachment payload. Defaults to `application/octet-stream` if not specified. * * Any valid [media type](https://www.iana.org/assignments/media-types/media-types.xhtml) is allowed. */ contentType?: string; /** * The type of the attachment. Defaults to `event.attachment` if not specified. */ attachmentType?: AttachmentType; } interface Event { [key: string]: any; } /** * The type of `Event`. * Note that `ErrorEvent's do not have a type (hence its undefined), * while all other events are required to have one. */ type EventType = 'transaction' | 'profile' | 'replay_event' | 'feedback' | undefined; interface ErrorEvent extends Event { type: undefined; } interface TransactionEvent extends Event { type: 'transaction'; } /** JSDoc */ interface EventHint { event_id?: string; captureContext?: any; mechanism?: Partial<Mechanism>; syntheticException?: Error | null; originalException?: unknown; attachments?: Attachment[]; data?: any; integrations?: string[]; } type Extra = unknown; type Extras = Record<string, Extra>; /** * Checks whether given value's type is one of a few Errors or Error-like * {@link isError}. * * @param wat A value to be checked. * @returns A boolean representing the result. */ declare function isError(wat: unknown): wat is Error; /** * Checks whether given value's type is ErrorEvent * {@link isErrorEvent}. * * @param wat A value to be checked. * @returns A boolean representing the result. */ declare function isErrorEvent(wat: unknown): boolean; /** * Checks whether given value's type is DOMError * {@link isDOMError}. * * @param wat A value to be checked. * @returns A boolean representing the result. */ declare function isDOMError(wat: unknown): boolean; /** * Checks whether given value's type is DOMException * {@link isDOMException}. * * @param wat A value to be checked. * @returns A boolean representing the result. */ declare function isDOMException(wat: unknown): boolean; /** * Checks whether given value's type is a string * {@link isString}. * * @param wat A value to be checked. * @returns A boolean representing the result. */ declare function isString(wat: unknown): wat is string; /** * Checks whether given string is parameterized * {@link isParameterizedString}. * * @param wat A value to be checked. * @returns A boolean representing the result. */ declare function isParameterizedString(wat: unknown): wat is ParameterizedString; /** * Checks whether given value is a primitive (undefined, null, number, boolean, string, bigint, symbol) * {@link isPrimitive}. * * @param wat A value to be checked. * @returns A boolean representing the result. */ declare function isPrimitive(wat: unknown): wat is Primitive; /** * Checks whether given value's type is an object literal, or a class instance. * {@link isPlainObject}. * * @param wat A value to be checked. * @returns A boolean representing the result. */ declare function isPlainObject(wat: unknown): wat is Record<string, unknown>; /** * Checks whether given value's type is an Event instance * {@link isEvent}. * * @param wat A value to be checked. * @returns A boolean representing the result. */ declare function isEvent(wat: unknown): wat is PolymorphicEvent; /** * Checks whether given value's type is an Element instance * {@link isElement}. * * @param wat A value to be checked. * @returns A boolean representing the result. */ declare function isElement(wat: unknown): boolean; /** * Checks whether given value's type is an regexp * {@link isRegExp}. * * @param wat A value to be checked. * @returns A boolean representing the result. */ declare function isRegExp(wat: unknown): wat is RegExp; /** * Checks whether given value has a then function. * @param wat A value to be checked. */ declare function isThenable(wat: any): wat is PromiseLike<any>; /** * Checks whether given value's type is a SyntheticEvent * {@link isSyntheticEvent}. * * @param wat A value to be checked. * @returns A boolean representing the result. */ declare function isSyntheticEvent(wat: unknown): boolean; /** * Checks whether given value's type is an instance of provided constructor. * {@link isInstanceOf}. * * @param wat A value to be checked. * @param base A constructor to be used in a check. * @returns A boolean representing the result. */ declare function isInstanceOf(wat: any, base: any): boolean; /** * Checks whether given value's type is a Vue ViewModel. * * @param wat A value to be checked. * @returns A boolean representing the result. */ declare function isVueViewModel(wat: unknown): boolean; /** * Returns true if we are in the browser. */ declare function isBrowser(): boolean; declare const logger: Console; /** * NOTE: In order to avoid circular dependencies, if you add a function to this module and it needs to print something, * you must either a) use `console.log` rather than the logger, or b) put your function elsewhere. */ /** * Checks whether we're in the Node.js or Browser environment * * @returns Answer to given question */ declare function isNodeEnv(): boolean; /** * Helper for dynamically loading module that should work with linked dependencies. * The problem is that we _should_ be using `require(require.resolve(moduleName, { paths: [cwd()] }))` * However it's _not possible_ to do that with Webpack, as it has to know all the dependencies during * build time. `require.resolve` is also not available in any other way, so we cannot create, * a fake helper like we do with `dynamicRequire`. * * We always prefer to use local package, thus the value is not returned early from each `try/catch` block. * That is to mimic the behavior of `require.resolve` exactly. * * @param moduleName module name to require * @param existingModule module to use for requiring * @returns possibly required module */ declare function loadModule<T>(moduleName: string, existingModule?: any): T | undefined; /** * Recursively normalizes the given object. * * - Creates a copy to prevent original input mutation * - Skips non-enumerable properties * - When stringifying, calls `toJSON` if implemented * - Removes circular references * - Translates non-serializable values (`undefined`/`NaN`/functions) to serializable format * - Translates known global objects/classes to a string representations * - Takes care of `Error` object serialization * - Optionally limits depth of final output * - Optionally limits number of properties/elements included in any single object/array * * @param input The object to be normalized. * @param depth The max depth to which to normalize the object. (Anything deeper stringified whole.) * @param maxProperties The max number of elements or properties to be included in any single array or * object in the normalized output. * @returns A normalized version of the object, or `"**non-serializable**"` if any errors are thrown during normalization. */ declare function normalize(input: unknown, depth?: number, maxProperties?: number): any; /** JSDoc */ declare function normalizeToSize<T>(object: { [key: string]: any; }, depth?: number, maxSize?: number): T; /** * Normalizes URLs in exceptions and stacktraces to a base path so Sentry can fingerprint * across platforms and working directory. * * @param url The URL to be normalized. * @param basePath The application base path. * @returns The normalized URL. */ declare function normalizeUrlToBase(url: string, basePath: string): string; /** * Replace a method in an object with a wrapped version of itself. * * @param source An object that contains a method to be wrapped. * @param name The name of the method to be wrapped. * @param replacementFactory A higher-order function that takes the original version of the given method and returns a * wrapped version. Note: The function returned by `replacementFactory` needs to be a non-arrow function, in order to * preserve the correct value of `this`, and the original method must be called using `origMethod.call(this, <other * args>)` or `origMethod.apply(this, [<other args>])` (rather than being called directly), again to preserve `this`. * @returns void */ declare function fill(source: { [key: string]: any; }, name: string, replacementFactory: (...args: any[]) => any): void; /** * Defines a non-enumerable property on the given object. * * @param obj The object on which to set the property * @param name The name of the property to be set * @param value The value to which to set the property */ declare function addNonEnumerableProperty(obj: object, name: string, value: unknown): void; /** * Remembers the original function on the wrapped function and * patches up the prototype. * * @param wrapped the wrapper function * @param original the original function that gets wrapped */ declare function markFunctionWrapped(wrapped: WrappedFunction, original: WrappedFunction): void; /** * This extracts the original function if available. See * `markFunctionWrapped` for more information. * * @param func the function to unwrap * @returns the unwrapped version of the function if available. */ declare function getOriginalFunction<T extends Function>(func: WrappedFunction<T>): T | undefined; /** * Transforms any `Error` or `Event` into a plain object with all of their enumerable properties, and some of their * non-enumerable properties attached. * * @param value Initial source that we have to transform in order for it to be usable by the serializer * @returns An Event or Error turned into an object - or the value argument itself, when value is neither an Event nor * an Error. */ declare function convertToPlainObject<V>(value: V): { [ownProps: string]: unknown; type: string; target: string; currentTarget: string; detail?: unknown; } | { [ownProps: string]: unknown; message: string; name: string; stack?: string; } | V; /** * Given any captured exception, extract its keys and create a sorted * and truncated list that will be used inside the event message. * eg. `Non-error exception captured with keys: foo, bar, baz` */ declare function extractExceptionKeysForMessage(exception: Record<string, unknown>, maxLength?: number): string; /** * Given any object, return a new object having removed all fields whose value was `undefined`. * Works recursively on objects and arrays. * * Attention: This function keeps circular references in the returned object. */ declare function dropUndefinedKeys<T>(inputValue: T): T; /** * Ensure that something is an object. * * Turns `undefined` and `null` into `String`s and all other primitives into instances of their respective wrapper * classes (String, Boolean, Number, etc.). Acts as the identity function on non-primitives. * * @param wat The subject of the objectification * @returns A version of `wat` which can safely be used with `Object` class methods */ declare function objectify(wat: unknown): typeof Object; /** JSDoc */ declare function resolve(...args: string[]): string; /** JSDoc */ declare function relative(from: string, to: string): string; /** JSDoc */ declare function normalizePath(path: string): string; /** JSDoc */ declare function isAbsolute(path: string): boolean; /** JSDoc */ declare function join(...args: string[]): string; /** JSDoc */ declare function dirname(path: string): string; /** JSDoc */ declare function basename(path: string, ext?: string): string; /** * Converts a string-based level into a `SeverityLevel`, normalizing it along the way. * * @param level String representation of desired `SeverityLevel`. * @returns The `SeverityLevel` corresponding to the given string, or 'log' if the string isn't a valid level. */ declare function severityLevelFromString(level: SeverityLevel | string): SeverityLevel; declare const UNKNOWN_FUNCTION = "?"; /** * Creates a stack parser with the supplied line parsers * * StackFrames are returned in the correct order for Sentry Exception * frames and with MXL SDK internal frames removed from the top and bottom * */ declare function createStackParser(...parsers: StackLineParser[]): StackParser; /** * Gets a stack parser implementation from Options.stackParser * @see Options * * If options contains an array of line parsers, it is converted into a parser */ declare function stackParserFromStackParserOptions(stackParser: StackParser | StackLineParser[]): StackParser; /** * Removes Sentry frames from the top and bottom of the stack if present and enforces a limit of max number of frames. * Assumes stack input is ordered from top to bottom and returns the reverse representation so call site of the * function that caused the crash is the last frame in the array. * @hidden */ declare function stripSentryFramesAndReverse(stack: ReadonlyArray<StackFrame>): StackFrame[]; /** * Safely extract function name from itself */ declare function getFunctionName(fn: unknown): string; /** * Get's stack frames from an event without needing to check for undefined properties. */ declare function getFramesFromEvent(event: Event): StackFrame[] | undefined; type GetModuleFn = (filename: string | undefined) => string | undefined; /** * Does this filename look like it's part of the app code? */ declare function filenameIsInApp(filename: string, isNative?: boolean): boolean; /** Node Stack line parser */ declare function node(getModule?: GetModuleFn): StackLineParserFn; /** * Node.js stack line parser * * This is in @sentry/core so it can be used from the Electron SDK in the browser for when `nodeIntegration == true`. * This allows it to be used without referencing or importing any node specific code which causes bundlers to complain */ declare function nodeStackLineParser(getModule?: GetModuleFn): StackLineParser; /** * Truncates given string to the maximum characters count * * @param str An object that contains serializable values * @param max Maximum number of characters in truncated string (0 = unlimited) * @returns string Encoded */ declare function truncate(str: string, max?: number): string; /** * This is basically just `trim_line` from * * @param str An object that contains serializable values * @param max Maximum number of characters in truncated string * @returns string Encoded */ declare function snipLine(line: string, colno: number): string; /** * Join values in array * @param input array of values to be joined together * @param delimiter string to be placed in-between values * @returns Joined values */ declare function safeJoin(input: unknown[], delimiter?: string): string; /** * Checks if the given value matches a regex or string * * @param value The string to test * @param pattern Either a regex or a string against which `value` will be matched * @param requireExactStringMatch If true, `value` must match `pattern` exactly. If false, `value` will match * `pattern` if it contains `pattern`. Only applies to string-type patterns. */ declare function isMatchingPattern(value: string, pattern: RegExp | string, requireExactStringMatch?: boolean): boolean; /** * Test the given string against an array of strings and regexes. By default, string matching is done on a * substring-inclusion basis rather than a strict equality basis * * @param testString The string to test * @param patterns The patterns against which to test the string * @param requireExactStringMatch If true, `testString` must match one of the given string patterns exactly in order to * count. If false, `testString` will match a string pattern if it contains that pattern. * @returns */ declare function stringMatchesSomePattern(testString: string, patterns?: Array<string | RegExp>, requireExactStringMatch?: boolean): boolean; type PartialURL = { host?: string; path?: string; protocol?: string; relative?: string; search?: string; hash?: string; }; /** * Parses string form of URL into an object * // borrowed from https://tools.ietf.org/html/rfc3986#appendix-B * // intentionally using regex and not <a/> href parsing trick because React Native and other * // environments where DOM might not be available * @returns parsed URL object */ declare function parseUrl(url: string): PartialURL; /** * Strip the query string and fragment off of a given URL or path (if present) * * @param urlPath Full URL or path, including possible query string and/or fragment * @returns URL or path without query string or fragment */ declare function stripUrlQueryAndFragment(urlPath: string): string; /** * Takes a URL object and returns a sanitized string which is safe to use as span name * see: https://develop.sentry.dev/sdk/data-handling/#structuring-data */ declare function getSanitizedUrlString(url: PartialURL): string; type Client = any; /** * Extracts stack frames from the error.stack string */ declare function parseStackFrames(stackParser: StackParser, error: Error): StackFrame[]; /** * Extracts stack frames from the error and builds a Sentry Exception */ declare function exceptionFromError(stackParser: StackParser, error: Error): Exception; /** * Builds and Event from a Exception * @hidden */ declare function eventFromUnknownInput(client: Client, stackParser: StackParser, exception: unknown, hint?: EventHint): Event; /** * Builds and Event from a Message * @hidden */ declare function eventFromMessage(stackParser: StackParser, message: ParameterizedString, level?: SeverityLevel, hint?: EventHint, attachStacktrace?: boolean): Event; type WatchdogReturn = { /** Resets the watchdog timer */ poll: () => void; /** Enables or disables the watchdog timer */ enabled: (state: boolean) => void; }; type CreateTimerImpl = () => { getTimeMs: () => number; reset: () => void; }; /** * A node.js watchdog timer * @param createTimer * @param pollInterval The interval that we expect to get polled at * @param anrThreshold The threshold for when we consider ANR * @param callback The callback to call for ANR * @returns An object with `poll` and `enabled` functions {@link WatchdogReturn} */ declare function watchdogTimer(createTimer: CreateTimerImpl, pollInterval: number, anrThreshold: number, callback: () => void): WatchdogReturn; interface Location { scriptId: string; lineNumber: number; columnNumber?: number; } interface CallFrame { functionName: string; location: Location; url: string; } /** * Converts Debugger.CallFrame to Sentry StackFrame */ declare function callFrameToStackFrame(frame: CallFrame, url: string | undefined, getModuleFromFilename: (filename: string | undefined) => string | undefined): StackFrame; /** A simple Least Recently Used map */ declare class LRUMap<K, V> { private readonly _maxSize; private readonly _cache; constructor(_maxSize: number); /** Get the current size of the cache */ get size(): number; /** Get an entry or undefined if it was not in the cache. Re-inserts to update the recently used order */ get(key: K): V | undefined; /** Insert an entry and evict an older entry if we've reached maxSize */ set(key: K, value: V): void; /** Remove an entry and return the entry if it was in the cache */ remove(key: K): V | undefined; /** Clear all entries */ clear(): void; /** Get all the keys */ keys(): Array<K>; /** Get all the values */ values(): Array<V>; } declare const SDK_VERSION: string; /** * Returns a map of filenames to debug identifiers. */ declare function getFilenameToDebugIdMap(stackParser: StackParser): Record<string, string>; /** * Returns a list of debug images for the given resources. */ declare function getDebugImagesForResources(stackParser: StackParser, resource_paths: ReadonlyArray<string>): DebugImage[]; type TrackHandlerPayload = { type: 'track'; payload: TrackPayload; } | { type: 'increment'; payload: IncrementPayload; } | { type: 'decrement'; payload: DecrementPayload; } | { type: 'alias'; payload: AliasPayload; } | { type: 'identify'; payload: IdentifyPayload; }; type TrackPayload = { name: string; properties?: Record<string, unknown>; profileId?: string; }; type TrackProperties = { [key: string]: unknown; profileId?: string; }; type IdentifyPayload = { profileId: string; email?: string; avatar?: string; properties?: Record<string, unknown>; }; type AliasPayload = { profileId: string; alias: string; }; type IncrementPayload = { profileId: string; property: string; value?: number; }; type DecrementPayload = { profileId: string; property: string; value?: number; }; type MxlAnalyticsOptions = { apiKey: string; apiUrl?: string; sdk?: string; sdkVersion?: string; waitForProfile?: boolean; filter?: (payload: TrackHandlerPayload) => boolean; disabled?: boolean; useBeacon?: boolean; }; declare class MxlAnalytics { options: MxlAnalyticsOptions; api: Api; profileId?: string; global?: Record<string, unknown>; queue: TrackHandlerPayload[]; constructor(options: MxlAnalyticsOptions); init(): void; ready(): void; send(payload: TrackHandlerPayload, useBeacon?: boolean): Promise<void>; setGlobalProperties(properties: Record<string, unknown>): void; track(name: string, properties?: TrackProperties, useBeacon?: boolean): Promise<void>; identify(payload: IdentifyPayload, useBeacon?: boolean): Promise<void>; alias(payload: AliasPayload, useBeacon?: boolean): Promise<void>; increment(payload: IncrementPayload, useBeacon?: boolean): Promise<void>; decrement(payload: DecrementPayload, useBeacon?: boolean): Promise<void>; clear(): void; private flush; } interface MxlAnalyticsEventOptions { profileId?: string; } interface PostEventPayload { name: string; timestamp: string; profileId?: string; properties?: Record<string, unknown> & MxlAnalyticsEventOptions; } interface UpdateProfilePayload { profileId: string; email?: string; avatar?: string; properties?: Record<string, unknown>; } interface IncrementProfilePayload { profileId: string; property: string; value: number; } interface DecrementProfilePayload { profileId?: string; property: string; value: number; } export { type AliasPayload, type Attachment, type AttachmentType, type DebugImage, type DebugMeta, type DecrementPayload, type DecrementProfilePayload, type ErrorEvent, type Event, type EventHint, type EventType, type Exception, type Extra, type Extras, GLOBAL_OBJ, type HttpHeaderValue, type IdentifyPayload, type IncrementPayload, type IncrementProfilePayload, type InternalGlobal, LRUMap, type Mechanism, MxlAnalytics, type MxlAnalyticsEventOptions, type MxlAnalyticsOptions, type ParameterizedString, type PolymorphicEvent, type PolymorphicRequest, type PostEventPayload, type Primitive, SDK_VERSION, type SdkSource, type SeverityLevel, type StackFrame, type StackLineParser, type StackLineParserFn, type StackParser, type Stacktrace, type TrackHandlerPayload, type TrackPayload, type TrackProperties, type TransactionEvent, UNKNOWN_FUNCTION, type UpdateProfilePayload, type WrappedFunction, addNonEnumerableProperty, basename, callFrameToStackFrame, convertToPlainObject, createStackParser, dirname, dropUndefinedKeys, eventFromMessage, eventFromUnknownInput, exceptionFromError, extractExceptionKeysForMessage, filenameIsInApp, fill, getComponentName, getDebugImagesForResources, getFilenameToDebugIdMap, getFramesFromEvent, getFunctionName, getLocationHref, getOriginalFunction, getSDKSource, getSanitizedUrlString, htmlTreeAsString, isAbsolute, isBrowser, isBrowserBundle, isDOMError, isDOMException, isElement, isError, isErrorEvent, isEvent, isInstanceOf, isMatchingPattern, isNodeEnv, isParameterizedString, isPlainObject, isPrimitive, isRegExp, isString, isSyntheticEvent, isThenable, isVueViewModel, join, loadModule, logger, markFunctionWrapped, node, nodeStackLineParser, normalize, normalizePath, normalizeToSize, normalizeUrlToBase, objectify, parseStackFrames, parseUrl, relative, resolve, safeJoin, severityLevelFromString, snipLine, stackParserFromStackParserOptions, stringMatchesSomePattern, stripSentryFramesAndReverse, stripUrlQueryAndFragment, truncate, watchdogTimer };