Methods
-
pause()
-
Pauses the MutationObserver. Call
resumeto start it back up. -
resume()
-
Resumes the MutationObserver after a
pause. -
start()
-
Initiate
MutationHandler.observeron theouter parent document.Uses
addObserverto instrument.Our internal handlerwill be called if something happens. -
stop()
-
Disable internal MutationObserver instance. Use this when uninstrumenting the site we're on.
-
add_event_resource(resource)
-
Adds a resource to the current event.
Might fail (return -1) if: a) There are no pending events b) The current event is complete c) There's no passed-in resource
Parameters:
Name Type Description resourceResource
Returns:
Event index, or -1 on failure
-
addEvent(resource)
-
If an event has triggered a resource to be fetched we add it to the list of pending events here and wait for it to eventually resolve.
Parameters:
Name Type Description resourceobject Resourceobject we are waiting forReturns:
Type: index
If we are already waiting for an event of this type null otherwise index in the
queue. -
calculateSpaTimings(resource)
-
Calculates SPA Back-End and Front-End timings for Hard and Soft SPA navigations.
Parameters:
Name Type Description resourceobject Resouce to calculate for
-
clearTimeout(index)
-
If this instance of the
MutationHandlerhas atimerset, clear itParameters:
Name Type Description indexnumber Index of the event in pending_events array
-
completeEvent( [index])
-
Completes the current event, marking the end time as 'now'.
Parameters:
Name Type Argument Description indexnumber <optional>
Optional Event index, defaults to last event
-
load_finished(index, loadEventEnd)
-
Decrement the number of
nodes_to_waitfor thePendingEvent Object.If the nodes_to_wait is decremented to 0 and the event type was SPA:
When we're finished waiting on the last node, the MVC engine (eg AngularJS) might still be doing some processing (eg on an XHR) before it adds some additional content (eg IMGs) to the page. We should wait a while (1 second) longer to see if this happens. If something else is added, we'll continue to wait for that content to complete. If nothing else is added, the end event will be the timestamp for when this load_finished(), not 1 second from now.
Parameters:
Name Type Description indexnumber Index of the event found in the pending_events array
loadEventEndTimeStamp TimeStamp at which the resource was finished loading
-
monitorMO(index)
-
Clear the flag preventing DOM mutation monitoring
Parameters:
Name Type Description indexnumber Index of the event in pending_events array
-
nodesWaitingFor( [index])
-
Determines how many nodes are being waited on
Parameters:
Name Type Argument Description indexnumber <optional>
Optional Event index, defaults to last event
Returns:
Type: number
Number of nodes being waited on
-
queue_is_empty()
-
Determines if the resources queue is empty
Returns:
Type: boolean
True if there are no outstanding resources
-
sendEvent(index)
-
If called with an event in the
pending events listtrigger a beacon for this event.When the beacon is sent for this event is depending on either having a crumb, in which case this beacon will be sent immediately. If that is not the case we wait 5 seconds and attempt to send the event again.
Parameters:
Name Type Description indexnumber Index in event list to send
Returns:
Type: undefined
Returns early if the event already completed
-
sendResource(resource, eventIndex)
-
Creates and triggers sending a beacon for a Resource that has finished loading.
Parameters:
Name Type Description resourceResource The Resource to send a beacon on
eventIndexnumber index of the event in the pending_events array
-
setTimeout(timeout, index)
-
Will create a new timer waiting for
timeoutmilliseconds to wait until a resources load time has ended or should have ended. If the timeout expires the Resource atindexwill be marked as timedout and result in an error Resource marked withXHR_STATUS_TIMEOUTas status information.Parameters:
Name Type Description timeoutnumber time ot wait for the resource to be loaded
indexnumber Index of the
Resourcein ourMutationHandler#pending_events -
timedout(index)
-
Sends a Beacon for the
Resourceatindexwith the statusXHR_STATUS_TIMEOUTcode, If there are multiple resources attached to thepending_eventsarray atindex.Parameters:
Name Type Description indexnumber Index of the event in pending_events array
-
wait_for_node(node, index)
-
Determines if we should wait for resources that would be fetched by the specified node.
Parameters:
Name Type Description nodeElement DOM node
indexnumber Event index
Type Definitions
-
load_cb(ev)
-
Once an asset has been loaded and the resource appeared in the page we check if it was part of the interesting events on the page and mark it as finished.
Parameters:
Name Type Description evEvent Load event Object
-
mutation_cb(mutations)
-
Callback called once
Mutation Observer instancenoticed a mutation on the page. This method will determine if a mutation on the page is interesting or not.Parameters:
Name Type Description mutationsArray.<Mutation> Mutation array describing changes to the DOM