@newrelic/browser-agent 1.312.1-rc.4 → 1.312.1-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.312.1-rc.4";
20
+ const VERSION = exports.VERSION = "1.312.1-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.312.1-rc.4";
20
+ const VERSION = exports.VERSION = "1.312.1-rc.6";
21
21
 
22
22
  /**
23
23
  * Exposes the build type of the agent
@@ -270,6 +270,25 @@ class Aggregate extends _aggregateBase.AggregateBase {
270
270
  this.addEvent(event);
271
271
  }, this.featureName, this.ee);
272
272
  }
273
+ if (!agentRef.init.feature_flags.includes('no_spv')) {
274
+ (0, _registerHandler.registerHandler)('spv', evt => {
275
+ this.addEvent({
276
+ eventType: 'SecurityPolicyViolation',
277
+ timestamp: this.#toEpoch(evt.timeStamp),
278
+ blockedUri: evt.blockedURI,
279
+ documentUri: evt.documentURI,
280
+ effectiveDirective: evt.effectiveDirective,
281
+ originalPolicy: evt.originalPolicy,
282
+ sourceFile: evt.sourceFile,
283
+ statusCode: evt.statusCode,
284
+ lineNumber: evt.lineNumber,
285
+ columnNumber: evt.columnNumber,
286
+ disposition: evt.disposition,
287
+ sample: evt.sample,
288
+ referrer: evt.referrer
289
+ });
290
+ }, this.featureName, this.ee);
291
+ }
273
292
  this.drain();
274
293
  });
275
294
  }
@@ -31,9 +31,10 @@ class Instrument extends _instrumentBase.InstrumentBase {
31
31
  constructor(agentRef) {
32
32
  super(agentRef, _constants.FEATURE_NAME);
33
33
  const websocketsEnabled = agentRef.init.feature_flags.includes('websockets');
34
+ const securityPolicyViolationEnabled = !agentRef.init.feature_flags.includes('no_spv');
34
35
 
35
36
  /** config values that gate whether the generic events aggregator should be imported at all */
36
- const genericEventSourceConfigs = [agentRef.init.page_action.enabled, agentRef.init.performance.capture_marks, agentRef.init.performance.capture_measures, agentRef.init.performance.resources.enabled, agentRef.init.user_actions.enabled, websocketsEnabled];
37
+ const genericEventSourceConfigs = [agentRef.init.page_action.enabled, agentRef.init.performance.capture_marks, agentRef.init.performance.capture_measures, agentRef.init.performance.resources.enabled, agentRef.init.user_actions.enabled, websocketsEnabled, securityPolicyViolationEnabled];
37
38
 
38
39
  /** feature specific APIs */
39
40
  (0, _addPageAction.setupAddPageActionAPI)(agentRef);
@@ -41,8 +42,24 @@ class Instrument extends _instrumentBase.InstrumentBase {
41
42
  (0, _finished.setupFinishedAPI)(agentRef);
42
43
  (0, _register.setupRegisterAPI)(agentRef);
43
44
  (0, _measure.setupMeasureAPI)(agentRef);
44
- let historyEE, websocketsEE;
45
- if (websocketsEnabled) websocketsEE = (0, _wrapWebsocket.wrapWebSocket)(this.ee);
45
+ this.removeOnAbort = new AbortController();
46
+ this.abortHandler = () => {
47
+ this.removeOnAbort.abort();
48
+ this.abortHandler = undefined; // weakly allow this abort op to run only once
49
+ };
50
+ let historyEE;
51
+ if (websocketsEnabled) {
52
+ // this can apply outside browser scope such as in worker
53
+ const websocketsEE = (0, _wrapWebsocket.wrapWebSocket)(this.ee);
54
+ websocketsEE.on('ws', nrData => {
55
+ (0, _handle.handle)('ws-complete', [nrData], undefined, this.featureName, this.ee);
56
+ });
57
+ }
58
+ if (securityPolicyViolationEnabled) {
59
+ _runtime.globalScope.addEventListener('securitypolicyviolation', evt => {
60
+ (0, _handle.handle)('spv', [evt], undefined, _features.FEATURE_NAMES.genericEvents, this.ee);
61
+ }, (0, _eventListenerOpts.eventListenerOpts)(false, this.removeOnAbort.signal));
62
+ }
46
63
  if (_runtime.isBrowserScope) {
47
64
  (0, _wrapFetch.wrapFetch)(this.ee, agentRef);
48
65
  (0, _wrapXhr.wrapXhr)(this.ee, agentRef);
@@ -61,7 +78,7 @@ class Instrument extends _instrumentBase.InstrumentBase {
61
78
  );
62
79
  _runtime.globalScope.addEventListener('error', () => {
63
80
  (0, _handle.handle)('uaErr', [], undefined, _features.FEATURE_NAMES.genericEvents, this.ee);
64
- }, (0, _eventListenerOpts.eventListenerOpts)(false, this.removeOnAbort?.signal));
81
+ }, (0, _eventListenerOpts.eventListenerOpts)(false, this.removeOnAbort.signal));
65
82
  this.ee.on('open-xhr-start', (args, xhr) => {
66
83
  if (!isInternalTraffic(args[1])) {
67
84
  xhr.addEventListener('readystatechange', () => {
@@ -69,7 +86,7 @@ class Instrument extends _instrumentBase.InstrumentBase {
69
86
  // HEADERS_RECEIVED
70
87
  (0, _handle.handle)('uaXhr', [], undefined, _features.FEATURE_NAMES.genericEvents, this.ee);
71
88
  }
72
- });
89
+ }, (0, _eventListenerOpts.eventListenerOpts)(undefined, this.removeOnAbort.signal));
73
90
  }
