@newrelic/browser-agent 1.304.0-rc.3 → 1.304.0-rc.5
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/dist/cjs/common/constants/env.cdn.js +1 -1
- package/dist/cjs/common/constants/env.npm.js +1 -1
- package/dist/cjs/common/util/mfe.js +4 -4
- package/dist/cjs/features/generic_events/aggregate/index.js +1 -1
- package/dist/cjs/features/generic_events/aggregate/user-actions/user-actions-aggregator.js +5 -9
- package/dist/cjs/features/generic_events/instrument/index.js +28 -33
- package/dist/cjs/loaders/api/register.js +1 -1
- package/dist/esm/common/constants/env.cdn.js +1 -1
- package/dist/esm/common/constants/env.npm.js +1 -1
- package/dist/esm/common/util/mfe.js +4 -4
- package/dist/esm/features/generic_events/aggregate/index.js +1 -1
- package/dist/esm/features/generic_events/aggregate/user-actions/user-actions-aggregator.js +5 -9
- package/dist/esm/features/generic_events/instrument/index.js +28 -33
- package/dist/esm/loaders/api/register.js +1 -1
- package/dist/types/common/util/mfe.d.ts +2 -5
- package/dist/types/common/util/mfe.d.ts.map +1 -1
- package/dist/types/features/generic_events/aggregate/user-actions/user-actions-aggregator.d.ts +0 -1
- package/dist/types/features/generic_events/aggregate/user-actions/user-actions-aggregator.d.ts.map +1 -1
- package/dist/types/features/generic_events/instrument/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/common/util/mfe.js +4 -4
- package/src/features/generic_events/aggregate/index.js +1 -1
- package/src/features/generic_events/aggregate/user-actions/user-actions-aggregator.js +5 -9
- package/src/features/generic_events/instrument/index.js +35 -37
- package/src/loaders/api/register.js +1 -1
|
@@ -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.304.0-rc.
|
|
20
|
+
const VERSION = exports.VERSION = "1.304.0-rc.5";
|
|
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.304.0-rc.
|
|
20
|
+
const VERSION = exports.VERSION = "1.304.0-rc.5";
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Exposes the build type of the agent
|
|
@@ -28,7 +28,7 @@ function hasValidValue(val) {
|
|
|
28
28
|
*
|
|
29
29
|
* @param {Object} [target] the registered target
|
|
30
30
|
* @param {AggregateInstance} [aggregateInstance] the aggregate instance calling the method
|
|
31
|
-
* @returns {
|
|
31
|
+
* @returns {Object} returns an empty object if args are not supplied or the aggregate instance is not supporting version 2
|
|
32
32
|
*/
|
|
33
33
|
function getVersion2Attributes(target, aggregateInstance) {
|
|
34
34
|
if (aggregateInstance?.harvestEndpointVersion !== 2) return {};
|
|
@@ -40,9 +40,9 @@ function getVersion2Attributes(target, aggregateInstance) {
|
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
return {
|
|
43
|
-
'
|
|
44
|
-
'
|
|
45
|
-
|
|
43
|
+
'source.id': target.id,
|
|
44
|
+
'source.name': target.name,
|
|
45
|
+
'source.type': target.type,
|
|
46
46
|
'parent.id': target.parent?.id || containerAgentEntityGuid
|
|
47
47
|
};
|
|
48
48
|
}
|
|
@@ -61,7 +61,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
61
61
|
}
|
|
62
62
|
let addUserAction = () => {/** no-op */};
|
|
63
63
|
if (_runtime.isBrowserScope && agentRef.init.user_actions.enabled) {
|
|
64
|
-
this.#userActionAggregator = new _userActionsAggregator.UserActionsAggregator(
|
|
64
|
+
this.#userActionAggregator = new _userActionsAggregator.UserActionsAggregator();
|
|
65
65
|
this.harvestOpts.beforeUnload = () => addUserAction?.(this.#userActionAggregator.aggregationEvent);
|
|
66
66
|
addUserAction = aggregatedUserAction => {
|
|
67
67
|
try {
|
|
@@ -18,14 +18,12 @@ class UserActionsAggregator {
|
|
|
18
18
|
/** @type {AggregatedUserAction=} */
|
|
19
19
|
#aggregationEvent = undefined;
|
|
20
20
|
#aggregationKey = '';
|
|
21
|
-
#ufEnabled = false;
|
|
22
21
|
#deadClickTimer = undefined;
|
|
23
22
|
#domObserver = undefined;
|
|
24
23
|
#errorClickTimer = undefined;
|
|
25
|
-
constructor(
|
|
26
|
-
if (
|
|
24
|
+
constructor() {
|
|
25
|
+
if ((0, _nreum.gosNREUMOriginals)().o.MO) {
|
|
27
26
|
this.#domObserver = new MutationObserver(this.isLiveClick.bind(this));
|
|
28
|
-
this.#ufEnabled = true;
|
|
29
27
|
}
|
|
30
28
|
}
|
|
31
29
|
get aggregationEvent() {
|
|
@@ -56,15 +54,13 @@ class UserActionsAggregator {
|
|
|
56
54
|
} else {
|
|
57
55
|
// return the prev existing one (if there is one)
|
|
58
56
|
const finishedEvent = this.#aggregationEvent;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
this.#errorClickCleanup();
|
|
62
|
-
}
|
|
57
|
+
this.#deadClickCleanup();
|
|
58
|
+
this.#errorClickCleanup();
|
|
63
59
|
|
|
64
60
|
// then start new event aggregation
|
|
65
61
|
this.#aggregationKey = aggregationKey;
|
|
66
62
|
this.#aggregationEvent = new _aggregatedUserAction.AggregatedUserAction(evt, selectorInfo);
|
|
67
|
-
if (
|
|
63
|
+
if (evt.type === 'click' && (selectorInfo.hasButton || selectorInfo.hasLink)) {
|
|
68
64
|
this.#deadClickSetup(this.#aggregationEvent);
|
|
69
65
|
this.#errorClickSetup();
|
|
70
66
|
}
|
|
@@ -31,7 +31,6 @@ 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 ufEnabled = agentRef.init.feature_flags.includes('user_frustrations');
|
|
35
34
|
|
|
36
35
|
/** config values that gate whether the generic events aggregator should be imported at all */
|
|
37
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];
|
|
@@ -43,13 +42,11 @@ class Instrument extends _instrumentBase.InstrumentBase {
|
|
|
43
42
|
(0, _register.setupRegisterAPI)(agentRef);
|
|
44
43
|
(0, _measure.setupMeasureAPI)(agentRef);
|
|
45
44
|
let historyEE, websocketsEE;
|
|
46
|
-
if (
|
|
45
|
+
if (websocketsEnabled) websocketsEE = (0, _wrapWebsocket.wrapWebSocket)(this.ee);
|
|
46
|
+
if (_runtime.isBrowserScope) {
|
|
47
47
|
(0, _wrapFetch.wrapFetch)(this.ee);
|
|
48
48
|
(0, _wrapXhr.wrapXhr)(this.ee);
|
|
49
49
|
historyEE = (0, _wrapHistory.wrapHistory)(this.ee);
|
|
50
|
-
}
|
|
51
|
-
if (websocketsEnabled) websocketsEE = (0, _wrapWebsocket.wrapWebSocket)(this.ee);
|
|
52
|
-
if (_runtime.isBrowserScope) {
|
|
53
50
|
if (agentRef.init.user_actions.enabled) {
|
|
54
51
|
_constants.OBSERVED_EVENTS.forEach(eventType => (0, _eventListenerOpts.windowAddEventListener)(eventType, evt => (0, _handle.handle)('ua', [evt], undefined, this.featureName, this.ee), true));
|
|
55
52
|
_constants.OBSERVED_WINDOW_EVENTS.forEach(eventType => {
|
|
@@ -62,36 +59,34 @@ class Instrument extends _instrumentBase.InstrumentBase {
|
|
|
62
59
|
}
|
|
63
60
|
// 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.
|
|
64
61
|
);
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
xhr.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
this.ee.on('fetch-start', fetchArguments => {
|
|
80
|
-
if (fetchArguments.length >= 1 && !isInternalTraffic((0, _extractUrl.extractUrl)(fetchArguments[0]))) {
|
|
81
|
-
(0, _handle.handle)('uaXhr', [], undefined, _features.FEATURE_NAMES.genericEvents, this.ee);
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
function isInternalTraffic(url) {
|
|
85
|
-
const parsedUrl = (0, _parseUrl.parseUrl)(url);
|
|
86
|
-
return agentRef.beacons.includes(parsedUrl.hostname + ':' + parsedUrl.port);
|
|
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
|
+
});
|
|
87
73
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
function navigationChange() {
|
|
93
|
-
historyEE.emit('navChange');
|
|
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);
|
|
94
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');
|
|
95
90
|
}
|
|
96
91
|
}
|
|
97
92
|
if (agentRef.init.performance.resources.enabled && _runtime.globalScope.PerformanceObserver?.supportedEntryTypes.includes('resource')) {
|
|
@@ -50,7 +50,7 @@ function register(agentRef, target, parent) {
|
|
|
50
50
|
const attrs = {};
|
|
51
51
|
(0, _console.warn)(54, 'newrelic.register');
|
|
52
52
|
target ||= {};
|
|
53
|
-
target.
|
|
53
|
+
target.type = 'MFE';
|
|
54
54
|
target.licenseKey ||= agentRef.info.licenseKey; // will inherit the license key from the container agent if not provided for brevity. A future state may dictate that we need different license keys to do different things.
|
|
55
55
|
target.blocked = false;
|
|
56
56
|
target.parent = parent || {};
|
|
@@ -20,7 +20,7 @@ export function hasValidValue(val) {
|
|
|
20
20
|
*
|
|
21
21
|
* @param {Object} [target] the registered target
|
|
22
22
|
* @param {AggregateInstance} [aggregateInstance] the aggregate instance calling the method
|
|
23
|
-
* @returns {
|
|
23
|
+
* @returns {Object} returns an empty object if args are not supplied or the aggregate instance is not supporting version 2
|
|
24
24
|
*/
|
|
25
25
|
export function getVersion2Attributes(target, aggregateInstance) {
|
|
26
26
|
if (aggregateInstance?.harvestEndpointVersion !== 2) return {};
|
|
@@ -32,9 +32,9 @@ export function getVersion2Attributes(target, aggregateInstance) {
|
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
return {
|
|
35
|
-
'
|
|
36
|
-
'
|
|
37
|
-
|
|
35
|
+
'source.id': target.id,
|
|
36
|
+
'source.name': target.name,
|
|
37
|
+
'source.type': target.type,
|
|
38
38
|
'parent.id': target.parent?.id || containerAgentEntityGuid
|
|
39
39
|
};
|
|
40
40
|
}
|
|
@@ -54,7 +54,7 @@ export class Aggregate extends AggregateBase {
|
|
|
54
54
|
}
|
|
55
55
|
let addUserAction = () => {/** no-op */};
|
|
56
56
|
if (isBrowserScope && agentRef.init.user_actions.enabled) {
|
|
57
|
-
this.#userActionAggregator = new UserActionsAggregator(
|
|
57
|
+
this.#userActionAggregator = new UserActionsAggregator();
|
|
58
58
|
this.harvestOpts.beforeUnload = () => addUserAction?.(this.#userActionAggregator.aggregationEvent);
|
|
59
59
|
addUserAction = aggregatedUserAction => {
|
|
60
60
|
try {
|
|
@@ -11,14 +11,12 @@ export class UserActionsAggregator {
|
|
|
11
11
|
/** @type {AggregatedUserAction=} */
|
|
12
12
|
#aggregationEvent = undefined;
|
|
13
13
|
#aggregationKey = '';
|
|
14
|
-
#ufEnabled = false;
|
|
15
14
|
#deadClickTimer = undefined;
|
|
16
15
|
#domObserver = undefined;
|
|
17
16
|
#errorClickTimer = undefined;
|
|
18
|
-
constructor(
|
|
19
|
-
if (
|
|
17
|
+
constructor() {
|
|
18
|
+
if (gosNREUMOriginals().o.MO) {
|
|
20
19
|
this.#domObserver = new MutationObserver(this.isLiveClick.bind(this));
|
|
21
|
-
this.#ufEnabled = true;
|
|
22
20
|
}
|
|
23
21
|
}
|
|
24
22
|
get aggregationEvent() {
|
|
@@ -49,15 +47,13 @@ export class UserActionsAggregator {
|
|
|
49
47
|
} else {
|
|
50
48
|
// return the prev existing one (if there is one)
|
|
51
49
|
const finishedEvent = this.#aggregationEvent;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
this.#errorClickCleanup();
|
|
55
|
-
}
|
|
50
|
+
this.#deadClickCleanup();
|
|
51
|
+
this.#errorClickCleanup();
|
|
56
52
|
|
|
57
53
|
// then start new event aggregation
|
|
58
54
|
this.#aggregationKey = aggregationKey;
|
|
59
55
|
this.#aggregationEvent = new AggregatedUserAction(evt, selectorInfo);
|
|
60
|
-
if (
|
|
56
|
+
if (evt.type === 'click' && (selectorInfo.hasButton || selectorInfo.hasLink)) {
|
|
61
57
|
this.#deadClickSetup(this.#aggregationEvent);
|
|
62
58
|
this.#errorClickSetup();
|
|
63
59
|
}
|
|
@@ -26,7 +26,6 @@ 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 ufEnabled = agentRef.init.feature_flags.includes('user_frustrations');
|
|
30
29
|
|
|
31
30
|
/** config values that gate whether the generic events aggregator should be imported at all */
|
|
32
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];
|
|
@@ -38,13 +37,11 @@ export class Instrument extends InstrumentBase {
|
|
|
38
37
|
setupRegisterAPI(agentRef);
|
|
39
38
|
setupMeasureAPI(agentRef);
|
|
40
39
|
let historyEE, websocketsEE;
|
|
41
|
-
if (
|
|
40
|
+
if (websocketsEnabled) websocketsEE = wrapWebSocket(this.ee);
|
|
41
|
+
if (isBrowserScope) {
|
|
42
42
|
wrapFetch(this.ee);
|
|
43
43
|
wrapXhr(this.ee);
|
|
44
44
|
historyEE = wrapHistory(this.ee);
|
|
45
|
-
}
|
|
46
|
-
if (websocketsEnabled) websocketsEE = wrapWebSocket(this.ee);
|
|
47
|
-
if (isBrowserScope) {
|
|
48
45
|
if (agentRef.init.user_actions.enabled) {
|
|
49
46
|
OBSERVED_EVENTS.forEach(eventType => windowAddEventListener(eventType, evt => handle('ua', [evt], undefined, this.featureName, this.ee), true));
|
|
50
47
|
OBSERVED_WINDOW_EVENTS.forEach(eventType => {
|
|
@@ -57,36 +54,34 @@ export class Instrument extends InstrumentBase {
|
|
|
57
54
|
}
|
|
58
55
|
// 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.
|
|
59
56
|
);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
xhr.
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
this.ee.on('fetch-start', fetchArguments => {
|
|
75
|
-
if (fetchArguments.length >= 1 && !isInternalTraffic(extractUrl(fetchArguments[0]))) {
|
|
76
|
-
handle('uaXhr', [], undefined, FEATURE_NAMES.genericEvents, this.ee);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
function isInternalTraffic(url) {
|
|
80
|
-
const parsedUrl = parseUrl(url);
|
|
81
|
-
return agentRef.beacons.includes(parsedUrl.hostname + ':' + parsedUrl.port);
|
|
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
|
+
});
|
|
82
68
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
function navigationChange() {
|
|
88
|
-
historyEE.emit('navChange');
|
|
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);
|
|
89
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');
|
|
90
85
|
}
|
|
91
86
|
}
|
|
92
87
|
if (agentRef.init.performance.resources.enabled && globalScope.PerformanceObserver?.supportedEntryTypes.includes('resource')) {
|
|
@@ -44,7 +44,7 @@ function register(agentRef, target, parent) {
|
|
|
44
44
|
const attrs = {};
|
|
45
45
|
warn(54, 'newrelic.register');
|
|
46
46
|
target ||= {};
|
|
47
|
-
target.
|
|
47
|
+
target.type = 'MFE';
|
|
48
48
|
target.licenseKey ||= agentRef.info.licenseKey; // will inherit the license key from the container agent if not provided for brevity. A future state may dictate that we need different license keys to do different things.
|
|
49
49
|
target.blocked = false;
|
|
50
50
|
target.parent = parent || {};
|
|
@@ -14,10 +14,7 @@ export function hasValidValue(val: any): boolean;
|
|
|
14
14
|
*
|
|
15
15
|
* @param {Object} [target] the registered target
|
|
16
16
|
* @param {AggregateInstance} [aggregateInstance] the aggregate instance calling the method
|
|
17
|
-
* @returns {
|
|
17
|
+
* @returns {Object} returns an empty object if args are not supplied or the aggregate instance is not supporting version 2
|
|
18
18
|
*/
|
|
19
|
-
export function getVersion2Attributes(target?: Object, aggregateInstance?: AggregateInstance):
|
|
20
|
-
"mfe.id": any;
|
|
21
|
-
"mfe.name": string;
|
|
22
|
-
} | {};
|
|
19
|
+
export function getVersion2Attributes(target?: Object, aggregateInstance?: AggregateInstance): Object;
|
|
23
20
|
//# sourceMappingURL=mfe.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mfe.d.ts","sourceRoot":"","sources":["../../../../src/common/util/mfe.js"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,0CAHW,MAAM,GACJ,OAAO,CAInB;AAED,iDAEC;AAED;;;;;;;GAOG;AACH,+CAJW,MAAM,sBACN,iBAAiB,GACf
|
|
1
|
+
{"version":3,"file":"mfe.d.ts","sourceRoot":"","sources":["../../../../src/common/util/mfe.js"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,0CAHW,MAAM,GACJ,OAAO,CAInB;AAED,iDAEC;AAED;;;;;;;GAOG;AACH,+CAJW,MAAM,sBACN,iBAAiB,GACf,MAAM,CAiBlB"}
|
package/dist/types/features/generic_events/aggregate/user-actions/user-actions-aggregator.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export class UserActionsAggregator {
|
|
2
|
-
constructor(userFrustrationsEnabled: any);
|
|
3
2
|
get aggregationEvent(): AggregatedUserAction | undefined;
|
|
4
3
|
/**
|
|
5
4
|
* Process the event and determine if a new aggregation set should be made or if it should increment the current aggregation
|
package/dist/types/features/generic_events/aggregate/user-actions/user-actions-aggregator.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-actions-aggregator.d.ts","sourceRoot":"","sources":["../../../../../../src/features/generic_events/aggregate/user-actions/user-actions-aggregator.js"],"names":[],"mappings":"AAUA;
|
|
1
|
+
{"version":3,"file":"user-actions-aggregator.d.ts","sourceRoot":"","sources":["../../../../../../src/features/generic_events/aggregate/user-actions/user-actions-aggregator.js"],"names":[],"mappings":"AAUA;IAcE,yDAQC;IAED;;;;OAIG;IACH,aAHW,KAAK,sBACH,oBAAoB,GAAC,SAAS,CA2B1C;IAED,yBAKC;IA0CD,oBAEC;;CACF;qCA9GoC,0BAA0B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/generic_events/instrument/index.js"],"names":[],"mappings":"AAwBA;IACE,2BAAiC;IACjC,
|
|
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"}
|
package/package.json
CHANGED
package/src/common/util/mfe.js
CHANGED
|
@@ -21,7 +21,7 @@ export function hasValidValue (val) {
|
|
|
21
21
|
*
|
|
22
22
|
* @param {Object} [target] the registered target
|
|
23
23
|
* @param {AggregateInstance} [aggregateInstance] the aggregate instance calling the method
|
|
24
|
-
* @returns {
|
|
24
|
+
* @returns {Object} returns an empty object if args are not supplied or the aggregate instance is not supporting version 2
|
|
25
25
|
*/
|
|
26
26
|
export function getVersion2Attributes (target, aggregateInstance) {
|
|
27
27
|
if (aggregateInstance?.harvestEndpointVersion !== 2) return {}
|
|
@@ -33,9 +33,9 @@ export function getVersion2Attributes (target, aggregateInstance) {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
return {
|
|
36
|
-
'
|
|
37
|
-
'
|
|
38
|
-
|
|
36
|
+
'source.id': target.id,
|
|
37
|
+
'source.name': target.name,
|
|
38
|
+
'source.type': target.type,
|
|
39
39
|
'parent.id': target.parent?.id || containerAgentEntityGuid
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -61,7 +61,7 @@ export class Aggregate extends AggregateBase {
|
|
|
61
61
|
|
|
62
62
|
let addUserAction = () => { /** no-op */ }
|
|
63
63
|
if (isBrowserScope && agentRef.init.user_actions.enabled) {
|
|
64
|
-
this.#userActionAggregator = new UserActionsAggregator(
|
|
64
|
+
this.#userActionAggregator = new UserActionsAggregator()
|
|
65
65
|
this.harvestOpts.beforeUnload = () => addUserAction?.(this.#userActionAggregator.aggregationEvent)
|
|
66
66
|
|
|
67
67
|
addUserAction = (aggregatedUserAction) => {
|
|
@@ -12,15 +12,13 @@ export class UserActionsAggregator {
|
|
|
12
12
|
/** @type {AggregatedUserAction=} */
|
|
13
13
|
#aggregationEvent = undefined
|
|
14
14
|
#aggregationKey = ''
|
|
15
|
-
#ufEnabled = false
|
|
16
15
|
#deadClickTimer = undefined
|
|
17
16
|
#domObserver = undefined
|
|
18
17
|
#errorClickTimer = undefined
|
|
19
18
|
|
|
20
|
-
constructor (
|
|
21
|
-
if (
|
|
19
|
+
constructor () {
|
|
20
|
+
if (gosNREUMOriginals().o.MO) {
|
|
22
21
|
this.#domObserver = new MutationObserver(this.isLiveClick.bind(this))
|
|
23
|
-
this.#ufEnabled = true
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
24
|
|
|
@@ -52,15 +50,13 @@ export class UserActionsAggregator {
|
|
|
52
50
|
} else {
|
|
53
51
|
// return the prev existing one (if there is one)
|
|
54
52
|
const finishedEvent = this.#aggregationEvent
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
this.#errorClickCleanup()
|
|
58
|
-
}
|
|
53
|
+
this.#deadClickCleanup()
|
|
54
|
+
this.#errorClickCleanup()
|
|
59
55
|
|
|
60
56
|
// then start new event aggregation
|
|
61
57
|
this.#aggregationKey = aggregationKey
|
|
62
58
|
this.#aggregationEvent = new AggregatedUserAction(evt, selectorInfo)
|
|
63
|
-
if (
|
|
59
|
+
if (evt.type === 'click' && (selectorInfo.hasButton || selectorInfo.hasLink)) {
|
|
64
60
|
this.#deadClickSetup(this.#aggregationEvent)
|
|
65
61
|
this.#errorClickSetup()
|
|
66
62
|
}
|
|
@@ -27,7 +27,6 @@ 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 ufEnabled = agentRef.init.feature_flags.includes('user_frustrations')
|
|
31
30
|
|
|
32
31
|
/** config values that gate whether the generic events aggregator should be imported at all */
|
|
33
32
|
const genericEventSourceConfigs = [
|
|
@@ -47,14 +46,12 @@ export class Instrument extends InstrumentBase {
|
|
|
47
46
|
setupMeasureAPI(agentRef)
|
|
48
47
|
|
|
49
48
|
let historyEE, websocketsEE
|
|
50
|
-
if (
|
|
49
|
+
if (websocketsEnabled) websocketsEE = wrapWebSocket(this.ee)
|
|
50
|
+
if (isBrowserScope) {
|
|
51
51
|
wrapFetch(this.ee)
|
|
52
52
|
wrapXhr(this.ee)
|
|
53
53
|
historyEE = wrapHistory(this.ee)
|
|
54
|
-
}
|
|
55
|
-
if (websocketsEnabled) websocketsEE = wrapWebSocket(this.ee)
|
|
56
54
|
|
|
57
|
-
if (isBrowserScope) {
|
|
58
55
|
if (agentRef.init.user_actions.enabled) {
|
|
59
56
|
OBSERVED_EVENTS.forEach(eventType =>
|
|
60
57
|
windowAddEventListener(eventType, (evt) => handle('ua', [evt], undefined, this.featureName, this.ee), true)
|
|
@@ -63,42 +60,40 @@ export class Instrument extends InstrumentBase {
|
|
|
63
60
|
const debounceHandler = debounce((evt) => { handle('ua', [evt], undefined, this.featureName, this.ee) }, 500, { leading: true })
|
|
64
61
|
windowAddEventListener(eventType, debounceHandler)
|
|
65
62
|
}
|
|
66
|
-
|
|
63
|
+
// 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.
|
|
67
64
|
)
|
|
68
65
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
xhr.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
})
|
|
81
|
-
}
|
|
82
|
-
})
|
|
83
|
-
this.ee.on('fetch-start', (fetchArguments) => {
|
|
84
|
-
if (fetchArguments.length >= 1 && !isInternalTraffic(extractUrl(fetchArguments[0]))) {
|
|
85
|
-
handle('uaXhr', [], undefined, FEATURE_NAMES.genericEvents, this.ee)
|
|
86
|
-
}
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
function isInternalTraffic (url) {
|
|
90
|
-
const parsedUrl = parseUrl(url)
|
|
91
|
-
return agentRef.beacons.includes(parsedUrl.hostname + ':' + parsedUrl.port)
|
|
66
|
+
globalScope.addEventListener('error', () => {
|
|
67
|
+
handle('uaErr', [], undefined, FEATURE_NAMES.genericEvents, this.ee)
|
|
68
|
+
}, eventListenerOpts(false, this.removeOnAbort?.signal))
|
|
69
|
+
|
|
70
|
+
this.ee.on('open-xhr-start', (args, xhr) => {
|
|
71
|
+
if (!isInternalTraffic(args[1])) {
|
|
72
|
+
xhr.addEventListener('readystatechange', () => {
|
|
73
|
+
if (xhr.readyState === 2) { // HEADERS_RECEIVED
|
|
74
|
+
handle('uaXhr', [], undefined, FEATURE_NAMES.genericEvents, this.ee)
|
|
75
|
+
}
|
|
76
|
+
})
|
|
92
77
|
}
|
|
78
|
+
})
|
|
79
|
+
this.ee.on('fetch-start', (fetchArguments) => {
|
|
80
|
+
if (fetchArguments.length >= 1 && !isInternalTraffic(extractUrl(fetchArguments[0]))) {
|
|
81
|
+
handle('uaXhr', [], undefined, FEATURE_NAMES.genericEvents, this.ee)
|
|
82
|
+
}
|
|
83
|
+
})
|
|
93
84
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
85
|
+
function isInternalTraffic (url) {
|
|
86
|
+
const parsedUrl = parseUrl(url)
|
|
87
|
+
return agentRef.beacons.includes(parsedUrl.hostname + ':' + parsedUrl.port)
|
|
88
|
+
}
|
|
98
89
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
90
|
+
historyEE.on('pushState-end', navigationChange)
|
|
91
|
+
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))
|
|
94
|
+
|
|
95
|
+
function navigationChange () {
|
|
96
|
+
historyEE.emit('navChange')
|
|
102
97
|
}
|
|
103
98
|
}
|
|
104
99
|
|
|
@@ -108,7 +103,10 @@ export class Instrument extends InstrumentBase {
|
|
|
108
103
|
handle('browserPerformance.resource', [entry], undefined, this.featureName, this.ee)
|
|
109
104
|
})
|
|
110
105
|
})
|
|
111
|
-
observer.observe({
|
|
106
|
+
observer.observe({
|
|
107
|
+
type: 'resource',
|
|
108
|
+
buffered: true
|
|
109
|
+
})
|
|
112
110
|
}
|
|
113
111
|
}
|
|
114
112
|
if (websocketsEnabled) { // this can apply outside browser scope such as in worker
|
|
@@ -45,7 +45,7 @@ function register (agentRef, target, parent) {
|
|
|
45
45
|
warn(54, 'newrelic.register')
|
|
46
46
|
|
|
47
47
|
target ||= {}
|
|
48
|
-
target.
|
|
48
|
+
target.type = 'MFE'
|
|
49
49
|
target.licenseKey ||= agentRef.info.licenseKey // will inherit the license key from the container agent if not provided for brevity. A future state may dictate that we need different license keys to do different things.
|
|
50
50
|
target.blocked = false
|
|
51
51
|
target.parent = parent || {}
|