@newrelic/browser-agent 1.301.0-rc.5 → 1.301.0-rc.6

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.RRWEB_PACKAGE_NAME = exports.D
17
17
  /**
18
18
  * Exposes the version of the agent
19
19
  */
20
- const VERSION = exports.VERSION = "1.301.0-rc.5";
20
+ const VERSION = exports.VERSION = "1.301.0-rc.6";
21
21
 
22
22
  /**
23
23
  * Exposes the build type of the agent
@@ -17,7 +17,7 @@ exports.VERSION = exports.RRWEB_VERSION = exports.RRWEB_PACKAGE_NAME = exports.D
17
17
  /**
18
18
  * Exposes the version of the agent
19
19
  */
20
- const VERSION = exports.VERSION = "1.301.0-rc.5";
20
+ const VERSION = exports.VERSION = "1.301.0-rc.6";
21
21
 
22
22
  /**
23
23
  * Exposes the build type of the agent
@@ -38,6 +38,13 @@ class Instrument extends _instrumentBase.InstrumentBase {
38
38
  (0, _finished.setupFinishedAPI)(agentRef);
39
39
  (0, _register.setupRegisterAPI)(agentRef);
40
40
  (0, _measure.setupMeasureAPI)(agentRef);
41
+ const ufEnabled = agentRef.init.feature_flags.includes('user_frustrations');
42
+ let historyEE;
43
+ if (_runtime.isBrowserScope && ufEnabled) {
44
+ (0, _wrapFetch.wrapFetch)(this.ee);
45
+ (0, _wrapXhr.wrapXhr)(this.ee);
46
+ historyEE = (0, _wrapHistory.wrapHistory)(this.ee);
47
+ }
41
48
  if (_runtime.isBrowserScope) {
42
49
  if (agentRef.init.user_actions.enabled) {
43
50
  _constants.OBSERVED_EVENTS.forEach(eventType => (0, _eventListenerOpts.windowAddEventListener)(eventType, evt => (0, _handle.handle)('ua', [evt], undefined, this.featureName, this.ee), true));
@@ -51,6 +58,37 @@ class Instrument extends _instrumentBase.InstrumentBase {
51
58
  }
52
59
  // Capture is not used here so that we don't get element focus/blur events, only the window's as they do not bubble. They are also not cancellable, so no worries about being front of line.
53
60
  );
61
+ if (ufEnabled) {
62
+ _runtime.globalScope.addEventListener('error', () => {
63
+ (0, _handle.handle)('uaErr', [], undefined, _features.FEATURE_NAMES.genericEvents, this.ee);
64
+ }, (0, _eventListenerOpts.eventListenerOpts)(false, this.removeOnAbort?.signal));
65
+ this.ee.on('open-xhr-start', (args, xhr) => {
66
+ if (!isInternalTraffic(args[1])) {
67
+ xhr.addEventListener('readystatechange', () => {
68
+ if (xhr.readyState === 2) {
69
+ // HEADERS_RECEIVED
70
+ (0, _handle.handle)('uaXhr', [], undefined, _features.FEATURE_NAMES.genericEvents, this.ee);
71
+ }
72
+ });
73
+ }
74
+ });
75
+ this.ee.on('fetch-start', fetchArguments => {
76
+ if (fetchArguments.length >= 1 && !isInternalTraffic((0, _extractUrl.extractUrl)(fetchArguments[0]))) {
77
+ (0, _handle.handle)('uaXhr', [], undefined, _features.FEATURE_NAMES.genericEvents, this.ee);
78
+ }
79
+ });
80
+ function isInternalTraffic(url) {
81
+ const parsedUrl = (0, _parseUrl.parseUrl)(url);
82
+ return agentRef.beacons.includes(parsedUrl.hostname + ':' + parsedUrl.port);
83
+ }
84
+ historyEE.on('pushState-end', navigationChange);
85
+ historyEE.on('replaceState-end', navigationChange);
86
+ window.addEventListener('hashchange', navigationChange, (0, _eventListenerOpts.eventListenerOpts)(true, this.removeOnAbort?.signal));
87
+ window.addEventListener('popstate', navigationChange, (0, _eventListenerOpts.eventListenerOpts)(true, this.removeOnAbort?.signal));
88
+ function navigationChange() {
89
+ historyEE.emit('navChange');
90
+ }
91
+ }
54
92
  }
55
93
  if (agentRef.init.performance.resources.enabled && _runtime.globalScope.PerformanceObserver?.supportedEntryTypes.includes('resource')) {
56
94
  const observer = new PerformanceObserver(list => {
@@ -63,14 +101,6 @@ class Instrument extends _instrumentBase.InstrumentBase {
63
101
  buffered: true
64
102
  });
65
103
  }
66
- const historyEE = (0, _wrapHistory.wrapHistory)(this.ee);
67
- historyEE.on('pushState-end', navigationChange);
68
- historyEE.on('replaceState-end', navigationChange);
69
- window.addEventListener('hashchange', navigationChange, (0, _eventListenerOpts.eventListenerOpts)(true, this.removeOnAbort?.signal));
70
- window.addEventListener('popstate', navigationChange, (0, _eventListenerOpts.eventListenerOpts)(true, this.removeOnAbort?.signal));
71
- function navigationChange() {
72
- historyEE.emit('navChange');
73
- }
74
104
  }
75
105
  try {
76
106
  this.removeOnAbort = new AbortController();
@@ -79,30 +109,6 @@ class Instrument extends _instrumentBase.InstrumentBase {
79
109
  this.removeOnAbort?.abort();
80
110
  this.abortHandler = undefined; // weakly allow this abort op to run only once
81
111
  };
82
- _runtime.globalScope.addEventListener('error', () => {
83
- (0, _handle.handle)('uaErr', [], undefined, _features.FEATURE_NAMES.genericEvents, this.ee);
84
- }, (0, _eventListenerOpts.eventListenerOpts)(false, this.removeOnAbort?.signal));
85
- (0, _wrapFetch.wrapFetch)(this.ee);
86
- (0, _wrapXhr.wrapXhr)(this.ee);
87
- this.ee.on('open-xhr-start', (args, xhr) => {
88
- if (!isInternalTraffic(args[1])) {
89
- xhr.addEventListener('readystatechange', () => {
90
- if (xhr.readyState === 2) {
91
- // HEADERS_RECEIVED
92
- (0, _handle.handle)('uaXhr', [], undefined, _features.FEATURE_NAMES.genericEvents, this.ee);
93
- }
94
- });
95
- }
96
- });
97
- this.ee.on('fetch-start', fetchArguments => {
98
- if (fetchArguments.length >= 1 && !isInternalTraffic((0, _extractUrl.extractUrl)(fetchArguments[0]))) {
99
- (0, _handle.handle)('uaXhr', [], undefined, _features.FEATURE_NAMES.genericEvents, this.ee);
100
- }
101
- });
102
- function isInternalTraffic(url) {
103
- const parsedUrl = (0, _parseUrl.parseUrl)(url);
104
- return agentRef.beacons.includes(parsedUrl.hostname + ':' + parsedUrl.port);
105
- }
106
112
 
107
113
  /** If any of the sources are active, import the aggregator. otherwise deregister */
108
114
  if (genericEventSourceConfigs.some(x => x)) this.importAggregator(agentRef, () => Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "generic_events-aggregate" */'../aggregate'))));else this.deregisterDrain();
@@ -11,7 +11,7 @@
11
11
  /**
12
12
  * Exposes the version of the agent
13
13
  */
14
- export const VERSION = "1.301.0-rc.5";
14
+ export const VERSION = "1.301.0-rc.6";
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.301.0-rc.5";
14
+ export const VERSION = "1.301.0-rc.6";
15
15
 
16
16
  /**
17
17
  * Exposes the build type of the agent
@@ -33,6 +33,13 @@ export class Instrument extends InstrumentBase {
33
33
  setupFinishedAPI(agentRef);
34
34
  setupRegisterAPI(agentRef);
35
35
  setupMeasureAPI(agentRef);
36
+ const ufEnabled = agentRef.init.feature_flags.includes('user_frustrations');
37
+ let historyEE;
38
+ if (isBrowserScope && ufEnabled) {
39
+ wrapFetch(this.ee);
40
+ wrapXhr(this.ee);
41
+ historyEE = wrapHistory(this.ee);
42
+ }
36
43
  if (isBrowserScope) {
37
44
  if (agentRef.init.user_actions.enabled) {
38
45
  OBSERVED_EVENTS.forEach(eventType => windowAddEventListener(eventType, evt => handle('ua', [evt], undefined, this.featureName, this.ee), true));
@@ -46,6 +53,37 @@ export class Instrument extends InstrumentBase {
46
53
  }
47
54
  // Capture is not used here so that we don't get element focus/blur events, only the window's as they do not bubble. They are also not cancellable, so no worries about being front of line.
48
55
  );
56
+ if (ufEnabled) {
57
+ globalScope.addEventListener('error', () => {
58
+ handle('uaErr', [], undefined, FEATURE_NAMES.genericEvents, this.ee);
59
+ }, eventListenerOpts(false, this.removeOnAbort?.signal));
60
+ this.ee.on('open-xhr-start', (args, xhr) => {
61
+ if (!isInternalTraffic(args[1])) {
62
+ xhr.addEventListener('readystatechange', () => {
63
+ if (xhr.readyState === 2) {
64
+ // HEADERS_RECEIVED
65
+ handle('uaXhr', [], undefined, FEATURE_NAMES.genericEvents, this.ee);
66
+ }
67
+ });
68
+ }
69
+ });
70
+ this.ee.on('fetch-start', fetchArguments => {
71
+ if (fetchArguments.length >= 1 && !isInternalTraffic(extractUrl(fetchArguments[0]))) {
72
+ handle('uaXhr', [], undefined, FEATURE_NAMES.genericEvents, this.ee);
73
+ }
74
+ });
75
+ function isInternalTraffic(url) {
76
+ const parsedUrl = parseUrl(url);
77
+ return agentRef.beacons.includes(parsedUrl.hostname + ':' + parsedUrl.port);
78
+ }
79
+ historyEE.on('pushState-end', navigationChange);
80
+ historyEE.on('replaceState-end', navigationChange);
81
+ window.addEventListener('hashchange', navigationChange, eventListenerOpts(true, this.removeOnAbort?.signal));
82
+ window.addEventListener('popstate', navigationChange, eventListenerOpts(true, this.removeOnAbort?.signal));
83
+ function navigationChange() {
84
+ historyEE.emit('navChange');
85
+ }
86
+ }
49
87
  }
50
88
  if (agentRef.init.performance.resources.enabled && globalScope.PerformanceObserver?.supportedEntryTypes.includes('resource')) {
51
89
  const observer = new PerformanceObserver(list => {
@@ -58,14 +96,6 @@ export class Instrument extends InstrumentBase {
58
96
  buffered: true
59
97
  });
60
98
  }
61
- const historyEE = wrapHistory(this.ee);
62
- historyEE.on('pushState-end', navigationChange);
63
- historyEE.on('replaceState-end', navigationChange);
64
- window.addEventListener('hashchange', navigationChange, eventListenerOpts(true, this.removeOnAbort?.signal));
65
- window.addEventListener('popstate', navigationChange, eventListenerOpts(true, this.removeOnAbort?.signal));
66
- function navigationChange() {
67
- historyEE.emit('navChange');
68
- }
69
99
  }
70
100
  try {
71
101
  this.removeOnAbort = new AbortController();
@@ -74,30 +104,6 @@ export class Instrument extends InstrumentBase {
74
104
  this.removeOnAbort?.abort();
75
105
  this.abortHandler = undefined; // weakly allow this abort op to run only once
76
106
  };
77
- globalScope.addEventListener('error', () => {
78
- handle('uaErr', [], undefined, FEATURE_NAMES.genericEvents, this.ee);
79
- }, eventListenerOpts(false, this.removeOnAbort?.signal));
80
- wrapFetch(this.ee);
81
- wrapXhr(this.ee);
82
- this.ee.on('open-xhr-start', (args, xhr) => {
83
- if (!isInternalTraffic(args[1])) {
84
- xhr.addEventListener('readystatechange', () => {
85
- if (xhr.readyState === 2) {
86
- // HEADERS_RECEIVED
87
- handle('uaXhr', [], undefined, FEATURE_NAMES.genericEvents, this.ee);
88
- }
89
- });
90
- }
91
- });
92
- this.ee.on('fetch-start', fetchArguments => {
93
- if (fetchArguments.length >= 1 && !isInternalTraffic(extractUrl(fetchArguments[0]))) {
94
- handle('uaXhr', [], undefined, FEATURE_NAMES.genericEvents, this.ee);
95
- }
96
- });
97
- function isInternalTraffic(url) {
98
- const parsedUrl = parseUrl(url);
99
- return agentRef.beacons.includes(parsedUrl.hostname + ':' + parsedUrl.port);
100
- }
101
107
 
102
108
  /** If any of the sources are active, import the aggregator. otherwise deregister */
103
109
  if (genericEventSourceConfigs.some(x => x)) this.importAggregator(agentRef, () => import(/* webpackChunkName: "generic_events-aggregate" */'../aggregate'));else this.deregisterDrain();
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/generic_events/instrument/index.js"],"names":[],"mappings":"AAuBA;IACE,2BAAiC;IACjC,2BAuFC;IArCG,2CAA0C;IAG5C,yBAGC;CAgCJ;AAED,8CAAuC;+BArGR,6BAA6B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/generic_events/instrument/index.js"],"names":[],"mappings":"AAuBA;IACE,2BAAiC;IACjC,2BAgGC;IAXG,2CAA0C;IAG5C,yBAGC;CAMJ;AAED,8CAAuC;+BA9GR,6BAA6B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newrelic/browser-agent",
3
- "version": "1.301.0-rc.5",
3
+ "version": "1.301.0-rc.6",
4
4
  "private": false,
5
5
  "author": "New Relic Browser Agent Team <browser-agent@newrelic.com>",
6
6
  "description": "New Relic Browser Agent",
@@ -41,6 +41,14 @@ export class Instrument extends InstrumentBase {
41
41
  setupRegisterAPI(agentRef)
42
42
  setupMeasureAPI(agentRef)
43
43
 
44
+ const ufEnabled = agentRef.init.feature_flags.includes('user_frustrations')
45
+ let historyEE
46
+ if (isBrowserScope && ufEnabled) {
47
+ wrapFetch(this.ee)
48
+ wrapXhr(this.ee)
49
+ historyEE = wrapHistory(this.ee)
50
+ }
51
+
44
52
  if (isBrowserScope) {
45
53
  if (agentRef.init.user_actions.enabled) {
46
54
  OBSERVED_EVENTS.forEach(eventType =>
@@ -52,7 +60,43 @@ export class Instrument extends InstrumentBase {
52
60
  }
53
61
  // Capture is not used here so that we don't get element focus/blur events, only the window's as they do not bubble. They are also not cancellable, so no worries about being front of line.
54
62
  )
63
+
64
+ if (ufEnabled) {
65
+ globalScope.addEventListener('error', () => {
66
+ handle('uaErr', [], undefined, FEATURE_NAMES.genericEvents, this.ee)
67
+ }, eventListenerOpts(false, this.removeOnAbort?.signal))
68
+
69
+ this.ee.on('open-xhr-start', (args, xhr) => {
70
+ if (!isInternalTraffic(args[1])) {
71
+ xhr.addEventListener('readystatechange', () => {
72
+ if (xhr.readyState === 2) { // HEADERS_RECEIVED
73
+ handle('uaXhr', [], undefined, FEATURE_NAMES.genericEvents, this.ee)
74
+ }
75
+ })
76
+ }
77
+ })
78
+ this.ee.on('fetch-start', (fetchArguments) => {
79
+ if (fetchArguments.length >= 1 && !isInternalTraffic(extractUrl(fetchArguments[0]))) {
80
+ handle('uaXhr', [], undefined, FEATURE_NAMES.genericEvents, this.ee)
81
+ }
82
+ })
83
+
84
+ function isInternalTraffic (url) {
85
+ const parsedUrl = parseUrl(url)
86
+ return agentRef.beacons.includes(parsedUrl.hostname + ':' + parsedUrl.port)
87
+ }
88
+
89
+ historyEE.on('pushState-end', navigationChange)
90
+ historyEE.on('replaceState-end', navigationChange)
91
+ window.addEventListener('hashchange', navigationChange, eventListenerOpts(true, this.removeOnAbort?.signal))
92
+ window.addEventListener('popstate', navigationChange, eventListenerOpts(true, this.removeOnAbort?.signal))
93
+
94
+ function navigationChange () {
95
+ historyEE.emit('navChange')
96
+ }
97
+ }
55
98
  }
99
+
56
100
  if (agentRef.init.performance.resources.enabled && globalScope.PerformanceObserver?.supportedEntryTypes.includes('resource')) {
57
101
  const observer = new PerformanceObserver((list) => {
58
102
  list.getEntries().forEach(entry => {
@@ -61,15 +105,6 @@ export class Instrument extends InstrumentBase {
61
105
  })
62
106
  observer.observe({ type: 'resource', buffered: true })
63
107
  }
64
-
65
- const historyEE = wrapHistory(this.ee)
66
- historyEE.on('pushState-end', navigationChange)
67
- historyEE.on('replaceState-end', navigationChange)
68
- window.addEventListener('hashchange', navigationChange, eventListenerOpts(true, this.removeOnAbort?.signal))
69
- window.addEventListener('popstate', navigationChange, eventListenerOpts(true, this.removeOnAbort?.signal))
70
- function navigationChange () {
71
- historyEE.emit('navChange')
72
- }
73
108
  }
74
109
 
75
110
  try {
@@ -81,32 +116,6 @@ export class Instrument extends InstrumentBase {
81
116
  this.abortHandler = undefined // weakly allow this abort op to run only once
82
117
  }
83
118
 
84
- globalScope.addEventListener('error', () => {
85
- handle('uaErr', [], undefined, FEATURE_NAMES.genericEvents, this.ee)
86
- }, eventListenerOpts(false, this.removeOnAbort?.signal))
87
-
88
- wrapFetch(this.ee)
89
- wrapXhr(this.ee)
90
- this.ee.on('open-xhr-start', (args, xhr) => {
91
- if (!isInternalTraffic(args[1])) {
92
- xhr.addEventListener('readystatechange', () => {
93
- if (xhr.readyState === 2) { // HEADERS_RECEIVED
94
- handle('uaXhr', [], undefined, FEATURE_NAMES.genericEvents, this.ee)
95
- }
96
- })
97
- }
98
- })
99
- this.ee.on('fetch-start', (fetchArguments) => {
100
- if (fetchArguments.length >= 1 && !isInternalTraffic(extractUrl(fetchArguments[0]))) {
101
- handle('uaXhr', [], undefined, FEATURE_NAMES.genericEvents, this.ee)
102
- }
103
- })
104
-
105
- function isInternalTraffic (url) {
106
- const parsedUrl = parseUrl(url)
107
- return agentRef.beacons.includes(parsedUrl.hostname + ':' + parsedUrl.port)
108
- }
109
-
110
119
  /** If any of the sources are active, import the aggregator. otherwise deregister */
111
120
  if (genericEventSourceConfigs.some(x => x)) this.importAggregator(agentRef, () => import(/* webpackChunkName: "generic_events-aggregate" */ '../aggregate'))
112
121
  else this.deregisterDrain()