Skip to content
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

feat: enable rrweb to record and replay log messages in console #424

Merged
merged 9 commits into from
Nov 29, 2020
Merged

feat: enable rrweb to record and replay log messages in console #424

merged 9 commits into from
Nov 29, 2020

Conversation

YunFeng0817
Copy link
Member

@YunFeng0817 YunFeng0817 commented Nov 22, 2020

this is the implementation of new feature request(issue #234 )(issue #317 )

here are a few points of description.

  1. users need to set recordLog option in rrweb.record's parameter to record log messages. The log recorder is off by default.
  2. support recording and replaying all kinds of console functions. But the reliability of them should be tested more
  3. the stringify function in stringify.ts needs improvement. e.g. robustness and better support for more kinds of object
  4. we can replay the log messages in a simulated html console like LogRocket by implementing the interface "ReplayLogger" in the future

@YunFeng0817 YunFeng0817 requested a review from Yuyz0112 November 23, 2020 02:07
hijack all of the console functions.
add listener to thrown errors
add limit to the max number of log records
this is the implementation of new feature request(issue #234)

here are a few points of description.
1. users need to set recordLog option in rrweb.record's parameter to record log messages.  The log recorder is off by default.
2. support recording and replaying all kinds of console functions. But the reliability of them should be tested more
3. the stringify function in  stringify.ts needs improvement. e.g. robustness, handler for cyclical structures and better support for more kinds of object
4. we can replay the log messages in a simulated html console like LogRocket by implementing the interface "ReplayLogger" in the future
1. handle cyclical structures
2. add stringify option to limit the length of result
3. handle function type
@YunFeng0817
Copy link
Member Author

@Yuyz0112 Could you please review this pull request😂 I've solved merge conflicts two times in the past one week

src/types.ts Outdated
};

// functions to replay log record
export type ReplayLogger = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

export type ReplayLogger = Record<LogLevel, (data: logData) => void>

Is this an equivalent?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this one is better!

@Yuyz0112
Copy link
Member

LGTM

Most of the design looks great and just a few things need to be tweaked.

@Yuyz0112 Yuyz0112 merged commit 4e7146e into rrweb-io:master Nov 29, 2020
@YunFeng0817 YunFeng0817 deleted the develop branch November 29, 2020 10:58
@eoghanmurray
Copy link
Contributor

There is no easy way to transmit events for when an unhandled exception happens on the page?
I.e. if we don't have a chance to catch and log with console.error because the exception happens in 3rd party js code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants