Syntax
newrelic.interaction()
Returns a new API object that is bound to the current SPA interaction.
Requirements
Browser Pro+SPA agent (v963 or higher)
If you're using npm to install the browser agent, you must enable the
spa
feature when instantiating theBrowserAgent
class. In thefeatures
array, add the following:import { Spa } from '@newrelic/browser-agent/features/spa';const options = {info: { ... },loader_config: { ... },init: { ... },features: [Spa]}For more information, see the npm browser installation documentation.
Description
The SPA monitoring interaction()
call returns a new API object that is bound to the current interaction.
- New interaction: If the API calls it when New Relic is not currently monitoring an interaction, a new interaction is created.
- New object: If the API calls it again within the same interaction, a new object referencing the current interaction is created.
Parameters
The parameters depend on the specific SPA interaction API call.
Return values
This method returns an API object that is bound to a specific BrowserInteraction
event. Each time this method is called for the same BrowserInteraction
, a new object is created, but it still references the same interaction.
Examples
SPA API methods can be used on newrelic.interaction()
. The methods can also be used on a handle you assign with a variable. For example:
myInteraction = newrelic.interaction();myInteraction.save();
The named handle can be saved and used from outside an interaction, but methods will have no effect after the interaction has ended.