New Relic Browser Agent: Getting Started and Best Practices

Author

Reads 385

Software Engineer Standing Beside Server Racks
Credit: pexels.com, Software Engineer Standing Beside Server Racks

To get started with the New Relic Browser Agent, you'll need to install it on your application. This can be done using npm or yarn, and the process is outlined in the installation section of the documentation.

The agent collects data on user interactions, such as page views and user sessions, which can help you understand how your application is being used. This data is then sent to New Relic for analysis.

One of the first steps in setting up the agent is to configure it to collect the data you need. This involves setting up data collectors and filters to ensure you're only collecting the data that's relevant to your application.

The New Relic Browser Agent is designed to be easy to use and integrate into your existing infrastructure.

Configuration and Setup

You can configure browser monitoring through NerdGraph, which allows you to change settings like the apdex of an application. This can be done using a specific mutation that is documented in the NerdGraph explorer.

Credit: youtube.com, Add Browser Instrumentation to Your Site in Minutes

To retrieve the application configuration, you can use the NerdGraph API, which returns the configuration in two formats: a JSON encoded string or an object that can be used directly in your application source code.

Browser applications can be created programmatically using the NerdGraph API, which allows for automatic creation and retrieval of the JavaScript snippet to instrument your browser app. This can be done with an example mutation that creates a new browser application with default settings.

To manually instrument browser monitoring, you can include scripts in your pages using the New Relic PHP agent API, which automatically generates the required JavaScript header and footer. This can be done using the auto_instrument agent settings, newrelic_get_browser_timing_header(), and newrelic_get_browser_timing_footer() functions.

Create an Application

You can create a new browser application using the NerdGraph API, which allows you to programmatically create and retrieve the JavaScript snippet to copy and paste into your browser app.

Credit: youtube.com, App Configuration, where does it go? Config files, env vars, external service?

This method is advantageous because it makes it easier to instrument your browser application with New Relic when the time comes.

Using the NerdGraph API also enables you to create a new browser application with default settings.

For example, you can use a mutation to create a new browser application, as shown in the example provided in the article.

To set up browser monitoring for multiple applications, you can use npm, which is explained in the article section "Instrument multiple apps with npm".

Configuring Monitoring

Configuring monitoring is a crucial step in setting up New Relic. You can configure browser monitoring through NerdGraph, which allows you to change settings such as the apdex of an application.

To do this, you'll need to reference the mutation documentation in the NerdGraph explorer, which outlines the available fields and their corresponding documentation. This way, you can easily find the information you need to make changes.

You can also create a new browser application using the NerdGraph API, which is useful for programmatically creating and retrieving the JavaScript snippet to copy and paste into your browser app. This approach is especially helpful when instrumenting multiple applications.

Credit: youtube.com, Automate monitor configurations using Configuration Rules

Here are the steps to create a new browser application with default settings:

  • Mutation:
  • Field:
  • Documentation:

Alternatively, you can manually instrument via the agent API by including the required scripts in your pages. This involves using the New Relic PHP agent's API to generate the JavaScript header and footer.

To manually instrument, you'll need to use the following functions:

  • auto_instrument agent settings
  • newrelic_get_browser_timing_header()
  • newrelic_get_browser_timing_footer()

By following these steps, you can effectively configure monitoring for your browser applications and start collecting data.

Create Segments

Creating segments is a crucial step in organizing and analyzing your data. You can create browser segments using the agentApplicationSegmentsReplaceAllBrowserSegmentAllowList mutation.

To create segments, you'll need to use a specific mutation, which is agentApplicationSegmentsReplaceAllBrowserSegmentAllowList. This mutation allows you to create browser segments.

Browser segments can be used to group your data in a more meaningful way. By grouping your browser monitoring results by browser segments, you can get a clearer picture of your data.

You can do this grouping in GraphQL, which is a more efficient and powerful way to analyze your data.

SetUserId API

Credit: youtube.com, /config - The Configuration Endpoint Your API Always Needed | Yaara Letz

The SetUserId API is now available, and it's a game-changer for user tracking. It defines a custom attribute containing a specified user ID, to be included in all payloads.

This API is an extension of the setCustomAttribute API and automatically persists between page loads. This means you don't have to worry about losing user data when they navigate away from your page.

With the SetUserId API, you can easily identify and track specific users across multiple interactions. It's a powerful tool for personalizing user experiences and improving engagement.

To use the SetUserId API, simply define a custom attribute containing the user's ID, and the API will take care of the rest.

Data Management

The New Relic Browser Agent allows for automatic data collection and management, making it easy to track and analyze user behavior.

This feature is particularly useful for companies with large user bases, as it enables them to quickly identify areas of improvement.

Credit: youtube.com, Our Browser Monitoring Agent is Open Source!

With automatic data collection, you can easily monitor user interactions, track errors, and gain insights into how your application is performing.

New Relic's data management capabilities also include customizable data sampling, which allows you to control the amount of data collected and reduce the load on your application.

By doing so, you can ensure that your application remains performant and responsive, even with a large volume of users.

Group Data by Segments

Grouping your data by segments is a game-changer for getting meaningful results. You can group your browser monitoring results by browser segments to get more meaningful data.

Using GraphQL is a more efficient way to group your data by segments, rather than doing it in the UI.

Query Parameter Supportability Metrics

Query parameter supportability metrics are essential for evaluating the health of your data management system. Adding these metrics allows you to capture legacy network method usage.

This can help you identify areas where outdated methods may be causing issues. By monitoring query parameter size statistics, you can also optimize your system for better performance.

Custom data size statistics are another crucial metric to track, as they can help you identify where data is being unnecessarily stored.

Custom Attributes Persistence

Credit: youtube.com, Using Attributes to Manage Data in Unity

Custom Attributes Persistence is a game-changer for data management, allowing custom attributes to be persisted between page loads via session storage.

Custom attributes may now be stored in session storage and restored on subsequent page loads, thanks to the new API method setCustomAttribute.

This means you can save custom attribute values and retrieve them later, which is super useful for applications that require data to be retained between sessions.

The setCustomAttribute method takes a third parameter, which defaults to false, indicating whether the custom attribute should be persisted in session storage.

If set to true, the custom attribute will be stored in session storage and restored on subsequent page loads, subject to the same-origin policy of the browser.

Frequently Asked Questions

What is the New Relic browser agent?

The New Relic browser agent is a small piece of JavaScript code that tracks your website's performance and sends data to New Relic for analysis. It helps you monitor and optimize your site's speed and user experience.

How to check New Relic browser agent version?

To check your New Relic browser agent version, view the page source and search for "js-agent.newrelic.com/nr-" followed by numbers, which indicate the current version. This will show you the version number, such as "593" in the example "js-agent.newrelic.com/nr-593.min.js

Nancy Rath

Copy Editor

Nancy Rath is a meticulous and detail-oriented Copy Editor with a passion for refining written content. With a keen eye for grammar, syntax, and style, she has honed her skills in ensuring that articles are polished and engaging. Her expertise spans a range of categories, including digital presentation design, where she has a particular interest in the intersection of visual and written communication.

Love What You Read? Stay Updated!

Join our community for insights, tips, and more.