@newrelic/browser-agent 1.252.1 → 1.254.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 +25 -0
- package/README.md +2 -2
- package/dist/cjs/cdn/experimental.js +6 -2
- package/dist/cjs/cdn/polyfills.js +2 -1
- package/dist/cjs/cdn/spa.js +5 -3
- package/dist/cjs/common/aggregate/aggregator.js +1 -8
- package/dist/cjs/common/config/state/init.js +7 -0
- package/dist/cjs/common/config/state/runtime.js +4 -1
- package/dist/cjs/common/constants/env.cdn.js +1 -1
- package/dist/cjs/common/constants/env.npm.js +1 -1
- package/dist/cjs/common/drain/drain.js +41 -27
- package/dist/cjs/common/event-emitter/contextual-ee.js +17 -12
- package/dist/cjs/common/harvest/harvest.js +5 -1
- package/dist/cjs/common/session/constants.js +2 -1
- package/dist/cjs/common/timing/nav-timing.js +8 -3
- package/dist/cjs/common/timing/now.js +1 -1
- package/dist/cjs/common/timing/time-keeper.js +94 -0
- package/dist/cjs/common/util/feature-flags.js +14 -31
- package/dist/cjs/common/wrap/index.js +0 -7
- package/dist/cjs/features/ajax/aggregate/index.js +41 -29
- package/dist/cjs/features/jserrors/aggregate/index.js +96 -84
- package/dist/cjs/features/metrics/aggregate/index.js +25 -24
- package/dist/cjs/features/page_action/aggregate/index.js +6 -4
- package/dist/cjs/features/page_view_event/aggregate/index.js +23 -3
- package/dist/cjs/features/page_view_event/aggregate/initialized-features.js +1 -0
- package/dist/cjs/features/page_view_timing/aggregate/index.js +15 -16
- package/dist/cjs/features/session_replay/aggregate/index.js +102 -92
- package/dist/cjs/features/session_replay/constants.js +5 -1
- package/dist/cjs/features/session_replay/instrument/index.js +24 -8
- package/dist/cjs/features/session_replay/shared/utils.js +26 -0
- package/dist/cjs/features/session_trace/aggregate/index.js +11 -8
- package/dist/cjs/features/soft_navigations/aggregate/ajax-node.js +50 -0
- package/dist/cjs/features/soft_navigations/aggregate/bel-node.js +29 -0
- package/dist/cjs/features/soft_navigations/aggregate/index.js +268 -0
- package/dist/cjs/features/soft_navigations/aggregate/initial-page-load-interaction.js +62 -0
- package/dist/cjs/features/soft_navigations/aggregate/interaction.js +146 -0
- package/dist/cjs/features/soft_navigations/constants.js +31 -0
- package/dist/cjs/features/soft_navigations/index.js +12 -0
- package/dist/cjs/features/soft_navigations/instrument/index.js +79 -0
- package/dist/cjs/features/spa/aggregate/index.js +23 -18
- package/dist/cjs/features/utils/agent-session.js +2 -1
- package/dist/cjs/features/utils/aggregate-base.js +18 -5
- package/dist/cjs/features/utils/feature-base.js +2 -0
- package/dist/cjs/features/utils/instrument-base.js +7 -9
- package/dist/cjs/features/utils/lazy-feature-loader.js +2 -0
- package/dist/cjs/loaders/agent-base.js +13 -3
- package/dist/cjs/loaders/agent.js +19 -22
- package/dist/cjs/loaders/api/api-methods.js +2 -1
- package/dist/cjs/loaders/api/api.js +15 -12
- package/dist/cjs/loaders/configure/configure.js +5 -2
- package/dist/cjs/loaders/configure/nonce.cdn.js +13 -0
- package/dist/cjs/loaders/configure/nonce.js +2 -13
- package/dist/cjs/loaders/configure/public-path.cdn.js +16 -0
- package/dist/cjs/loaders/configure/public-path.js +2 -8
- package/dist/cjs/loaders/features/enabled-features.js +1 -1
- package/dist/cjs/loaders/features/features.js +3 -1
- package/dist/esm/cdn/experimental.js +5 -2
- package/dist/esm/cdn/polyfills.js +2 -1
- package/dist/esm/cdn/spa.js +3 -1
- package/dist/esm/common/aggregate/aggregator.js +1 -8
- package/dist/esm/common/config/state/init.js +7 -0
- package/dist/esm/common/config/state/runtime.js +4 -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/drain/drain.js +40 -27
- package/dist/esm/common/event-emitter/contextual-ee.js +17 -12
- package/dist/esm/common/harvest/harvest.js +5 -1
- package/dist/esm/common/session/constants.js +1 -0
- package/dist/esm/common/timing/nav-timing.js +8 -3
- package/dist/esm/common/timing/now.js +1 -1
- package/dist/esm/common/timing/time-keeper.js +88 -0
- package/dist/esm/common/util/feature-flags.js +14 -31
- package/dist/esm/common/wrap/index.js +1 -2
- package/dist/esm/features/ajax/aggregate/index.js +43 -31
- package/dist/esm/features/jserrors/aggregate/index.js +96 -84
- package/dist/esm/features/metrics/aggregate/index.js +25 -24
- package/dist/esm/features/page_action/aggregate/index.js +6 -4
- package/dist/esm/features/page_view_event/aggregate/index.js +23 -3
- package/dist/esm/features/page_view_event/aggregate/initialized-features.js +1 -0
- package/dist/esm/features/page_view_timing/aggregate/index.js +15 -16
- package/dist/esm/features/session_replay/aggregate/index.js +103 -93
- package/dist/esm/features/session_replay/constants.js +4 -0
- package/dist/esm/features/session_replay/instrument/index.js +25 -9
- package/dist/esm/features/session_replay/shared/utils.js +17 -0
- package/dist/esm/features/session_trace/aggregate/index.js +11 -8
- package/dist/esm/features/soft_navigations/aggregate/ajax-node.js +43 -0
- package/dist/esm/features/soft_navigations/aggregate/bel-node.js +22 -0
- package/dist/esm/features/soft_navigations/aggregate/index.js +261 -0
- package/dist/esm/features/soft_navigations/aggregate/initial-page-load-interaction.js +55 -0
- package/dist/esm/features/soft_navigations/aggregate/interaction.js +140 -0
- package/dist/esm/features/soft_navigations/constants.js +25 -0
- package/dist/esm/features/soft_navigations/index.js +1 -0
- package/dist/esm/features/soft_navigations/instrument/index.js +73 -0
- package/dist/esm/features/spa/aggregate/index.js +23 -18
- package/dist/esm/features/utils/agent-session.js +2 -1
- package/dist/esm/features/utils/aggregate-base.js +18 -5
- package/dist/esm/features/utils/feature-base.js +2 -0
- package/dist/esm/features/utils/instrument-base.js +8 -10
- package/dist/esm/features/utils/lazy-feature-loader.js +2 -0
- package/dist/esm/loaders/agent-base.js +13 -3
- package/dist/esm/loaders/agent.js +19 -22
- package/dist/esm/loaders/api/api-methods.js +2 -1
- package/dist/esm/loaders/api/api.js +15 -12
- package/dist/esm/loaders/configure/configure.js +5 -2
- package/dist/esm/loaders/configure/nonce.cdn.js +11 -0
- package/dist/esm/loaders/configure/nonce.js +1 -11
- package/dist/esm/loaders/configure/public-path.cdn.js +9 -0
- package/dist/esm/loaders/configure/public-path.js +2 -8
- package/dist/esm/loaders/features/enabled-features.js +1 -1
- package/dist/esm/loaders/features/features.js +3 -1
- package/dist/types/common/aggregate/aggregator.d.ts.map +1 -1
- package/dist/types/common/config/state/init.d.ts.map +1 -1
- package/dist/types/common/config/state/runtime.d.ts.map +1 -1
- package/dist/types/common/drain/drain.d.ts +6 -0
- package/dist/types/common/drain/drain.d.ts.map +1 -1
- package/dist/types/common/event-emitter/contextual-ee.d.ts +2 -1
- package/dist/types/common/event-emitter/contextual-ee.d.ts.map +1 -1
- package/dist/types/common/harvest/harvest.d.ts.map +1 -1
- package/dist/types/common/session/constants.d.ts +1 -0
- package/dist/types/common/session/constants.d.ts.map +1 -1
- package/dist/types/common/timing/nav-timing.d.ts.map +1 -1
- package/dist/types/common/timing/time-keeper.d.ts +31 -0
- package/dist/types/common/timing/time-keeper.d.ts.map +1 -0
- package/dist/types/common/util/feature-flags.d.ts +11 -2
- package/dist/types/common/util/feature-flags.d.ts.map +1 -1
- package/dist/types/common/wrap/index.d.ts +1 -2
- package/dist/types/common/wrap/index.d.ts.map +1 -1
- package/dist/types/features/ajax/aggregate/index.d.ts +5 -5
- package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/aggregate/index.d.ts +4 -3
- package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/page_action/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/page_view_event/aggregate/initialized-features.d.ts.map +1 -1
- package/dist/types/features/page_view_timing/aggregate/index.d.ts +0 -2
- package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/aggregate/index.d.ts +1 -1
- package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/constants.d.ts +4 -0
- package/dist/types/features/session_replay/constants.d.ts.map +1 -1
- package/dist/types/features/session_replay/instrument/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/shared/utils.d.ts +4 -0
- package/dist/types/features/session_replay/shared/utils.d.ts.map +1 -0
- package/dist/types/features/soft_navigations/aggregate/ajax-node.d.ts +19 -0
- package/dist/types/features/soft_navigations/aggregate/ajax-node.d.ts.map +1 -0
- package/dist/types/features/soft_navigations/aggregate/bel-node.d.ts +16 -0
- package/dist/types/features/soft_navigations/aggregate/bel-node.d.ts.map +1 -0
- package/dist/types/features/soft_navigations/aggregate/index.d.ts +34 -0
- package/dist/types/features/soft_navigations/aggregate/index.d.ts.map +1 -0
- package/dist/types/features/soft_navigations/aggregate/initial-page-load-interaction.d.ts +12 -0
- package/dist/types/features/soft_navigations/aggregate/initial-page-load-interaction.d.ts.map +1 -0
- package/dist/types/features/soft_navigations/aggregate/interaction.d.ts +50 -0
- package/dist/types/features/soft_navigations/aggregate/interaction.d.ts.map +1 -0
- package/dist/types/features/soft_navigations/constants.d.ts +20 -0
- package/dist/types/features/soft_navigations/constants.d.ts.map +1 -0
- package/dist/types/features/soft_navigations/index.d.ts +2 -0
- package/dist/types/features/soft_navigations/index.d.ts.map +1 -0
- package/dist/types/features/soft_navigations/instrument/index.d.ts +7 -0
- package/dist/types/features/soft_navigations/instrument/index.d.ts.map +1 -0
- package/dist/types/features/spa/aggregate/index.d.ts +2 -0
- package/dist/types/features/spa/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/utils/agent-session.d.ts.map +1 -1
- package/dist/types/features/utils/aggregate-base.d.ts +2 -2
- package/dist/types/features/utils/aggregate-base.d.ts.map +1 -1
- package/dist/types/features/utils/feature-base.d.ts +1 -0
- package/dist/types/features/utils/feature-base.d.ts.map +1 -1
- package/dist/types/features/utils/instrument-base.d.ts +1 -7
- package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
- package/dist/types/features/utils/lazy-feature-loader.d.ts.map +1 -1
- package/dist/types/loaders/agent-base.d.ts +5 -1
- package/dist/types/loaders/agent-base.d.ts.map +1 -1
- package/dist/types/loaders/agent.d.ts +2 -2
- package/dist/types/loaders/agent.d.ts.map +1 -1
- package/dist/types/loaders/api/api-methods.d.ts.map +1 -1
- package/dist/types/loaders/api/api.d.ts +3 -5
- package/dist/types/loaders/api/api.d.ts.map +1 -1
- package/dist/types/loaders/configure/configure.d.ts.map +1 -1
- package/dist/types/loaders/configure/public-path.d.ts +1 -1
- package/dist/types/loaders/configure/public-path.d.ts.map +1 -1
- package/dist/types/loaders/features/features.d.ts +1 -0
- package/dist/types/loaders/features/features.d.ts.map +1 -1
- package/dist/types/loaders/micro-agent.d.ts +0 -1
- package/dist/types/loaders/micro-agent.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/cdn/experimental.js +4 -2
- package/src/cdn/polyfills.js +1 -0
- package/src/cdn/spa.js +3 -1
- package/src/common/aggregate/aggregator.js +2 -11
- package/src/common/config/state/init.js +3 -1
- package/src/common/config/state/runtime.js +4 -1
- package/src/common/drain/drain.js +41 -28
- package/src/common/event-emitter/contextual-ee.js +21 -13
- package/src/common/harvest/harvest.js +4 -1
- package/src/common/session/constants.js +1 -0
- package/src/common/timing/nav-timing.js +7 -3
- package/src/common/timing/now.js +1 -1
- package/src/common/timing/time-keeper.js +96 -0
- package/src/common/util/feature-flags.js +13 -31
- package/src/common/wrap/index.js +1 -2
- package/src/features/ajax/aggregate/index.js +43 -33
- package/src/features/jserrors/aggregate/index.js +82 -87
- package/src/features/metrics/aggregate/index.js +18 -17
- package/src/features/page_action/aggregate/index.js +6 -5
- package/src/features/page_view_event/aggregate/index.js +19 -3
- package/src/features/page_view_event/aggregate/initialized-features.js +1 -0
- package/src/features/page_view_timing/aggregate/index.js +15 -15
- package/src/features/session_replay/aggregate/index.js +95 -92
- package/src/features/session_replay/constants.js +5 -0
- package/src/features/session_replay/instrument/index.js +24 -9
- package/src/features/session_replay/shared/utils.js +19 -0
- package/src/features/session_trace/aggregate/index.js +2 -2
- package/src/features/soft_navigations/aggregate/ajax-node.js +57 -0
- package/src/features/soft_navigations/aggregate/bel-node.js +26 -0
- package/src/features/soft_navigations/aggregate/index.js +256 -0
- package/src/features/soft_navigations/aggregate/initial-page-load-interaction.js +53 -0
- package/src/features/soft_navigations/aggregate/interaction.js +159 -0
- package/src/features/soft_navigations/constants.js +29 -0
- package/src/features/soft_navigations/index.js +1 -0
- package/src/features/soft_navigations/instrument/index.js +67 -0
- package/src/features/spa/aggregate/index.js +20 -17
- package/src/features/utils/agent-session.js +2 -1
- package/src/features/utils/aggregate-base.js +16 -8
- package/src/features/utils/feature-base.js +3 -0
- package/src/features/utils/instrument-base.js +8 -10
- package/src/features/utils/lazy-feature-loader.js +2 -0
- package/src/loaders/agent-base.js +13 -3
- package/src/loaders/agent.js +20 -19
- package/src/loaders/api/api-methods.js +4 -1
- package/src/loaders/api/api.js +15 -13
- package/src/loaders/configure/configure.js +4 -1
- package/src/loaders/configure/nonce.cdn.js +12 -0
- package/src/loaders/configure/nonce.js +1 -12
- package/src/loaders/configure/public-path.cdn.js +9 -0
- package/src/loaders/configure/public-path.js +2 -8
- package/src/loaders/features/enabled-features.js +1 -1
- package/src/loaders/features/features.js +3 -1
- package/dist/cjs/common/wrap/wrap-raf.js +0 -55
- package/dist/cjs/loaders/configure/nonce.npm.js +0 -2
- package/dist/cjs/loaders/configure/public-path.npm.js +0 -10
- package/dist/esm/common/wrap/wrap-raf.js +0 -48
- package/dist/esm/loaders/configure/nonce.npm.js +0 -1
- package/dist/esm/loaders/configure/public-path.npm.js +0 -3
- package/dist/types/common/wrap/wrap-raf.d.ts +0 -16
- package/dist/types/common/wrap/wrap-raf.d.ts.map +0 -1
- package/dist/types/loaders/configure/nonce.npm.d.ts +0 -1
- package/dist/types/loaders/configure/nonce.npm.d.ts.map +0 -1
- package/dist/types/loaders/configure/public-path.npm.d.ts +0 -2
- package/dist/types/loaders/configure/public-path.npm.d.ts.map +0 -1
- package/src/common/wrap/wrap-raf.js +0 -52
- package/src/loaders/configure/nonce.npm.js +0 -1
- package/src/loaders/configure/public-path.npm.js +0 -3
|
@@ -16,6 +16,7 @@ var _features = require("../../../loaders/features/features");
|
|
|
16
16
|
var _constants2 = require("../../metrics/constants");
|
|
17
17
|
var _aggregateBase = require("../../utils/aggregate-base");
|
|
18
18
|
var _gql = require("./gql");
|
|
19
|
+
var _nreum = require("../../../common/window/nreum");
|
|
19
20
|
/*
|
|
20
21
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
21
22
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -26,12 +27,15 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
26
27
|
constructor(agentIdentifier, aggregator) {
|
|
27
28
|
super(agentIdentifier, aggregator, _constants.FEATURE_NAME);
|
|
28
29
|
const agentInit = (0, _config.getConfiguration)(agentIdentifier);
|
|
29
|
-
const allAjaxIsEnabled = agentInit.ajax.enabled !== false;
|
|
30
30
|
(0, _registerHandler.registerHandler)('xhr', storeXhr, this.featureName, this.ee);
|
|
31
|
-
|
|
31
|
+
this.waitForFlags([]).then(() => {
|
|
32
|
+
const scheduler = new _harvestScheduler.HarvestScheduler('events', {
|
|
33
|
+
onFinished: onEventsHarvestFinished,
|
|
34
|
+
getPayload: prepareHarvest
|
|
35
|
+
}, this);
|
|
36
|
+
scheduler.startTimer(harvestTimeSeconds);
|
|
32
37
|
this.drain();
|
|
33
|
-
|
|
34
|
-
}
|
|
38
|
+
});
|
|
35
39
|
const denyList = (0, _config.getRuntime)(agentIdentifier).denyList;
|
|
36
40
|
(0, _denyList.setDenyList)(denyList);
|
|
37
41
|
let ajaxEvents = [];
|
|
@@ -50,27 +54,23 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
50
54
|
spaAjaxEvents
|
|
51
55
|
};
|
|
52
56
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
delete spaAjaxEvents[interaction.id];
|
|
57
|
-
});
|
|
58
|
-
ee.on('interactionDiscarded', interaction => {
|
|
57
|
+
|
|
58
|
+
// --- v Used by old spa feature
|
|
59
|
+
ee.on('interactionDone', (interaction, wasSaved) => {
|
|
59
60
|
if (!spaAjaxEvents[interaction.id]) return;
|
|
60
|
-
|
|
61
|
-
//
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
if (!wasSaved) {
|
|
62
|
+
// if the ixn was saved, then its ajax reqs are part of the payload whereas if it was discarded, it should still be harvested in the ajax feature itself
|
|
63
|
+
spaAjaxEvents[interaction.id].forEach(function (item) {
|
|
64
|
+
ajaxEvents.push(item);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
64
67
|
delete spaAjaxEvents[interaction.id];
|
|
65
68
|
});
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
scheduler.startTimer(harvestTimeSeconds);
|
|
72
|
-
});
|
|
73
|
-
this.drain();
|
|
69
|
+
// --- ^
|
|
70
|
+
// --- v Used by new soft nav
|
|
71
|
+
(0, _registerHandler.registerHandler)('returnAjax', event => ajaxEvents.push(event), this.featureName, this.ee);
|
|
72
|
+
// --- ^
|
|
73
|
+
|
|
74
74
|
const beacon = (0, _config.getInfo)(agentIdentifier).errorBeacon;
|
|
75
75
|
const proxyBeacon = agentInit.proxy.beacon;
|
|
76
76
|
function storeXhr(params, metrics, startTime, endTime, type) {
|
|
@@ -83,16 +83,25 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
83
83
|
} else {
|
|
84
84
|
hash = (0, _stringify.stringify)([params.status, params.host, params.pathname]);
|
|
85
85
|
}
|
|
86
|
+
const shouldCollect = (0, _denyList.shouldCollectEvent)(params);
|
|
87
|
+
const ajaxMetricDenyListEnabled = agentInit.feature_flags?.includes('ajax_metrics_deny_list');
|
|
86
88
|
|
|
87
89
|
// store as metric
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
if (shouldCollect || !ajaxMetricDenyListEnabled) {
|
|
91
|
+
aggregator.store('xhr', hash, params, metrics);
|
|
92
|
+
}
|
|
93
|
+
if (!shouldCollect) {
|
|
91
94
|
if (params.hostname === beacon || proxyBeacon && params.hostname === proxyBeacon) {
|
|
92
95
|
// This doesn't make a distinction if the same-domain request is going to a different port or path...
|
|
93
96
|
(0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['Ajax/Events/Excluded/Agent'], undefined, _features.FEATURE_NAMES.metrics, ee);
|
|
97
|
+
if (ajaxMetricDenyListEnabled) {
|
|
98
|
+
(0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['Ajax/Metrics/Excluded/Agent'], undefined, _features.FEATURE_NAMES.metrics, ee);
|
|
99
|
+
}
|
|
94
100
|
} else {
|
|
95
101
|
(0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['Ajax/Events/Excluded/App'], undefined, _features.FEATURE_NAMES.metrics, ee);
|
|
102
|
+
if (ajaxMetricDenyListEnabled) {
|
|
103
|
+
(0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['Ajax/Metrics/Excluded/App'], undefined, _features.FEATURE_NAMES.metrics, ee);
|
|
104
|
+
}
|
|
96
105
|
}
|
|
97
106
|
return;
|
|
98
107
|
}
|
|
@@ -122,10 +131,13 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
122
131
|
query: this?.parsedOrigin?.search
|
|
123
132
|
});
|
|
124
133
|
if (event.gql) (0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['Ajax/Events/GraphQL/Bytes-Added', (0, _stringify.stringify)(event.gql).length], undefined, _features.FEATURE_NAMES.metrics, ee);
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
134
|
+
const softNavInUse = Boolean((0, _nreum.getNREUMInitializedAgent)(agentIdentifier)?.features?.[_features.FEATURE_NAMES.softNav]);
|
|
135
|
+
if (softNavInUse) {
|
|
136
|
+
// For newer soft nav (when running), pass the event to it for evaluation -- either part of an interaction or is given back
|
|
137
|
+
(0, _handle.handle)('ajax', [event], undefined, _features.FEATURE_NAMES.softNav, ee);
|
|
138
|
+
} else if (this.spaNode) {
|
|
139
|
+
// For old spa (when running), if the ajax happened inside an interaction, hold it until the interaction finishes
|
|
140
|
+
const interactionId = this.spaNode.interaction.id;
|
|
129
141
|
spaAjaxEvents[interactionId] = spaAjaxEvents[interactionId] || [];
|
|
130
142
|
spaAjaxEvents[interactionId].push(event);
|
|
131
143
|
} else {
|
|
@@ -19,6 +19,8 @@ var _runtime = require("../../../common/constants/runtime");
|
|
|
19
19
|
var _constants = require("../constants");
|
|
20
20
|
var _features = require("../../../loaders/features/features");
|
|
21
21
|
var _aggregateBase = require("../../utils/aggregate-base");
|
|
22
|
+
var _nreum = require("../../../common/window/nreum");
|
|
23
|
+
var _drain = require("../../../common/drain/drain");
|
|
22
24
|
/*
|
|
23
25
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
24
26
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -37,42 +39,41 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
37
39
|
this.stackReported = {};
|
|
38
40
|
this.observedAt = {};
|
|
39
41
|
this.pageviewReported = {};
|
|
40
|
-
this.
|
|
42
|
+
this.bufferedErrorsUnderSpa = {};
|
|
41
43
|
this.currentBody = undefined;
|
|
42
44
|
this.errorOnPage = false;
|
|
43
45
|
|
|
44
46
|
// this will need to change to match whatever ee we use in the instrument
|
|
45
|
-
this.ee.on('
|
|
46
|
-
|
|
47
|
-
// this will need to change to match whatever ee we use in the instrument
|
|
48
|
-
this.ee.on('interactionDiscarded', interaction => this.onInteractionDiscarded(interaction));
|
|
47
|
+
this.ee.on('interactionDone', (interaction, wasSaved) => this.onInteractionDone(interaction, wasSaved));
|
|
49
48
|
(0, _registerHandler.registerHandler)('err', function () {
|
|
50
49
|
return _this.storeError(...arguments);
|
|
51
50
|
}, this.featureName, this.ee);
|
|
52
51
|
(0, _registerHandler.registerHandler)('ierr', function () {
|
|
53
52
|
return _this.storeError(...arguments);
|
|
54
53
|
}, this.featureName, this.ee);
|
|
54
|
+
(0, _registerHandler.registerHandler)('softNavFlush', (interactionId, wasFinished, softNavAttrs) => this.onSoftNavNotification(interactionId, wasFinished, softNavAttrs), this.featureName, this.ee); // when an ixn is done or cancelled
|
|
55
|
+
|
|
55
56
|
const harvestTimeSeconds = (0, _config.getConfigurationValue)(this.agentIdentifier, 'jserrors.harvestTimeSeconds') || 10;
|
|
56
|
-
const scheduler = new _harvestScheduler.HarvestScheduler('jserrors', {
|
|
57
|
-
onFinished: function () {
|
|
58
|
-
return _this.onHarvestFinished(...arguments);
|
|
59
|
-
}
|
|
60
|
-
}, this);
|
|
61
|
-
scheduler.harvest.on('jserrors', function () {
|
|
62
|
-
return _this.onHarvestStarted(...arguments);
|
|
63
|
-
});
|
|
64
57
|
|
|
65
|
-
//
|
|
66
|
-
this.
|
|
67
|
-
|
|
58
|
+
// 0 == off, 1 == on
|
|
59
|
+
this.waitForFlags(['err']).then(_ref => {
|
|
60
|
+
let [errFlag] = _ref;
|
|
61
|
+
if (errFlag) {
|
|
62
|
+
const scheduler = new _harvestScheduler.HarvestScheduler('jserrors', {
|
|
63
|
+
onFinished: function () {
|
|
64
|
+
return _this.onHarvestFinished(...arguments);
|
|
65
|
+
}
|
|
66
|
+
}, this);
|
|
67
|
+
scheduler.harvest.on('jserrors', function () {
|
|
68
|
+
return _this.onHarvestStarted(...arguments);
|
|
69
|
+
});
|
|
70
|
+
scheduler.startTimer(harvestTimeSeconds);
|
|
71
|
+
this.drain();
|
|
72
|
+
} else {
|
|
73
|
+
this.blocked = true; // if rum response determines that customer lacks entitlements for spa endpoint, this feature shouldn't harvest
|
|
74
|
+
(0, _drain.deregisterDrain)(this.agentIdentifier, this.featureName);
|
|
75
|
+
}
|
|
68
76
|
});
|
|
69
|
-
|
|
70
|
-
// If RUM-call's response determines that customer lacks entitlements for the /jserror ingest endpoint, don't harvest at all.
|
|
71
|
-
(0, _registerHandler.registerHandler)('block-err', () => {
|
|
72
|
-
this.blocked = true;
|
|
73
|
-
scheduler.stopTimer(true);
|
|
74
|
-
}, this.featureName, this.ee);
|
|
75
|
-
this.drain();
|
|
76
77
|
}
|
|
77
78
|
onHarvestStarted(options) {
|
|
78
79
|
// this gets rid of dependency in AJAX module
|
|
@@ -193,82 +194,93 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
193
194
|
time
|
|
194
195
|
};
|
|
195
196
|
|
|
196
|
-
//
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
(0, _handle.handle)('errorAgg',
|
|
200
|
-
(0, _handle.handle)('errorAgg', msg, undefined, _features.FEATURE_NAMES.spa, this.ee);
|
|
201
|
-
(0, _handle.handle)('errorAgg', msg, undefined, _features.FEATURE_NAMES.sessionReplay, this.ee);
|
|
202
|
-
|
|
197
|
+
// Trace sends the error in its payload, and both trace & replay simply listens for any error to occur.
|
|
198
|
+
const jsErrorEvent = [type, bucketHash, params, newMetrics, customAttributes];
|
|
199
|
+
(0, _handle.handle)('errorAgg', jsErrorEvent, undefined, _features.FEATURE_NAMES.sessionTrace, this.ee);
|
|
200
|
+
(0, _handle.handle)('errorAgg', jsErrorEvent, undefined, _features.FEATURE_NAMES.sessionReplay, this.ee);
|
|
203
201
|
// still send EE events for other features such as above, but stop this one from aggregating internal data
|
|
204
202
|
if (this.blocked) return;
|
|
205
|
-
|
|
206
|
-
if
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
203
|
+
const softNavInUse = Boolean((0, _nreum.getNREUMInitializedAgent)(this.agentIdentifier)?.features[_features.FEATURE_NAMES.softNav]);
|
|
204
|
+
// Note: the following are subject to potential race cond wherein if the other feature aren't fully initialized, it'll be treated as there being no associated interaction.
|
|
205
|
+
// They each will also tack on their respective properties to the params object as part of the decision flow.
|
|
206
|
+
if (softNavInUse) (0, _handle.handle)('jserror', [params, time], undefined, _features.FEATURE_NAMES.softNav, this.ee);else (0, _handle.handle)('errorAgg', jsErrorEvent, undefined, _features.FEATURE_NAMES.spa, this.ee);
|
|
207
|
+
if (params.browserInteractionId && !params._softNavFinished) {
|
|
208
|
+
// hold onto the error until the in-progress interaction is done, eithered saved or discarded
|
|
209
|
+
this.bufferedErrorsUnderSpa[params.browserInteractionId] ??= [];
|
|
210
|
+
this.bufferedErrorsUnderSpa[params.browserInteractionId].push(jsErrorEvent);
|
|
211
|
+
} else if (params._interactionId != null) {
|
|
212
|
+
// same as above, except tailored for the way old spa does it
|
|
213
|
+
this.bufferedErrorsUnderSpa[params._interactionId] = this.bufferedErrorsUnderSpa[params._interactionId] || [];
|
|
214
|
+
this.bufferedErrorsUnderSpa[params._interactionId].push(jsErrorEvent);
|
|
210
215
|
} else {
|
|
211
|
-
//
|
|
212
|
-
|
|
213
|
-
(
|
|
214
|
-
if (customAttributes) {
|
|
215
|
-
(0, _mapOwn.mapOwn)(customAttributes, setCustom);
|
|
216
|
-
}
|
|
217
|
-
var jsAttributesHash = (0, _stringHashCode.stringHashCode)((0, _stringify.stringify)(customParams));
|
|
218
|
-
var aggregateHash = bucketHash + ':' + jsAttributesHash;
|
|
219
|
-
this.aggregator.store(type, aggregateHash, params, newMetrics, customParams);
|
|
216
|
+
// Either there is no interaction (then all these params properties will be undefined) OR there's a related soft navigation that's already completed.
|
|
217
|
+
// The old spa does not look up completed interactions at all, so there's no need to consider it.
|
|
218
|
+
this.#storeJserrorForHarvest(jsErrorEvent, params.browserInteractionId !== undefined, params._softNavAttributes);
|
|
220
219
|
}
|
|
220
|
+
}
|
|
221
|
+
#storeJserrorForHarvest(errorInfoArr, softNavOccurredFinished) {
|
|
222
|
+
let softNavCustomAttrs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
223
|
+
let [type, bucketHash, params, newMetrics, localAttrs] = errorInfoArr;
|
|
224
|
+
const allCustomAttrs = {};
|
|
225
|
+
if (softNavOccurredFinished) {
|
|
226
|
+
Object.entries(softNavCustomAttrs).forEach(_ref2 => {
|
|
227
|
+
let [k, v] = _ref2;
|
|
228
|
+
return setCustom(k, v);
|
|
229
|
+
}); // when an ixn finishes, it'll include stuff in jsAttributes + attrs specific to the ixn
|
|
230
|
+
bucketHash += params.browserInteractionId;
|
|
231
|
+
delete params._softNavAttributes; // cleanup temp properties from synchronous evaluation; this is harmless when async from soft nav (properties DNE)
|
|
232
|
+
delete params._softNavFinished;
|
|
233
|
+
} else {
|
|
234
|
+
// interaction was cancelled -> error should not be associated OR there was no interaction
|
|
235
|
+
Object.entries((0, _config.getInfo)(this.agentIdentifier).jsAttributes).forEach(_ref3 => {
|
|
236
|
+
let [k, v] = _ref3;
|
|
237
|
+
return setCustom(k, v);
|
|
238
|
+
});
|
|
239
|
+
delete params.browserInteractionId;
|
|
240
|
+
}
|
|
241
|
+
if (localAttrs) Object.entries(localAttrs).forEach(_ref4 => {
|
|
242
|
+
let [k, v] = _ref4;
|
|
243
|
+
return setCustom(k, v);
|
|
244
|
+
}); // local custom attrs are applied in either case with the highest precedence
|
|
245
|
+
|
|
246
|
+
const jsAttributesHash = (0, _stringHashCode.stringHashCode)((0, _stringify.stringify)(allCustomAttrs));
|
|
247
|
+
const aggregateHash = bucketHash + ':' + jsAttributesHash;
|
|
248
|
+
this.aggregator.store(type, aggregateHash, params, newMetrics, allCustomAttrs);
|
|
221
249
|
function setCustom(key, val) {
|
|
222
|
-
|
|
250
|
+
allCustomAttrs[key] = val && typeof val === 'object' ? (0, _stringify.stringify)(val) : val;
|
|
223
251
|
}
|
|
224
252
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
var
|
|
231
|
-
|
|
232
|
-
(0, _mapOwn.mapOwn)(interaction.root.attrs.custom, setCustom);
|
|
233
|
-
(0, _mapOwn.mapOwn)(
|
|
253
|
+
|
|
254
|
+
// TO-DO: Remove this function when old spa is taken out. #storeJserrorForHarvest handles the work with the softnav feature.
|
|
255
|
+
onInteractionDone(interaction, wasSaved) {
|
|
256
|
+
if (!this.bufferedErrorsUnderSpa[interaction.id] || this.blocked) return;
|
|
257
|
+
this.bufferedErrorsUnderSpa[interaction.id].forEach(item => {
|
|
258
|
+
var allCustomAttrs = {};
|
|
259
|
+
const localCustomAttrs = item[4];
|
|
260
|
+
(0, _mapOwn.mapOwn)(interaction.root.attrs.custom, setCustom); // tack on custom attrs from the interaction
|
|
261
|
+
(0, _mapOwn.mapOwn)(localCustomAttrs, setCustom);
|
|
234
262
|
var params = item[2];
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
params.parentNodeId = params._interactionNodeId.toString();
|
|
239
|
-
delete params._interactionNodeId;
|
|
240
|
-
}
|
|
241
|
-
var hash = item[1] + interaction.root.attrs.id;
|
|
242
|
-
var jsAttributesHash = (0, _stringHashCode.stringHashCode)((0, _stringify.stringify)(customParams));
|
|
243
|
-
var aggregateHash = hash + ':' + jsAttributesHash;
|
|
244
|
-
this.aggregator.store(item[0], aggregateHash, params, item[3], customParams);
|
|
245
|
-
function setCustom(key, val) {
|
|
246
|
-
customParams[key] = val && typeof val === 'object' ? (0, _stringify.stringify)(val) : val;
|
|
263
|
+
if (wasSaved) {
|
|
264
|
+
params.browserInteractionId = interaction.root.attrs.id;
|
|
265
|
+
if (params._interactionNodeId) params.parentNodeId = params._interactionNodeId.toString();
|
|
247
266
|
}
|
|
248
|
-
});
|
|
249
|
-
delete this.errorCache[interaction.id];
|
|
250
|
-
}
|
|
251
|
-
onInteractionDiscarded(interaction) {
|
|
252
|
-
if (!this.errorCache || !this.errorCache[interaction.id] || this.blocked) return;
|
|
253
|
-
this.errorCache[interaction.id].forEach(item => {
|
|
254
|
-
var customParams = {};
|
|
255
|
-
var globalCustomParams = item[4];
|
|
256
|
-
var localCustomParams = item[5];
|
|
257
|
-
(0, _mapOwn.mapOwn)(globalCustomParams, setCustom);
|
|
258
|
-
(0, _mapOwn.mapOwn)(interaction.root.attrs.custom, setCustom);
|
|
259
|
-
(0, _mapOwn.mapOwn)(localCustomParams, setCustom);
|
|
260
|
-
var params = item[2];
|
|
261
267
|
delete params._interactionId;
|
|
262
268
|
delete params._interactionNodeId;
|
|
263
|
-
var hash = item[1];
|
|
264
|
-
var jsAttributesHash = (0, _stringHashCode.stringHashCode)((0, _stringify.stringify)(
|
|
269
|
+
var hash = wasSaved ? item[1] + interaction.root.attrs.id : item[1];
|
|
270
|
+
var jsAttributesHash = (0, _stringHashCode.stringHashCode)((0, _stringify.stringify)(allCustomAttrs));
|
|
265
271
|
var aggregateHash = hash + ':' + jsAttributesHash;
|
|
266
|
-
this.aggregator.store(item[0], aggregateHash,
|
|
272
|
+
this.aggregator.store(item[0], aggregateHash, params, item[3], allCustomAttrs);
|
|
267
273
|
function setCustom(key, val) {
|
|
268
|
-
|
|
274
|
+
allCustomAttrs[key] = val && typeof val === 'object' ? (0, _stringify.stringify)(val) : val;
|
|
269
275
|
}
|
|
270
276
|
});
|
|
271
|
-
delete this.
|
|
277
|
+
delete this.bufferedErrorsUnderSpa[interaction.id];
|
|
278
|
+
}
|
|
279
|
+
onSoftNavNotification(interactionId, wasFinished, softNavAttrs) {
|
|
280
|
+
if (this.blocked) return;
|
|
281
|
+
this.bufferedErrorsUnderSpa[interactionId]?.forEach(jsErrorEvent => this.#storeJserrorForHarvest(jsErrorEvent, wasFinished, softNavAttrs) // this should not modify the re-used softNavAttrs contents
|
|
282
|
+
);
|
|
283
|
+
delete this.bufferedErrorsUnderSpa[interactionId]; // wipe the list of jserrors so they aren't duplicated by another call to the same id
|
|
272
284
|
}
|
|
273
285
|
}
|
|
274
286
|
exports.Aggregate = Aggregate;
|
|
@@ -15,35 +15,34 @@ var _load = require("../../../common/window/load");
|
|
|
15
15
|
var _eventListenerOpts = require("../../../common/event-listener/event-listener-opts");
|
|
16
16
|
var _runtime = require("../../../common/constants/runtime");
|
|
17
17
|
var _aggregateBase = require("../../utils/aggregate-base");
|
|
18
|
+
var _drain = require("../../../common/drain/drain");
|
|
18
19
|
class Aggregate extends _aggregateBase.AggregateBase {
|
|
19
20
|
static featureName = _constants.FEATURE_NAME;
|
|
20
21
|
constructor(agentIdentifier, aggregator) {
|
|
21
22
|
super(agentIdentifier, aggregator, _constants.FEATURE_NAME);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
this.waitForFlags(['err']).then(_ref => {
|
|
24
|
+
let [errFlag] = _ref;
|
|
25
|
+
if (errFlag) {
|
|
26
|
+
// *cli, Mar 23 - Per NR-94597, this feature should only harvest ONCE at the (potential) EoL time of the page.
|
|
27
|
+
const scheduler = new _harvestScheduler.HarvestScheduler('jserrors', {
|
|
28
|
+
onUnload: () => this.unload()
|
|
29
|
+
}, this);
|
|
30
|
+
// this is needed to ensure EoL is "on" and sent
|
|
31
|
+
scheduler.harvest.on('jserrors', () => ({
|
|
32
|
+
body: this.aggregator.take(['cm', 'sm'])
|
|
33
|
+
}));
|
|
34
|
+
this.drain();
|
|
35
|
+
} else {
|
|
36
|
+
this.blocked = true; // if rum response determines that customer lacks entitlements for spa endpoint, this feature shouldn't harvest
|
|
37
|
+
(0, _drain.deregisterDrain)(this.agentIdentifier, this.featureName);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
29
40
|
|
|
30
41
|
// Allow features external to the metrics feature to capture SMs and CMs through the event emitter
|
|
31
42
|
(0, _registerHandler.registerHandler)(_constants.SUPPORTABILITY_METRIC_CHANNEL, this.storeSupportabilityMetrics.bind(this), this.featureName, this.ee);
|
|
32
43
|
(0, _registerHandler.registerHandler)(_constants.CUSTOM_METRIC_CHANNEL, this.storeEventMetrics.bind(this), this.featureName, this.ee);
|
|
33
44
|
this.singleChecks(); // checks that are run only one time, at script load
|
|
34
45
|
this.eachSessionChecks(); // the start of every time user engages with page
|
|
35
|
-
|
|
36
|
-
this.ee.on("drain-".concat(this.featureName), () => {
|
|
37
|
-
// *cli, Mar 23 - Per NR-94597, this feature should only harvest ONCE at the (potential) EoL time of the page.
|
|
38
|
-
scheduler = new _harvestScheduler.HarvestScheduler('jserrors', {
|
|
39
|
-
onUnload: () => this.unload()
|
|
40
|
-
}, this);
|
|
41
|
-
scheduler.harvest.on('jserrors', () => ({
|
|
42
|
-
body: this.aggregator.take(['cm', 'sm'])
|
|
43
|
-
}));
|
|
44
|
-
}); // this is needed to ensure EoL is "on" and sent
|
|
45
|
-
|
|
46
|
-
this.drain();
|
|
47
46
|
}
|
|
48
47
|
storeSupportabilityMetrics(name, value) {
|
|
49
48
|
if (this.blocked) return;
|
|
@@ -67,6 +66,11 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
67
66
|
distMethod,
|
|
68
67
|
loaderType
|
|
69
68
|
} = (0, _config.getRuntime)(this.agentIdentifier);
|
|
69
|
+
const {
|
|
70
|
+
proxy,
|
|
71
|
+
privacy,
|
|
72
|
+
page_view_timing
|
|
73
|
+
} = (0, _config.getConfiguration)(this.agentIdentifier);
|
|
70
74
|
if (loaderType) this.storeSupportabilityMetrics("Generic/LoaderType/".concat(loaderType, "/Detected"));
|
|
71
75
|
if (distMethod) this.storeSupportabilityMetrics("Generic/DistMethod/".concat(distMethod, "/Detected"));
|
|
72
76
|
if (_runtime.isBrowserScope) {
|
|
@@ -82,6 +86,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
82
86
|
this.storeSupportabilityMetrics('Framework/' + framework + '/Detected');
|
|
83
87
|
});
|
|
84
88
|
});
|
|
89
|
+
if (!privacy.cookies_enabled) this.storeSupportabilityMetrics('Config/SessionTracking/Disabled');
|
|
90
|
+
if (page_view_timing.long_task) this.storeSupportabilityMetrics('Config/LongTask/Enabled');
|
|
85
91
|
} else if (_runtime.isWorkerScope) {
|
|
86
92
|
this.storeSupportabilityMetrics('Generic/Runtime/Worker/Detected');
|
|
87
93
|
} else {
|
|
@@ -100,13 +106,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
100
106
|
if (rules.length > 0 && !(0, _obfuscate.validateRules)(rules)) this.storeSupportabilityMetrics('Generic/Obfuscate/Invalid');
|
|
101
107
|
|
|
102
108
|
// Check if proxy for either chunks or beacon is being used
|
|
103
|
-
const {
|
|
104
|
-
proxy,
|
|
105
|
-
privacy
|
|
106
|
-
} = (0, _config.getConfiguration)(this.agentIdentifier);
|
|
107
109
|
if (proxy.assets) this.storeSupportabilityMetrics('Config/AssetsUrl/Changed');
|
|
108
110
|
if (proxy.beacon) this.storeSupportabilityMetrics('Config/BeaconUrl/Changed');
|
|
109
|
-
if (!(_runtime.isBrowserScope && privacy.cookies_enabled)) this.storeSupportabilityMetrics('Config/SessionTracking/Disabled');
|
|
110
111
|
}
|
|
111
112
|
eachSessionChecks() {
|
|
112
113
|
if (!_runtime.isBrowserScope) return;
|
|
@@ -13,6 +13,7 @@ var _config = require("../../../common/config/config");
|
|
|
13
13
|
var _constants = require("../constants");
|
|
14
14
|
var _runtime = require("../../../common/constants/runtime");
|
|
15
15
|
var _aggregateBase = require("../../utils/aggregate-base");
|
|
16
|
+
var _drain = require("../../../common/drain/drain");
|
|
16
17
|
/*
|
|
17
18
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
18
19
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -37,8 +38,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
37
38
|
return _this.addPageAction(...arguments);
|
|
38
39
|
}, this.featureName, this.ee);
|
|
39
40
|
this.waitForFlags(['ins']).then(_ref => {
|
|
40
|
-
let [
|
|
41
|
-
if (
|
|
41
|
+
let [insFlag] = _ref;
|
|
42
|
+
if (insFlag) {
|
|
42
43
|
const scheduler = new _harvestScheduler.HarvestScheduler('ins', {
|
|
43
44
|
onFinished: function () {
|
|
44
45
|
return _this.onHarvestFinished(...arguments);
|
|
@@ -48,11 +49,12 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
48
49
|
return _this.onHarvestStarted(...arguments);
|
|
49
50
|
});
|
|
50
51
|
scheduler.startTimer(this.harvestTimeSeconds, 0);
|
|
52
|
+
this.drain();
|
|
51
53
|
} else {
|
|
52
|
-
this.blocked = true;
|
|
54
|
+
this.blocked = true; // if rum response determines that customer lacks entitlements for ins endpoint, this feature shouldn't harvest
|
|
55
|
+
(0, _drain.deregisterDrain)(this.agentIdentifier, this.featureName);
|
|
53
56
|
}
|
|
54
57
|
});
|
|
55
|
-
this.drain();
|
|
56
58
|
}
|
|
57
59
|
onHarvestStarted(options) {
|
|
58
60
|
const {
|
|
@@ -17,6 +17,10 @@ var _aggregateBase = require("../../utils/aggregate-base");
|
|
|
17
17
|
var _firstContentfulPaint = require("../../../common/vitals/first-contentful-paint");
|
|
18
18
|
var _firstPaint = require("../../../common/vitals/first-paint");
|
|
19
19
|
var _timeToFirstByte = require("../../../common/vitals/time-to-first-byte");
|
|
20
|
+
var _drain = require("../../../common/drain/drain");
|
|
21
|
+
var _features = require("../../../loaders/features/features");
|
|
22
|
+
var _handle = require("../../../common/event-emitter/handle");
|
|
23
|
+
var _constants2 = require("../../metrics/constants");
|
|
20
24
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
21
25
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
22
26
|
class Aggregate extends _aggregateBase.AggregateBase {
|
|
@@ -125,7 +129,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
125
129
|
cbFinished: _ref3 => {
|
|
126
130
|
let {
|
|
127
131
|
status,
|
|
128
|
-
responseText
|
|
132
|
+
responseText,
|
|
133
|
+
xhr,
|
|
134
|
+
fullUrl
|
|
129
135
|
} = _ref3;
|
|
130
136
|
if (status >= 400 || status === 0) {
|
|
131
137
|
// Adding retry logic for the rum call will be a separate change
|
|
@@ -133,11 +139,25 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
133
139
|
return;
|
|
134
140
|
}
|
|
135
141
|
try {
|
|
136
|
-
|
|
142
|
+
this.timeKeeper.processRumRequest(xhr, fullUrl);
|
|
143
|
+
} catch (error) {
|
|
144
|
+
(0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['PVE/NRTime/Calculation/Failed'], undefined, _features.FEATURE_NAMES.metrics, this.ee);
|
|
145
|
+
(0, _drain.drain)(this.agentIdentifier, _features.FEATURE_NAMES.metrics, true);
|
|
146
|
+
this.ee.abort();
|
|
147
|
+
(0, _console.warn)('Could not calculate New Relic server time. Agent shutting down.');
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
try {
|
|
151
|
+
const {
|
|
152
|
+
app,
|
|
153
|
+
...flags
|
|
154
|
+
} = JSON.parse(responseText);
|
|
155
|
+
agentRuntime.appMetadata = app;
|
|
156
|
+
(0, _featureFlags.activateFeatures)(flags, this.agentIdentifier);
|
|
137
157
|
this.drain();
|
|
138
158
|
} catch (err) {
|
|
139
159
|
this.ee.abort();
|
|
140
|
-
(0, _console.warn)('RUM call failed. Agent shutting down.');
|
|
160
|
+
(0, _console.warn)('RUM call failed. Agent shutting down.', err);
|
|
141
161
|
}
|
|
142
162
|
}
|
|
143
163
|
});
|
|
@@ -43,17 +43,6 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
43
43
|
this.timings = [];
|
|
44
44
|
this.timingsSent = [];
|
|
45
45
|
this.curSessEndRecorded = false;
|
|
46
|
-
_firstPaint.firstPaint.subscribe(this.#handleVitalMetric);
|
|
47
|
-
_firstContentfulPaint.firstContentfulPaint.subscribe(this.#handleVitalMetric);
|
|
48
|
-
_firstInputDelay.firstInputDelay.subscribe(this.#handleVitalMetric);
|
|
49
|
-
_largestContentfulPaint.largestContentfulPaint.subscribe(this.#handleVitalMetric);
|
|
50
|
-
_interactionToNextPaint.interactionToNextPaint.subscribe(this.#handleVitalMetric);
|
|
51
|
-
_timeToFirstByte.timeToFirstByte.subscribe(_ref2 => {
|
|
52
|
-
let {
|
|
53
|
-
entries
|
|
54
|
-
} = _ref2;
|
|
55
|
-
this.addTiming('load', Math.round(entries[0].loadEventEnd));
|
|
56
|
-
});
|
|
57
46
|
if ((0, _config.getConfigurationValue)(this.agentIdentifier, 'page_view_timing.long_task') === true) _longTask.longTask.subscribe(this.#handleVitalMetric);
|
|
58
47
|
|
|
59
48
|
/* It's important that CWV api, like "onLCP", is called before this scheduler is initialized. The reason is because they listen to the same
|
|
@@ -63,9 +52,19 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
63
52
|
(0, _registerHandler.registerHandler)('winPagehide', msTimestamp => this.recordPageUnload(msTimestamp), this.featureName, this.ee);
|
|
64
53
|
const initialHarvestSeconds = (0, _config.getConfigurationValue)(this.agentIdentifier, 'page_view_timing.initialHarvestSeconds') || 10;
|
|
65
54
|
const harvestTimeSeconds = (0, _config.getConfigurationValue)(this.agentIdentifier, 'page_view_timing.harvestTimeSeconds') || 30;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
55
|
+
this.waitForFlags([]).then(() => {
|
|
56
|
+
_firstPaint.firstPaint.subscribe(this.#handleVitalMetric);
|
|
57
|
+
_firstContentfulPaint.firstContentfulPaint.subscribe(this.#handleVitalMetric);
|
|
58
|
+
_firstInputDelay.firstInputDelay.subscribe(this.#handleVitalMetric);
|
|
59
|
+
_largestContentfulPaint.largestContentfulPaint.subscribe(this.#handleVitalMetric);
|
|
60
|
+
_interactionToNextPaint.interactionToNextPaint.subscribe(this.#handleVitalMetric);
|
|
61
|
+
_timeToFirstByte.timeToFirstByte.subscribe(_ref2 => {
|
|
62
|
+
let {
|
|
63
|
+
entries
|
|
64
|
+
} = _ref2;
|
|
65
|
+
this.addTiming('load', Math.round(entries[0].loadEventEnd));
|
|
66
|
+
});
|
|
67
|
+
const scheduler = new _harvestScheduler.HarvestScheduler('events', {
|
|
69
68
|
onFinished: function () {
|
|
70
69
|
return _this.onHarvestFinished(...arguments);
|
|
71
70
|
},
|
|
@@ -73,9 +72,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
73
72
|
return _this.prepareHarvest(...arguments);
|
|
74
73
|
}
|
|
75
74
|
}, this);
|
|
76
|
-
|
|
75
|
+
scheduler.startTimer(harvestTimeSeconds, initialHarvestSeconds);
|
|
76
|
+
this.drain();
|
|
77
77
|
});
|
|
78
|
-
this.drain();
|
|
79
78
|
}
|
|
80
79
|
|
|
81
80
|
/**
|