• /
  • EnglishEspañol日本語한국어Português
  • Inicia sesiónComenzar ahora

Using browser APIs

The browser APIs allow you to customize and extend your . To begin using the APIs, ensure the browser agent is present on every page you want to monitor.

Below are use cases for each browser API method.

Traces and events

To monitor traces and events, use these methods:

If you want to...

Use this API

Track an action that New Relic doesn't automatically track

newrelic.addPageAction()

Add an object to an in-progress session trace

newrelic.addToTrace()

Record a time point when your page is finished according to custom criteria

newrelic.finished()

Add an attribute name and value to subsequent events on the page

newrelic.setCustomAttribute()

Add application version information to subsequent events on the page

newrelic.setApplicationVersion()

Group page views by setting a page name

newrelic.setPageViewName()

Add user id information to subsequent events on the page

newrelic.setUserId()

Capture a single browser log event

newrelic.log()

Automatically capture messages passing through your existing logger methods as log events

newrelic.wrapLogger()

Report errors

To report errors in your application, use these methods:

If you want to...

Use this API

Tag errors with your app's version information

newrelic.addRelease()

Capture a caught or handled error without disrupting your app's operation

newrelic.noticeError()

Selectively ignore a known error

newrelic.setErrorHandler()

Track single page apps (SPA only)

To track single page applications, use these SPA API methods:

If you want to...

Use this API

Set the actionText (the text of the HTML element clicked) of a SPA interaction.

newrelic.interaction().actionText()

Trace sub-components of a SPA interaction separately

newrelic.interaction().createTracer() (deprecated)

End a SPA interaction

newrelic.interaction().end()

Aggregate data associated with the current interaction

newrelic.interaction().getContext()

Ignore an interaction

newrelic.interaction().ignore()

Return a new API object bound to the current interaction

newrelic.interaction()

Adjust attributes, such as name and ignored attributes, before the interaction is recorded

newrelic.interaction().onEnd()

Ensure a browser interaction will be saved when it ends

newrelic.interaction().save()

Add a custom attribute to the current interaction

newrelic.interaction().setAttribute()

Give SPA routes more accurate names than default names

newrelic.interaction().setCurrentRouteName

Control agent data collection behaviors

To control agent harvesting behaviors, use these API methods:

If you want to...

Use this API

Prevent feature(s) from harvesting until manually triggered

newrelic.start()

Manually start session replay collection

newrelic.recordReplay()

Manually pause session replay collection

newrelic.pauseReplay()

Copyright © 2024 New Relic Inc.

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