Revert "temp revert #81"

This reverts commit 835161c737.
This commit is contained in:
Yanzhen Yu
2026-04-01 12:00:00 +08:00
parent bd6474cae5
commit f872ed143b
5 changed files with 36 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
import record from './record';
import record, { addCustomEvent } from './record';
import { Replayer } from './replay';
import { mirror } from './utils';
@@ -8,4 +8,4 @@ export {
MouseInteractions,
ReplayerEvents,
} from './types';
export { record, Replayer, mirror };
export { record, addCustomEvent, Replayer, mirror };

View File

@@ -25,6 +25,21 @@ 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,