UNPKG

highlight.run

Version:

Open source, fullstack monitoring. Capture frontend errors, record server side logs, and visualize what broke with session replay.

1,314 lines (1,239 loc) 58.2 kB
import { EvaluationSeriesContext } from '@launchdarkly/js-client-sdk'; import { EvaluationSeriesData } from '@launchdarkly/js-client-sdk'; import { eventWithTime } from '@highlight-run/rrweb-types'; import { GraphQLClient } from 'graphql-request'; import { GraphQLClientRequestHeaders } from 'graphql-request/build/cjs/types'; import { Hook as Hook_2 } from '@launchdarkly/js-client-sdk'; import { LDContext } from '@launchdarkly/js-client-sdk'; import { LDEvaluationReason } from '@launchdarkly/js-client-sdk'; import { LDFlagValue } from '@launchdarkly/js-client-sdk'; import { LDPluginEnvironmentMetadata } from '@launchdarkly/js-client-sdk'; import { LDPluginMetadata } from '@launchdarkly/js-client-sdk'; import { listenerHandler } from '@highlight-run/rrweb-types'; import { ProductAnalyticsEvents as ProductAnalyticsEvents_2 } from 'client/types/observe'; import { StackFrame } from 'stacktrace-js'; declare type AddSessionFeedbackMutation = { __typename?: 'Mutation'; addSessionFeedback: string; }; declare type AddSessionFeedbackMutationVariables = Exact<{ session_secure_id: Scalars['String']['input']; user_name?: InputMaybe<Scalars['String']['input']>; user_email?: InputMaybe<Scalars['String']['input']>; verbatim: Scalars['String']['input']; timestamp: Scalars['Timestamp']['input']; }>; declare type AddSessionPropertiesMutation = { __typename?: 'Mutation'; addSessionProperties: string; }; declare type AddSessionPropertiesMutationVariables = Exact<{ session_secure_id: Scalars['String']['input']; properties_object?: InputMaybe<Scalars['Any']['input']>; }>; declare const ALL_CONSOLE_METHODS: readonly ["assert", "count", "countReset", "debug", "dir", "dirxml", "error", "group", "groupCollapsed", "groupEnd", "info", "log", "table", "time", "timeEnd", "timeLog", "trace", "warn"]; declare interface AmplitudeIntegrationOptions extends DefaultIntegrationOptions { apiKey?: string; } declare type AsyncEventsMessage = { type: MessageType.AsyncEvents; id: number; hasSessionUnloaded: boolean; highlightLogs: string; events: eventWithTime[]; messages: ConsoleMessage[]; errors: ErrorMessage[]; resourcesString: string; webSocketEventsString: string; }; declare type AsyncEventsResponse = { type: MessageType.AsyncEvents; id: number; eventsSize: number; compressedSize: number; }; declare type CommonOptions = { /** * Do not use this. * @private */ debug?: boolean | DebugOptions; /** * Specifies the name of the app. */ serviceName?: string; /** * Specifies the version of your application. * This is commonly a Git hash or a semantic version. */ version?: string; /** * Specifies where to send Highlight session data. * You should not have to set this unless you are running an on-premise instance. */ backendUrl?: string; /** * Set to `sessionStorage` to bypass all `window.localStorage` usage. * This can help with compliance for cookie-consent regulation. * Using `sessionStorage` will cause app close+reopens to start a new highlight session, * as the session ID will not persist. */ storageMode?: 'sessionStorage' | 'localStorage'; /** * By default, session data is stored in the `sessionStorage` of the browser. * Set to `true` to store session data in a cookie instead. * This can help with compliance for cookie-consent regulation. */ sessionCookie?: boolean; /** * Specifies if Highlight should not automatically initialize when the class is created. * This should be used with `.start()` and `.stop()` if you want to control when Highlight records. * @default false */ manualStart?: boolean; /** * Key to use to determine the sessionSecureID in order to override session generation logic. * If a sessionKey is provided, the session will be combined with the previous session with the same key. * Otherwise, the current session logic will be used to generate a sessionSecureID. */ sessionKey?: string; /** * A function that returns a friendly name for a given context. * This name will be used to identify the session in the observability UI. * ```ts * contextFriendlyName: (context: LDContext) => { * if(context.kind === 'multi' && context.user?.email) { * return context.user.email; * } else if(context.kind === 'user') { * return context.key; * } * // Use the default identifier for contexts which don't contain a user. * return undefined; * } * ``` * @param context The context to get a friendly name for. * @returns The friendly name for the context, or undefined to use the * default identifier. */ contextFriendlyName?: (context: LDContext) => string | undefined; }; declare type ConsoleMessage = { value?: Array<string>; attributes?: string; time: number; type: string; trace?: StackFrame[]; }; declare type ConsoleMethods = ConsoleMethodsTuple[number]; declare type ConsoleMethodsTuple = typeof ALL_CONSOLE_METHODS; declare type CustomEventResponse = { type: MessageType.CustomEvent; tag: string; payload: any; }; declare type DebugOptions = { clientInteractions?: boolean; domRecording?: boolean; }; declare type DefaultIntegrationOptions = { disabled?: boolean; }; declare type ErrorMessage = { event: string; type: ErrorMessageType; url: string; source: string; lineNumber: number; columnNumber: number; stackTrace: StackFrame[]; /** The Unix Time of when the error was thrown. */ timestamp: string; payload?: string; error?: Error; id: string; }; declare type ErrorMessageType = 'console.error' | 'window.onerror' | 'window.onunhandledrejection' | 'custom' | 'React.ErrorBoundary'; declare type ErrorObjectInput = { columnNumber: Scalars['Int']['input']; event: Scalars['String']['input']; id?: InputMaybe<Scalars['String']['input']>; lineNumber: Scalars['Int']['input']; payload?: InputMaybe<Scalars['String']['input']>; source: Scalars['String']['input']; stackTrace: Array<InputMaybe<StackFrameInput>>; timestamp: Scalars['Timestamp']['input']; type: Scalars['String']['input']; url: Scalars['String']['input']; }; declare type Exact<T extends { [key: string]: unknown; }> = { [K in keyof T]: T[K]; }; declare type FeedbackMessage = { type: MessageType.Feedback; verbatim: string; timestamp: string; userName?: string; userEmail?: string; }; declare type GetSamplingConfigQuery = { __typename?: 'Query'; sampling: { __typename?: 'SamplingConfig'; spans?: Array<{ __typename?: 'SpanSamplingConfig'; samplingRatio: number; name?: { __typename?: 'MatchConfig'; regexValue?: string | null; matchValue?: any | null; } | null; attributes?: Array<{ __typename?: 'AttributeMatchConfig'; key: { __typename?: 'MatchConfig'; regexValue?: string | null; matchValue?: any | null; }; attribute: { __typename?: 'MatchConfig'; regexValue?: string | null; matchValue?: any | null; }; }> | null; events?: Array<{ __typename?: 'SpanEventMatchConfig'; name?: { __typename?: 'MatchConfig'; regexValue?: string | null; matchValue?: any | null; } | null; attributes?: Array<{ __typename?: 'AttributeMatchConfig'; key: { __typename?: 'MatchConfig'; regexValue?: string | null; matchValue?: any | null; }; attribute: { __typename?: 'MatchConfig'; regexValue?: string | null; matchValue?: any | null; }; }> | null; }> | null; }> | null; logs?: Array<{ __typename?: 'LogSamplingConfig'; samplingRatio: number; message?: { __typename?: 'MatchConfig'; regexValue?: string | null; matchValue?: any | null; } | null; severityText?: { __typename?: 'MatchConfig'; regexValue?: string | null; matchValue?: any | null; } | null; attributes?: Array<{ __typename?: 'AttributeMatchConfig'; key: { __typename?: 'MatchConfig'; regexValue?: string | null; matchValue?: any | null; }; attribute: { __typename?: 'MatchConfig'; regexValue?: string | null; matchValue?: any | null; }; }> | null; }> | null; }; }; declare type GetSamplingConfigQueryVariables = Exact<{ organization_verbose_id: Scalars['String']['input']; }>; declare function getSdk(client: GraphQLClient, withWrapper?: SdkFunctionWrapper): { PushPayload(variables: PushPayloadMutationVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<PushPayloadMutation>; PushSessionEvents(variables: PushSessionEventsMutationVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<PushSessionEventsMutation>; identifySession(variables: IdentifySessionMutationVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<IdentifySessionMutation>; addSessionProperties(variables: AddSessionPropertiesMutationVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<AddSessionPropertiesMutation>; pushMetrics(variables: PushMetricsMutationVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<PushMetricsMutation>; addSessionFeedback(variables: AddSessionFeedbackMutationVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<AddSessionFeedbackMutation>; initializeSession(variables: InitializeSessionMutationVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<InitializeSessionMutation>; Ignore(variables: IgnoreQueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<IgnoreQuery>; GetSamplingConfig(variables: GetSamplingConfigQueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<GetSamplingConfigQuery>; }; declare type GetStatusMessage = { type: MessageType.GetStatus; }; declare interface Headers_2 { [key: string]: any; } declare type HighlightClassOptions = { organizationID: number | string; debug?: boolean | DebugOptions; backendUrl?: string; tracingOrigins?: boolean | (string | RegExp)[]; disableNetworkRecording?: boolean; networkRecording?: boolean | NetworkRecordingOptions; disableBackgroundRecording?: boolean; disableConsoleRecording?: boolean; disableSessionRecording?: boolean; reportConsoleErrors?: boolean; consoleMethodsToRecord?: ConsoleMethods[]; privacySetting?: PrivacySettingOption; maskAllInputs?: boolean; maskInputOptions?: MaskInputOptions; maskTextClass?: string | RegExp; maskTextSelector?: string; blockClass?: string | RegExp; blockSelector?: string; ignoreClass?: string; ignoreSelector?: string; enableSegmentIntegration?: boolean; enableCanvasRecording?: boolean; enablePerformanceRecording?: boolean; enablePromisePatch?: boolean; samplingStrategy?: SamplingStrategy; inlineImages?: boolean; inlineVideos?: boolean; inlineStylesheet?: boolean; recordCrossOriginIframe?: boolean; firstloadVersion?: string; environment?: 'development' | 'production' | 'staging' | string; appVersion?: string; serviceName?: string; sessionKey?: string; sessionShortcut?: SessionShortcutOptions; sessionSecureID: string; storageMode?: 'sessionStorage' | 'localStorage'; sessionCookie?: boolean; sendMode?: 'webworker' | 'local'; otlpEndpoint?: HighlightOptions['otlpEndpoint']; otel?: HighlightOptions['otel']; productAnalytics?: boolean | ProductAnalyticsEvents_2; contextFriendlyName?: (context: LDContext) => string | undefined; }; declare interface HighlightClientRequestWorker { postMessage: (message: HighlightClientWorkerParams) => void; onmessage: (message: MessageEvent<HighlightClientWorkerResponse>) => void; } declare type HighlightClientWorkerParams = { message: InitializeMessage | ResetMessage | GetStatusMessage | AsyncEventsMessage | IdentifyMessage | PropertiesMessage | MetricsMessage | FeedbackMessage; }; declare type HighlightClientWorkerResponse = { response?: AsyncEventsResponse | CustomEventResponse | StopEventResponse | StatusResponse; }; declare type HighlightOptions = CommonOptions & { /** * Specifies where the backend of the app lives. If specified, Highlight will attach the * X-Highlight-Request header to outgoing requests whose destination URLs match a substring * or regexp from this list, so that backend errors can be linked back to the session. * If 'true' is specified, all requests to the current domain will be matched. * @example tracingOrigins: ['localhost', /^\//, 'backend.myapp.com'] */ tracingOrigins?: boolean | (string | RegExp)[]; /** * This disables recording network requests. * The data includes the URLs, the size of the request, and how long the request took. * @default false * @deprecated Use `networkRecording` instead. */ disableNetworkRecording?: boolean; /** * Specifies how and what Highlight records from network requests and responses. */ networkRecording?: boolean | NetworkRecordingOptions; /** * If set, Highlight will not record when your app is not visible (in the background). * By default, Highlight will record in the background. * @default false */ disableBackgroundRecording?: boolean; /** * Specifies whether Highlight will record console messages. * @default false */ disableConsoleRecording?: boolean; /** * Specifies whether Highlight will record user session replays. * Unless you are using Highlight only for error monitoring, you do not want to set this to true. * @default false */ disableSessionRecording?: boolean; /** * Specifies whether Highlight will report `console.error` invocations as Highlight Errors. * @default false */ reportConsoleErrors?: boolean; /** * Specifies which console methods to record. * The value here will be ignored if `disabledConsoleRecording` is `true`. * @default All console methods. * @example consoleMethodsToRecord: ['log', 'info', 'error'] */ consoleMethodsToRecord?: ConsoleMethods[]; enableSegmentIntegration?: boolean; /** * Specifies the environment your application is running in. * This is useful to distinguish whether your session was recorded on localhost or in production. * @default 'production' */ environment?: 'development' | 'staging' | 'production' | string; /** * Specifies how much data Highlight should redact during recording. * strict - Highlight will redact all text data on the page. * default - Highlight will redact text data on the page that is associated with personal identifiable data. * none - Highlight will not redact any text data on the page. * // Redacted text will be randomized. Instead of seeing "Hello World" in a recording, you will see "1fds1 j59a0". * @see {@link https://docs.highlight.run/docs/privacy} for more information. */ privacySetting?: PrivacySettingOption; /** * Specifies whether to record canvas elements or not. * @default false */ enableCanvasRecording?: boolean; /** * Specifies whether to record performance metrics (e.g. FPS, device memory). * @default true */ enablePerformanceRecording?: boolean; /** * Specifies whether window.Promise should be patched * to record the stack trace of promise rejections. * @default true */ enablePromisePatch?: boolean; /** * Configure the recording sampling options, eg. how frequently we record canvas updates. */ samplingStrategy?: SamplingStrategy; /** * Specifies whether to inline images into the recording. * This means that images that are local to the client (eg. client-generated blob: urls) * will be serialized into the recording and will be valid on replay. * This will also use canvas snapshotting to inline <video> elements * that use `src="blob:..."` data or webcam feeds (blank src) as <canvas> elements * Only enable this if you are running into issues with client-local images. * Will negatively affect performance. * @default false */ inlineImages?: boolean; /** * Specifies whether to inline <video> elements into the recording. * This means that video that are not accessible at a later time * (eg., a signed URL that is short lived) * will be serialized into the recording and will be valid on replay. * Only enable this if you are running into issues with the normal serialization. * Will negatively affect performance. * @default false */ inlineVideos?: boolean; /** * Specifies whether to inline stylesheets into the recording. * This means that stylesheets that are local to the client (eg. client-generated blob: urls) * will be serialized into the recording and will be valid on replay. * Only enable this if you are running into issues with client-local stylesheets. * May negatively affect performance. * @default true */ inlineStylesheet?: boolean; /** * Enables recording of cross-origin iframes. Should be set in both the parent window and * in the cross-origin iframe. * @default false */ recordCrossOriginIframe?: boolean; /** * Deprecated: this setting is now inferred automatically. Passing this option does nothing. * @deprecated */ isCrossOriginIframe?: boolean; integrations?: IntegrationOptions; /** * Specifies the keyboard shortcut to open the current session in Highlight. * @see {@link https://docs.highlight.run/session-shortcut} for more information. */ sessionShortcut?: SessionShortcutOptions; /** * By default, data is serialized and send by the Web Worker. Set to `local` to force * sending from the main js thread. Only use `local` for custom environments where Web Workers * are not available (ie. Figma plugins). */ sendMode?: 'webworker' | 'local'; /** * OTLP endpoint for OpenTelemetry tracing. */ otlpEndpoint?: string; /** * OTLP options for OpenTelemetry tracing. Instrumentations are enabled by default. */ otel?: OtelOptions; }; /** * Interface for extending SDK functionality via hooks. */ declare type Hook = Omit<Hook_2, 'afterEvaluation'> & { /** * This method is called during the execution of the variation method * after the flag value has been determined. The method is executed synchronously. * * @param hookContext Contains read-only information about the evaluation * being performed. * @param data A record associated with each stage of hook invocations. Each * stage is called with the data of the previous stage for a series. * @param detail The result of the evaluation. This value should not be * modified. * @returns Data to use when executing the next state of the hook in the evaluation series. It is * recommended to expand the previous input into the return. This helps ensure your stage remains * compatible moving forward as more stages are added. * ```js * return {...data, "my-new-field": /*my data/*} * ``` */ afterEvaluation?(hookContext: EvaluationSeriesContext, data: EvaluationSeriesData, detail: { /** * The result of the flag evaluation. This will be either one of the flag's variations or * the default value that was passed to `LDClient.variationDetail`. */ value: LDFlagValue; /** * The index of the returned value within the flag's list of variations, e.g. 0 for the * first variation-- or `null` if the default value was returned. */ variationIndex?: number | null; /** * An object describing the main factor that influenced the flag evaluation value. */ reason?: LDEvaluationReason | null; }): EvaluationSeriesData; }; declare type IdentifyMessage = { type: MessageType.Identify; userIdentifier: string; userObject: any; source?: Source; }; declare type IdentifySessionMutation = { __typename?: 'Mutation'; identifySession: string; }; declare type IdentifySessionMutationVariables = Exact<{ session_secure_id: Scalars['String']['input']; user_identifier: Scalars['String']['input']; user_object?: InputMaybe<Scalars['Any']['input']>; }>; declare type IgnoreQuery = { __typename?: 'Query'; ignore?: any | null; }; declare type IgnoreQueryVariables = Exact<{ id: Scalars['ID']['input']; }>; declare type InitializeMessage = { type: MessageType.Initialize; backend: string; sessionSecureID: string; debug: boolean; recordingStartTime: number; }; declare type InitializeSessionMutation = { __typename?: 'Mutation'; initializeSession: { __typename?: 'InitializeSessionResponse'; secure_id: string; project_id: string; sampling?: { __typename?: 'SamplingConfig'; spans?: Array<{ __typename?: 'SpanSamplingConfig'; samplingRatio: number; name?: { __typename?: 'MatchConfig'; regexValue?: string | null; matchValue?: any | null; } | null; attributes?: Array<{ __typename?: 'AttributeMatchConfig'; key: { __typename?: 'MatchConfig'; regexValue?: string | null; matchValue?: any | null; }; attribute: { __typename?: 'MatchConfig'; regexValue?: string | null; matchValue?: any | null; }; }> | null; events?: Array<{ __typename?: 'SpanEventMatchConfig'; name?: { __typename?: 'MatchConfig'; regexValue?: string | null; matchValue?: any | null; } | null; attributes?: Array<{ __typename?: 'AttributeMatchConfig'; key: { __typename?: 'MatchConfig'; regexValue?: string | null; matchValue?: any | null; }; attribute: { __typename?: 'MatchConfig'; regexValue?: string | null; matchValue?: any | null; }; }> | null; }> | null; }> | null; logs?: Array<{ __typename?: 'LogSamplingConfig'; samplingRatio: number; message?: { __typename?: 'MatchConfig'; regexValue?: string | null; matchValue?: any | null; } | null; severityText?: { __typename?: 'MatchConfig'; regexValue?: string | null; matchValue?: any | null; } | null; attributes?: Array<{ __typename?: 'AttributeMatchConfig'; key: { __typename?: 'MatchConfig'; regexValue?: string | null; matchValue?: any | null; }; attribute: { __typename?: 'MatchConfig'; regexValue?: string | null; matchValue?: any | null; }; }> | null; }> | null; } | null; }; }; declare type InitializeSessionMutationVariables = Exact<{ session_secure_id: Scalars['String']['input']; session_key?: InputMaybe<Scalars['String']['input']>; organization_verbose_id: Scalars['String']['input']; enable_strict_privacy: Scalars['Boolean']['input']; privacy_setting: Scalars['String']['input']; enable_recording_network_contents: Scalars['Boolean']['input']; clientVersion: Scalars['String']['input']; firstloadVersion: Scalars['String']['input']; clientConfig: Scalars['String']['input']; environment: Scalars['String']['input']; id: Scalars['String']['input']; appVersion?: InputMaybe<Scalars['String']['input']>; serviceName: Scalars['String']['input']; client_id: Scalars['String']['input']; network_recording_domains?: InputMaybe<Array<Scalars['String']['input']> | Scalars['String']['input']>; disable_session_recording?: InputMaybe<Scalars['Boolean']['input']>; }>; declare type InputMaybe<T> = Maybe<T>; declare interface IntegrationClient { init(sessionSecureID: string): void; identify(sessionSecureID: string, user_identifier: string, user_object: object, source?: Source): void; error(sessionSecureID: string, error: ErrorMessage): void; track(sessionSecureID: string, metadata: object): void; recordGauge(sessionSecureID: string, metric: RecordMetric): void; getHooks?(metadata: LDPluginEnvironmentMetadata): Hook[]; } declare type IntegrationOptions = { amplitude?: AmplitudeIntegrationOptions; intercom?: IntercomIntegrationOptions; mixpanel?: MixpanelIntegrationOptions; }; declare interface IntercomIntegrationOptions extends DefaultIntegrationOptions { } declare interface LDClientMin { track(key: string, data?: any, metricValue?: number): void; identify(ctx: any): void; addHook(hook: Hook): void; } declare interface LDPlugin { getMetadata(): LDPluginMetadata; register(client: LDClientMin, environmentMetadata: LDPluginEnvironmentMetadata): void; getHooks?(metadata: LDPluginEnvironmentMetadata): Hook[]; } declare class Logger { debug: boolean | undefined; name: string | undefined; constructor(debug?: boolean, name?: string); log(...data: any[]): void; warn(...data: any[]): void; } declare type MaskInputOptions = Partial<{ color: boolean; date: boolean; 'datetime-local': boolean; email: boolean; month: boolean; number: boolean; range: boolean; search: boolean; tel: boolean; text: boolean; time: boolean; url: boolean; week: boolean; textarea: boolean; select: boolean; password: boolean; }>; declare type Maybe<T> = T | null; declare enum MessageType { Initialize = 0, Reset = 1, AsyncEvents = 2, Identify = 3, Properties = 4, Metrics = 5, Feedback = 6, CustomEvent = 7, Stop = 8, GetStatus = 9 } declare interface Metadata_2 { [key: string]: any; } declare enum MetricCategory { Device = "Device", WebVital = "WebVital", Performance = "Performance", Frontend = "Frontend", Backend = "Backend" } declare type MetricInput = { category?: InputMaybe<Scalars['String']['input']>; group?: InputMaybe<Scalars['String']['input']>; name: Scalars['String']['input']; parent_span_id?: InputMaybe<Scalars['String']['input']>; session_secure_id: Scalars['String']['input']; span_id?: InputMaybe<Scalars['String']['input']>; tags?: InputMaybe<Array<MetricTag>>; timestamp: Scalars['Timestamp']['input']; trace_id?: InputMaybe<Scalars['String']['input']>; value: Scalars['Float']['input']; }; declare type MetricsMessage = { type: MessageType.Metrics; metrics: { name: string; value: number; category: MetricCategory; group: string; timestamp: Date; tags: { name: string; value: string; }[]; }[]; }; declare type MetricTag = { name: Scalars['String']['input']; value: Scalars['String']['input']; }; declare interface MixpanelIntegrationOptions extends DefaultIntegrationOptions { projectToken?: string; } declare type NetworkRecordingOptions = { /** * Enables recording of network requests. * The data includes the URLs, the size of the request, and how long the request took. * @default true */ enabled?: boolean; /** * This enables recording XMLHttpRequest and Fetch headers and bodies. * @default false */ recordHeadersAndBody?: boolean; /** * This disables recording WebSocket events. * WebSocket events are recorded by default if recordHeadersAndBody is set. * @default false */ disableWebSocketEventRecordings?: boolean; /** * Request and response headers where the value is not recorded. * The header value is replaced with '[REDACTED]'. * These headers are case-insensitive. * `recordHeadersAndBody` needs to be enabled. * This option will be ignored if `headerKeysToRecord` is set. * @example * networkHeadersToRedact: ['Secret-Header', 'Plain-Text-Password'] */ networkHeadersToRedact?: string[]; /** * Specifies the keys for request/response JSON body that should not be recorded. * The body value is replaced with '[REDACTED]'. * These keys are case-insensitive. * `enabled` and `recordHeadersAndBody` need to be `true`. Otherwise this option will be ignored. * @example bodyKeysToRedact: ['secret-token', 'plain-text-password'] * // Only `body.id` and `body.pageNumber` will be recorded. * body = { * 'id': '123', * 'pageNumber': '1', * 'secret-token': 'super-sensitive-value', * 'plain-text-password': 'password123', * } */ networkBodyKeysToRedact?: string[]; /** * URLs to not record headers and bodies for, and to not propagate trace * headers (e.g. `traceparent`) to. Each entry is matched as a * case-insensitive substring of the full request URL; a match suppresses * both recording and trace-header propagation for that request. * To disable recording headers and bodies for all URLs, set `recordHeadersAndBody` to `false`. * @default ['https://www.googleapis.com/identitytoolkit', 'https://securetoken.googleapis.com'] */ urlBlocklist?: string[]; /** * Specifies the keys for request/response headers to record. * This option will override `networkHeadersToRedact` if specified. * `enabled` and `recordHeadersAndBody` need to be `true`. Otherwise this option will be ignored. * @example headerKeysToRecord: ['id', 'pageNumber'] * // Only `headers.id` and `headers.pageNumber` will be recorded. * headers = { * 'id': '123', * 'pageNumber': '1', * 'secret-token': 'super-sensitive-value', * 'plain-text-password': 'password123', * } */ headerKeysToRecord?: string[]; /** * Specifies the keys for request/response JSON body to record. * This option will override `networkBodyKeysToRedact` if specified. * `enabled` and `recordHeadersAndBody` need to be `true`. Otherwise this option will be ignored. * @example bodyKeysToRecord: ['id', 'pageNumber'] * // Only `body.id` and `body.pageNumber` will be recorded. * body = { * 'id': '123', * 'pageNumber': '1', * 'secret-token': 'super-sensitive-value', * 'plain-text-password': 'password123', * } */ bodyKeysToRecord?: string[]; /** * Record frontend network request metrics that are sent to * the following list of domains. A domain substring match is used to * determine if a network request matches one of the following values. * @example destinationDomains: ['backend.example.com'] * // if your frontend makes requests to `backend.example.com` that you would like to record */ destinationDomains?: string[]; /** * Function to edit/remove data in request/response pairs or ignore the pair entirely. * @example * ``` * requestResponseSanitizer: pair => { * if (pair.request.url.toLowerCase().indexOf('ignore') !== -1) { * // ignore the entire request/response pair (no network logs) * return null * } * * if (pair.response.body.indexOf('secret') !== -1) { * // remove the body in the response * delete pair.response.body; * } * * return pair * } * ``` * */ requestResponseSanitizer?: (pair: RequestResponsePair) => RequestResponsePair | null; }; declare type ObserveOptions = CommonOptions & { /** * Specifies where the backend of the app lives. If specified, the SDK will attach the * traceparent header to outgoing requests whose destination URLs match a substring * or regexp from this list, so that backend errors can be linked back to the session. * If 'true' is specified, all requests to the current domain will be matched. * @example tracingOrigins: ['localhost', /^\//, 'backend.myapp.com'] */ tracingOrigins?: boolean | (string | RegExp)[]; /** * Specifies how and what the SDK records from network requests and responses. */ networkRecording?: boolean | NetworkRecordingOptions; /** * Specifies whether the SDK will record console messages. * @default false */ disableConsoleRecording?: boolean; /** * Specifies whether the SDK will report `console.error` invocations as Errors. * @default false */ reportConsoleErrors?: boolean; /** * Specifies which console methods to record. * The value here will be ignored if `disabledConsoleRecording` is `true`. * @default All console methods. * @example consoleMethodsToRecord: ['log', 'info', 'error'] */ consoleMethodsToRecord?: ConsoleMethods[]; /** * Specifies whether to record performance metrics (e.g. FPS, device memory). * @default true */ enablePerformanceRecording?: boolean; /** * Specifies whether to record main-thread `longtask` entries (>50ms) as * `long_task.duration` histogram samples. * @default true */ enableLongtaskRecording?: boolean; /** * Specifies whether to subscribe to the browser Reporting API and emit * CSP/intervention reports as errors and deprecation reports as warn logs. * @default true */ enableReportingObserver?: boolean; /** * Specifies the environment your application is running in. * This is useful to distinguish whether your session was recorded on localhost or in production. * @default 'production' */ environment?: 'development' | 'staging' | 'production' | string; /** * Specifies whether window.Promise should be patched * to record the stack trace of promise rejections. * @default true */ enablePromisePatch?: boolean; /** * OTLP options for OpenTelemetry tracing. Instrumentations are enabled by default. */ otel?: OtelOptions & { /** * OTLP HTTP endpoint for OpenTelemetry tracing. */ otlpEndpoint?: string; }; /** * Specifies whether to record product analytics events. * @default true */ productAnalytics?: boolean | ProductAnalyticsEvents; }; declare type OtelInstrumentatonOptions = { '@opentelemetry/instrumentation-document-load'?: false; '@opentelemetry/instrumentation-fetch'?: false; '@opentelemetry/instrumentation-xml-http-request'?: false; '@opentelemetry/instrumentation-user-interaction'?: false; }; declare type OtelOptions = { instrumentations?: OtelInstrumentatonOptions; }; declare class Plugin_2<T extends RecordOptions | ObserveOptions> { protected sessionSecureID: string; constructor(options?: T); configureSession(ldCredential: string, options?: T): void; } declare type PrivacySettingOption = 'strict' | 'default' | 'none'; declare type ProductAnalyticsEvents = { /** * Specifies whether to record product analytics for clicks. * Requires the use of the @opentelemetry/instrumentation-user-interaction instrumentation. * @default true */ clicks?: boolean; /** * Specifies whether to record product analytics for page views. * Requires the use of the @opentelemetry/instrumentation-document-load instrumentation. * @default true */ pageViews?: boolean; /** * Specifies whether to record product analytics for custom events. * @default true */ trackEvents?: boolean; }; declare type PropertiesMessage = { type: MessageType.Properties; propertiesObject: any; propertyType?: PropertyType; }; declare type PropertyType = { type?: 'track' | 'session'; source?: Source; }; declare type PushMetricsMutation = { __typename?: 'Mutation'; pushMetrics: number; }; declare type PushMetricsMutationVariables = Exact<{ metrics: Array<InputMaybe<MetricInput>> | InputMaybe<MetricInput>; }>; declare type PushPayloadMutation = { __typename?: 'Mutation'; pushPayload: number; }; declare type PushPayloadMutationVariables = Exact<{ session_secure_id: Scalars['String']['input']; payload_id: Scalars['ID']['input']; events: ReplayEventsInput; messages: Scalars['String']['input']; resources: Scalars['String']['input']; web_socket_events: Scalars['String']['input']; errors: Array<InputMaybe<ErrorObjectInput>> | InputMaybe<ErrorObjectInput>; is_beacon?: InputMaybe<Scalars['Boolean']['input']>; has_session_unloaded?: InputMaybe<Scalars['Boolean']['input']>; highlight_logs?: InputMaybe<Scalars['String']['input']>; }>; declare type PushSessionEventsMutation = { __typename?: 'Mutation'; pushSessionEvents?: any | null; }; declare type PushSessionEventsMutationVariables = Exact<{ session_secure_id: Scalars['String']['input']; payload_id: Scalars['Int64ID']['input']; data: Scalars['String']['input']; }>; declare class Record_2 extends Plugin_2<RecordOptions> implements LDPlugin { record: RecordSDK | undefined; options: RecordOptions | undefined; constructor(options?: RecordOptions); private initialize; getMetadata(): { name: string; }; register(client: LDClientMin, environmentMetadata: LDPluginEnvironmentMetadata): void; getHooks?(metadata: LDPluginEnvironmentMetadata): Hook[]; } export { Record_2 as Record } declare interface Record_3 { /** * Start the session when running in `manualStart` mode. * Can be used to force start a new session. * @param options the session start options. */ start: (options?: StartOptions) => Promise<void>; /** * Stop the session recording. */ stop: () => void; /** * Add custom session-level properties. These are attached to the current session * and are searchable, but do not create timeline Track events. */ addSessionProperties: (properties: { [key: string]: any; }) => void; /** * Snapshot an HTML <canvas> element in WebGL manual snapshotting mode. * See {@link https://www.highlight.io/docs/getting-started/browser/replay-configuration/canvas#manual-snapshotting} * for more information. */ snapshot: (element: HTMLCanvasElement) => Promise<void>; getSession: () => SessionDetails | null; getRecordingState: () => 'NotRecording' | 'Recording'; register(client: LDClientMin, environmentMetadata: LDPluginEnvironmentMetadata): void; getHooks?(metadata: LDPluginEnvironmentMetadata): Hook[]; } declare interface RecordMetric { name: string; value: number; category?: MetricCategory; group?: string; tags?: { name: string; value: string; }[]; } declare type RecordOptions = CommonOptions & { /** * Specifies where the backend of the app lives. If specified, the SDK will attach the * traceparent header to outgoing requests whose destination URLs match a substring * or regexp from this list, so that backend errors can be linked back to the session. * If 'true' is specified, all requests to the current domain will be matched. * @example tracingOrigins: ['localhost', /^\//, 'backend.myapp.com'] */ tracingOrigins?: boolean | (string | RegExp)[]; /** * If set, the SDK will not record when your app is not visible (in the background). * By default, the SDK will record in the background. * @default false */ disableBackgroundRecording?: boolean; enableSegmentIntegration?: boolean; /** * Specifies the environment your application is running in. * This is useful to distinguish whether your session was recorded on localhost or in production. * @default 'production' */ environment?: 'development' | 'staging' | 'production' | string; /** * Specifies how much data the SDK should redact during recording. * strict - the SDK will redact all text data, input fields, images and videos on the page. * default - the SDK will redact text data on the page that resembles PII (based on regex patterns). * none - the SDK will not redact any text data on the page. * // Redacted text will be randomized. Instead of seeing "Hello World" in a recording, you will see "1fds1 j59a0". * @see {@link https://launchdarkly.com/docs/sdk/features/session-replay-config#privacy} for more information. */ privacySetting?: PrivacySettingOption; /** * Enable masking all <input/> elements. Only applies if privacySetting is `none`. */ maskAllInputs?: boolean; /** * Customize the input element types that are masked. Only applies if privacySetting is `none`. */ maskInputOptions?: MaskInputOptions; /** * Customize which elements' text should be masked by specifying a CSS class name or RegExp. * Default class is 'highlight-mask'. */ maskTextClass?: string | RegExp; /** * Customize which elements' text should be masked via a CSS selector that will match the element * and its descendants. */ maskTextSelector?: string; /** * Customize which elements should be blocked (not recorded) by specifying a class name or RegExp. * Default is 'highlight-block'. */ blockClass?: string | RegExp; /** * Customize which elements should be blocked via a CSS selector. */ blockSelector?: string; /** * Customize which elements and their descendants should be ignored from DOM events by class. * Default is 'highlight-ignore'. */ ignoreClass?: string; /** * Customize which elements should be ignored from DOM events via a CSS selector. */ ignoreSelector?: string; /** * Specifies whether to record canvas elements or not. * @default false */ enableCanvasRecording?: boolean; /** * Configure the recording sampling options, eg. how frequently we record canvas updates. */ samplingStrategy?: SamplingStrategy; /** * Specifies whether to inline images into the recording. * This means that images that are local to the client (eg. client-generated blob: urls) * will be serialized into the recording and will be valid on replay. * This will also use canvas snapshotting to inline <video> elements * that use `src="blob:..."` data or webcam feeds (blank src) as <canvas> elements * Only enable this if you are running into issues with client-local images. * Will negatively affect performance. * @default false */ inlineImages?: boolean; /** * Specifies whether to inline <video> elements into the recording. * This means that video that are not accessible at a later time * (eg., a signed URL that is short lived) * will be serialized into the recording and will be valid on replay. * Only enable this if you are running into issues with the normal serialization. * Will negatively affect performance. * @default false */ inlineVideos?: boolean; /** * Specifies whether to inline stylesheets into the recording. * This means that stylesheets that are local to the client (eg. client-generated blob: urls) * will be serialized into the recording and will be valid on replay. * Only enable this if you are running into issues with client-local stylesheets. * May negatively affect performance. * @default true */ inlineStylesheet?: boolean; /** * Enables recording of cross-origin iframes. Should be set in both the parent window and * in the cross-origin iframe. * @default false */ recordCrossOriginIframe?: boolean; integrations?: IntegrationOptions; /** * Specifies the keyboard shortcut to open the current session replay. * @see {@link https://launchdarkly.com/docs/sdk/features/session-replay-config#retrieve-session-urls-on-the-client} for more information. */ sessionShortcut?: SessionShortcutOptions; /** * By default, data is serialized and send by the Web Worker. Set to `local` to force * sending from the main js thread. Only use `local` for custom environments where Web Workers * are not available (ie. Figma plugins). */ sendMode?: 'webworker' | 'local'; }; declare class RecordSDK implements Record_3 { options: HighlightClassOptions; /** Determines if the client is running on a Highlight property (e.g. frontend). */ isRunningOnHighlight: boolean; /** Verbose project ID that is exposed to users. Legacy users may still be using ints. */ organizationID: string; graphqlSDK: Sdk; events: eventWithTime[]; sessionData: SessionData; ready: boolean; manualStopped: boolean; state: 'NotRecording' | 'Recording'; logger: Logger; enableSegmentIntegration: boolean; privacySetting: PrivacySettingOption; enableCanvasRecording: boolean; samplingStrategy: SamplingStrategy; inlineImages: boolean; inlineVideos: boolean; inlineStylesheet: boolean; debugOptions: DebugOptions; listeners: listenerHandler[]; firstloadVersion: string; environment: string; sessionShortcut: SessionShortcutOptions; /** The end-user's app version. This isn't Highlight's version. */ appVersion: string | undefined; serviceName: string; _worker: HighlightClientRequestWorker; _optionsInternal: Omit<RecordOptions, 'firstloadVersion'>; _backendUrl: string; _recordingStartTime: number; _isOnLocalHost: boolean; _onToggleFeedbackFormVisibility: () => void; _isCrossOriginIframe: boolean; _eventBytesSinceSnapshot: number; _lastSnapshotTime: number; _lastVisibilityChangeTime: number; pushPayloadTimerId: ReturnType<typeof setTimeout> | undefined; hasSessionUnloaded: boolean; hasPushedData: boolean; reloaded: boolean; _hasPreviouslyInitialized: boolean; _recordStop: listenerHandler | undefined; _integrations: IntegrationClient[]; constructor(options: HighlightClassOptions); _reset({ forceNew, sessionKey, }: { forceNew?: boolean; sessionKey?: string; }): Promise<void>; _initMembers(options: HighlightClassOptions): void; identify(user_identifier: string, user_object?: {}, source?: Source): void; track(event: string, metadata?: Metadata_2): void; ad