Skip to content

Commit a855b92

Browse files
committed
add docs about debugging the browser agent
1 parent 90a1ba4 commit a855b92

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
title: How to debug the New Relic Browser Agent
3+
type: troubleshooting
4+
tags:
5+
- Browser
6+
- Browser monitoring
7+
- Troubleshooting
8+
metaDescription: Learn how to debug the New Relic Browser Agent live in your browser.
9+
freshnessValidatedDate: never
10+
---
11+
12+
## Problem
13+
14+
You need to debug an issue with the New Relic Browser Agent and want to to better understand live agent behaviors and data collection.
15+
16+
## Solution
17+
18+
If your application is instrumented with [<InlinePopover type="browser"/>](/docs/browser/new-relic-browser/installation-configuration/troubleshooting-browser-monitoring-installation) and you want to inspect agent activity, follow these steps:
19+
20+
<Steps>
21+
22+
<Step>
23+
24+
## Enable debug logging [#enable-debug-logging]
25+
26+
To get more insight into the agent's activity, [enable debug logging](/docs/browser/browser-monitoring/browser-pro-features/browser-logs/get-started/).
27+
28+
The browser agent emits warning codes using `console.debug`, and this setting will capture those logs to your New Relic browser application, helping you track agent activity and problems.
29+
30+
## Inspect agent logs [#inspect-agent-logs]
31+
32+
To inspect locally, open your browser's developer console and look for `debug` messages prefixed with `New Relic Warning:`. These messages indicate agent issues, tied to known [warning codes](https://github.com/newrelic/newrelic-browser-agent/blob/main/docs/warning-codes.md).
33+
34+
To inspect agent logs across all instances of your web application, [check your logs](/docs/browser/browser-monitoring/browser-pro-features/browser-logs/view-browser-logs/logs-of-a-browser-app/) on [one.newrelic.com](https://one.newrelic.com).
35+
36+
These logs can help you identify known issues with the browser agent and its configuration within your pages.
37+
38+
</Step>
39+
40+
<Step>
41+
42+
## Monitor network requests [#monitor-network-requests]
43+
44+
Use the Network tab in your browser's developer tools to monitor requests sent by the agent. Look for calls to domains like `bam.nr-data.net` or `js-agent.newrelic.com`.
45+
46+
If you see failed requests or errors, check for network issues, ad blockers, or CSP rules that might be interfering with agent communication.
47+
48+
Expected endpoints under `js-agent.newrelic.com`:
49+
- PageView: `/`
50+
- AjaxRequest, BrowserInteraction, PageViewTiming: `/events`
51+
- PageAction, BrowserPerformance, UserAction, Custom Events: `/ins`
52+
- Log: `/browser/logs`
53+
- JavaScriptError, Ajax Timeslice Metrics: `/jserrors/`
54+
- SessionReplay, SessionTrace: `browser/blobs`
55+
56+
</Step>
57+
58+
<Step>
59+
60+
## Use inspection events for troubleshooting [#use-inspection-events]
61+
62+
The agent emits inspection events that can be captured for deeper troubleshooting. To listen for these events, you can add a listener in your console:
63+
64+
```js
65+
document.addEventListener('newrelic', function(e) {
66+
console.log('NR Inspection Event:', e.detail);
67+
});
68+
```
69+
70+
This will log inspection events emitted by the agent, providing details about feature status, errors, lifecycles, harvesting and configuration.
71+
72+
**Note:** Inspection events are available in agent versions 1.285.0 and higher. Inspection events are emitted immediately upon creation in the agent, any events emitted by the agent before the above event listener is created on the end-user machine will be missed.
73+
74+
</Step>
75+
76+
</Steps>
77+
78+
<Callout variant="tip">
79+
If you need further assistance with debugging or interpreting inspection events, or debugging problems with your web application and New Relic, visit [support.newrelic.com](https://support.newrelic.com) for help.
80+
</Callout>

0 commit comments

Comments
 (0)