@coralogix/browser
Version:
Official Coralogix SDK for browsers
104 lines (103 loc) • 9.76 kB
TypeScript
import { eventWithTime } from '@rrweb/types';
import { SlimDOMOptions } from 'rrweb-snapshot';
import { CoralogixEventType } from '../types';
import { recordOptions } from 'rrweb';
/**
* Record config properties - based on rrweb
*
* | key | default | description |
* | ------------------------ | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
* | emit | required | the callback function to get emitted events |
* | checkoutEveryNth | - | take a full snapshot after every N events<br />refer to the [checkout](#checkout) chapter |
* | checkoutEveryNms | - | take a full snapshot after every N ms<br />refer to the [checkout](#checkout) chapter |
* | blockClass | 'rr-block' | Use a string or RegExp to configure which elements should be blocked, refer to the [privacy](#privacy) chapter |
* | blockSelector | null | Use a string to configure which selector should be blocked, refer to the [privacy](#privacy) chapter |
* | ignoreClass | 'rr-ignore' | Use a string or RegExp to configure which elements should be ignored, refer to the [privacy](#privacy) chapter |
* | ignoreSelector | null | Use a string to configure which selector should be ignored, refer to the [privacy](#privacy) chapter |
* | ignoreCSSAttributes | null | array of CSS attributes that should be ignored |
* | maskTextClass | 'rr-mask' | Use a string or RegExp to configure which elements should be masked, refer to the [privacy](#privacy) chapter |
* | maskTextSelector | null | Use a string to configure which selector should be masked, refer to the [privacy](#privacy) chapter |
* | maskAllInputs | false | mask all input content as \* |
* | maskInputOptions | { password: true } | mask some kinds of input \*<br />refer to the [list](https://github.com/rrweb-io/rrweb/blob/588164aa12f1d94576f89ae0210b98f6e971c895/packages/rrweb-snapshot/src/types.ts#L77-L95) |
* | maskInputFn | - | customize mask input content recording logic |
* | maskTextFn | - | customize mask text content recording logic |
* | slimDOMOptions | {} | remove unnecessary parts of the DOM <br />refer to the [list](https://github.com/rrweb-io/rrweb/blob/588164aa12f1d94576f89ae0210b98f6e971c895/packages/rrweb-snapshot/src/types.ts#L97-L108) |
* | dataURLOptions | {} | Canvas image format and quality ,This parameter will be passed to the OffscreenCanvas.convertToBlob(),Using this parameter effectively reduces the size of the recorded data |
* | inlineStylesheet | true | whether to inline the stylesheet in the events |
* | hooks | {} | hooks for events<br />refer to the [list](https://github.com/rrweb-io/rrweb/blob/9488deb6d54a5f04350c063d942da5e96ab74075/src/types.ts#L207) |
* | packFn | - | refer to the [storage optimization recipe](./docs/recipes/optimize-storage.md) |
* | sampling | - | refer to the [storage optimization recipe](./docs/recipes/optimize-storage.md) |
* | recordCanvas | false | Whether to record the canvas element. Available options:<br/>`false`, <br/>`true` |
* | recordCrossOriginIframes | false | Whether to record cross origin iframes. rrweb has to be injected in each child iframe for this to work. Available options:<br/>`false`, <br/>`true` |
* | recordAfter | 'load' | If the document is not ready, then the recorder will start recording after the specified event is fired. Available options: `DOMContentLoaded`, `load` |
* | inlineImages | false | whether to record the image content |
* | collectFonts | false | whether to collect fonts in the website |
* | userTriggeredOnInput | false | whether to add `userTriggered` on input events that indicates if this event was triggered directly by the user or not. [What is `userTriggered`?](https://github.com/rrweb-io/rrweb/pull/495) |
* | plugins | [] | load plugins to provide extended record functions. [What is plugins?](./docs/recipes/plugin.md) |
* | errorHandler | - | A callback that is called if something inside of rrweb throws an error. The callback receives the error as argument.
*/
export interface SessionRecordingConfig extends Omit<recordOptions<eventWithTime>, 'emit' | 'packFn' | 'plugins' | 'hooks' | 'slimDOMOptions'> {
enable: boolean;
autoStartSessionRecording: boolean;
recordConsoleEvents?: boolean;
maxMutations?: number;
excludeDOMOptions?: SlimDOMOptions;
/** Percentage of overall sessions recording being tracked, defaults to 100% and applied after the overall sample rate sessionSampleRate */
sessionRecordingSampleRate?: number;
workerUrl?: string;
}
export interface SessionWithErrorConfig {
enable: boolean;
maxRumEvents?: number;
maxRecordTime?: number;
/**
* Specifies the instrumentation data to be sent for sessions with errors, defaulting to web-vitals only.
* The instrumentation data will only be sent if it is enabled in the main configuration.
* This data will be sent immediately, even if no error has occurred.
*/
instrumentationsToSend?: Partial<Record<CoralogixEventType, boolean>>;
}
export interface SessionConfig {
sessionSampleRate?: number;
alwaysTrackSessionsWithErrors?: boolean;
onlyWithErrorConfig?: SessionWithErrorConfig;
keepSessionAfterReload?: boolean;
}
export type RecordEvent = eventWithTime;
export type RecordPluginEvent<T = any> = {
type: SessionRecordingEventType.Plugin;
data: {
plugin: string;
payload: T;
};
timestamp: number;
};
export declare enum SessionRecordingEventType {
DomContentLoaded = 0,
Load = 1,
FullSnapshot = 2,
IncrementalSnapshot = 3,
Meta = 4,
Custom = 5,
Plugin = 6
}
export interface SessionRecordingMetadata {
segmentIndex: number;
segmentSize: number;
segmentTimestamp: number;
sessionId: string;
sessionCreationDate: number;
application: string;
subIndex: number | undefined;
snapshotId?: string;
}
export type SessionRecordingWorkerEvent = 'compressRecordData' | 'splitRecordData' | 'sendRecordData' | 'stopRecording';
export interface SessionRecordingWorkerData {
sessionId: string;
sessionCreationDate: number;
gzipBlob?: Blob;
chunkIndex?: number;
totalChunks?: number;
event: SessionRecordingWorkerEvent;
screenshotId?: string;
}