@newrelic/browser-agent 1.292.1-rc.3 → 1.292.1-rc.4

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.
@@ -17,7 +17,7 @@ exports.VERSION = exports.RRWEB_VERSION = exports.DIST_METHOD = exports.BUILD_EN
17
17
  /**
18
18
  * Exposes the version of the agent
19
19
  */
20
- const VERSION = exports.VERSION = "1.292.1-rc.3";
20
+ const VERSION = exports.VERSION = "1.292.1-rc.4";
21
21
 
22
22
  /**
23
23
  * Exposes the build type of the agent
@@ -17,7 +17,7 @@ exports.VERSION = exports.RRWEB_VERSION = exports.DIST_METHOD = exports.BUILD_EN
17
17
  /**
18
18
  * Exposes the version of the agent
19
19
  */
20
- const VERSION = exports.VERSION = "1.292.1-rc.3";
20
+ const VERSION = exports.VERSION = "1.292.1-rc.4";
21
21
 
22
22
  /**
23
23
  * Exposes the build type of the agent
@@ -78,6 +78,7 @@ function createWrapperWithEmitter(emitter, always) {
78
78
  var originalThis;
79
79
  var ctx;
80
80
  var result;
81
+ let thrownError;
81
82
  try {
82
83
  originalThis = this;
83
84
  args = [...arguments];
@@ -92,17 +93,31 @@ function createWrapperWithEmitter(emitter, always) {
92
93
 
93
94
  // Warning: start events may mutate args!
94
95
  safeEmit(prefix + 'start', [args, originalThis, methodName], ctx, bubble);
96
+ const fnStartTime = performance.now();
97
+ let fnEndTime = fnStartTime;
95
98
  try {
96
99
  result = fn.apply(originalThis, args);
100
+ fnEndTime = performance.now();
97
101
  return result;
98
102
  } catch (err) {
103
+ fnEndTime = performance.now();
99
104
  safeEmit(prefix + 'err', [args, originalThis, err], ctx, bubble);
100
-
101
105
  // rethrow error so we don't effect execution by observing.
102
- throw err;
106
+ thrownError = err;
107
+ throw thrownError;
103
108
  } finally {
104
- // happens no matter what.
105
- safeEmit(prefix + 'end', [args, originalThis, result], ctx, bubble);
109
+ const duration = fnEndTime - fnStartTime;
110
+ const task = {
111
+ duration,
112
+ isLongTask: duration >= 50,
113
+ methodName,
114
+ thrownError
115
+ // could add more properties here later if needed by downstream features
116
+ };
117
+ // standalone long task message
118
+ if (task.isLongTask) safeEmit('long-task', [task], ctx, bubble);
119
+ // -end message also includes the task execution info
120
+ safeEmit(prefix + 'end', [args, originalThis, result, task], ctx, bubble);
106
121
  }
107
122
  }
108
123
  }
@@ -11,7 +11,7 @@
11
11
  /**
12
12
  * Exposes the version of the agent
13
13
  */
14
- export const VERSION = "1.292.1-rc.3";
14
+ export const VERSION = "1.292.1-rc.4";
15
15
 
16
16
  /**
17
17
  * Exposes the build type of the agent
@@ -11,7 +11,7 @@
11
11
  /**
12
12
  * Exposes the version of the agent
13
13
  */
14
- export const VERSION = "1.292.1-rc.3";
14
+ export const VERSION = "1.292.1-rc.4";
15
15
 
