@newrelic/browser-agent 1.270.2 → 1.271.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/cjs/common/constants/env.cdn.js +1 -1
- package/dist/cjs/common/constants/env.npm.js +1 -1
- package/dist/cjs/features/jserrors/shared/cast-error.js +9 -3
- package/dist/cjs/features/utils/instrument-base.js +9 -9
- package/dist/esm/common/constants/env.cdn.js +1 -1
- package/dist/esm/common/constants/env.npm.js +1 -1
- package/dist/esm/features/jserrors/shared/cast-error.js +9 -3
- package/dist/esm/features/utils/instrument-base.js +9 -9
- package/dist/types/features/jserrors/shared/cast-error.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/features/jserrors/shared/cast-error.js +9 -4
- package/src/features/utils/instrument-base.js +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,20 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.271.0](https://github.com/newrelic/newrelic-browser-agent/compare/v1.270.3...v1.271.0) (2024-11-01)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Ignore unhandled promise rejections that lack a valid reason ([#1233](https://github.com/newrelic/newrelic-browser-agent/issues/1233)) ([25a1fff](https://github.com/newrelic/newrelic-browser-agent/commit/25a1fffb91fa5936766a7bc89d735b3018aa62a2))
|
|
12
|
+
|
|
13
|
+
## [1.270.3](https://github.com/newrelic/newrelic-browser-agent/compare/v1.270.2...v1.270.3) (2024-10-31)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* Ensure all lazy loaded modules issue warning instead of errors ([#1234](https://github.com/newrelic/newrelic-browser-agent/issues/1234)) ([cdfdab7](https://github.com/newrelic/newrelic-browser-agent/commit/cdfdab701bda6266416ad27750e63e8e9e0e075b))
|
|
19
|
+
|
|
6
20
|
## [1.270.2](https://github.com/newrelic/newrelic-browser-agent/compare/v1.270.1...v1.270.2) (2024-10-28)
|
|
7
21
|
|
|
8
22
|
|
|
@@ -12,7 +12,7 @@ exports.VERSION = exports.RRWEB_VERSION = exports.DIST_METHOD = exports.BUILD_EN
|
|
|
12
12
|
/**
|
|
13
13
|
* Exposes the version of the agent
|
|
14
14
|
*/
|
|
15
|
-
const VERSION = exports.VERSION = "1.
|
|
15
|
+
const VERSION = exports.VERSION = "1.271.0";
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Exposes the build type of the agent
|
|
@@ -12,7 +12,7 @@ exports.VERSION = exports.RRWEB_VERSION = exports.DIST_METHOD = exports.BUILD_EN
|
|
|
12
12
|
/**
|
|
13
13
|
* Exposes the version of the agent
|
|
14
14
|
*/
|
|
15
|
-
const VERSION = exports.VERSION = "1.
|
|
15
|
+
const VERSION = exports.VERSION = "1.271.0";
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Exposes the build type of the agent
|
|
@@ -32,8 +32,15 @@ function castError(error) {
|
|
|
32
32
|
* @returns {Error} An Error object with the message as the casted reason
|
|
33
33
|
*/
|
|
34
34
|
function castPromiseRejectionEvent(promiseRejectionEvent) {
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
const prefix = 'Unhandled Promise Rejection';
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* If the casted return value is falsy like this, it will get dropped and not produce an error event for harvest.
|
|
39
|
+
* We drop promise rejections that could not form a valid error stack or message deriving from the .reason attribute
|
|
40
|
+
* -- such as a manually invoked rejection without an argument -- since they lack reproduction value and create confusion.
|
|
41
|
+
* */
|
|
42
|
+
if (!promiseRejectionEvent?.reason) return;
|
|
43
|
+
if (canTrustError(promiseRejectionEvent.reason)) {
|
|
37
44
|
try {
|
|
38
45
|
promiseRejectionEvent.reason.message = prefix + ': ' + promiseRejectionEvent.reason.message;
|
|
39
46
|
return castError(promiseRejectionEvent.reason);
|
|
@@ -41,7 +48,6 @@ function castPromiseRejectionEvent(promiseRejectionEvent) {
|
|
|
41
48
|
return castError(promiseRejectionEvent.reason);
|
|
42
49
|
}
|
|
43
50
|
}
|
|
44
|
-
if (typeof promiseRejectionEvent.reason === 'undefined') return castError(prefix);
|
|
45
51
|
const error = castError(promiseRejectionEvent.reason);
|
|
46
52
|
error.message = prefix + ': ' + error?.message;
|
|
47
53
|
return error;
|
|
@@ -95,20 +95,20 @@ class InstrumentBase extends _featureBase.FeatureBase {
|
|
|
95
95
|
if (this.featureName === _features.FEATURE_NAMES.sessionReplay) this.abortHandler?.(); // SR should stop recording if session DNE
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
// Create a single Aggregator for this agent if DNE yet; to be used by jserror endpoint features.
|
|
99
|
-
if (!agentRef.sharedAggregator) {
|
|
100
|
-
agentRef.sharedAggregator = Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "shared-aggregator" */'../../common/aggregate/aggregator')));
|
|
101
|
-
const {
|
|
102
|
-
Aggregator
|
|
103
|
-
} = await agentRef.sharedAggregator;
|
|
104
|
-
agentRef.sharedAggregator = new Aggregator();
|
|
105
|
-
} else await agentRef.sharedAggregator; // if another feature is already importing the aggregator, wait for it to finish
|
|
106
|
-
|
|
107
98
|
/**
|
|
108
99
|
* Note this try-catch differs from the one in Agent.run() in that it's placed later in a page's lifecycle and
|
|
109
100
|
* it's only responsible for aborting its one specific feature, rather than all.
|
|
110
101
|
*/
|
|
111
102
|
try {
|
|
103
|
+
// Create a single Aggregator for this agent if DNE yet; to be used by jserror endpoint features.
|
|
104
|
+
if (!agentRef.sharedAggregator) {
|
|
105
|
+
agentRef.sharedAggregator = Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "shared-aggregator" */'../../common/aggregate/aggregator')));
|
|
106
|
+
const {
|
|
107
|
+
Aggregator
|
|
108
|
+
} = await agentRef.sharedAggregator;
|
|
109
|
+
agentRef.sharedAggregator = new Aggregator();
|
|
110
|
+
} else await agentRef.sharedAggregator; // if another feature is already importing the aggregator, wait for it to finish
|
|
111
|
+
|
|
112
112
|
if (!this.#shouldImportAgg(this.featureName, session)) {
|
|
113
113
|
(0, _drain.drain)(this.agentIdentifier, this.featureName);
|
|
114
114
|
loadedSuccessfully(false); // aggregate module isn't loaded at all
|
|
@@ -25,8 +25,15 @@ export function castError(error) {
|
|
|
25
25
|
* @returns {Error} An Error object with the message as the casted reason
|
|
26
26
|
*/
|
|
27
27
|
export function castPromiseRejectionEvent(promiseRejectionEvent) {
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
const prefix = 'Unhandled Promise Rejection';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* If the casted return value is falsy like this, it will get dropped and not produce an error event for harvest.
|
|
32
|
+
* We drop promise rejections that could not form a valid error stack or message deriving from the .reason attribute
|
|
33
|
+
* -- such as a manually invoked rejection without an argument -- since they lack reproduction value and create confusion.
|
|
34
|
+
* */
|
|
35
|
+
if (!promiseRejectionEvent?.reason) return;
|
|
36
|
+
if (canTrustError(promiseRejectionEvent.reason)) {
|
|
30
37
|
try {
|
|
31
38
|
promiseRejectionEvent.reason.message = prefix + ': ' + promiseRejectionEvent.reason.message;
|
|
32
39
|
return castError(promiseRejectionEvent.reason);
|
|
@@ -34,7 +41,6 @@ export function castPromiseRejectionEvent(promiseRejectionEvent) {
|
|
|
34
41
|
return castError(promiseRejectionEvent.reason);
|
|
35
42
|
}
|
|
36
43
|
}
|
|
37
|
-
if (typeof promiseRejectionEvent.reason === 'undefined') return castError(prefix);
|
|
38
44
|
const error = castError(promiseRejectionEvent.reason);
|
|
39
45
|
error.message = prefix + ': ' + error?.message;
|
|
40
46
|
return error;
|
|
@@ -90,20 +90,20 @@ export class InstrumentBase extends FeatureBase {
|
|
|
90
90
|
if (this.featureName === FEATURE_NAMES.sessionReplay) this.abortHandler?.(); // SR should stop recording if session DNE
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
// Create a single Aggregator for this agent if DNE yet; to be used by jserror endpoint features.
|
|
94
|
-
if (!agentRef.sharedAggregator) {
|
|
95
|
-
agentRef.sharedAggregator = import(/* webpackChunkName: "shared-aggregator" */'../../common/aggregate/aggregator');
|
|
96
|
-
const {
|
|
97
|
-
Aggregator
|
|
98
|
-
} = await agentRef.sharedAggregator;
|
|
99
|
-
agentRef.sharedAggregator = new Aggregator();
|
|
100
|
-
} else await agentRef.sharedAggregator; // if another feature is already importing the aggregator, wait for it to finish
|
|
101
|
-
|
|
102
93
|
/**
|
|
103
94
|
* Note this try-catch differs from the one in Agent.run() in that it's placed later in a page's lifecycle and
|
|
104
95
|
* it's only responsible for aborting its one specific feature, rather than all.
|
|
105
96
|
*/
|
|
106
97
|
try {
|
|
98
|
+
// Create a single Aggregator for this agent if DNE yet; to be used by jserror endpoint features.
|
|
99
|
+
if (!agentRef.sharedAggregator) {
|
|
100
|
+
agentRef.sharedAggregator = import(/* webpackChunkName: "shared-aggregator" */'../../common/aggregate/aggregator');
|
|
101
|
+
const {
|
|
102
|
+
Aggregator
|
|
103
|
+
} = await agentRef.sharedAggregator;
|
|
104
|
+
agentRef.sharedAggregator = new Aggregator();
|
|
105
|
+
} else await agentRef.sharedAggregator; // if another feature is already importing the aggregator, wait for it to finish
|
|
106
|
+
|
|
107
107
|
if (!this.#shouldImportAgg(this.featureName, session)) {
|
|
108
108
|
drain(this.agentIdentifier, this.featureName);
|
|
109
109
|
loadedSuccessfully(false); // aggregate module isn't loaded at all
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cast-error.d.ts","sourceRoot":"","sources":["../../../../../src/features/jserrors/shared/cast-error.js"],"names":[],"mappings":"AAEA;;;;;KAKK;AACL,iCAHa,GAAG,GACD,KAAK,GAAC,aAAa,CAmBjC;AAED;;;;KAIK;AACL,uEAFe,KAAK,
|
|
1
|
+
{"version":3,"file":"cast-error.d.ts","sourceRoot":"","sources":["../../../../../src/features/jserrors/shared/cast-error.js"],"names":[],"mappings":"AAEA;;;;;KAKK;AACL,iCAHa,GAAG,GACD,KAAK,GAAC,aAAa,CAmBjC;AAED;;;;KAIK;AACL,uEAFe,KAAK,CAwBnB;AAED;;;;KAIK;AACL,2CAHa,UAAU,GACR,KAAK,GAAC,aAAa,CAUjC;8BArE6B,kBAAkB"}
|
package/package.json
CHANGED
|
@@ -31,9 +31,16 @@ export function castError (error) {
|
|
|
31
31
|
* @returns {Error} An Error object with the message as the casted reason
|
|
32
32
|
*/
|
|
33
33
|
export function castPromiseRejectionEvent (promiseRejectionEvent) {
|
|
34
|
-
|
|
34
|
+
const prefix = 'Unhandled Promise Rejection'
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
/**
|
|
37
|
+
* If the casted return value is falsy like this, it will get dropped and not produce an error event for harvest.
|
|
38
|
+
* We drop promise rejections that could not form a valid error stack or message deriving from the .reason attribute
|
|
39
|
+
* -- such as a manually invoked rejection without an argument -- since they lack reproduction value and create confusion.
|
|
40
|
+
* */
|
|
41
|
+
if (!promiseRejectionEvent?.reason) return
|
|
42
|
+
|
|
43
|
+
if (canTrustError(promiseRejectionEvent.reason)) {
|
|
37
44
|
try {
|
|
38
45
|
promiseRejectionEvent.reason.message = prefix + ': ' + promiseRejectionEvent.reason.message
|
|
39
46
|
return castError(promiseRejectionEvent.reason)
|
|
@@ -42,8 +49,6 @@ export function castPromiseRejectionEvent (promiseRejectionEvent) {
|
|
|
42
49
|
}
|
|
43
50
|
}
|
|
44
51
|
|
|
45
|
-
if (typeof promiseRejectionEvent.reason === 'undefined') return castError(prefix)
|
|
46
|
-
|
|
47
52
|
const error = castError(promiseRejectionEvent.reason)
|
|
48
53
|
error.message = prefix + ': ' + error?.message
|
|
49
54
|
return error
|
|
@@ -90,18 +90,18 @@ export class InstrumentBase extends FeatureBase {
|
|
|
90
90
|
if (this.featureName === FEATURE_NAMES.sessionReplay) this.abortHandler?.() // SR should stop recording if session DNE
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
// Create a single Aggregator for this agent if DNE yet; to be used by jserror endpoint features.
|
|
94
|
-
if (!agentRef.sharedAggregator) {
|
|
95
|
-
agentRef.sharedAggregator = import(/* webpackChunkName: "shared-aggregator" */ '../../common/aggregate/aggregator')
|
|
96
|
-
const { Aggregator } = await agentRef.sharedAggregator
|
|
97
|
-
agentRef.sharedAggregator = new Aggregator()
|
|
98
|
-
} else await agentRef.sharedAggregator // if another feature is already importing the aggregator, wait for it to finish
|
|
99
|
-
|
|
100
93
|
/**
|
|
101
94
|
* Note this try-catch differs from the one in Agent.run() in that it's placed later in a page's lifecycle and
|
|
102
95
|
* it's only responsible for aborting its one specific feature, rather than all.
|
|
103
96
|
*/
|
|
104
97
|
try {
|
|
98
|
+
// Create a single Aggregator for this agent if DNE yet; to be used by jserror endpoint features.
|
|
99
|
+
if (!agentRef.sharedAggregator) {
|
|
100
|
+
agentRef.sharedAggregator = import(/* webpackChunkName: "shared-aggregator" */ '../../common/aggregate/aggregator')
|
|
101
|
+
const { Aggregator } = await agentRef.sharedAggregator
|
|
102
|
+
agentRef.sharedAggregator = new Aggregator()
|
|
103
|
+
} else await agentRef.sharedAggregator // if another feature is already importing the aggregator, wait for it to finish
|
|
104
|
+
|
|
105
105
|
if (!this.#shouldImportAgg(this.featureName, session)) {
|
|
106
106
|
drain(this.agentIdentifier, this.featureName)
|
|
107
107
|
loadedSuccessfully(false) // aggregate module isn't loaded at all
|