rrweb icon indicating copy to clipboard operation
rrweb copied to clipboard

Added scripts for saving and viewing snapshots

Open croqaz opened this issue 3 years ago • 7 comments

Hi. I wanted to share these 2 useful scripts that I actually use. They can showcase how to use rrWeb, and the script for viewing snapshots is really useful in debug. The scripts are kind of rough. I didn't want to use any special CLI flag parsing libraries, but maybe they are useful? Any suggestions are welcome.

croqaz avatar Mar 23 '22 12:03 croqaz

Hi @croqaz, thanks for sharing your scripts, very interesting to see how you are using rrweb-snapshots. And I agree that it might help people use rrweb-snapshots themselves.

For consistency with packages/rrweb and yarn repl, it would be nice if we could rename the script folder to scripts and remove rrweb_ from the filenames of your scripts. It would also be perfect if the output files of these scripts would be saved to packages/rrweb-snapshot/temp/.

The last thing missing to really makes it consistent with yarn repl would be to also add these scripts as a package.json script. Example: https://github.com/rrweb-io/rrweb/blob/072b81b53485f64e3d8bd242dc202ce68c3f32c5/packages/rrweb/package.json#L11

Juice10 avatar Mar 29 '22 15:03 Juice10

Thank you for the comment @Juice10 , it sounds great and I implemented everything. I also added a shortcut command for generating the dist/rrweb-snapshot.js file, I hope that's OK. I think I only need to use the /temp/ file that you mentioned.

croqaz avatar Mar 30 '22 13:03 croqaz

@croqaz Thanks for the PR! Do you mind updating the script usage from yarn snapshot and yarn rebuild to yarn repl snapshot and yarn repl rebuild? This will help us keep the script's entry minimal.

If so, I can help with this change.

Yuyz0112 avatar Apr 09 '22 06:04 Yuyz0112

@croqaz Thanks for the PR! Do you mind updating the script usage from yarn snapshot and yarn rebuild to yarn repl snapshot and yarn repl rebuild? This will help us keep the script's entry minimal.

I don't think I mind if that helps, but from I could look at the rest of the repl commands, they are located in packages/rrweb. Doesn't that make running these scripts much more complicated? Or we should move them in that folder as well?

croqaz avatar Apr 11 '22 10:04 croqaz

@croqaz IMO, I think npm scripts are a set of scripts to maintain the package, like dev/test/build/etc. And in this use case, I think the snapshot/rebuild commands are good for doing some quick tests with the code, so I propose to move these kinds of commands to the category of repl, which means a simple interactive env to play the code.

If we create a tool called rrweb-snapshot-cli, then two top-level commands, snapshot and rebuild, make great sense.

Yuyz0112 avatar Apr 12 '22 15:04 Yuyz0112

FYI: https://github.com/rrweb-io/rrweb/pull/1033 will get merged soon which will change the build command to yarn build and the location of the rrweb-snapshot.js to dist/rrweb-snapshot.umd.cjs. That will impact this PR a little bit

Juice10 avatar Apr 18 '24 09:04 Juice10

Hi folks! I don't use rrweb for a very long time and I won't be working on this PR anymore. Not sure if I should close the PR... maybe somebody else can pickup the scripts and continue building? They personally helped me a lot, but maybe other people have a different way of working with this. Anyway, feel free to close this! Cheers

croqaz avatar Apr 18 '24 12:04 croqaz