16
16
  /**
17
17
  * Exposes the build type of the agent
@@ -71,6 +71,7 @@ export function createWrapperWithEmitter(emitter, always) {
71
71
  var originalThis;
72
72
  var ctx;
73
73
  var result;
74
+ let thrownError;
74
75
  try {
75
76
  originalThis = this;
76
77
  args = [...arguments];
@@ -85,17 +86,31 @@ export function createWrapperWithEmitter(emitter, always) {
85
86
 
86
87
  // Warning: start events may mutate args!
87
88
  safeEmit(prefix + 'start', [args, originalThis, methodName], ctx, bubble);
89
+ const fnStartTime = performance.now();
90
+ let fnEndTime = fnStartTime;
88
91
  try {
89
92
  result = fn.apply(originalThis, args);
93
+ fnEndTime = performance.now();
90
94
  return result;
91
95
  } catch (err) {
96
+ fnEndTime = performance.now();
92
97
  safeEmit(prefix + 'err', [args, originalThis, err], ctx, bubble);
93
-
94
98
  // rethrow error so we don't effect execution by observing.
95
- throw err;
99
+ thrownError = err;
100
+ throw thrownError;
96
101
  } finally {
97
- // happens no matter what.
98
- safeEmit(prefix + 'end', [args, originalThis, result], ctx, bubble);
102
+ const duration = fnEndTime - fnStartTime;
103
+ const task = {
104
+ duration,
105
+ isLongTask: duration >= 50,
106
+ methodName,
107
+ thrownError
108
+ // could add more properties here later if needed by downstream features
109
+ };
110
+ // standalone long task message
111
+ if (task.isLongTask) safeEmit('long-task', [task], ctx, bubble);
112
+ // -end message also includes the task execution info
113
+ safeEmit(prefix + 'end', [args, originalThis, result, task], ctx, bubble);
99
114
  }
100
115
  }
101
116
  }
@@ -1 +1 @@
1
- {"version":3,"file":"wrap-function.d.ts","sourceRoot":"","sources":["../../../../src/common/wrap/wrap-function.js"],"names":[],"mappings":"AA6BA;;;;;GAKG;AACH,mDAJW,MAAM,UACN,OAAO,YAgIjB;AAgBD;;;;;;;;GAQG;AACH,2BANW,MAAM,MACN,MAAM,YACN,MAAM,GAEJ,MAAM,CA2BlB;AAtMD,0BAA6C"}
1
+ {"version":3,"file":"wrap-function.d.ts","sourceRoot":"","sources":["../../../../src/common/wrap/wrap-function.js"],"names":[],"mappings":"AA6BA;;;;;GAKG;AACH,mDAJW,MAAM,UACN,OAAO,YA+IjB;AAgBD;;;;;;;;GAQG;AACH,2BANW,MAAM,MACN,MAAM,YACN,MAAM,GAEJ,MAAM,CA2BlB;AArND,0BAA6C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newrelic/browser-agent",
3
- "version": "1.292.1-rc.3",
3
+ "version": "1.292.1-rc.4",
4
4
  "private": false,
5
5
  "author": "New Relic Browser Agent Team <browser-agent@newrelic.com>",
6
6
  "description": "New Relic Browser Agent",
@@ -76,6 +76,7 @@ export function createWrapperWithEmitter (emitter, always) {
76
76
  var originalThis
77
77
  var ctx
78
78
  var result
79
+ let thrownError
79
80
 
80
81
  try {
81
82
  originalThis = this
@@ -93,17 +94,31 @@ export function createWrapperWithEmitter (emitter, always) {
93
94
  // Warning: start events may mutate args!
94
95
  safeEmit(prefix + 'start', [args, originalThis, methodName], ctx, bubble)
95
96
 
97
+ const fnStartTime = performance.now()
98
+ let fnEndTime = fnStartTime
96
99
  try {
97
100
  result = fn.apply(originalThis, args)
101
+ fnEndTime = performance.now()
98
102
  return result
99
103
  } catch (err) {
104
+ fnEndTime = performance.now()
100
105
  safeEmit(prefix + 'err', [args, originalThis, err], ctx, bubble)
101
-
102
106
  // rethrow error so we don't effect execution by observing.
103
- throw err
107
+ thrownError = err
108
+ throw thrownError
104
109
  } finally {
105
- // happens no matter what.
106
- safeEmit(prefix + 'end', [args, originalThis, result], ctx, bubble)
110
+ const duration = fnEndTime - fnStartTime
111
+ const task = {
112
+ duration,
113
+ isLongTask: duration >= 50,
114
+ methodName,
115
+ thrownError
116
+ // could add more properties here later if needed by downstream features
117
+ }
118
+ // standalone long task message
119
+ if (task.isLongTask) safeEmit('long-task', [task], ctx, bubble)
120
+ // -end message also includes the task execution info
121
+ safeEmit(prefix + 'end', [args, originalThis, result, task], ctx, bubble)
107
122
  }
108
123
  }
109
124
  }