-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
plugin API #598
Merged
Merged
plugin API #598
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
YunFeng0817
approved these changes
Jun 27, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The plugin mechanism looks great to me!
And I did a little change to the replay code.
@Mark-Fenng I've updated several commits and add the description in this PR. |
YunFeng0817
approved these changes
Jun 27, 2021
Merged
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There are some long-term feature-requested in our issue list, including:
And we also get some feedback from users who want rrweb to keep the minimal implementation of record and replay the web, which is stable and performant.
The plugin API is the solution to these questions.
Interface
Same to with other functionality in rrweb, a plugin can implement record or replay or both features.
Both record and replay plugins have a type interface.
example
record plugin
In this example, the record plugin will emit events like this:
replay plugin
A replay plugin can interact with the replayer by using
context.replayer
.naming a plugin
A record plugin should have a unique name, and it will be stored in the event it emits.
Since we will have both plugins in the rrweb repo and plugins in users' own codebase, which may cause naming conflicts in the future, we strongly recommended users naming their own plugins in this way:
For example
rrweb/console@1
orgithub/pr@2
.bundling
The plugins will be bundled into the all-in-one entry and also have a standalone version for iife, CommonJS, and ESmodule.
breaking changes
In this PR, we migrated the log recording feature into the new plugin API, which introduces some breaking changes.
The record option
recordLog
has been removed, the new API is:The replay option
logConfig
has been removed, the new API is:And data recorded by the legacy log recording feature will replay correctly with any extra work.