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

Monitor for DOM changes #14

Open
G0dwin opened this issue Mar 16, 2017 · 0 comments
Open

Monitor for DOM changes #14

G0dwin opened this issue Mar 16, 2017 · 0 comments

Comments

@G0dwin
Copy link
Collaborator

G0dwin commented Mar 16, 2017

This would probably be better inside a Rails specific package but it would be nice to look for DOM changes, particularly after Ajax calls. If we were to create a marmara-rails package, we could inject JS code into each page that would call an endpoint to initiate a record call. We could monitor for AJAX calls using:

(function() {
  var requestOpen = XMLHttpRequest.prototype.open;
  XMLHttpRequest.prototype.open = function() {
    this.addEventListener('load', function() {
      if (this.readyState === 4) {
        if (this.responseText !== 'marmara-ok') {
          // make an AJAX call to our '/__marmara_record' endpoint which will call Marmara.record and return 'marmara-ok';
        }
      }
    });
    requestOpen.apply(this, arguments);
  };
})();
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

No branches or pull requests

1 participant