temp revert #81

This patch introduce a breaking change in rrweb-record's API, so
we will revert it in 0.7.x and release it in 0.8.
This commit is contained in:
Yanzhen Yu
2019-08-12 21:21:53 +08:00
parent 7ddf1f8ddb
commit 835161c737
5 changed files with 4 additions and 36 deletions

View File

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

View File

@@ -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,

View File

@@ -23,7 +23,6 @@ interface ISuite extends Suite {
interface IWindow extends Window {
rrweb: {
record: (options: recordOptions) => listenerHandler | undefined;
addCustomEvent<T>(tag: string, payload: T): void;
};
emit: (e: eventWithTime) => undefined;
}
@@ -181,19 +180,4 @@ describe('record', function(this: ISuite) {
await this.page.waitFor(50);
assertSnapshot(this.events, __filename, 'async-checkout');
});
it('can add custom event', async () => {
await this.page.evaluate(() => {
const { record, addCustomEvent } = (window as IWindow).rrweb;
record({
emit: (window as IWindow).emit,
});
addCustomEvent<number>('tag1', 1);
addCustomEvent<{ a: string }>('tag2', {
a: 'b',
});
});
await this.page.waitFor(50);
assertSnapshot(this.events, __filename, 'custom-event');
});
});

4
typings/index.d.ts vendored
View File

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

View File

@@ -1,4 +1,3 @@
import { recordOptions, listenerHandler } from '../types';
export declare function addCustomEvent<T>(tag: string, payload: T): void;
declare function record(options?: recordOptions): listenerHandler | undefined;
export default record;