title | type | shortDescription | tags | metaDescription | redirects | freshnessValidatedDate | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
setName (SPA API) |
apiDoc |
Sets the name and trigger of a SPA's browser interaction regardless of the type of interaction. |
|
SPA API call with browser to set the name and trigger of a browser interaction that is not a route change or URL change. |
|
never |
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.
-
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.
This SPA monitoring method sets the name and trigger of a browser interaction. The name will be exposed as the browserInteractionName
attribute in the 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()
method also names the current route. When you use both:
setName()
takes precedence for naming the interaction.- The
previousRouteName
andtargetRouteName
attributes are still set with values passed tosetCurrentRouteName()
.
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 mostLikeButtonClick
interactions.
<th>
Description
</th>
</tr>
Parameter |
---|
`$name`
|
This method returns the same API object created by interaction()
.
document.getElementById('subscribe').addEventListener('submit', () => {
newrelic.interaction().setName('createSubscription');
createSubscription();
});