@newrelic/browser-agent 1.275.0 → 1.276.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/config/init.js +44 -8
- package/dist/cjs/common/constants/env.cdn.js +1 -1
- package/dist/cjs/common/constants/env.npm.js +1 -1
- package/dist/cjs/features/ajax/instrument/index.js +1 -1
- package/dist/cjs/features/generic_events/aggregate/index.js +68 -5
- package/dist/cjs/features/generic_events/constants.js +7 -2
- package/dist/cjs/features/generic_events/instrument/index.js +20 -8
- package/dist/cjs/features/jserrors/aggregate/index.js +3 -2
- package/dist/cjs/features/jserrors/aggregate/internal-errors.js +2 -2
- package/dist/cjs/features/jserrors/instrument/index.js +2 -2
- package/dist/cjs/features/metrics/aggregate/index.js +1 -35
- package/dist/esm/common/config/init.js +39 -3
- package/dist/esm/common/constants/env.cdn.js +1 -1
- package/dist/esm/common/constants/env.npm.js +1 -1
- package/dist/esm/features/ajax/instrument/index.js +1 -1
- package/dist/esm/features/generic_events/aggregate/index.js +69 -6
- package/dist/esm/features/generic_events/constants.js +6 -1
- package/dist/esm/features/generic_events/instrument/index.js +21 -9
- package/dist/esm/features/jserrors/aggregate/index.js +3 -2
- package/dist/esm/features/jserrors/aggregate/internal-errors.js +2 -2
- package/dist/esm/features/jserrors/instrument/index.js +2 -2
- package/dist/esm/features/metrics/aggregate/index.js +1 -35
- package/dist/types/common/config/init.d.ts.map +1 -1
- package/dist/types/features/generic_events/aggregate/index.d.ts +1 -0
- package/dist/types/features/generic_events/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/generic_events/constants.d.ts +5 -0
- package/dist/types/features/generic_events/instrument/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/aggregate/index.d.ts +2 -1
- package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/aggregate/internal-errors.d.ts +1 -1
- package/dist/types/features/jserrors/aggregate/internal-errors.d.ts.map +1 -1
- package/dist/types/features/metrics/aggregate/index.d.ts +0 -1
- package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
- package/package.json +13 -1
- package/src/common/config/init.js +21 -3
- package/src/features/ajax/instrument/index.js +1 -1
- package/src/features/generic_events/aggregate/index.js +71 -6
- package/src/features/generic_events/constants.js +6 -0
- package/src/features/generic_events/instrument/index.js +21 -10
- package/src/features/jserrors/aggregate/index.js +3 -2
- package/src/features/jserrors/aggregate/internal-errors.js +2 -2
- package/src/features/jserrors/instrument/index.js +2 -2
- package/src/features/metrics/aggregate/index.js +1 -33
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.276.0](https://github.com/newrelic/newrelic-browser-agent/compare/v1.275.0...v1.276.0) (2024-12-16)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* allow feature flags to control experimental features ([#1282](https://github.com/newrelic/newrelic-browser-agent/issues/1282)) ([537e72d](https://github.com/newrelic/newrelic-browser-agent/commit/537e72da0821792006abd16c41ffa025fd73b474))
|
|
12
|
+
* Capture Page Resource Assets ([#1257](https://github.com/newrelic/newrelic-browser-agent/issues/1257)) ([e4c7deb](https://github.com/newrelic/newrelic-browser-agent/commit/e4c7debe2a1653efdad8940c55a71dd0140ce900))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* Fix syntax error in fallback when tracking xhr readyState ([#1272](https://github.com/newrelic/newrelic-browser-agent/issues/1272)) ([2bb6b5b](https://github.com/newrelic/newrelic-browser-agent/commit/2bb6b5b2e104a6b3ac9ceb70d396f65cfb61c1bd))
|
|
18
|
+
* Ignore reserved attribute names on UserActions tied to the window ([#1261](https://github.com/newrelic/newrelic-browser-agent/issues/1261)) ([8410dbe](https://github.com/newrelic/newrelic-browser-agent/commit/8410dbeef30aeb0e578c63a293ec311c3d42f8da))
|
|
19
|
+
|
|
6
20
|
## [1.275.0](https://github.com/newrelic/newrelic-browser-agent/compare/v1.274.0...v1.275.0) (2024-12-03)
|
|
7
21
|
|
|
8
22
|
|
|
@@ -6,15 +6,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.getConfiguration = getConfiguration;
|
|
7
7
|
exports.getConfigurationValue = getConfigurationValue;
|
|
8
8
|
exports.setConfiguration = setConfiguration;
|
|
9
|
-
var _constants = require("../../features/
|
|
9
|
+
var _constants = require("../../features/generic_events/constants");
|
|
10
|
+
var _constants2 = require("../../features/logging/constants");
|
|
10
11
|
var _querySelector = require("../dom/query-selector");
|
|
11
|
-
var
|
|
12
|
+
var _constants3 = require("../session/constants");
|
|
12
13
|
var _console = require("../util/console");
|
|
13
14
|
var _nreum = require("../window/nreum");
|
|
14
15
|
var _configurable = require("./configurable");
|
|
15
16
|
const nrMask = '[data-nr-mask]';
|
|
16
17
|
const model = () => {
|
|
17
18
|
const hiddenState = {
|
|
19
|
+
feature_flags: [],
|
|
20
|
+
experimental: {
|
|
21
|
+
marks: false,
|
|
22
|
+
measures: false,
|
|
23
|
+
resources: false
|
|
24
|
+
},
|
|
18
25
|
mask_selector: '*',
|
|
19
26
|
block_selector: '[data-nr-block]',
|
|
20
27
|
mask_input_options: {
|
|
@@ -52,7 +59,12 @@ const model = () => {
|
|
|
52
59
|
cors_use_tracecontext_headers: undefined,
|
|
53
60
|
allowed_origins: undefined
|
|
54
61
|
},
|
|
55
|
-
feature_flags
|
|
62
|
+
get feature_flags() {
|
|
63
|
+
return hiddenState.feature_flags;
|
|
64
|
+
},
|
|
65
|
+
set feature_flags(val) {
|
|
66
|
+
hiddenState.feature_flags = val;
|
|
67
|
+
},
|
|
56
68
|
generic_events: {
|
|
57
69
|
enabled: true,
|
|
58
70
|
harvestTimeSeconds: 30,
|
|
@@ -70,7 +82,7 @@ const model = () => {
|
|
|
70
82
|
enabled: true,
|
|
71
83
|
harvestTimeSeconds: 10,
|
|
72
84
|
autoStart: true,
|
|
73
|
-
level:
|
|
85
|
+
level: _constants2.LOG_LEVELS.INFO
|
|
74
86
|
},
|
|
75
87
|
metrics: {
|
|
76
88
|
enabled: true,
|
|
@@ -90,8 +102,32 @@ const model = () => {
|
|
|
90
102
|
autoStart: true
|
|
91
103
|
},
|
|
92
104
|
performance: {
|
|
93
|
-
capture_marks
|
|
94
|
-
|
|
105
|
+
get capture_marks() {
|
|
106
|
+
return hiddenState.feature_flags.includes(_constants.FEATURE_FLAGS.MARKS) || hiddenState.experimental.marks;
|
|
107
|
+
},
|
|
108
|
+
set capture_marks(val) {
|
|
109
|
+
hiddenState.experimental.marks = val;
|
|
110
|
+
},
|
|
111
|
+
get capture_measures() {
|
|
112
|
+
return hiddenState.feature_flags.includes(_constants.FEATURE_FLAGS.MEASURES) || hiddenState.experimental.measures;
|
|
113
|
+
},
|
|
114
|
+
set capture_measures(val) {
|
|
115
|
+
hiddenState.experimental.measures = val;
|
|
116
|
+
},
|
|
117
|
+
resources: {
|
|
118
|
+
// whether to run this subfeature or not in the generic_events feature. false by default through experimental phase, but flipped to true once GA'd
|
|
119
|
+
get enabled() {
|
|
120
|
+
return hiddenState.feature_flags.includes(_constants.FEATURE_FLAGS.RESOURCES) || hiddenState.experimental.resources;
|
|
121
|
+
},
|
|
122
|
+
set enabled(val) {
|
|
123
|
+
hiddenState.experimental.resources = val;
|
|
124
|
+
},
|
|
125
|
+
asset_types: [],
|
|
126
|
+
// MDN types to collect, empty array will collect all types
|
|
127
|
+
first_party_domains: [],
|
|
128
|
+
// when included, will decorate the resource as first party if matching
|
|
129
|
+
ignore_newrelic: true // ignore capturing internal agent scripts and harvest calls
|
|
130
|
+
}
|
|
95
131
|
},
|
|
96
132
|
privacy: {
|
|
97
133
|
cookies_enabled: true
|
|
@@ -103,8 +139,8 @@ const model = () => {
|
|
|
103
139
|
beacon: undefined // likewise for the url to which we send analytics
|
|
104
140
|
},
|
|
105
141
|
session: {
|
|
106
|
-
expiresMs:
|
|
107
|
-
inactiveMs:
|
|
142
|
+
expiresMs: _constants3.DEFAULT_EXPIRES_MS,
|
|
143
|
+
inactiveMs: _constants3.DEFAULT_INACTIVE_MS
|
|
108
144
|
},
|
|
109
145
|
session_replay: {
|
|
110
146
|
// feature settings
|
|
@@ -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.276.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.276.0";
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Exposes the build type of the agent
|
|
@@ -346,7 +346,7 @@ function subscribeToEvents(agentRef, ee, handler, dt) {
|
|
|
346
346
|
if ((0, _denyList.hasUndefinedHostname)(params)) return; // don't bother with XHR of url with no hostname
|
|
347
347
|
|
|
348
348
|
metrics.duration = (0, _now.now)() - this.startTime;
|
|
349
|
-
if (!this.
|
|
349
|
+
if (!this.loadCaptureCalled && xhr.readyState === 4) {
|
|
350
350
|
captureXhrData(this, xhr);
|
|
351
351
|
} else if (params.status == null) {
|
|
352
352
|
params.status = 0;
|
|
@@ -18,6 +18,7 @@ var _traverse = require("../../../common/util/traverse");
|
|
|
18
18
|
var _features = require("../../../loaders/features/features");
|
|
19
19
|
var _userActionsAggregator = require("./user-actions/user-actions-aggregator");
|
|
20
20
|
var _iframe = require("../../../common/dom/iframe");
|
|
21
|
+
var _handle = require("../../../common/event-emitter/handle");
|
|
21
22
|
/*
|
|
22
23
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
23
24
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -36,6 +37,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
36
37
|
this.deregisterDrain();
|
|
37
38
|
return;
|
|
38
39
|
}
|
|
40
|
+
this.trackSupportabilityMetrics();
|
|
39
41
|
if (agentRef.init.page_action.enabled) {
|
|
40
42
|
(0, _registerHandler.registerHandler)('api-addPageAction', (timestamp, name, attributes) => {
|
|
41
43
|
this.addEvent({
|
|
@@ -77,19 +79,28 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
77
79
|
...((0, _iframe.isIFrameWindow)(window) && {
|
|
78
80
|
iframe: true
|
|
79
81
|
}),
|
|
80
|
-
...(
|
|
82
|
+
...(canTrustTargetAttribute('id') && {
|
|
81
83
|
targetId: target.id
|
|
82
84
|
}),
|
|
83
|
-
...(
|
|
85
|
+
...(canTrustTargetAttribute('tagName') && {
|
|
84
86
|
targetTag: target.tagName
|
|
85
87
|
}),
|
|
86
|
-
...(
|
|
88
|
+
...(canTrustTargetAttribute('type') && {
|
|
87
89
|
targetType: target.type
|
|
88
90
|
}),
|
|
89
|
-
...(
|
|
91
|
+
...(canTrustTargetAttribute('className') && {
|
|
90
92
|
targetClass: target.className
|
|
91
93
|
})
|
|
92
94
|
});
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Only trust attributes that exist on HTML element targets, which excludes the window and the document targets
|
|
98
|
+
* @param {string} attribute The attribute to check for on the target element
|
|
99
|
+
* @returns {boolean} Whether the target element has the attribute and can be trusted
|
|
100
|
+
*/
|
|
101
|
+
function canTrustTargetAttribute(attribute) {
|
|
102
|
+
return !!(aggregatedUserAction.selectorPath !== 'window' && aggregatedUserAction.selectorPath !== 'document' && target instanceof HTMLElement && target?.[attribute]);
|
|
103
|
+
}
|
|
93
104
|
}
|
|
94
105
|
} catch (e) {
|
|
95
106
|
// do nothing for now
|
|
@@ -116,10 +127,11 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
116
127
|
const observer = new PerformanceObserver(list => {
|
|
117
128
|
list.getEntries().forEach(entry => {
|
|
118
129
|
try {
|
|
130
|
+
(0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['Generic/Performance/' + type + '/Seen']);
|
|
119
131
|
this.addEvent({
|
|
120
132
|
eventType: 'BrowserPerformance',
|
|
121
133
|
timestamp: Math.floor(agentRef.runtime.timeKeeper.correctRelativeTimestamp(entry.startTime)),
|
|
122
|
-
entryName: entry.name,
|
|
134
|
+
entryName: (0, _cleanUrl.cleanURL)(entry.name),
|
|
123
135
|
entryDuration: entry.duration,
|
|
124
136
|
entryType: type,
|
|
125
137
|
...(entry.detail && {
|
|
@@ -139,6 +151,47 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
139
151
|
// Something failed in our set up, likely the browser does not support PO's... do nothing
|
|
140
152
|
}
|
|
141
153
|
}
|
|
154
|
+
if (_runtime.isBrowserScope && agentRef.init.performance.resources.enabled) {
|
|
155
|
+
(0, _registerHandler.registerHandler)('browserPerformance.resource', entry => {
|
|
156
|
+
try {
|
|
157
|
+
// convert the entry to a plain object and separate the name and duration from the object
|
|
158
|
+
// you need to do this to be able to spread it into the addEvent call later, and name and duration
|
|
159
|
+
// would be duplicative of entryName and entryDuration and are protected keys in NR1
|
|
160
|
+
const {
|
|
161
|
+
name,
|
|
162
|
+
duration,
|
|
163
|
+
...entryObject
|
|
164
|
+
} = entry.toJSON();
|
|
165
|
+
let firstParty = false;
|
|
166
|
+
try {
|
|
167
|
+
const entryDomain = new URL(name).hostname;
|
|
168
|
+
const isNr = entryDomain.includes('newrelic.com') || entryDomain.includes('nr-data.net') || entryDomain.includes('nr-local.net');
|
|
169
|
+
/** decide if we should ignore nr-specific assets */
|
|
170
|
+
if (this.agentRef.init.performance.resources.ignore_newrelic && isNr) return;
|
|
171
|
+
/** decide if we should ignore the asset type (empty means allow everything, which is the default) */
|
|
172
|
+
if (this.agentRef.init.performance.resources.asset_types.length && !this.agentRef.init.performance.resources.asset_types.includes(entryObject.initiatorType)) return;
|
|
173
|
+
/** decide if the entryDomain is a first party domain */
|
|
174
|
+
firstParty = entryDomain === _runtime.globalScope?.location.hostname || agentRef.init.performance.resources.first_party_domains.includes(entryDomain);
|
|
175
|
+
if (firstParty) (0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['Generic/Performance/FirstPartyResource/Seen']);
|
|
176
|
+
if (isNr) (0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['Generic/Performance/NrResource/Seen']);
|
|
177
|
+
} catch (err) {
|
|
178
|
+
// couldnt parse the URL, so firstParty will just default to false
|
|
179
|
+
}
|
|
180
|
+
(0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['Generic/Performance/Resource/Seen']);
|
|
181
|
+
const event = {
|
|
182
|
+
...entryObject,
|
|
183
|
+
eventType: 'BrowserPerformance',
|
|
184
|
+
timestamp: Math.floor(agentRef.runtime.timeKeeper.correctRelativeTimestamp(entryObject.startTime)),
|
|
185
|
+
entryName: name,
|
|
186
|
+
entryDuration: duration,
|
|
187
|
+
firstParty
|
|
188
|
+
};
|
|
189
|
+
this.addEvent(event);
|
|
190
|
+
} catch (err) {
|
|
191
|
+
this.ee.emit('internal-error', [err, 'GenericEvents-Resource']);
|
|
192
|
+
}
|
|
193
|
+
}, this.featureName, this.ee);
|
|
194
|
+
}
|
|
142
195
|
this.harvestScheduler = new _harvestScheduler.HarvestScheduler(_features.FEATURE_TO_ENDPOINT[this.featureName], {
|
|
143
196
|
onFinished: result => this.postHarvestCleanup(result.sent && result.retry),
|
|
144
197
|
onUnload: () => addUserAction?.(this.userActionAggregator.aggregationEvent)
|
|
@@ -209,5 +262,15 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
209
262
|
at: this.agentRef.info.atts
|
|
210
263
|
};
|
|
211
264
|
}
|
|
265
|
+
trackSupportabilityMetrics() {
|
|
266
|
+
/** track usage SMs to improve these experimental features */
|
|
267
|
+
const configPerfTag = 'Config/Performance/';
|
|
268
|
+
if (this.agentRef.init.performance.capture_marks) (0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, [configPerfTag + 'CaptureMarks/Enabled']);
|
|
269
|
+
if (this.agentRef.init.performance.capture_measures) (0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, [configPerfTag + 'CaptureMeasures/Enabled']);
|
|
270
|
+
if (this.agentRef.init.performance.resources.enabled) (0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, [configPerfTag + 'Resources/Enabled']);
|
|
271
|
+
if (this.agentRef.init.performance.resources.asset_types?.length !== 0) (0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, [configPerfTag + 'Resources/AssetTypes/Changed']);
|
|
272
|
+
if (this.agentRef.init.performance.resources.first_party_domains?.length !== 0) (0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, [configPerfTag + 'Resources/FirstPartyDomains/Changed']);
|
|
273
|
+
if (this.agentRef.init.performance.resources.ignore_newrelic === false) (0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, [configPerfTag + 'Resources/IgnoreNewrelic/Changed']);
|
|
274
|
+
}
|
|
212
275
|
}
|
|
213
276
|
exports.Aggregate = Aggregate;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.RAGE_CLICK_THRESHOLD_MS = exports.RAGE_CLICK_THRESHOLD_EVENTS = exports.OBSERVED_WINDOW_EVENTS = exports.OBSERVED_EVENTS = exports.MAX_PAYLOAD_SIZE = exports.IDEAL_PAYLOAD_SIZE = exports.FEATURE_NAME = void 0;
|
|
6
|
+
exports.RAGE_CLICK_THRESHOLD_MS = exports.RAGE_CLICK_THRESHOLD_EVENTS = exports.OBSERVED_WINDOW_EVENTS = exports.OBSERVED_EVENTS = exports.MAX_PAYLOAD_SIZE = exports.IDEAL_PAYLOAD_SIZE = exports.FEATURE_NAME = exports.FEATURE_FLAGS = void 0;
|
|
7
7
|
var _features = require("../../loaders/features/features");
|
|
8
8
|
const FEATURE_NAME = exports.FEATURE_NAME = _features.FEATURE_NAMES.genericEvents;
|
|
9
9
|
const IDEAL_PAYLOAD_SIZE = exports.IDEAL_PAYLOAD_SIZE = 64000;
|
|
@@ -11,4 +11,9 @@ const MAX_PAYLOAD_SIZE = exports.MAX_PAYLOAD_SIZE = 1000000;
|
|
|
11
11
|
const OBSERVED_EVENTS = exports.OBSERVED_EVENTS = ['auxclick', 'click', 'copy', 'keydown', 'paste', 'scrollend'];
|
|
12
12
|
const OBSERVED_WINDOW_EVENTS = exports.OBSERVED_WINDOW_EVENTS = ['focus', 'blur'];
|
|
13
13
|
const RAGE_CLICK_THRESHOLD_EVENTS = exports.RAGE_CLICK_THRESHOLD_EVENTS = 4;
|
|
14
|
-
const RAGE_CLICK_THRESHOLD_MS = exports.RAGE_CLICK_THRESHOLD_MS = 1000;
|
|
14
|
+
const RAGE_CLICK_THRESHOLD_MS = exports.RAGE_CLICK_THRESHOLD_MS = 1000;
|
|
15
|
+
const FEATURE_FLAGS = exports.FEATURE_FLAGS = {
|
|
16
|
+
MARKS: 'experimental.marks',
|
|
17
|
+
MEASURES: 'experimental.measures',
|
|
18
|
+
RESOURCES: 'experimental.resources'
|
|
19
|
+
};
|
|
@@ -17,14 +17,26 @@ class Instrument extends _instrumentBase.InstrumentBase {
|
|
|
17
17
|
static featureName = _constants.FEATURE_NAME;
|
|
18
18
|
constructor(agentRef, auto = true) {
|
|
19
19
|
super(agentRef, _constants.FEATURE_NAME, auto);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
/** config values that gate whether the generic events aggregator should be imported at all */
|
|
21
|
+
const genericEventSourceConfigs = [agentRef.init.page_action.enabled, agentRef.init.performance.capture_marks, agentRef.init.performance.capture_measures, agentRef.init.user_actions.enabled, agentRef.init.performance.resources.enabled];
|
|
22
|
+
if (_runtime.isBrowserScope) {
|
|
23
|
+
if (agentRef.init.user_actions.enabled) {
|
|
24
|
+
_constants.OBSERVED_EVENTS.forEach(eventType => (0, _eventListenerOpts.windowAddEventListener)(eventType, evt => (0, _handle.handle)('ua', [evt], undefined, this.featureName, this.ee), true));
|
|
25
|
+
_constants.OBSERVED_WINDOW_EVENTS.forEach(eventType => (0, _eventListenerOpts.windowAddEventListener)(eventType, evt => (0, _handle.handle)('ua', [evt], undefined, this.featureName, this.ee))
|
|
26
|
+
// 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.
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
if (agentRef.init.performance.resources.enabled && _runtime.globalScope.PerformanceObserver?.supportedEntryTypes.includes('resource')) {
|
|
30
|
+
const observer = new PerformanceObserver(list => {
|
|
31
|
+
list.getEntries().forEach(entry => {
|
|
32
|
+
(0, _handle.handle)('browserPerformance.resource', [entry], undefined, this.featureName, this.ee);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
observer.observe({
|
|
36
|
+
type: 'resource',
|
|
37
|
+
buffered: true
|
|
38
|
+
});
|
|
39
|
+
}
|
|
28
40
|
}
|
|
29
41
|
|
|
30
42
|
/** If any of the sources are active, import the aggregator. otherwise deregister */
|
|
@@ -112,9 +112,10 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
112
112
|
* @param {boolean=} internal if the error was "caught" and deemed "internal" before reporting to the jserrors feature
|
|
113
113
|
* @param {object=} customAttributes any custom attributes to be included in the error payload
|
|
114
114
|
* @param {boolean=} hasReplay a flag indicating if the error occurred during a replay session
|
|
115
|
+
* @param {string=} swallowReason a string indicating pre-defined reason if swallowing the error. Mainly used by the internal error SMs.
|
|
115
116
|
* @returns
|
|
116
117
|
*/
|
|
117
|
-
storeError(err, time, internal, customAttributes, hasReplay) {
|
|
118
|
+
storeError(err, time, internal, customAttributes, hasReplay, swallowReason) {
|
|
118
119
|
if (!err) return;
|
|
119
120
|
// are we in an interaction
|
|
120
121
|
time = time || (0, _now.now)();
|
|
@@ -132,7 +133,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
132
133
|
const {
|
|
133
134
|
shouldSwallow,
|
|
134
135
|
reason
|
|
135
|
-
} = (0, _internalErrors.evaluateInternalError)(stackInfo, internal);
|
|
136
|
+
} = (0, _internalErrors.evaluateInternalError)(stackInfo, internal, swallowReason);
|
|
136
137
|
if (shouldSwallow) {
|
|
137
138
|
(0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['Internal/Error/' + reason], undefined, _features.FEATURE_NAMES.metrics, this.ee);
|
|
138
139
|
return;
|
|
@@ -11,10 +11,10 @@ const REASON_SECURITY_POLICY = 'Security-Policy';
|
|
|
11
11
|
* @param {Object} stackInfo - The error stack information.
|
|
12
12
|
* @returns {boolean} - Whether the error should be swallowed or not.
|
|
13
13
|
*/
|
|
14
|
-
function evaluateInternalError(stackInfo, internal) {
|
|
14
|
+
function evaluateInternalError(stackInfo, internal, reason) {
|
|
15
15
|
const output = {
|
|
16
16
|
shouldSwallow: internal || false,
|
|
17
|
-
reason: 'Other'
|
|
17
|
+
reason: reason || 'Other'
|
|
18
18
|
};
|
|
19
19
|
const leadingFrame = stackInfo.frames?.[0];
|
|
20
20
|
/** If we cant otherwise determine from the frames and message, the default of internal + reason will be the fallback */
|
|
@@ -26,9 +26,9 @@ class Instrument extends _instrumentBase.InstrumentBase {
|
|
|
26
26
|
// this try-catch can be removed when IE11 is completely unsupported & gone
|
|
27
27
|
this.removeOnAbort = new AbortController();
|
|
28
28
|
} catch (e) {}
|
|
29
|
-
this.ee.on('internal-error', error => {
|
|
29
|
+
this.ee.on('internal-error', (error, reason) => {
|
|
30
30
|
if (!this.abortHandler) return;
|
|
31
|
-
(0, _handle.handle)('ierr', [(0, _castError.castError)(error), (0, _now.now)(), true, {}, this.#replayRunning], undefined, this.featureName, this.ee);
|
|
31
|
+
(0, _handle.handle)('ierr', [(0, _castError.castError)(error), (0, _now.now)(), true, {}, this.#replayRunning, reason], undefined, this.featureName, this.ee);
|
|
32
32
|
});
|
|
33
33
|
this.ee.on(_constants2.SR_EVENT_EMITTER_TYPES.REPLAY_RUNNING, isRunning => {
|
|
34
34
|
this.#replayRunning = isRunning;
|
|
@@ -154,41 +154,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
154
154
|
});
|
|
155
155
|
}
|
|
156
156
|
unload() {
|
|
157
|
-
|
|
158
|
-
if (this.resourcesSent) return;
|
|
159
|
-
this.resourcesSent = true; // make sure this only gets sent once
|
|
160
|
-
|
|
161
|
-
// Capture SMs around network resources using the performance API to assess
|
|
162
|
-
// work to split this out from the ST nodes
|
|
163
|
-
// differentiate between internal+external and ajax+non-ajax
|
|
164
|
-
const ajaxResources = ['beacon', 'fetch', 'xmlhttprequest'];
|
|
165
|
-
const internalUrls = ['nr-data.net', 'newrelic.com', 'nr-local.net', 'localhost'];
|
|
166
|
-
function isInternal(x) {
|
|
167
|
-
return internalUrls.some(y => x.name.indexOf(y) >= 0);
|
|
168
|
-
}
|
|
169
|
-
function isAjax(x) {
|
|
170
|
-
return ajaxResources.includes(x.initiatorType);
|
|
171
|
-
}
|
|
172
|
-
const allResources = performance?.getEntriesByType('resource') || [];
|
|
173
|
-
allResources.forEach(entry => {
|
|
174
|
-
if (isInternal(entry)) {
|
|
175
|
-
if (isAjax(entry)) this.storeSupportabilityMetrics('Generic/Resources/Ajax/Internal');else this.storeSupportabilityMetrics('Generic/Resources/Non-Ajax/Internal');
|
|
176
|
-
} else {
|
|
177
|
-
if (isAjax(entry)) this.storeSupportabilityMetrics('Generic/Resources/Ajax/External');else this.storeSupportabilityMetrics('Generic/Resources/Non-Ajax/External');
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
// Capture SMs for performance markers and measures to assess the usage and possible inclusion of this
|
|
182
|
-
// data in the agent for use in NR
|
|
183
|
-
if (typeof performance !== 'undefined') {
|
|
184
|
-
const markers = performance.getEntriesByType('mark');
|
|
185
|
-
const measures = performance.getEntriesByType('measure');
|
|
186
|
-
if (markers.length) this.storeSupportabilityMetrics('Generic/Performance/Mark/Seen', markers.length);
|
|
187
|
-
if (measures.length) this.storeSupportabilityMetrics('Generic/Performance/Measure/Seen', measures.length);
|
|
188
|
-
}
|
|
189
|
-
} catch (e) {
|
|
190
|
-
// do nothing
|
|
191
|
-
}
|
|
157
|
+
// do nothing for now, marks and measures and resources stats are now being captured by the ge feature
|
|
192
158
|
}
|
|
193
159
|
}
|
|
194
160
|
exports.Aggregate = Aggregate;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FEATURE_FLAGS } from '../../features/generic_events/constants';
|
|
1
2
|
import { LOG_LEVELS } from '../../features/logging/constants';
|
|
2
3
|
import { isValidSelector } from '../dom/query-selector';
|
|
3
4
|
import { DEFAULT_EXPIRES_MS, DEFAULT_INACTIVE_MS } from '../session/constants';
|
|
@@ -7,6 +8,12 @@ import { getModeledObject } from './configurable';
|
|
|
7
8
|
const nrMask = '[data-nr-mask]';
|
|
8
9
|
const model = () => {
|
|
9
10
|
const hiddenState = {
|
|
11
|
+
feature_flags: [],
|
|
12
|
+
experimental: {
|
|
13
|
+
marks: false,
|
|
14
|
+
measures: false,
|
|
15
|
+
resources: false
|
|
16
|
+
},
|
|
10
17
|
mask_selector: '*',
|
|
11
18
|
block_selector: '[data-nr-block]',
|
|
12
19
|
mask_input_options: {
|
|
@@ -44,7 +51,12 @@ const model = () => {
|
|
|
44
51
|
cors_use_tracecontext_headers: undefined,
|
|
45
52
|
allowed_origins: undefined
|
|
46
53
|
},
|
|
47
|
-
feature_flags
|
|
54
|
+
get feature_flags() {
|
|
55
|
+
return hiddenState.feature_flags;
|
|
56
|
+
},
|
|
57
|
+
set feature_flags(val) {
|
|
58
|
+
hiddenState.feature_flags = val;
|
|
59
|
+
},
|
|
48
60
|
generic_events: {
|
|
49
61
|
enabled: true,
|
|
50
62
|
harvestTimeSeconds: 30,
|
|
@@ -82,8 +94,32 @@ const model = () => {
|
|
|
82
94
|
autoStart: true
|
|
83
95
|
},
|
|
84
96
|
performance: {
|
|
85
|
-
capture_marks
|
|
86
|
-
|
|
97
|
+
get capture_marks() {
|
|
98
|
+
return hiddenState.feature_flags.includes(FEATURE_FLAGS.MARKS) || hiddenState.experimental.marks;
|
|
99
|
+
},
|
|
100
|
+
set capture_marks(val) {
|
|
101
|
+
hiddenState.experimental.marks = val;
|
|
102
|
+
},
|
|
103
|
+
get capture_measures() {
|
|
104
|
+
return hiddenState.feature_flags.includes(FEATURE_FLAGS.MEASURES) || hiddenState.experimental.measures;
|
|
105
|
+
},
|
|
106
|
+
set capture_measures(val) {
|
|
107
|
+
hiddenState.experimental.measures = val;
|
|
108
|
+
},
|
|
109
|
+
resources: {
|
|
110
|
+
// whether to run this subfeature or not in the generic_events feature. false by default through experimental phase, but flipped to true once GA'd
|
|
111
|
+
get enabled() {
|
|
112
|
+
return hiddenState.feature_flags.includes(FEATURE_FLAGS.RESOURCES) || hiddenState.experimental.resources;
|
|
113
|
+
},
|
|
114
|
+
set enabled(val) {
|
|
115
|
+
hiddenState.experimental.resources = val;
|
|
116
|
+
},
|
|
117
|
+
asset_types: [],
|
|
118
|
+
// MDN types to collect, empty array will collect all types
|
|
119
|
+
first_party_domains: [],
|
|
120
|
+
// when included, will decorate the resource as first party if matching
|
|
121
|
+
ignore_newrelic: true // ignore capturing internal agent scripts and harvest calls
|
|
122
|
+
}
|
|
87
123
|
},
|
|
88
124
|
privacy: {
|
|
89
125
|
cookies_enabled: true
|
|
@@ -338,7 +338,7 @@ function subscribeToEvents(agentRef, ee, handler, dt) {
|
|
|
338
338
|
if (hasUndefinedHostname(params)) return; // don't bother with XHR of url with no hostname
|
|
339
339
|
|
|
340
340
|
metrics.duration = now() - this.startTime;
|
|
341
|
-
if (!this.
|
|
341
|
+
if (!this.loadCaptureCalled && xhr.readyState === 4) {
|
|
342
342
|
captureXhrData(this, xhr);
|
|
343
343
|
} else if (params.status == null) {
|
|
344
344
|
params.status = 0;
|