/**
* MIT License
*
* Copyright (c) 2020-present ReplaUX.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/** @internal */
declare global {
interface Window {
rrwebRecord: any;
}
}
/** Supported events: `recording`
* @remark Helps autocomplete and type checking for {@link ReplaUX.on} and the rest of events. */
export declare type TEvents = 'recording';
/**
* # Settings interface
*
* Defiines how to configure {@link ReplayUX}.
* All the parameters that starts with `rec` can be used via html `
* ```
* */
export interface IReplayUXSettings {
/** The recording type
* @default 'page'
* @html-attribute `rec-type` */
recType?: string;
/**
* The recording id that will help to identify the recording.
* @default empty string
* @html-attribute `rec-id` */
recId?: string;
/** The title of the recording
* @default empty string
* @html-attribute `rec-title` */
recTitle?: string;
/** A description for the recording
* @default empty string
* @html-attribute `rec-description` */
recDescription?: string;
/** The User ID, by default it will generate a random one and save as cookie for later uses
* @default random value
* @html-attribute `rec-uid` */
recUid?: string;
/** Required when it is not possible to protect `replayux.com` account with domain,
* for example, for use in hybrid mobile app screen recordings.
* @default empty string
* @html-attribute `rec-api-key` */
recApiKey?: string;
/** Start recording immediately
* @default true
* @html-attribute `rec-auto-start` */
recAutoStart?: boolean;
/**
* Additional options, {@link https://github.com/rrweb-io/rrweb/blob/master/guide.md#record}.
* When a string is provided (for example, in a `
* ```
*
* ### Javascript
*
* To use the component from Javascript is as easy as instantiating the component. Global
* `replayux` variable will be available in the `window` context.
*
* @example Load ReplayUX and start recording immediately
*
* - First load the script without any `rec-` attribute:
* ```html
*
* ```
*
* - Then from javascript:
* ```js
* new replayux.ReplayUX({
* recId: 'basic',
* recTitle: 'Basic example',
* recDescription: 'Recording the basic example page',
* recUid: 'uid',
* recCookiesEnabled: true,
* });
* ```
*
* ### Package
*
* To use the component from the package, the package must be installed first (npm or yarn).
*
* @example Load ReplayUX and start recording immediately
*
* - Install the package:
* ```
* npm install replayux --save
* ```
*
* - Use on *Typescript* or *Javascript* code:
* ```js
* import { ReplayUX } from 'replayux';
* // or legendary const { ReplayUX } = require('replayux');
* new replayux.ReplayUX({
* recId: 'basic',
* recTitle: 'Basic example',
* recDescription: 'Recording the basic example page',
* recUid: 'uid',
* recCookiesEnabled: true,
* });
* ```
*/
export declare class ReplayUX {
/** @internal the promise for rrweb lazy load */
private static p;
/** @interal sid: session id, unique for each recording */
private a;
/** @internal events: the recorded events */
private e;
/** @internal sendIntervalTimeout: the setInterval timeout value, in order to clear interval */
private i;
/** @internal stopRRWebCb: the callback to stop rrweb recording */
private o;
/** @internal subscriptions object with listeners for each event */
private u;
/** @internal the time a recording has started */
private t;
/** @internal ReplayUX settings */
private g;
/** Indicates whether it is recording or not */
isRecording: boolean;
/**
* Get/set ReplayUX settings {@link IReplayUXSettings}
* When updating settings in the middle of a recording, new settings will be saved
* when the recording finishes.
*
* @remark Please note that there are some settings that cannot be modified after
* `start()` method has been called.
*/
get settings(): IReplayUXSettings;
/**
* Get/set ReplayUX settings {@link IReplayUXSettings}
* When updating settings in the middle of a recording, new settings will be saved
* when the recording finishes.
*
* @remark Please note that there are some settings that cannot be modified after
* `start()` method has been called.
*
* @param newSettings New settings that will override old ones
*/
set settings(newSettings: IReplayUXSettings);
/**
* Creates a new {@link ReplayUX} class.
* @param settings ReplayUX settings {@link IReplayUXSettings}
*/
constructor(settings: IReplayUXSettings);
/** Start the recording as soon as recorder is available */
start(): void;
/** Stop recording immediately */
stop(): null;
/**
* Removes the uid cookie
*/
removeUid(): void;
/**
* Adds the `listener` function to the end of the listeners array for the event named `eventName`.
* No checks are made to see if the `listener` has already been added.
* Multiple calls passing the same combination of `eventName` and `listener`
* will result in the `listener` being added, and called, multiple times.
* @param eventName The name of the event
* @param listener The callback function
*/
on(eventName: TEvents, listener: Function): void;
/**
* Removes all listeners, or those of the specified `eventName`.
* @param eventName The name of the event
*/
removeAllListeners(eventName: TEvents): void;
/**
* Removes the specified listener from the listener array for the event named `eventName`.
* @param eventName The name of the event
* @param listener The callback function
*/
removeListener(eventName: TEvents, listener: Function): void;
/**
* Alias for `removeListener()`.
* @param eventName The name of the event
* @param listener The callback function
*/
off(eventName: TEvents, listener: Function): void;
/**
* @internal lazyLoadRrweb: Loads rrweb script and assigns the loading to a promise
* so we can wait for the script to be loaded to start recording.
*/
private l;
/** @internal sendEvents: Sends the recorded events to backend server */
private s;
/** @internal getRandom: Generates a random number */
private r;
}
/**
* When {@link ReplayUX} is installed via `
* ```
*
* This variable contains the instance used to record so it can be used to control the recording.
*/
declare const recorder: ReplayUX;
export { recorder };