Technical Details What Hawk does under the hood

Responsible Monkey Patching

Monkey patching is a technique that dynamically replaces a method at runtime, without changing the original source code. It can view, add to, modify or suppress the original method. However, Hawk’s monkey patching takes great care to leave the original functionality untouched; if we monkey patch a method, it’s only to analyze, never to change anything. Like this:

const realFetchImplementation = window.fetch
window.fetch = function (arg1, arg2) {
  const result = realFetchImplementation.apply(this, arguments)
  // Hawk code
  return result
}


Here is a list of the Javascript methods that we monkey patch:

fetch requests & responses

Used to:

  • Report errors
  • Gather user information
XMLHttpRequest requests & responses

Used to:

  • Report errors
  • Gather user information
window.history.pushState & window.history.replaceState

Used to:

  • Watch for changes to the page URL
Console methods (assert, clear, count, dir, error, group, groupCollapsed, groupEnd, info, log, table, time, timeEnd, trace and warn )

Used to:

  • Report errors

Event Listeners

Just as with monkey patching, our event listeners are clean and safe. If another script has registered any event handlers for an event that we use, we make sure to call those handlers responsibly.
Here is a list of the event handlers we use:

unhandledrejection

Used to:

  • Report errors
Javascript errors

Used to:

  • Report errors
scroll and resize

Used to:

  • Display user session screenshots
mousemove and keydown

Used to:

  • Detect when users are active

Other Tools we Use

MutationObserver

Used to:

  • Display user session screenshots
WebSockets

We use websockets to communicate between our server and the end user’s browser

Cookies & sessionStorage

These are used to store an identifier, which allows us to distinguish between different devices, browsers or tabs coming from the same IP address.

Other Technical Topics

Technical information about a Hawk’s default data masking can be found here.
A complete list of all the criteria used in Hawk’s filters can be found here.


Did you find this article helpful?