Skip to content

Latest commit

 

History

History
142 lines (99 loc) · 4.83 KB

README.md

File metadata and controls

142 lines (99 loc) · 4.83 KB

Reanimator

Capture and replay JavaScript applications

Reanimator captures non-deterministic input to a JavaScript application in a log that can replayed at a later date. It was originally designed for recording web application crashes in the wild for later debugging, but it may be useful for other purposes, such as usability testing and tutorials.

Reanimator consists of a core, which is responsible for capture setup and driving the replay, and one or more plugins, which are responsible for capturing and replaying non-deterministic input.

Reanimator ships with plugins for capturing and replaying random numbers, dates, and timer interrupts. In addition, Reanimator provides plugins for capturing and replaying callback invocations in the following frameworks:

  • jQuery 1.8.3

Reanimator was inspired by Mugshot by James Mickens, Jeremy Elson, and Jon Howell.

Demos

Tile game

API

Reanimator.capture

Capture non-deterministic input

Call this method to begin logging non-deterministic input to your JavaScript application. To capture a useful log, you must call Reanimator.capture before such input occurs, but after libraries like jQuery have been loaded.

The log is reset whenever this method is called.

Reanimator.replay

Replay a log of non-deterministic input

Arguments

  • log - object - the log to replay, in the format emitted by Reanimator.flush
  • config - object - configuration object
    • config.delay - string | integer - how long Reanimator should wait before replaying the next event in the log

      For a fixed delay, specify the number of ms between steps (the default is 0). If the string 'realtime' is specified, Reanimator will make a good faith effort to replay the events with the actual delays recorded in the log.

Reanimator.flush

Return a copy of the current log

Returns a copy of the current log as an object with the following properties:

  • dates - [ number ] - captured dates, specified in ms since the epoch

  • random - [ number ] - captured random numbers generated by Math.random

  • events - [ object ] - captured callback invocations

    Each element is an object with the following properties:

    • type - string - the type of the recorded callback
    • time - number - the time the callback was fired (ms since the epoch)
    • details - any - any additional details necessary to replay the callback

Reanimator.cleanUp

Stop capturing or replaying and restore native methods and objects

This method does not clear the most recent log.

Reanimator.plug

Install a plugin to capture and replay some non-deterministic input

Arguments

  • type - string - a unique string corresponding to the type property of any events the plugin will log
  • plugin - object - the plugin to install

A plugin is an object that implements the following methods:

  • init: initialize the plugin

    Called once, by plug

    Arguments

    • native - object - an object to store a reference to any native methods or objects the plugin interposes on
  • capture: prepare to capture the input the plugin is responsible for

    Called by Reanimator.capture

  • cleanUp - restore any native methods or objects the plugin interposed on

  • beforeReplay - prepare to replay

    Optional; called by Reanimator.replay immediately before the first event is replayed

    Arguments

    • log - object - the log to be replayed
    • config - object - the replay configuration
  • replay - replay a captured event

    Required if the plugin logs to events, optional otherwise

    Arguments

    • event - object - the event to replay, in the format specified above in Reanimator.flush

License

Reanimator is made available under the MIT License.

Acknowledgements and Attribution

Thanks to James Mickens, Jeremy Elson, and Jon Howell for their excellent work on Mugshot, which inspired Reanimator.

The image demos/tile-game/img/reanimator.jpg is the work [Re-Animator] (http://fav.me/d24n0v9) and is copyright (c) 2009 ~cool-slayer and made available under an Attribution-Noncommercial-No Derivative Works 3.0 License.