re-add addCustomEvent function via function property
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import record, { addCustomEvent } from './record';
|
import record from './record';
|
||||||
import { Replayer } from './replay';
|
import { Replayer } from './replay';
|
||||||
import { mirror } from './utils';
|
import { mirror } from './utils';
|
||||||
|
|
||||||
@@ -8,4 +8,7 @@ export {
|
|||||||
MouseInteractions,
|
MouseInteractions,
|
||||||
ReplayerEvents,
|
ReplayerEvents,
|
||||||
} from './types';
|
} from './types';
|
||||||
|
|
||||||
|
const { addCustomEvent } = record;
|
||||||
|
|
||||||
export { record, addCustomEvent, Replayer, mirror };
|
export { record, addCustomEvent, Replayer, mirror };
|
||||||
|
|||||||
@@ -25,21 +25,6 @@ function wrapEvent(e: event): eventWithTime {
|
|||||||
|
|
||||||
let wrappedEmit!: (e: eventWithTime, isCheckout?: boolean) => void;
|
let wrappedEmit!: (e: eventWithTime, isCheckout?: boolean) => void;
|
||||||
|
|
||||||
export function addCustomEvent<T>(tag: string, payload: T) {
|
|
||||||
if (!wrappedEmit) {
|
|
||||||
throw new Error('please add custom event after start recording');
|
|
||||||
}
|
|
||||||
wrappedEmit(
|
|
||||||
wrapEvent({
|
|
||||||
type: EventType.Custom,
|
|
||||||
data: {
|
|
||||||
tag,
|
|
||||||
payload,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function record(options: recordOptions = {}): listenerHandler | undefined {
|
function record(options: recordOptions = {}): listenerHandler | undefined {
|
||||||
const {
|
const {
|
||||||
emit,
|
emit,
|
||||||
@@ -228,4 +213,19 @@ function record(options: recordOptions = {}): listenerHandler | undefined {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
record.addCustomEvent = <T>(tag: string, payload: T) => {
|
||||||
|
if (!wrappedEmit) {
|
||||||
|
throw new Error('please add custom event after start recording');
|
||||||
|
}
|
||||||
|
wrappedEmit(
|
||||||
|
wrapEvent({
|
||||||
|
type: EventType.Custom,
|
||||||
|
data: {
|
||||||
|
tag,
|
||||||
|
payload,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export default record;
|
export default record;
|
||||||
|
|||||||
3
typings/index.d.ts
vendored
3
typings/index.d.ts
vendored
@@ -1,5 +1,6 @@
|
|||||||
import record, { addCustomEvent } from './record';
|
import record from './record';
|
||||||
import { Replayer } from './replay';
|
import { Replayer } from './replay';
|
||||||
import { mirror } from './utils';
|
import { mirror } from './utils';
|
||||||
export { EventType, IncrementalSource, MouseInteractions, ReplayerEvents, } from './types';
|
export { EventType, IncrementalSource, MouseInteractions, ReplayerEvents, } from './types';
|
||||||
|
declare const addCustomEvent: <T>(tag: string, payload: T) => void;
|
||||||
export { record, addCustomEvent, Replayer, mirror };
|
export { record, addCustomEvent, Replayer, mirror };
|
||||||
|
|||||||
4
typings/record/index.d.ts
vendored
4
typings/record/index.d.ts
vendored
@@ -1,4 +1,6 @@
|
|||||||
import { recordOptions, listenerHandler } from '../types';
|
import { recordOptions, listenerHandler } from '../types';
|
||||||
export declare function addCustomEvent<T>(tag: string, payload: T): void;
|
|
||||||
declare function record(options?: recordOptions): listenerHandler | undefined;
|
declare function record(options?: recordOptions): listenerHandler | undefined;
|
||||||
|
declare namespace record {
|
||||||
|
var addCustomEvent: <T>(tag: string, payload: T) => void;
|
||||||
|
}
|
||||||
export default record;
|
export default record;
|
||||||
|
|||||||
Reference in New Issue
Block a user