74
91
  });
75
92
  this.ee.on('fetch-start', fetchArguments => {
@@ -83,8 +100,8 @@ class Instrument extends _instrumentBase.InstrumentBase {
83
100
  }
84
101
  historyEE.on('pushState-end', navigationChange);
85
102
  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));
103
+ window.addEventListener('hashchange', navigationChange, (0, _eventListenerOpts.eventListenerOpts)(true, this.removeOnAbort.signal));
104
+ window.addEventListener('popstate', navigationChange, (0, _eventListenerOpts.eventListenerOpts)(true, this.removeOnAbort.signal));
88
105
  function navigationChange() {
89
106
  historyEE.emit('navChange');
90
107
  }
@@ -101,20 +118,6 @@ class Instrument extends _instrumentBase.InstrumentBase {
101
118
  });
102
119
  }
103
120
  }
104
- if (websocketsEnabled) {
105
- // this can apply outside browser scope such as in worker
106
- websocketsEE.on('ws', nrData => {
107
- (0, _handle.handle)('ws-complete', [nrData], undefined, this.featureName, this.ee);
108
- });
109
- }
110
- try {
111
- this.removeOnAbort = new AbortController();
112
- } catch (e) {}
113
- this.abortHandler = () => {
114
- this.removeOnAbort?.abort();
115
- this.abortHandler = undefined; // weakly allow this abort op to run only once
116
- };
117
-
118
121
  /** If any of the sources are active, import the aggregator. otherwise deregister */
119
122
  if (genericEventSourceConfigs.some(x => x)) this.importAggregator(agentRef, () => Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "generic_events-aggregate" */'../aggregate'))));else this.deregisterDrain();
120
123
  }
@@ -4,23 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Metrics = exports.Instrument = void 0;
7
- var _runtime = require("../../../common/constants/runtime");
8
- var _handle = require("../../../common/event-emitter/handle");
9
7
  var _instrumentBase = require("../../utils/instrument-base");
10
8
  var _constants = require("../constants");
11
9
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); } /**
12
- * Copyright 2020-2025 New Relic, Inc. All rights reserved.
10
+ * Copyright 2020-2026 New Relic, Inc. All rights reserved.
13
11
  * SPDX-License-Identifier: Apache-2.0
14
12
  */
15
13
  class Instrument extends _instrumentBase.InstrumentBase {
16
14
  static featureName = _constants.FEATURE_NAME;
17
15
  constructor(agentRef) {
18
16
  super(agentRef, _constants.FEATURE_NAME);
19
- if (_runtime.isBrowserScope) {
20
- document.addEventListener('securitypolicyviolation', e => {
21
- (0, _handle.handle)(_constants.SUPPORTABILITY_METRIC_CHANNEL, ['Generic/CSPViolation/Detected'], undefined, this.featureName, this.ee);
22
- });
23
- }
24
17
  this.importAggregator(agentRef, () => Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "metrics-aggregate" */'../aggregate'))));
25
18
  }
26
19
  }
@@ -11,7 +11,7 @@
11
11
  /**
12
12
  * Exposes the version of the agent
13
13
  */
