SPA: newrelic.interaction().setName

newrelic.interaction().setName(string NAME, string TRIGGER)
Sets the name and trigger of a SPA's browser interaction that is not a route change or URL change.

Requirements

Requires New Relic Browser agent version nr-963 or higher.

Access to this feature depends on your subscription level. New Relic's single page app (SPA) monitoring is only available with New Relic Browser Pro.

Description

This SPA monitoring method sets the name and trigger of a browser interaction. The name will be exposed as the browserInteractionName attribute in the Insights BrowserInteraction event. It will also be used for grouping in the UI.

By default, browserInteractionName is named after an associated URL or route. Use setName when you want to record an interaction that is not a route change or URL change.

The setCurrentRouteName API names the current route. When you use both setName and setCurrentRouteName:

  • The setName takes precedence for naming the interaction.
  • The previousRouteName and targetRouteName attributes are still set with values passed to setCurrentRouteName.

Using these methods together allows many options for filtering and grouping in the UI. For example, you can:

  • Filter down to interactions of a certain type, such as LikeButtonClick.
  • Then, group by targetRouteName to see what routes have the most LikeButtonClick interactions.

Parameters

Parameter Description

NAME

string

Required.

TRIGGER

string

Optional. If not null, this will set the TRIGGER attribute on the BrowserInteraction event.

Return Value(s)

This method returns the same API object created by newrelic.interaction().

Example(s)

document.getElementById('subscribe').addEventListener('submit', () => {
    newrelic.interaction().setName('createSubscription')
    createSubscription()
})