re-add addCustomEvent function via function property
This commit is contained in:
@@ -25,21 +25,6 @@ function wrapEvent(e: event): eventWithTime {
|
||||
|
||||
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 {
|
||||
const {
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user