Skip to content

Commit 1a2e06c

Browse files
chore: update readme features (#1511)
1 parent c015d2f commit 1a2e06c

File tree

1 file changed

+96
-8
lines changed

1 file changed

+96
-8
lines changed

README.md

Lines changed: 96 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,63 @@ The following features may be disabled by adding `init` entries as shown above.
8686
- `ajax`
8787
- `generic_events`
8888
- `jserrors`
89+
- `logging`
8990
- `metrics`
9091
- `page_view_timing`
9192
- `session_replay`
9293
- `session_trace`
94+
- `soft_navigations`
9395
- `spa`
9496

97+
***Individual event types within the `generic_events` feature can also be disabled. See [Disabling Individual Generic Events](#disabling-individual-generic-events)***
98+
9599
See the [New Relic documentation site](https://docs.newrelic.com/docs/browser/browser-monitoring/getting-started/introduction-browser-monitoring/) for information on the above features.
96100

101+
### Disabling Individual Generic Events
102+
The following event types reported by the `generic_events` feature can be individually disabled in the `init` configuration.
103+
104+
#### Page Actions
105+
```javascript
106+
const options = {
107+
info: { ... },
108+
loader_config: { ... },
109+
init: {
110+
page_action: {enabled: false}
111+
...
112+
}
113+
}
114+
```
115+
116+
#### User Actions
117+
```javascript
118+
const options = {
119+
info: { ... },
120+
loader_config: { ... },
121+
init: {
122+
user_actions: {enabled: false}
123+
...
124+
}
125+
}
126+
```
127+
128+
#### Performance (Marks, Measures, Resources)
129+
```javascript
130+
const options = {
131+
info: { ... },
132+
loader_config: { ... },
133+
init: {
134+
performance: {
135+
capture_marks: false, // disable performance mark collection
136+
capture_measures: false, // disable performance measure collection
137+
resources: {
138+
enabled: false // disable performance resource collection
139+
}
140+
}
141+
...
142+
}
143+
}
144+
```
145+
97146
## Options Parameter
98147

99148
The `options` parameter used, or passed in, when instantiating the `BrowserAgent` class can include the following arguments:
@@ -118,6 +167,23 @@ The examples above use the `BrowserAgent` class, which is the best option for mo
118167

119168
Using the base `Agent` class, it is also possible to compose a custom agent by passing an array called `features` in the `options` object, containing only the desired feature modules. Depending on which features are included, this may yield a smaller loader script and improved performance.
120169

170+
The following feature modules are available for inclusion in the `features` array:
171+
172+
```javascript
173+
import { Ajax } from '@newrelic/browser-agent/features/ajax';
174+
import { GenericEvents } from '@newrelic/browser-agent/features/generic_events';
175+
import { JSErrors } from '@newrelic/browser-agent/features/jserrors';
176+
import { Logging } from '@newrelic/browser-agent/features/logging';
177+
import { Metrics } from '@newrelic/browser-agent/features/metrics';
178+
import { PageViewEvent } from '@newrelic/browser-agent/features/page_view_event';
179+
import { PageViewTiming } from '@newrelic/browser-agent/features/page_view_timing';
180+
import { SessionReplay } from '@newrelic/browser-agent/features/session_replay';
181+
import { SessionTrace } from '@newrelic/browser-agent/features/session_trace';
182+
import { SoftNav } from '@newrelic/browser-agent/features/soft_navigations';
183+
import { Spa } from '@newrelic/browser-agent/features/spa';
184+
```
185+
186+
### Example 1 - "Page Load Agent"
121187
The example below includes three feature modules: `Metrics`, `PageViewEvent`, and `PageViewTiming`.
122188

123189
```javascript
@@ -142,17 +208,39 @@ new Agent({
142208
})
143209
```
144210

145-
The following feature modules are available for inclusion in the `features` array:
211+
### Example 2: "Custom Events Agent"
212+
The example below builds an agent that only allows custom events (`.recordCustomEvent(...)`) and does not automatically detect any other event types besides a PageView event (required). It also [disables the automatic collection of certain generic events](#disabling-individual-generic-events) to ensure only manual events are captured.
146213

147214
```javascript
148-
import { Ajax } from '@newrelic/browser-agent/features/ajax';
149-
import { JSErrors } from '@newrelic/browser-agent/features/jserrors';
150-
import { Metrics } from '@newrelic/browser-agent/features/metrics';
215+
import { Agent } from '@newrelic/browser-agent/loaders/agent'
151216
import { GenericEvents } from '@newrelic/browser-agent/features/generic_events';
152-
import { PageViewEvent } from '@newrelic/browser-agent/features/page_view_event';
153-
import { PageViewTiming } from '@newrelic/browser-agent/features/page_view_timing';
154-
import { SessionTrace } from '@newrelic/browser-agent/features/session_trace';
155-
import { Spa } from '@newrelic/browser-agent/features/spa';
217+
218+
const options = {
219+
info: { ... },
220+
loader_config: { ... },
221+
init: {
222+
// disable the automatic collection of UserAction events
223+
user_actions: {enabled: false},
224+
// disable the automatic collection of BrowserPerformance events
225+
performance: {
226+
capture_marks: false,
227+
capture_measures: false,
228+
resources: {enabled: false}
229+
}
230+
}
231+
}
232+
233+
const browserAgent = new Agent({
234+
...options,
235+
features: [
236+
GenericEvents
237+
]
238+
})
239+
240+
// manually capture page actions
241+
browserAgent.addPageAction(...)
242+
// manually capture custom events
243+
browserAgent.recordCustomEvent(...)
156244
```
157245

158246
## Deploying one or more "micro" agents per page

0 commit comments

Comments
 (0)