Skip to content

Commit d3fdb6b

Browse files
Merge branch 'main' into page-resources-feature
2 parents 8dc4ce7 + e00a469 commit d3fdb6b

File tree

10 files changed

+97
-96
lines changed

10 files changed

+97
-96
lines changed

.github/actions/build-ab/templates/released.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ window.NREUM={
2525
enabled: true
2626
},
2727
performance: {
28-
capture_marks: true,
28+
capture_marks: false,
2929
capture_measures: true
3030
},
3131
proxy: {}

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [1.274.0](https://github.com/newrelic/newrelic-browser-agent/compare/v1.273.1...v1.274.0) (2024-11-19)
7+
8+
9+
### Features
10+
11+
* Upgrade SessionReplay libraries to latest version ([#1251](https://github.com/newrelic/newrelic-browser-agent/issues/1251)) ([2d8d114](https://github.com/newrelic/newrelic-browser-agent/commit/2d8d114e70ba2861fb5639e132f25c9c03df871b))
12+
13+
## [1.273.1](https://github.com/newrelic/newrelic-browser-agent/compare/v1.273.0...v1.273.1) (2024-11-18)
14+
15+
16+
### Bug Fixes
17+
18+
* Multiple MicroAgent undefined session and limit available API ([#1252](https://github.com/newrelic/newrelic-browser-agent/issues/1252)) ([19cbb63](https://github.com/newrelic/newrelic-browser-agent/commit/19cbb634b5016e3e8ce0c40a6bf1ee59156c78eb))
19+
620
## [1.273.0](https://github.com/newrelic/newrelic-browser-agent/compare/v1.272.0...v1.273.0) (2024-11-11)
721

822

changelog.json

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,40 @@
11
{
22
"repository": "newrelic/newrelic-browser-agent",
33
"entries": [
4+
{
5+
"changes": [
6+
{
7+
"type": "feat",
8+
"sha": "2d8d114e70ba2861fb5639e132f25c9c03df871b",
9+
"message": "Upgrade SessionReplay libraries to latest version",
10+
"issues": [
11+
"1251"
12+
]
13+
}
14+
],
15+
"version": "1.274.0",
16+
"language": "JAVASCRIPT",
17+
"artifactName": "@newrelic/browser-agent",
18+
"id": "5c0da2d3-92eb-4ab8-8952-bdb5ac32c823",
19+
"createTime": "2024-11-19T20:16:39.794Z"
20+
},
21+
{
22+
"changes": [
23+
{
24+
"type": "fix",
25+
"sha": "19cbb634b5016e3e8ce0c40a6bf1ee59156c78eb",
26+
"message": "Multiple MicroAgent undefined session and limit available API",
27+
"issues": [
28+
"1252"
29+
]
30+
}
31+
],
32+
"version": "1.273.1",
33+
"language": "JAVASCRIPT",
34+
"artifactName": "@newrelic/browser-agent",
35+
"id": "efd8b450-06d8-450b-8130-d57024674e1b",
36+
"createTime": "2024-11-18T16:05:55.225Z"
37+
},
438
{
539
"changes": [
640
{
@@ -2201,5 +2235,5 @@
22012235
"createTime": "2023-05-08T21:11:35.144Z"
22022236
}
22032237
],
2204-
"updateTime": "2024-11-11T17:36:53.044Z"
2238+
"updateTime": "2024-11-19T20:16:39.794Z"
22052239
}

package-lock.json

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@newrelic/browser-agent",
3-
"version": "1.273.0",
3+
"version": "1.274.0",
44
"private": false,
55
"author": "New Relic Browser Agent Team <[email protected]>",
66
"description": "New Relic Browser Agent",
@@ -195,7 +195,7 @@
195195
},
196196
"dependencies": {
197197
"fflate": "0.7.4",
198-
"rrweb": "2.0.0-alpha.12",
198+
"rrweb": "^2.0.0-alpha.17",
199199
"web-vitals": "4.2.3"
200200
},
201201
"devDependencies": {

src/features/generic_events/aggregate/index.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { now } from '../../../common/timing/now'
1313
import { registerHandler } from '../../../common/event-emitter/register-handler'
1414
import { SUPPORTABILITY_METRIC_CHANNEL } from '../../metrics/constants'
1515
import { applyFnToProps } from '../../../common/util/traverse'
16-
import { IDEAL_PAYLOAD_SIZE } from '../../../common/constants/agent-constants'
1716
import { FEATURE_TO_ENDPOINT } from '../../../loaders/features/features'
1817
import { UserActionsAggregator } from './user-actions/user-actions-aggregator'
1918
import { isIFrameWindow } from '../../../common/dom/iframe'
@@ -222,9 +221,16 @@ export class Aggregate extends AggregateBase {
222221
...obj
223222
}
224223

225-
this.events.add(eventAttributes)
226-
227-
this.checkEventLimits()
224+
const addedEvent = this.events.add(eventAttributes)
225+
if (!addedEvent && !this.events.isEmpty()) {
226+
/** could not add the event because it pushed the buffer over the limit
227+
* so we harvest early, and try to add it again now that the buffer is cleared
228+
* if it fails again, we do nothing
229+
*/
230+
this.ee.emit(SUPPORTABILITY_METRIC_CHANNEL, ['GenericEvents/Harvest/Max/Seen'])
231+
this.harvestScheduler.runHarvest()
232+
this.events.add(eventAttributes)
233+
}
228234
}
229235

230236
serializer (eventBuffer) {
@@ -234,15 +240,7 @@ export class Aggregate extends AggregateBase {
234240
queryStringsBuilder () {
235241
return { ua: this.agentRef.info.userAttributes, at: this.agentRef.info.atts }
236242
}
237-
238-
checkEventLimits () {
239-
// check if we've reached any harvest limits...
240-
if (this.events.byteSize() > IDEAL_PAYLOAD_SIZE) {
241-
this.ee.emit(SUPPORTABILITY_METRIC_CHANNEL, ['GenericEvents/Harvest/Max/Seen'])
242-
this.harvestScheduler.runHarvest()
243-
}
244-
}
245-
243+
246244
trackSupportabilityMetrics () {
247245
/** track usage SMs to improve these experimental features */
248246
const configPerfTag = 'Config/Performance/'

src/features/session_replay/shared/recorder.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,6 @@ export class Recorder {
9999
inlineImages: inline_images,
100100
collectFonts: collect_fonts,
101101
checkoutEveryNms: CHECKOUT_MS[this.parent.mode],
102-
/** Emits errors thrown by rrweb directly before bubbling them up to the window */
103-
errorHandler: (err) => {
104-
/** capture rrweb errors as "internal" errors only */
105-
this.parent.ee.emit('internal-error', [err])
106-
/** returning true informs rrweb to swallow the error instead of throwing it to the window */
107-
return true
108-
},
109102
recordAfter: 'DOMContentLoaded'
110103
})
111104

tests/components/generic_events/aggregate/index.test.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,30 @@ test('should warn if invalid event is provide', async () => {
6161
expect(console.debug).toHaveBeenCalledWith('New Relic Warning: https://github.com/newrelic/newrelic-browser-agent/blob/main/docs/warning-codes.md#44', undefined)
6262
})
6363

64-
test('should only buffer 64kb of events at a time', async () => {
64+
test('should harvest early if will exceed 1mb', async () => {
6565
genericEventsAggregate.ee.emit('rumresp', [{ ins: 1 }])
6666

6767
await new Promise(process.nextTick)
6868

6969
genericEventsAggregate.harvestScheduler.runHarvest = jest.fn()
70-
genericEventsAggregate.addEvent({ name: 'test', eventType: 'x'.repeat(63000) })
70+
genericEventsAggregate.addEvent({ name: 'test', eventType: 'x'.repeat(900000) })
7171

7272
expect(genericEventsAggregate.harvestScheduler.runHarvest).not.toHaveBeenCalled()
73-
genericEventsAggregate.addEvent({ name: 1000, eventType: 'x'.repeat(1000) })
73+
genericEventsAggregate.addEvent({ name: 1000, eventType: 'x'.repeat(100000) })
7474
expect(genericEventsAggregate.harvestScheduler.runHarvest).toHaveBeenCalled()
7575
})
7676

77+
test('should not harvest if single event will exceed 1mb', async () => {
78+
genericEventsAggregate.ee.emit('rumresp', [{ ins: 1 }])
79+
80+
await new Promise(process.nextTick)
81+
82+
genericEventsAggregate.harvestScheduler.runHarvest = jest.fn()
83+
genericEventsAggregate.addEvent({ name: 'test', eventType: 'x'.repeat(1000000) })
84+
85+
expect(genericEventsAggregate.harvestScheduler.runHarvest).not.toHaveBeenCalled()
86+
})
87+
7788
describe('sub-features', () => {
7889
beforeEach(async () => {
7990
genericEventsAggregate.ee.emit('rumresp', [{ ins: 1 }])

tests/specs/err/error-payload.e2e.js

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
/* globals errorFn, noticeErrorFn */
2-
3-
const { Key } = require('webdriverio')
4-
const { notSafari, notIOS, notAndroid } = require('../../../tools/browser-matcher/common-matchers.mjs')
5-
const { srConfig } = require('../util/helpers')
6-
const { testErrorsRequest, testSupportMetricsRequest } = require('../../../tools/testing-server/utils/expect-tests')
2+
const { testErrorsRequest } = require('../../../tools/testing-server/utils/expect-tests')
73

84
describe('error payloads', () => {
95
let errorsCapture
@@ -132,28 +128,4 @@ describe('error payloads', () => {
132128

133129
expect(errorResults).toEqual([])
134130
})
135-
136-
/**
137-
* This is a specific bug observed in rrweb for specific browsers tied to contenteditable divs.
138-
* This serves a purpose of checking that rrweb errors are not reported as `err`
139-
* **/
140-
it.withBrowsersMatching([notSafari, notAndroid, notIOS])('should collect rrweb errors only as internal error supportability metric', async () => {
141-
const jsErrCapture = await browser.testHandle.createNetworkCaptures('bamServer', { test: testErrorsRequest })
142-
const smCapture = await browser.testHandle.createNetworkCaptures('bamServer', { test: testSupportMetricsRequest })
143-
await browser.enableSessionReplay()
144-
const [jseCaptureResults, smCaptureResults] = await Promise.all([
145-
jsErrCapture.waitForResult({ timeout: 10000 }),
146-
smCapture.waitForResult({ totalCount: 1 }),
147-
browser.url(await browser.testHandle.assetURL('rrweb-instrumented.html', srConfig()))
148-
.then(() => browser.waitForSessionReplayRecording())
149-
.then(() => $('#content-editable-div'))
150-
.then((elem) => elem.click())
151-
.then(() => browser.keys([Key.Ctrl, Key.Backspace]))
152-
.then(() => browser.refresh())
153-
])
154-
155-
const sms = smCaptureResults[0].request.body.sm
156-
expect(sms.find(sm => sm.params.name === 'Internal/Error/Rrweb')).toBeTruthy()
157-
expect(jseCaptureResults).toEqual([])
158-
})
159131
})

tests/specs/ins/harvesting.e2e.js

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ describe('ins harvesting', () => {
102102
pageUrl: expect.any(String),
103103
timestamp: expect.any(Number)
104104
})
105-
expect(clickUAs[1].actionDuration).toBeGreaterThan(0)
105+
expect(clickUAs[1].actionDuration).toBeGreaterThanOrEqual(0)
106106
expect(clickUAs[1].actionMs).toEqual(expect.stringMatching(/^\[\d+(,\d+){4}\]$/))
107107
})
108108

@@ -327,35 +327,14 @@ describe('ins harvesting', () => {
327327
insightsCapture.waitForResult({ timeout: 10000 }),
328328
browser.execute(function () {
329329
let i = 0
330-
while (i++ < 1010) {
330+
while (i++ < 10000) {
331331
newrelic.addPageAction('foobar')
332332
}
333333
})
334334
])
335335
expect(insightsResult.length).toBeTruthy()
336336
})
337337

338-
it('should harvest early when buffer gets too large (one big event)', async () => {
339-
const testUrl = await browser.testHandle.assetURL('instrumented.html', { init: { generic_events: { harvestTimeSeconds: 30 } } })
340-
await browser.url(testUrl)
341-
.then(() => browser.waitForAgentLoad())
342-
343-
const [insightsResult] = await Promise.all([
344-
insightsCapture.waitForResult({ timeout: 10000 }),
345-
browser.execute(function () {
346-
newrelic.addPageAction('foobar', createLargeObject())
347-
function createLargeObject () {
348-
let i = 0; let obj = {}
349-
while (i++ < 64000) {
350-
obj[i] = 'x'
351-
}
352-
return obj
353-
}
354-
})
355-
])
356-
expect(insightsResult.length).toBeTruthy()
357-
})
358-
359338
it('should not harvest if too large', async () => {
360339
const testUrl = await browser.testHandle.assetURL('instrumented.html')
361340
await browser.url(testUrl)
@@ -367,7 +346,7 @@ describe('ins harvesting', () => {
367346
newrelic.addPageAction('foobar', createLargeObject())
368347
function createLargeObject () {
369348
let i = 0; let obj = {}
370-
while (i++ < 100000) {
349+
while (i++ < 1000000) {
371350
obj[i] = Math.random()
372351
}
373352
return obj

0 commit comments

Comments
 (0)