14
- export const VERSION = "1.312.1-rc.4";
14
+ export const VERSION = "1.312.1-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.312.1-rc.4";
14
+ export const VERSION = "1.312.1-rc.6";
15
15
 
16
16
  /**
17
17
  * Exposes the build type of the agent
@@ -263,6 +263,25 @@ export class Aggregate extends AggregateBase {
263
263
  this.addEvent(event);
264
264
  }, this.featureName, this.ee);
265
265
  }
266
+ if (!agentRef.init.feature_flags.includes('no_spv')) {
267
+ registerHandler('spv', evt => {
268
+ this.addEvent({
269
+ eventType: 'SecurityPolicyViolation',
270
+ timestamp: this.#toEpoch(evt.timeStamp),
271
+ blockedUri: evt.blockedURI,
272
+ documentUri: evt.documentURI,
273
+ effectiveDirective: evt.effectiveDirective,
274
+ originalPolicy: evt.originalPolicy,
275
+ sourceFile: evt.sourceFile,
276
+ statusCode: evt.statusCode,
277
+ lineNumber: evt.lineNumber,
278
+ columnNumber: evt.columnNumber,
279
+ disposition: evt.disposition,
280
+ sample: evt.sample,
281
+ referrer: evt.referrer
282
+ });
283
+ }, this.featureName, this.ee);
284
+ }
266
285
  this.drain();
267
286
  });
268
287
  }
@@ -26,9 +26,10 @@ export class Instrument extends InstrumentBase {
26
26
  constructor(agentRef) {
27
27
  super(agentRef, FEATURE_NAME);
28
28
  const websocketsEnabled = agentRef.init.feature_flags.includes('websockets');
29
+ const securityPolicyViolationEnabled = !agentRef.init.feature_flags.includes('no_spv');
29
30
 
30
31
  /** config values that gate whether the generic events aggregator should be imported at all */
31
- const genericEventSourceConfigs = [agentRef.init.page_action.enabled, agentRef.init.performance.capture_marks, agentRef.init.performance.capture_measures, agentRef.init.performance.resources.enabled, agentRef.init.user_actions.enabled, websocketsEnabled];
32
+ const genericEventSourceConfigs = [agentRef.init.page_action.enabled, agentRef.init.performance.capture_marks, agentRef.init.performance.capture_measures, agentRef.init.performance.resources.enabled, agentRef.init.user_actions.enabled, websocketsEnabled, securityPolicyViolationEnabled];
32
33
 
33
34
  /** feature specific APIs */
34
35
  setupAddPageActionAPI(agentRef);
@@ -36,8 +37,24 @@ export class Instrument extends InstrumentBase {
36
37
  setupFinishedAPI(agentRef);
37
38
  setupRegisterAPI(agentRef);
38
39
  setupMeasureAPI(agentRef);
39
- let historyEE, websocketsEE;
40
- if (websocketsEnabled) websocketsEE = wrapWebSocket(this.ee);
40
+ this.removeOnAbort = new AbortController();
41
+ this.abortHandler = () => {
42
+ this.removeOnAbort.abort();
43
+ this.abortHandler = undefined; // weakly allow this abort op to run only once
44
+ };
45
+ let historyEE;
46
+ if (websocketsEnabled) {
47
+ // this can apply outside browser scope such as in worker
48
+ const websocketsEE = wrapWebSocket(this.ee);
49
+ websocketsEE.on('ws', nrData => {
50
+ handle('ws-complete', [nrData], undefined, this.featureName, this.ee);
51
+ });
52
+ }
53
+ if (securityPolicyViolationEnabled) {
54
+ globalScope.addEventListener('securitypolicyviolation', evt => {
55
+ handle('spv', [evt], undefined, FEATURE_NAMES.genericEvents, this.ee);
56
+ }, eventListenerOpts(false, this.removeOnAbort.signal));
57
+ }
41
58
  if (isBrowserScope) {
42
59
  wrapFetch(this.ee, agentRef);
43
60
  wrapXhr(this.ee, agentRef);
@@ -56,7 +73,7 @@ export class Instrument extends InstrumentBase {
56
73
  );
57
74
  globalScope.addEventListener('error', () => {
58
75
  handle('uaErr', [], undefined, FEATURE_NAMES.genericEvents, this.ee);
59
- }, eventListenerOpts(false, this.removeOnAbort?.signal));
76
+ }, eventListenerOpts(false, this.removeOnAbort.signal));
60
77
  this.ee.on('open-xhr-start', (args, xhr) => {
61
78
  if (!isInternalTraffic(args[1])) {
62
79
  xhr.addEventListener('readystatechange', () => {
@@ -64,7 +81,7 @@ export class Instrument extends InstrumentBase {
64
81
  // HEADERS_RECEIVED
65
82
  handle('uaXhr', [], undefined, FEATURE_NAMES.genericEvents, this.ee);
66
83
  }
67
- });
84
+ }, eventListenerOpts(undefined, this.removeOnAbort.signal));
68
85
  }
69
86
  });
70
87
  this.ee.on('fetch-start', fetchArguments => {
@@ -78,8 +95,8 @@ export class Instrument extends InstrumentBase {
78
95
  }
79
96
  historyEE.on('pushState-end', navigationChange);
80
97
  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));
98
+ window.addEventListener('hashchange', navigationChange, eventListenerOpts(true, this.removeOnAbort.signal));
99
+ window.addEventListener('popstate', navigationChange, eventListenerOpts(true, this.removeOnAbort.signal));
83
100
  function navigationChange() {
84
101
  historyEE.emit('navChange');
85
102
  }
@@ -96,20 +113,6 @@ export class Instrument extends InstrumentBase {
96
113
  });
97
114
  }
98
115
  }
99
- if (websocketsEnabled) {
100
- // this can apply outside browser scope such as in worker
101
- websocketsEE.on('ws', nrData => {
102
- handle('ws-complete', [nrData], undefined, this.featureName, this.ee);
103
- });
104
- }
105
- try {
106
- this.removeOnAbort = new AbortController();
107
- } catch (e) {}
108
- this.abortHandler = () => {
109
- this.removeOnAbort?.abort();
110
- this.abortHandler = undefined; // weakly allow this abort op to run only once
111
- };
112
-
113
116
  /** If any of the sources are active, import the aggregator. otherwise deregister */
114
117
  if (genericEventSourceConfigs.some(x => x)) this.importAggregator(agentRef, () => import(/* webpackChunkName: "generic_events-aggregate" */'../aggregate'));else this.deregisterDrain();
115
118
  }
@@ -1,21 +1,14 @@
1
1
  /**
2
- * Copyright 2020-2025 New Relic, Inc. All rights reserved.
2
+ * Copyright 2020-2026 New Relic, Inc. All rights reserved.
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
6
- import { isBrowserScope } from '../../../common/constants/runtime';
7
- import { handle } from '../../../common/event-emitter/handle';
8
6
  import { InstrumentBase } from '../../utils/instrument-base';
9
- import { FEATURE_NAME, SUPPORTABILITY_METRIC_CHANNEL } from '../constants';
7
+ import { FEATURE_NAME } from '../constants';
10
8
  export class Instrument extends InstrumentBase {
11
9
  static featureName = FEATURE_NAME;
12
10
  constructor(agentRef) {
13
11
  super(agentRef, FEATURE_NAME);
14
- if (isBrowserScope) {
15
- document.addEventListener('securitypolicyviolation', e => {
16
- handle(SUPPORTABILITY_METRIC_CHANNEL, ['Generic/CSPViolation/Detected'], undefined, this.featureName, this.ee);
17
- });
18
- }
19
12
  this.importAggregator(agentRef, () => import(/* webpackChunkName: "metrics-aggregate" */'../aggregate'));
20
13
  }
21
14
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/generic_events/aggregate/index.js"],"names":[],"mappings":"AAkBA;IACE,2BAAiC;IAGjC,2BAkPC;IAhPC,gCAAkG;IAmPpG;;;;;;;;;;;;OAYG;IACH,eAJW,MAAM,YAAC,WACP,MAAM,YAAC,QAmCjB;IAED,qCAEC;IAED;;;MAEC;;CAsBF;8BA9U6B,4BAA4B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/generic_events/aggregate/index.js"],"names":[],"mappings":"AAkBA;IACE,2BAAiC;IAGjC,2BAqQC;IAnQC,gCAAkG;IAsQpG;;;;;;;;;;;;OAYG;IACH,eAJW,MAAM,YAAC,WACP,MAAM,YAAC,QAmCjB;IAED,qCAEC;IAED;;;MAEC;;CAsBF;8BAjW6B,4BAA4B"}
@@ -1,7 +1,7 @@
1
1
  export class Instrument extends InstrumentBase {
2
2
  static featureName: string;
3
3
  constructor(agentRef: any);
4
- removeOnAbort: AbortController | undefined;
4
+ removeOnAbort: AbortController;
5
5
  abortHandler: () => void;
6
6
  }
7
7
  export const GenericEvents: typeof Instrument;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/generic_events/instrument/index.js"],"names":[],"mappings":"AAwBA;IACE,2BAAiC;IACjC,2BAuGC;IAXG,2CAA0C;IAG5C,yBAGC;CAMJ;AAED,8CAAuC;+BAtHR,6BAA6B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/generic_events/instrument/index.js"],"names":[],"mappings":"AAwBA;IACE,2BAAiC;IACjC,2BA0GC;IAnFC,+BAA0C;IAC1C,yBAGC;CAgFJ;AAED,8CAAuC;+BAzHR,6BAA6B"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/metrics/instrument/index.js"],"names":[],"mappings":"AAaA;IACE,2BAAiC;IACjC,2BAUC;CACF;AAED,wCAAiC;+BArBF,6BAA6B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/metrics/instrument/index.js"],"names":[],"mappings":"AAQA;IACE,2BAAiC;IACjC,2BAIC;CACF;AAED,wCAAiC;+BAZF,6BAA6B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newrelic/browser-agent",
3
- "version": "1.312.1-rc.4",
3
+ "version": "1.312.1-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",
@@ -259,6 +259,25 @@ export class Aggregate extends AggregateBase {
259
259
  this.addEvent(event)
260
260
  }, this.featureName, this.ee)
261
261
  }
262
+ if (!agentRef.init.feature_flags.includes('no_spv')) {
263
+ registerHandler('spv', (evt) => {
264
+ this.addEvent({
265
+ eventType: 'SecurityPolicyViolation',
266
+ timestamp: this.#toEpoch(evt.timeStamp),
267
+ blockedUri: evt.blockedURI,
268
+ documentUri: evt.documentURI,
269
+ effectiveDirective: evt.effectiveDirective,
270
+ originalPolicy: evt.originalPolicy,
271
+ sourceFile: evt.sourceFile,
272
+ statusCode: evt.statusCode,
273
+ lineNumber: evt.lineNumber,
274
+ columnNumber: evt.columnNumber,
275
+ disposition: evt.disposition,
276
+ sample: evt.sample,
277
+ referrer: evt.referrer
278
+ })
279
+ }, this.featureName, this.ee)
280
+ }
262
281
 
263
282
  this.drain()
264
283
  })
@@ -27,6 +27,7 @@ export class Instrument extends InstrumentBase {
27
27
  constructor (agentRef) {
28
28
  super(agentRef, FEATURE_NAME)
29
29
  const websocketsEnabled = agentRef.init.feature_flags.includes('websockets')
30
+ const securityPolicyViolationEnabled = !agentRef.init.feature_flags.includes('no_spv')
30
31
 
31
32
  /** config values that gate whether the generic events aggregator should be imported at all */
32
33
  const genericEventSourceConfigs = [
@@ -35,7 +36,8 @@ export class Instrument extends InstrumentBase {
35
36
  agentRef.init.performance.capture_measures,
36
37
  agentRef.init.performance.resources.enabled,
37
38
  agentRef.init.user_actions.enabled,
38
- websocketsEnabled
39
+ websocketsEnabled,
40
+ securityPolicyViolationEnabled
39
41
  ]
40
42
 
41
43
  /** feature specific APIs */
@@ -45,8 +47,24 @@ export class Instrument extends InstrumentBase {
45
47
  setupRegisterAPI(agentRef)
46
48
  setupMeasureAPI(agentRef)
47
49
 
48
- let historyEE, websocketsEE
49
- if (websocketsEnabled) websocketsEE = wrapWebSocket(this.ee)
50
+ this.removeOnAbort = new AbortController()
51
+ this.abortHandler = () => {
52
+ this.removeOnAbort.abort()
53
+ this.abortHandler = undefined // weakly allow this abort op to run only once
54
+ }
55
+
56
+ let historyEE
57
+ if (websocketsEnabled) { // this can apply outside browser scope such as in worker
58
+ const websocketsEE = wrapWebSocket(this.ee)
59
+ websocketsEE.on('ws', (nrData) => {
60
+ handle('ws-complete', [nrData], undefined, this.featureName, this.ee)
61
+ })
62
+ }
63
+ if (securityPolicyViolationEnabled) {
64
+ globalScope.addEventListener('securitypolicyviolation', (evt) => {
65
+ handle('spv', [evt], undefined, FEATURE_NAMES.genericEvents, this.ee)
66
+ }, eventListenerOpts(false, this.removeOnAbort.signal))
67
+ }
50
68
  if (isBrowserScope) {
51
69
  wrapFetch(this.ee, agentRef)
52
70
  wrapXhr(this.ee, agentRef)
@@ -65,7 +83,7 @@ export class Instrument extends InstrumentBase {
65
83
 
66
84
  globalScope.addEventListener('error', () => {
67
85
  handle('uaErr', [], undefined, FEATURE_NAMES.genericEvents, this.ee)
68
- }, eventListenerOpts(false, this.removeOnAbort?.signal))
86
+ }, eventListenerOpts(false, this.removeOnAbort.signal))
69
87
 
70
88
  this.ee.on('open-xhr-start', (args, xhr) => {
71
89
  if (!isInternalTraffic(args[1])) {
@@ -73,7 +91,7 @@ export class Instrument extends InstrumentBase {
73
91
  if (xhr.readyState === 2) { // HEADERS_RECEIVED
74
92
  handle('uaXhr', [], undefined, FEATURE_NAMES.genericEvents, this.ee)
75
93
  }
76
- })
94
+ }, eventListenerOpts(undefined, this.removeOnAbort.signal))
77
95
  }
78
96
  })
79
97
  this.ee.on('fetch-start', (fetchArguments) => {
@@ -89,8 +107,8 @@ export class Instrument extends InstrumentBase {
89
107
 
90
108
  historyEE.on('pushState-end', navigationChange)
91
109
  historyEE.on('replaceState-end', navigationChange)
92
- window.addEventListener('hashchange', navigationChange, eventListenerOpts(true, this.removeOnAbort?.signal))
93
- window.addEventListener('popstate', navigationChange, eventListenerOpts(true, this.removeOnAbort?.signal))
110
+ window.addEventListener('hashchange', navigationChange, eventListenerOpts(true, this.removeOnAbort.signal))
111
+ window.addEventListener('popstate', navigationChange, eventListenerOpts(true, this.removeOnAbort.signal))
94
112
 
95
113
  function navigationChange () {
96
114
  historyEE.emit('navChange')
@@ -109,21 +127,6 @@ export class Instrument extends InstrumentBase {
109
127
  })
110
128
  }
111
129
  }
112
- if (websocketsEnabled) { // this can apply outside browser scope such as in worker
113
- websocketsEE.on('ws', (nrData) => {
114
- handle('ws-complete', [nrData], undefined, this.featureName, this.ee)
115
- })
116
- }
117
-
118
- try {
119
- this.removeOnAbort = new AbortController()
120
- } catch (e) {}
121
-
122
- this.abortHandler = () => {
123
- this.removeOnAbort?.abort()
124
- this.abortHandler = undefined // weakly allow this abort op to run only once
125
- }
126
-
127
130
  /** If any of the sources are active, import the aggregator. otherwise deregister */
128
131
  if (genericEventSourceConfigs.some(x => x)) this.importAggregator(agentRef, () => import(/* webpackChunkName: "generic_events-aggregate" */ '../aggregate'))
129
132
  else this.deregisterDrain()
@@ -1,27 +1,16 @@
1
1
  /**
2
- * Copyright 2020-2025 New Relic, Inc. All rights reserved.
2
+ * Copyright 2020-2026 New Relic, Inc. All rights reserved.
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
6
- import { isBrowserScope } from '../../../common/constants/runtime'
7
- import { handle } from '../../../common/event-emitter/handle'
8
6
  import { InstrumentBase } from '../../utils/instrument-base'
9
- import {
10
- FEATURE_NAME,
11
- SUPPORTABILITY_METRIC_CHANNEL
12
- } from '../constants'
7
+ import { FEATURE_NAME } from '../constants'
13
8
 
14
9
  export class Instrument extends InstrumentBase {
15
10
  static featureName = FEATURE_NAME
16
11
  constructor (agentRef) {
17
12
  super(agentRef, FEATURE_NAME)
18
13
 
19
- if (isBrowserScope) {
20
- document.addEventListener('securitypolicyviolation', (e) => {
21
- handle(SUPPORTABILITY_METRIC_CHANNEL, ['Generic/CSPViolation/Detected'], undefined, this.featureName, this.ee)
22
- })
23
- }
24
-
25
14
  this.importAggregator(agentRef, () => import(/* webpackChunkName: "metrics-aggregate" */ '../aggregate'))
26
15
  }
27
16
  }