diff --git a/README.md b/README.md index 61019d3f..111c37ea 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,10 @@ +
+
+
+ Try rrweb +
+ # rrweb [](https://travis-ci.org/rrweb-io/rrweb) @@ -8,6 +15,10 @@ rrweb refers to 'record and replay the web', which is a tool for recording and r **Currently, rrweb has already solved many difficult problems in recording and replaying, but the data structure may still be changed before the release of Version 1.0. So please be cautious to use rrweb in the production environment.** +## Guide + +[**📚 Read the rrweb guide here. 📚**](./guide.md) + ## Project Structure rrweb is mainly composed of 3 parts: @@ -31,12 +42,12 @@ rrweb is mainly composed of 3 parts: - hijack Ajax/fetch API and record request events - use TraceKit to log exception events -## Internal Design + ## Contribute Guide @@ -51,33 +62,4 @@ Since we want the record and replay sides to share a strongly typed data structu In addition to adding integration tests and unit tests, rrweb also provides a REPL testing tool. -Run `npm run repl` to launch a browser and ask for a URL you want to test on the CLI: - -``` -Enter the url you want to record, e.g https://react-redux.realworld.io: -``` - -Waiting for the browser to open the specified page and print following messages on the CLI: - -``` -Enter the url you want to record, e.g https://react-redux.realworld.io: https://github.com -Going to open https://github.com... -Ready to record. You can do any interaction on the page. -Once you want to finish the recording, enter 'y' to start replay: -``` - -At this point, you can interact in the web page. After the desired operations have been recorded, enter 'y' on the CLI, and the test tool will replay the operations to verify whether the recording was successful. - -The following messages will be printed on the CLI during replay: - -``` -Enter 'y' to persistently store these recorded events: -``` - -At this point, you can enter 'y' again on the CLI. The test tool will save the recorded session into a static HTML file and prompt for the location: - -``` -Saved at PATH_TO_YOUR_REPO/temp/replay_2018_11_23T07_53_30.html -``` - -This file uses the latest rrweb bundle code, so we can run `npm run bundle:browser` after patching the code, then refresh the static file to see and debug the impact of the latest code on replay. +[Using the REPL tool](./guide.md#REPL-tool) diff --git a/README.zh_CN.md b/README.zh_CN.md index 3c71a4c5..9458e755 100644 --- a/README.zh_CN.md +++ b/README.zh_CN.md @@ -1,3 +1,10 @@ +
+
+
+ Try rrweb +
+ # rrweb [](https://travis-ci.org/rrweb-io/rrweb) @@ -6,6 +13,10 @@ rrweb 是 'record and replay the web' 的简写,旨在利用现代浏览器所 **目前 rrweb 已经解决了许多录制与回放中的难点问题,但在 1.0 版本 release 之前数据结构仍有可能发生变化,请谨慎用于生产环境中。** +## 指南 + +[**📚 rrweb 使用指南 📚**](./guide.zh_CN.md) + ## 项目结构 rrweb 主要由 3 部分组成: diff --git a/guide.md b/guide.md new file mode 100644 index 00000000..59b58588 --- /dev/null +++ b/guide.md @@ -0,0 +1,237 @@ +# Guide + +[中文指南](./guide.zh_CN.md) + +## Installation + +### Direct ` +``` + +Also, you can link to a specific version number that you can update manually: + +```html + +``` + +#### Only include the recorder code + +rrweb's code includes both the record and the replay parts. Most of the time you only need include the record part into your target web Apps. +This also can be done by using the CDN service: + +```html + +``` + +### NPM + +```shell +npm install --save rrweb +``` + +rrweb provides both commonJS and ES modules bundles, which is easy to use with the popular bundlers. + +## Getting Started + +### Record + +If you only include record code with ` +``` + +Or installed by using NPM: + +```shell +npm install --save rrweb-player +``` + +##### Usage + +```js +new rrwebPlayer({ + target: document.body, // customizable root element + data: { + events, + }, +}); +``` + +## API + +### rrweb + +#### rrweb.record + +```typescript +type record = (options: recordOptions) => listenerHandler; + +type recordOptions = { + emit: (e: eventWithTime) => void; +}; +type listenerHandler = () => void; +``` + +#### rrweb.Replayer + +```typescript +class Replayer { + public wrapper: HTMLDivElement; + + constructor(events: eventWithTime[], config?: Partial