• /
  • EnglishEspañol日本語한국어Português
  • ログイン今すぐ開始

setName (SPA API)

Syntax

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

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 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 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.

ヒント

This API call applies to data in SPA page views in browser and the BrowserInteraction event type. To set a custom name for standard page views and the PageView event type, see setPageViewName. Using both calls together is recommended.

Parameters

Parameter

Description

$name

string

Required. If null, the name will be set using the targetGroupedUrl attribute.

If not null, this will set the browserInteractionName attribute in the BrowserInteraction event.

$trigger

string

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

Return values

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

Examples

document.getElementById('subscribe').addEventListener('submit', () => {
newrelic.interaction().setName('createSubscription');
createSubscription();
});
Copyright © 2024 New Relic株式会社。

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.