@newrelic/browser-agent 1.270.3 → 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 CHANGED
@@ -3,6 +3,13 @@
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
+
6
13
  ## [1.270.3](https://github.com/newrelic/newrelic-browser-agent/compare/v1.270.2...v1.270.3) (2024-10-31)
7
14
 
8
15
 
@@ -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.270.3";
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.270.3";
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
- let prefix = 'Unhandled Promise Rejection';
36
- if (canTrustError(promiseRejectionEvent?.reason)) {
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;
@@ -6,7 +6,7 @@
6
6
  /**
7
7
  * Exposes the version of the agent
8
8
  */
9
- export const VERSION = "1.270.3";
9
+ export const VERSION = "1.271.0";
10
10
 
11
11
  /**
12
12
  * Exposes the build type of the agent
@@ -6,7 +6,7 @@
6
6
  /**
7
7
  * Exposes the version of the agent
8
8
  */
9
- export const VERSION = "1.270.3";
9
+ export const VERSION = "1.271.0";
10
10
 
11
11
  /**
12
12
  * Exposes the build type of the agent
@@ -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
- let prefix = 'Unhandled Promise Rejection';
29
- if (canTrustError(promiseRejectionEvent?.reason)) {
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;
@@ -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,CAmBnB;AAED;;;;KAIK;AACL,2CAHa,UAAU,GACR,KAAK,GAAC,aAAa,CAUjC;8BAhE6B,kBAAkB"}
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newrelic/browser-agent",
3
- "version": "1.270.3",
3
+ "version": "1.271.0",
4
4
  "private": false,
5
5
  "author": "New Relic Browser Agent Team <browser-agent@newrelic.com>",
6
6
  "description": "New Relic Browser Agent",
@@ -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
- let prefix = 'Unhandled Promise Rejection'
34
+ const prefix = 'Unhandled Promise Rejection'
35
35
 
36
- if (canTrustError(promiseRejectionEvent?.reason)) {
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