@newrelic/browser-agent 1.232.0 → 1.233.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/dist/cjs/cdn/polyfills.js +5 -2
- package/dist/cjs/common/config/state/configurable.js +15 -26
- package/dist/cjs/common/config/state/info.js +1 -1
- package/dist/cjs/common/config/state/init.js +101 -56
- package/dist/cjs/common/config/state/loader-config.js +1 -1
- package/dist/cjs/common/config/state/runtime.js +1 -5
- 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 +1 -1
- package/dist/cjs/common/harvest/harvest-scheduler.js +30 -10
- package/dist/cjs/common/harvest/harvest.js +119 -55
- package/dist/cjs/common/session/session-entity.js +35 -22
- package/dist/cjs/common/session/session-entity.test.js +73 -49
- package/dist/cjs/common/timer/interaction-timer.js +9 -12
- package/dist/cjs/common/url/canonicalize-url.js +32 -0
- package/dist/cjs/common/url/canonicalize-url.test.js +42 -0
- package/dist/cjs/common/url/clean-url.js +10 -3
- package/dist/cjs/common/url/protocol.test.js +0 -1
- package/dist/cjs/common/util/feature-flags.js +2 -1
- package/dist/cjs/common/util/global-scope.js +4 -2
- package/dist/cjs/common/util/submit-data.js +57 -18
- package/dist/cjs/common/wrap/wrap-fetch.js +1 -3
- package/dist/cjs/common/wrap/wrap-function.js +1 -3
- package/dist/cjs/common/wrap/wrap-promise.js +1 -1
- package/dist/cjs/features/ajax/aggregate/index.js +2 -2
- package/dist/cjs/features/ajax/instrument/index.js +1 -1
- package/dist/cjs/features/jserrors/aggregate/canonical-function-name.js +12 -4
- package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.js +93 -10
- package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.test.js +164 -38
- package/dist/cjs/features/jserrors/aggregate/index.js +29 -48
- package/dist/cjs/features/jserrors/instrument/index.js +0 -2
- package/dist/cjs/features/metrics/aggregate/framework-detection.js +67 -0
- package/dist/cjs/features/metrics/aggregate/framework-detection.test.js +137 -0
- package/dist/cjs/features/metrics/aggregate/index.js +7 -3
- package/dist/cjs/features/metrics/aggregate/polyfill-detection.es5.js +14 -0
- package/dist/cjs/features/metrics/aggregate/polyfill-detection.es5.test.js +17 -0
- package/dist/cjs/features/metrics/aggregate/polyfill-detection.js +53 -0
- package/dist/cjs/features/metrics/aggregate/polyfill-detection.test.js +165 -0
- package/dist/cjs/features/page_action/aggregate/index.js +2 -2
- package/dist/cjs/features/page_view_event/aggregate/index.js +6 -3
- package/dist/cjs/features/page_view_timing/aggregate/index.js +2 -2
- package/dist/cjs/features/session_replay/aggregate/index.js +333 -0
- package/dist/cjs/features/session_replay/constants.js +9 -0
- package/dist/cjs/features/session_replay/index.js +12 -0
- package/dist/cjs/features/session_replay/instrument/index.js +29 -0
- package/dist/cjs/features/session_trace/aggregate/index.js +163 -164
- package/dist/cjs/features/session_trace/constants.js +2 -9
- package/dist/cjs/features/session_trace/instrument/index.js +24 -66
- package/dist/cjs/features/spa/aggregate/index.js +2 -2
- package/dist/cjs/features/utils/agent-session.js +1 -2
- package/dist/cjs/features/utils/aggregate-base.js +64 -0
- package/dist/cjs/features/utils/feature-base.js +0 -31
- package/dist/cjs/features/utils/handler-cache.js +3 -4
- package/dist/cjs/features/utils/instrument-base.js +42 -10
- package/dist/cjs/features/utils/{lazy-loader.js → lazy-feature-loader.js} +4 -2
- package/dist/cjs/loaders/agent.js +1 -1
- package/dist/cjs/loaders/api/apiAsync.js +3 -1
- package/dist/cjs/loaders/configure/configure.js +3 -3
- package/dist/cjs/loaders/features/featureDependencies.js +0 -12
- package/dist/cjs/loaders/features/features.js +3 -1
- package/dist/cjs/loaders/micro-agent.js +6 -6
- package/dist/esm/cdn/polyfills.js +5 -2
- package/dist/esm/common/config/state/configurable.js +14 -24
- package/dist/esm/common/config/state/info.js +2 -2
- package/dist/esm/common/config/state/init.js +102 -57
- package/dist/esm/common/config/state/loader-config.js +2 -2
- package/dist/esm/common/config/state/runtime.js +2 -4
- 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 +1 -1
- package/dist/esm/common/harvest/harvest-scheduler.js +30 -10
- package/dist/esm/common/harvest/harvest.js +121 -56
- package/dist/esm/common/session/session-entity.js +35 -22
- package/dist/esm/common/session/session-entity.test.js +73 -49
- package/dist/esm/common/timer/interaction-timer.js +9 -12
- package/dist/esm/common/url/canonicalize-url.js +27 -0
- package/dist/esm/common/url/canonicalize-url.test.js +38 -0
- package/dist/esm/common/url/clean-url.js +10 -3
- package/dist/esm/common/url/protocol.test.js +0 -1
- package/dist/esm/common/util/feature-flags.js +2 -1
- package/dist/esm/common/util/global-scope.js +1 -0
- package/dist/esm/common/util/submit-data.js +57 -18
- package/dist/esm/common/wrap/wrap-fetch.js +1 -2
- package/dist/esm/common/wrap/wrap-function.js +1 -2
- package/dist/esm/common/wrap/wrap-promise.js +1 -1
- package/dist/esm/features/ajax/aggregate/index.js +2 -2
- package/dist/esm/features/ajax/instrument/index.js +1 -1
- package/dist/esm/features/jserrors/aggregate/canonical-function-name.js +12 -4
- package/dist/esm/features/jserrors/aggregate/compute-stack-trace.js +93 -10
- package/dist/esm/features/jserrors/aggregate/compute-stack-trace.test.js +149 -25
- package/dist/esm/features/jserrors/aggregate/index.js +30 -48
- package/dist/esm/features/jserrors/instrument/index.js +0 -1
- package/dist/esm/features/metrics/aggregate/framework-detection.js +61 -0
- package/dist/esm/features/metrics/aggregate/framework-detection.test.js +133 -0
- package/dist/esm/features/metrics/aggregate/index.js +7 -3
- package/dist/esm/features/metrics/aggregate/polyfill-detection.es5.js +8 -0
- package/dist/esm/features/metrics/aggregate/polyfill-detection.es5.test.js +15 -0
- package/dist/esm/features/metrics/aggregate/polyfill-detection.js +47 -0
- package/dist/esm/features/metrics/aggregate/polyfill-detection.test.js +163 -0
- package/dist/esm/features/page_action/aggregate/index.js +2 -2
- package/dist/esm/features/page_view_event/aggregate/index.js +6 -3
- package/dist/esm/features/page_view_timing/aggregate/index.js +2 -2
- package/dist/esm/features/session_replay/aggregate/index.js +327 -0
- package/dist/esm/features/session_replay/constants.js +2 -0
- package/dist/esm/features/session_replay/index.js +12 -0
- package/dist/esm/features/session_replay/instrument/index.js +21 -0
- package/dist/esm/features/session_trace/aggregate/index.js +163 -163
- package/dist/esm/features/session_trace/constants.js +1 -5
- package/dist/esm/features/session_trace/instrument/index.js +24 -66
- package/dist/esm/features/spa/aggregate/index.js +2 -2
- package/dist/esm/features/utils/agent-session.js +1 -2
- package/dist/esm/features/utils/aggregate-base.js +57 -0
- package/dist/esm/features/utils/feature-base.js +1 -32
- package/dist/esm/features/utils/handler-cache.js +3 -4
- package/dist/esm/features/utils/instrument-base.js +42 -10
- package/dist/esm/features/utils/{lazy-loader.js → lazy-feature-loader.js} +3 -1
- package/dist/esm/loaders/agent.js +1 -1
- package/dist/esm/loaders/api/apiAsync.js +3 -1
- package/dist/esm/loaders/configure/configure.js +3 -3
- package/dist/esm/loaders/features/featureDependencies.js +0 -11
- package/dist/esm/loaders/features/features.js +3 -1
- package/dist/esm/loaders/micro-agent.js +6 -6
- package/dist/types/common/config/state/configurable.d.ts +1 -3
- package/dist/types/common/config/state/configurable.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/harvest/harvest-scheduler.d.ts.map +1 -1
- package/dist/types/common/harvest/harvest.d.ts +37 -34
- package/dist/types/common/harvest/harvest.d.ts.map +1 -1
- package/dist/types/common/session/session-entity.d.ts +6 -3
- package/dist/types/common/session/session-entity.d.ts.map +1 -1
- package/dist/types/common/timer/interaction-timer.d.ts +2 -1
- package/dist/types/common/timer/interaction-timer.d.ts.map +1 -1
- package/dist/types/common/url/canonicalize-url.d.ts +9 -0
- package/dist/types/common/url/canonicalize-url.d.ts.map +1 -0
- package/dist/types/common/url/clean-url.d.ts +7 -1
- package/dist/types/common/url/clean-url.d.ts.map +1 -1
- package/dist/types/common/util/feature-flags.d.ts.map +1 -1
- package/dist/types/common/util/global-scope.d.ts +1 -0
- package/dist/types/common/util/global-scope.d.ts.map +1 -1
- package/dist/types/common/util/submit-data.d.ts +40 -14
- package/dist/types/common/util/submit-data.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-fetch.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-function.d.ts.map +1 -1
- package/dist/types/features/ajax/aggregate/index.d.ts +2 -2
- package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/aggregate/canonical-function-name.d.ts +8 -1
- package/dist/types/features/jserrors/aggregate/canonical-function-name.d.ts.map +1 -1
- package/dist/types/features/jserrors/aggregate/compute-stack-trace.d.ts +48 -19
- package/dist/types/features/jserrors/aggregate/compute-stack-trace.d.ts.map +1 -1
- package/dist/types/features/jserrors/aggregate/index.d.ts +14 -5
- package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -1
- package/dist/types/features/metrics/aggregate/framework-detection.d.ts.map +1 -0
- package/dist/types/features/metrics/aggregate/index.d.ts +2 -2
- package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/metrics/aggregate/polyfill-detection.d.ts +6 -0
- package/dist/types/features/metrics/aggregate/polyfill-detection.d.ts.map +1 -0
- package/dist/types/features/metrics/aggregate/polyfill-detection.es5.d.ts +7 -0
- package/dist/types/features/metrics/aggregate/polyfill-detection.es5.d.ts.map +1 -0
- package/dist/types/features/page_action/aggregate/index.d.ts +3 -3
- package/dist/types/features/page_action/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/page_view_event/aggregate/index.d.ts +2 -2
- package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/page_view_timing/aggregate/index.d.ts +2 -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 +96 -0
- package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -0
- package/dist/types/features/session_replay/constants.d.ts +2 -0
- package/dist/types/features/session_replay/constants.d.ts.map +1 -0
- package/dist/types/features/session_replay/index.d.ts +2 -0
- package/dist/types/features/session_replay/index.d.ts.map +1 -0
- package/dist/types/features/session_replay/instrument/index.d.ts +6 -0
- package/dist/types/features/session_replay/instrument/index.d.ts.map +1 -0
- package/dist/types/features/session_trace/aggregate/index.d.ts +8 -57
- package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_trace/constants.d.ts +0 -3
- package/dist/types/features/session_trace/constants.d.ts.map +1 -1
- package/dist/types/features/session_trace/instrument/index.d.ts +1 -3
- package/dist/types/features/session_trace/instrument/index.d.ts.map +1 -1
- package/dist/types/features/spa/aggregate/index.d.ts +2 -2
- 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 +11 -0
- package/dist/types/features/utils/aggregate-base.d.ts.map +1 -0
- package/dist/types/features/utils/feature-base.d.ts +0 -5
- package/dist/types/features/utils/feature-base.d.ts.map +1 -1
- package/dist/types/features/utils/handler-cache.d.ts.map +1 -1
- package/dist/types/features/utils/instrument-base.d.ts +3 -1
- package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
- package/dist/types/features/utils/{lazy-loader.d.ts → lazy-feature-loader.d.ts} +2 -2
- package/dist/types/features/utils/lazy-feature-loader.d.ts.map +1 -0
- package/dist/types/loaders/configure/configure.d.ts.map +1 -1
- package/dist/types/loaders/features/featureDependencies.d.ts +0 -1
- package/dist/types/loaders/features/featureDependencies.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/package.json +31 -22
- package/src/cdn/polyfills.js +4 -1
- package/src/common/config/state/configurable.js +18 -24
- package/src/common/config/state/info.js +2 -2
- package/src/common/config/state/init.js +62 -28
- package/src/common/config/state/loader-config.js +2 -2
- package/src/common/config/state/runtime.js +2 -4
- package/src/common/drain/drain.js +1 -1
- package/src/common/harvest/harvest-scheduler.js +35 -10
- package/src/common/harvest/harvest.js +73 -50
- package/src/common/session/session-entity.js +34 -23
- package/src/common/session/session-entity.test.js +57 -51
- package/src/common/timer/interaction-timer.js +9 -12
- package/src/common/url/canonicalize-url.js +28 -0
- package/src/common/url/canonicalize-url.test.js +34 -0
- package/src/common/url/clean-url.js +10 -3
- package/src/common/url/protocol.test.js +0 -1
- package/src/common/util/feature-flags.js +2 -2
- package/src/common/util/global-scope.js +2 -0
- package/src/common/util/submit-data.js +28 -17
- package/src/common/wrap/wrap-fetch.js +1 -2
- package/src/common/wrap/wrap-function.js +1 -2
- package/src/common/wrap/wrap-promise.js +1 -1
- package/src/features/ajax/aggregate/index.js +2 -2
- package/src/features/ajax/instrument/index.js +1 -1
- package/src/features/jserrors/aggregate/canonical-function-name.js +12 -4
- package/src/features/jserrors/aggregate/compute-stack-trace.js +85 -11
- package/src/features/jserrors/aggregate/compute-stack-trace.test.js +141 -24
- package/src/features/jserrors/aggregate/index.js +28 -52
- package/src/features/jserrors/instrument/index.js +0 -1
- package/src/features/metrics/aggregate/framework-detection.js +73 -0
- package/src/features/metrics/aggregate/framework-detection.test.js +201 -0
- package/src/features/metrics/aggregate/index.js +8 -3
- package/src/features/metrics/aggregate/polyfill-detection.es5.js +9 -0
- package/src/features/metrics/aggregate/polyfill-detection.es5.test.js +16 -0
- package/src/features/metrics/aggregate/polyfill-detection.js +48 -0
- package/src/features/metrics/aggregate/polyfill-detection.test.js +163 -0
- package/src/features/page_action/aggregate/index.js +2 -2
- package/src/features/page_view_event/aggregate/index.js +5 -5
- package/src/features/page_view_timing/aggregate/index.js +2 -2
- package/src/features/session_replay/aggregate/index.js +314 -0
- package/src/features/session_replay/constants.js +3 -0
- package/src/features/session_replay/index.js +12 -0
- package/src/features/session_replay/instrument/index.js +22 -0
- package/src/features/session_trace/aggregate/index.js +148 -188
- package/src/features/session_trace/constants.js +0 -4
- package/src/features/session_trace/instrument/index.js +17 -69
- package/src/features/spa/aggregate/index.js +2 -2
- package/src/features/utils/agent-session.js +1 -2
- package/src/features/utils/aggregate-base.js +51 -0
- package/src/features/utils/feature-base.js +1 -31
- package/src/features/utils/handler-cache.js +3 -4
- package/src/features/utils/instrument-base.js +40 -8
- package/src/features/utils/{lazy-loader.js → lazy-feature-loader.js} +3 -1
- package/src/loaders/agent.js +1 -1
- package/src/loaders/api/apiAsync.js +1 -1
- package/src/loaders/configure/configure.js +4 -3
- package/src/loaders/features/featureDependencies.js +0 -12
- package/src/loaders/features/features.js +3 -1
- package/src/loaders/micro-agent.js +4 -4
- package/dist/cjs/common/metrics/framework-detection.js +0 -72
- package/dist/cjs/common/util/user-agent.js +0 -57
- package/dist/cjs/common/window/supports-performance-observer.js +0 -15
- package/dist/esm/common/metrics/framework-detection.js +0 -66
- package/dist/esm/common/util/user-agent.js +0 -48
- package/dist/esm/common/window/supports-performance-observer.js +0 -9
- package/dist/types/common/metrics/framework-detection.d.ts.map +0 -1
- package/dist/types/common/util/user-agent.d.ts +0 -5
- package/dist/types/common/util/user-agent.d.ts.map +0 -1
- package/dist/types/common/window/supports-performance-observer.d.ts +0 -2
- package/dist/types/common/window/supports-performance-observer.d.ts.map +0 -1
- package/dist/types/features/utils/lazy-loader.d.ts.map +0 -1
- package/src/common/metrics/framework-detection.js +0 -71
- package/src/common/util/user-agent.js +0 -56
- package/src/common/window/supports-performance-observer.js +0 -10
- /package/dist/types/{common/metrics → features/metrics/aggregate}/framework-detection.d.ts +0 -0
|
@@ -6,93 +6,67 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.Aggregate = void 0;
|
|
7
7
|
var _registerHandler = require("../../../common/event-emitter/register-handler");
|
|
8
8
|
var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
|
|
9
|
-
var _mapOwn = require("../../../common/util/map-own");
|
|
10
9
|
var _stringify = require("../../../common/util/stringify");
|
|
11
10
|
var _parseUrl = require("../../../common/url/parse-url");
|
|
12
|
-
var _supportsPerformanceObserver = require("../../../common/window/supports-performance-observer");
|
|
13
|
-
var _lodash = _interopRequireDefault(require("lodash._slice"));
|
|
14
11
|
var _config = require("../../../common/config/config");
|
|
15
12
|
var _now = require("../../../common/timing/now");
|
|
16
13
|
var _constants = require("../constants");
|
|
17
14
|
var _drain = require("../../../common/drain/drain");
|
|
18
15
|
var _handlerCache = require("../../utils/handler-cache");
|
|
19
|
-
var
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
var _aggregateBase = require("../../utils/aggregate-base");
|
|
21
17
|
/*
|
|
22
18
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
23
19
|
* SPDX-License-Identifier: Apache-2.0
|
|
24
20
|
*/
|
|
25
21
|
|
|
26
|
-
|
|
22
|
+
const ignoredEvents = {
|
|
23
|
+
// we find that certain events make the data too noisy to be useful
|
|
24
|
+
global: {
|
|
25
|
+
mouseup: true,
|
|
26
|
+
mousedown: true
|
|
27
|
+
},
|
|
28
|
+
// certain events are present both in the window and in PVT metrics. PVT metrics are prefered so the window events should be ignored
|
|
29
|
+
window: {
|
|
30
|
+
load: true,
|
|
31
|
+
pagehide: true
|
|
32
|
+
},
|
|
33
|
+
// when ajax instrumentation is disabled, all XMLHttpRequest events will return with origin = xhrOriginMissing and should be ignored
|
|
34
|
+
xhrOriginMissing: {
|
|
35
|
+
ignoreAll: true
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const toAggregate = {
|
|
39
|
+
typing: [1000, 2000],
|
|
40
|
+
scrolling: [100, 1000],
|
|
41
|
+
mousing: [1000, 2000],
|
|
42
|
+
touching: [1000, 2000]
|
|
43
|
+
};
|
|
44
|
+
const MAX_TRACE_DURATION = 15 * 60 * 1000; // 15 minutes
|
|
45
|
+
|
|
46
|
+
class Aggregate extends _aggregateBase.AggregateBase {
|
|
27
47
|
static featureName = _constants.FEATURE_NAME;
|
|
28
|
-
constructor(agentIdentifier, aggregator) {
|
|
48
|
+
constructor(agentIdentifier, aggregator, argsObj) {
|
|
29
49
|
var _this;
|
|
30
50
|
// Very unlikely, but in case the existing XMLHttpRequest.prototype object on the page couldn't be wrapped.
|
|
31
51
|
super(agentIdentifier, aggregator, _constants.FEATURE_NAME);
|
|
32
52
|
_this = this;
|
|
33
53
|
if (!(0, _config.getRuntime)(agentIdentifier).xhrWrappable) return;
|
|
34
|
-
|
|
54
|
+
this.resourceObserver = argsObj?.resourceObserver; // undefined if observer couldn't be created
|
|
35
55
|
this.ptid = '';
|
|
36
|
-
this.ignoredEvents = {
|
|
37
|
-
// we find that certain events make the data too noisy to be useful
|
|
38
|
-
global: {
|
|
39
|
-
mouseup: true,
|
|
40
|
-
mousedown: true
|
|
41
|
-
},
|
|
42
|
-
// certain events are present both in the window and in PVT metrics. PVT metrics are prefered so the window events should be ignored
|
|
43
|
-
window: {
|
|
44
|
-
load: true,
|
|
45
|
-
pagehide: true
|
|
46
|
-
},
|
|
47
|
-
// when ajax instrumentation is disabled, all XMLHttpRequest events will return with origin = xhrOriginMissing and should be ignored
|
|
48
|
-
xhrOriginMissing: {
|
|
49
|
-
ignoreAll: true
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
this.toAggregate = {
|
|
53
|
-
typing: [1000, 2000],
|
|
54
|
-
scrolling: [100, 1000],
|
|
55
|
-
mousing: [1000, 2000],
|
|
56
|
-
touching: [1000, 2000]
|
|
57
|
-
};
|
|
58
|
-
this.rename = {
|
|
59
|
-
typing: {
|
|
60
|
-
keydown: true,
|
|
61
|
-
keyup: true,
|
|
62
|
-
keypress: true
|
|
63
|
-
},
|
|
64
|
-
mousing: {
|
|
65
|
-
mousemove: true,
|
|
66
|
-
mouseenter: true,
|
|
67
|
-
mouseleave: true,
|
|
68
|
-
mouseover: true,
|
|
69
|
-
mouseout: true
|
|
70
|
-
},
|
|
71
|
-
scrolling: {
|
|
72
|
-
scroll: true
|
|
73
|
-
},
|
|
74
|
-
touching: {
|
|
75
|
-
touchstart: true,
|
|
76
|
-
touchmove: true,
|
|
77
|
-
touchend: true,
|
|
78
|
-
touchcancel: true,
|
|
79
|
-
touchenter: true,
|
|
80
|
-
touchleave: true
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
56
|
this.trace = {};
|
|
84
57
|
this.nodeCount = 0;
|
|
85
58
|
this.sentTrace = null;
|
|
86
59
|
this.harvestTimeSeconds = (0, _config.getConfigurationValue)(agentIdentifier, 'session_trace.harvestTimeSeconds') || 10;
|
|
87
60
|
this.maxNodesPerHarvest = (0, _config.getConfigurationValue)(agentIdentifier, 'session_trace.maxNodesPerHarvest') || 1000;
|
|
88
61
|
this.laststart = 0;
|
|
62
|
+
const handlerCache = new _handlerCache.HandlerCache();
|
|
89
63
|
(0, _registerHandler.registerHandler)('feat-stn', () => {
|
|
90
64
|
if (typeof PerformanceNavigationTiming !== 'undefined') {
|
|
91
|
-
this.storeTiming(window.performance
|
|
65
|
+
this.storeTiming(window.performance.getEntriesByType('navigation')[0]);
|
|
92
66
|
} else {
|
|
93
|
-
this.storeTiming(window.performance
|
|
67
|
+
this.storeTiming(window.performance.timing);
|
|
94
68
|
}
|
|
95
|
-
|
|
69
|
+
const scheduler = new _harvestScheduler.HarvestScheduler('resources', {
|
|
96
70
|
onFinished: onHarvestFinished.bind(this),
|
|
97
71
|
retryDelay: this.harvestTimeSeconds
|
|
98
72
|
}, this);
|
|
@@ -100,38 +74,37 @@ class Aggregate extends _featureBase.FeatureBase {
|
|
|
100
74
|
scheduler.runHarvest({
|
|
101
75
|
needResponse: true
|
|
102
76
|
}); // sends first stn harvest immediately
|
|
103
|
-
|
|
77
|
+
handlerCache.decide(true);
|
|
104
78
|
function onHarvestFinished(result) {
|
|
105
|
-
// start timer only if ptid was returned by server
|
|
106
79
|
if (result.sent && result.responseText && !this.ptid) {
|
|
107
|
-
|
|
108
|
-
(0, _config.getRuntime)(this.agentIdentifier).ptid = this.ptid;
|
|
80
|
+
// continue interval harvest only if ptid was returned by server on the first
|
|
81
|
+
(0, _config.getRuntime)(this.agentIdentifier).ptid = this.ptid = result.responseText;
|
|
109
82
|
scheduler.startTimer(this.harvestTimeSeconds);
|
|
110
83
|
}
|
|
111
84
|
if (result.sent && result.retry && this.sentTrace) {
|
|
112
|
-
|
|
113
|
-
|
|
85
|
+
// merge previous trace back into buffer to retry for next harvest
|
|
86
|
+
Object.entries(this.sentTrace).forEach(_ref => {
|
|
87
|
+
let [name, listOfSTNodes] = _ref;
|
|
88
|
+
if (this.nodeCount >= this.maxNodesPerHarvest) return;
|
|
89
|
+
this.nodeCount += listOfSTNodes.length;
|
|
90
|
+
this.trace[name] = this.trace[name] ? listOfSTNodes.concat(this.trace[name]) : listOfSTNodes;
|
|
114
91
|
});
|
|
115
92
|
this.sentTrace = null;
|
|
116
93
|
}
|
|
117
94
|
}
|
|
118
95
|
function prepareHarvest(options) {
|
|
119
|
-
if ((0, _now.now)() >
|
|
96
|
+
if ((0, _now.now)() > MAX_TRACE_DURATION) {
|
|
120
97
|
// been collecting for over 15 min, empty trace object and bail
|
|
121
98
|
scheduler.stopTimer();
|
|
122
99
|
this.trace = {};
|
|
123
100
|
return;
|
|
124
101
|
}
|
|
125
|
-
|
|
126
|
-
// only send when there are more than 30 nodes to send
|
|
102
|
+
// Only harvest when there are more than 30 nodes to send after the very first.
|
|
127
103
|
if (this.ptid && this.nodeCount <= 30) return;
|
|
128
104
|
return this.takeSTNs(options.retry);
|
|
129
105
|
}
|
|
130
|
-
handlerCache.decide(true);
|
|
131
|
-
}, this.featureName, this.ee);
|
|
132
|
-
(0, _registerHandler.registerHandler)('block-stn', () => {
|
|
133
|
-
handlerCache.decide(false);
|
|
134
106
|
}, this.featureName, this.ee);
|
|
107
|
+
(0, _registerHandler.registerHandler)('block-stn', () => handlerCache.decide(false), this.featureName, this.ee);
|
|
135
108
|
|
|
136
109
|
// register the handlers immediately... but let the handlerCache decide if the data should actually get stored...
|
|
137
110
|
(0, _registerHandler.registerHandler)('bst', function () {
|
|
@@ -184,19 +157,28 @@ class Aggregate extends _featureBase.FeatureBase {
|
|
|
184
157
|
}, this.featureName, this.ee);
|
|
185
158
|
(0, _drain.drain)(this.agentIdentifier, this.featureName);
|
|
186
159
|
}
|
|
160
|
+
|
|
161
|
+
// PageViewTiming (FEATURE) events and metrics, such as 'load', 'lcp', etc. pipes into ST here.
|
|
187
162
|
processPVT(name, value, attrs) {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
if (
|
|
163
|
+
this.storeTiming({
|
|
164
|
+
[name]: value
|
|
165
|
+
});
|
|
166
|
+
if (hasFID(name, attrs)) this.storeEvent({
|
|
192
167
|
type: 'fid',
|
|
193
168
|
target: 'document'
|
|
194
169
|
}, 'document', value, value + attrs.fid);
|
|
170
|
+
function hasFID(name, attrs) {
|
|
171
|
+
return name === 'fi' && !!attrs && typeof attrs.fid === 'number';
|
|
172
|
+
}
|
|
195
173
|
}
|
|
196
|
-
|
|
174
|
+
|
|
175
|
+
// This processes the aforementioned PVT and the first navigation entry of the page.
|
|
176
|
+
storeTiming(timingEntry) {
|
|
177
|
+
if (!timingEntry) return;
|
|
178
|
+
|
|
197
179
|
// loop iterates through prototype also (for FF)
|
|
198
|
-
for (let key in
|
|
199
|
-
|
|
180
|
+
for (let key in timingEntry) {
|
|
181
|
+
let val = timingEntry[key];
|
|
200
182
|
|
|
201
183
|
// ignore size and status type nodes that do not map to timestamp metrics
|
|
202
184
|
const lck = key.toLowerCase();
|
|
@@ -205,31 +187,33 @@ class Aggregate extends _featureBase.FeatureBase {
|
|
|
205
187
|
// ignore inherited methods, meaningless 0 values, and bogus timestamps
|
|
206
188
|
// that are in the future (Microsoft Edge seems to sometimes produce these)
|
|
207
189
|
if (!(typeof val === 'number' && val >= 0)) continue;
|
|
208
|
-
|
|
190
|
+
val = Math.round(val);
|
|
209
191
|
this.storeSTN({
|
|
210
192
|
n: key,
|
|
211
|
-
s:
|
|
212
|
-
e:
|
|
193
|
+
s: val,
|
|
194
|
+
e: val,
|
|
213
195
|
o: 'document',
|
|
214
196
|
t: 'timing'
|
|
215
197
|
});
|
|
216
198
|
}
|
|
217
199
|
}
|
|
200
|
+
|
|
201
|
+
// Tracks duration of native APIs wrapped by wrap-timer & wrap-raf.
|
|
218
202
|
storeTimer(target, start, end, type) {
|
|
219
|
-
|
|
220
|
-
if (type === 'requestAnimationFrame') category = type;
|
|
221
|
-
var evt = {
|
|
203
|
+
const evt = {
|
|
222
204
|
n: type,
|
|
223
205
|
s: start,
|
|
224
206
|
e: end,
|
|
225
207
|
o: 'window',
|
|
226
|
-
t:
|
|
208
|
+
t: type === 'requestAnimationFrame' ? type : 'timer'
|
|
227
209
|
};
|
|
228
210
|
this.storeSTN(evt);
|
|
229
211
|
}
|
|
212
|
+
|
|
213
|
+
// Tracks the events and their listener's duration on objects wrapped by wrap-events.
|
|
230
214
|
storeEvent(currentEvent, target, start, end) {
|
|
231
|
-
if (this.shouldIgnoreEvent(currentEvent, target)) return
|
|
232
|
-
|
|
215
|
+
if (this.shouldIgnoreEvent(currentEvent, target)) return;
|
|
216
|
+
const evt = {
|
|
233
217
|
n: this.evtName(currentEvent.type),
|
|
234
218
|
s: start,
|
|
235
219
|
e: end,
|
|
@@ -244,31 +228,60 @@ class Aggregate extends _featureBase.FeatureBase {
|
|
|
244
228
|
}
|
|
245
229
|
this.storeSTN(evt);
|
|
246
230
|
}
|
|
231
|
+
shouldIgnoreEvent(event, target) {
|
|
232
|
+
const origin = this.evtOrigin(event.target, target);
|
|
233
|
+
if (event.type in ignoredEvents.global) return true;
|
|
234
|
+
if (!!ignoredEvents[origin] && ignoredEvents[origin].ignoreAll) return true;
|
|
235
|
+
if (!!ignoredEvents[origin] && event.type in ignoredEvents[origin]) return true;
|
|
236
|
+
return false;
|
|
237
|
+
}
|
|
247
238
|
evtName(type) {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
239
|
+
switch (type) {
|
|
240
|
+
case 'keydown':
|
|
241
|
+
case 'keyup':
|
|
242
|
+
case 'keypress':
|
|
243
|
+
return 'typing';
|
|
244
|
+
case 'mousemove':
|
|
245
|
+
case 'mouseenter':
|
|
246
|
+
case 'mouseleave':
|
|
247
|
+
case 'mouseover':
|
|
248
|
+
case 'mouseout':
|
|
249
|
+
return 'mousing';
|
|
250
|
+
case 'scroll':
|
|
251
|
+
return 'scrolling';
|
|
252
|
+
case 'touchstart':
|
|
253
|
+
case 'touchmove':
|
|
254
|
+
case 'touchend':
|
|
255
|
+
case 'touchcancel':
|
|
256
|
+
case 'touchenter':
|
|
257
|
+
case 'touchleave':
|
|
258
|
+
return 'touching';
|
|
259
|
+
default:
|
|
260
|
+
return type;
|
|
261
|
+
}
|
|
253
262
|
}
|
|
254
263
|
evtOrigin(t, target) {
|
|
255
|
-
|
|
264
|
+
let origin = 'unknown';
|
|
256
265
|
if (t && t instanceof XMLHttpRequest) {
|
|
257
|
-
|
|
266
|
+
const params = this.ee.context(t).params;
|
|
258
267
|
if (!params || !params.status || !params.method || !params.host || !params.pathname) return 'xhrOriginMissing';
|
|
259
268
|
origin = params.status + ' ' + params.method + ': ' + params.host + params.pathname;
|
|
260
269
|
} else if (t && typeof t.tagName === 'string') {
|
|
261
270
|
origin = t.tagName.toLowerCase();
|
|
262
271
|
if (t.id) origin += '#' + t.id;
|
|
263
|
-
if (t.className)
|
|
272
|
+
if (t.className) {
|
|
273
|
+
for (let i = 0; i < t.classList.length; i++) origin += '.' + t.classList[i];
|
|
274
|
+
}
|
|
264
275
|
}
|
|
265
276
|
if (origin === 'unknown') {
|
|
266
277
|
if (typeof target === 'string') origin = target;else if (target === document) origin = 'document';else if (target === window) origin = 'window';else if (target instanceof FileReader) origin = 'FileReader';
|
|
267
278
|
}
|
|
268
279
|
return origin;
|
|
269
280
|
}
|
|
281
|
+
|
|
282
|
+
// Tracks when the window history API specified by wrap-history is used.
|
|
270
283
|
storeHist(path, old, time) {
|
|
271
|
-
|
|
284
|
+
const node = {
|
|
272
285
|
n: 'history.pushState',
|
|
273
286
|
s: time,
|
|
274
287
|
e: time,
|
|
@@ -277,11 +290,15 @@ class Aggregate extends _featureBase.FeatureBase {
|
|
|
277
290
|
};
|
|
278
291
|
this.storeSTN(node);
|
|
279
292
|
}
|
|
293
|
+
|
|
294
|
+
// Processes all the PerformanceResourceTiming entries captured (by observer).
|
|
280
295
|
storeResources(resources) {
|
|
281
296
|
if (!resources || resources.length === 0) return;
|
|
282
297
|
resources.forEach(currentResource => {
|
|
283
|
-
|
|
284
|
-
|
|
298
|
+
if ((currentResource.fetchStart | 0) <= this.laststart) return; // don't recollect already-seen resources
|
|
299
|
+
|
|
300
|
+
const parsed = (0, _parseUrl.parseUrl)(currentResource.name);
|
|
301
|
+
const res = {
|
|
285
302
|
n: currentResource.initiatorType,
|
|
286
303
|
s: currentResource.fetchStart | 0,
|
|
287
304
|
e: currentResource.responseEnd | 0,
|
|
@@ -289,16 +306,15 @@ class Aggregate extends _featureBase.FeatureBase {
|
|
|
289
306
|
// resource.name is actually a URL so it's the source
|
|
290
307
|
t: currentResource.entryType
|
|
291
308
|
};
|
|
292
|
-
|
|
293
|
-
// don't recollect old resources
|
|
294
|
-
if (res.s <= this.laststart) return;
|
|
295
309
|
this.storeSTN(res);
|
|
296
310
|
});
|
|
297
311
|
this.laststart = resources[resources.length - 1].fetchStart | 0;
|
|
298
312
|
}
|
|
313
|
+
|
|
314
|
+
// JavascriptError (FEATURE) events pipes into ST here.
|
|
299
315
|
storeErrorAgg(type, name, params, metrics) {
|
|
300
|
-
if (type !== 'err') return;
|
|
301
|
-
|
|
316
|
+
if (type !== 'err') return; // internal errors are purposefully ignored
|
|
317
|
+
const node = {
|
|
302
318
|
n: 'error',
|
|
303
319
|
s: metrics.time,
|
|
304
320
|
e: metrics.time,
|
|
@@ -307,9 +323,11 @@ class Aggregate extends _featureBase.FeatureBase {
|
|
|
307
323
|
};
|
|
308
324
|
this.storeSTN(node);
|
|
309
325
|
}
|
|
326
|
+
|
|
327
|
+
// Ajax (FEATURE) events--XML & fetches--pipes into ST here.
|
|
310
328
|
storeXhrAgg(type, name, params, metrics) {
|
|
311
329
|
if (type !== 'xhr') return;
|
|
312
|
-
|
|
330
|
+
const node = {
|
|
313
331
|
n: 'Ajax',
|
|
314
332
|
s: metrics.time,
|
|
315
333
|
e: metrics.time + metrics.duration,
|
|
@@ -318,46 +336,46 @@ class Aggregate extends _featureBase.FeatureBase {
|
|
|
318
336
|
};
|
|
319
337
|
this.storeSTN(node);
|
|
320
338
|
}
|
|
339
|
+
|
|
340
|
+
// Central function called by all the other store__ & addToTrace API to append a trace node.
|
|
321
341
|
storeSTN(stn) {
|
|
322
|
-
// limit the
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
if (!traceArr) traceArr = this.trace[stn.n] = [];
|
|
326
|
-
traceArr.push(stn);
|
|
342
|
+
if (this.nodeCount >= this.maxNodesPerHarvest) return; // limit the amount of data that is stored at once
|
|
343
|
+
|
|
344
|
+
if (this.trace[stn.n]) this.trace[stn.n].push(stn);else this.trace[stn.n] = [stn];
|
|
327
345
|
this.nodeCount++;
|
|
328
346
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
if (this.nodeCount >= this.maxNodesPerHarvest) return;
|
|
332
|
-
var traceArr = this.trace[key];
|
|
333
|
-
if (!traceArr) traceArr = this.trace[key] = [];
|
|
334
|
-
this.trace[key] = nodes.concat(traceArr);
|
|
335
|
-
this.nodeCount += nodes.length;
|
|
336
|
-
}
|
|
347
|
+
|
|
348
|
+
// Used by session trace's harvester to create the payload body.
|
|
337
349
|
takeSTNs(retry) {
|
|
338
|
-
|
|
339
|
-
|
|
350
|
+
if (!this.resourceObserver) {
|
|
351
|
+
// if PO isn't supported, this checks resourcetiming buffer every harvest.
|
|
340
352
|
this.storeResources(window.performance.getEntriesByType('resource'));
|
|
341
353
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
354
|
+
const stns = Object.entries(this.trace).flatMap(_ref2 => {
|
|
355
|
+
let [name, listOfSTNodes] = _ref2;
|
|
356
|
+
// basically take the "this.trace" map-obj and concat all the list-type values
|
|
357
|
+
if (!(name in toAggregate)) return listOfSTNodes;
|
|
358
|
+
// Special processing for event nodes dealing with user inputs:
|
|
359
|
+
const reindexByOriginFn = this.smearEvtsByOrigin(name);
|
|
360
|
+
const partitionListByOriginMap = listOfSTNodes.sort((a, b) => a.s - b.s).reduce(reindexByOriginFn, {});
|
|
361
|
+
return Object.values(partitionListByOriginMap).flat(); // join the partitions back into 1-D, now ordered by origin then start time
|
|
362
|
+
}, this);
|
|
346
363
|
if (stns.length === 0) return {};
|
|
347
364
|
if (retry) {
|
|
348
365
|
this.sentTrace = this.trace;
|
|
349
366
|
}
|
|
350
367
|
this.trace = {};
|
|
351
368
|
this.nodeCount = 0;
|
|
352
|
-
|
|
369
|
+
const stnInfo = {
|
|
353
370
|
qs: {
|
|
354
|
-
st:
|
|
371
|
+
st: String((0, _config.getRuntime)(this.agentIdentifier).offset)
|
|
355
372
|
},
|
|
356
373
|
body: {
|
|
357
374
|
res: stns
|
|
358
375
|
}
|
|
359
376
|
};
|
|
360
377
|
if (!this.ptid) {
|
|
378
|
+
// send custom and user attributes on the very first ST harvest only
|
|
361
379
|
const {
|
|
362
380
|
userAttributes,
|
|
363
381
|
atts,
|
|
@@ -365,54 +383,35 @@ class Aggregate extends _featureBase.FeatureBase {
|
|
|
365
383
|
} = (0, _config.getInfo)(this.agentIdentifier);
|
|
366
384
|
stnInfo.qs.ua = userAttributes;
|
|
367
385
|
stnInfo.qs.at = atts;
|
|
368
|
-
|
|
386
|
+
const ja = (0, _stringify.stringify)(jsAttributes);
|
|
369
387
|
stnInfo.qs.ja = ja === '{}' ? null : ja;
|
|
370
388
|
}
|
|
371
389
|
return stnInfo;
|
|
372
390
|
}
|
|
373
|
-
byStart(a, b) {
|
|
374
|
-
return a.s - b.s;
|
|
375
|
-
}
|
|
376
391
|
smearEvtsByOrigin(name) {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
return (byOrigin,
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
if (name === 'scrolling' && !
|
|
385
|
-
lastO[
|
|
386
|
-
|
|
387
|
-
lastArr.push(
|
|
388
|
-
} else if (last &&
|
|
389
|
-
last.e =
|
|
392
|
+
const maxGap = toAggregate[name][0];
|
|
393
|
+
const maxLen = toAggregate[name][1];
|
|
394
|
+
const lastO = {};
|
|
395
|
+
return (byOrigin, evtNode) => {
|
|
396
|
+
let lastArr = byOrigin[evtNode.o];
|
|
397
|
+
if (!lastArr) lastArr = byOrigin[evtNode.o] = [];
|
|
398
|
+
const last = lastO[evtNode.o];
|
|
399
|
+
if (name === 'scrolling' && !trivial(evtNode)) {
|
|
400
|
+
lastO[evtNode.o] = null;
|
|
401
|
+
evtNode.n = 'scroll';
|
|
402
|
+
lastArr.push(evtNode);
|
|
403
|
+
} else if (last && evtNode.s - last.s < maxLen && last.e > evtNode.s - maxGap) {
|
|
404
|
+
last.e = evtNode.e;
|
|
390
405
|
} else {
|
|
391
|
-
lastO[
|
|
392
|
-
lastArr.push(
|
|
406
|
+
lastO[evtNode.o] = evtNode;
|
|
407
|
+
lastArr.push(evtNode);
|
|
393
408
|
}
|
|
394
409
|
return byOrigin;
|
|
395
410
|
};
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
flatten(a, b) {
|
|
401
|
-
return a.concat(b);
|
|
402
|
-
}
|
|
403
|
-
hasFID(name, attrs) {
|
|
404
|
-
return name === 'fi' && !!attrs && typeof attrs.fid === 'number';
|
|
405
|
-
}
|
|
406
|
-
trivial(node) {
|
|
407
|
-
var limit = 4;
|
|
408
|
-
if (node && typeof node.e === 'number' && typeof node.s === 'number' && node.e - node.s < limit) return true;else return false;
|
|
409
|
-
}
|
|
410
|
-
shouldIgnoreEvent(event, target) {
|
|
411
|
-
var origin = this.evtOrigin(event.target, target);
|
|
412
|
-
if (event.type in this.ignoredEvents.global) return true;
|
|
413
|
-
if (!!this.ignoredEvents[origin] && this.ignoredEvents[origin].ignoreAll) return true;
|
|
414
|
-
if (!!this.ignoredEvents[origin] && event.type in this.ignoredEvents[origin]) return true;
|
|
415
|
-
return false;
|
|
411
|
+
function trivial(node) {
|
|
412
|
+
const limit = 4;
|
|
413
|
+
if (node && typeof node.e === 'number' && typeof node.s === 'number' && node.e - node.s < limit) return true;else return false;
|
|
414
|
+
}
|
|
416
415
|
}
|
|
417
416
|
}
|
|
418
417
|
exports.Aggregate = Aggregate;
|
|
@@ -3,13 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.START = exports.
|
|
7
|
-
var _config = require("../../common/config/config");
|
|
6
|
+
exports.START = exports.RESOURCE = exports.PUSH_STATE = exports.FN_START = exports.FN_END = exports.FEATURE_NAME = exports.END = exports.BST_TIMER = exports.BST_RESOURCE = void 0;
|
|
8
7
|
var _features = require("../../loaders/features/features");
|
|
9
8
|
const FEATURE_NAME = _features.FEATURE_NAMES.sessionTrace;
|
|
10
9
|
exports.FEATURE_NAME = FEATURE_NAME;
|
|
11
|
-
const RESOURCE_TIMING_BUFFER_FULL = 'resourcetimingbufferfull';
|
|
12
|
-
exports.RESOURCE_TIMING_BUFFER_FULL = RESOURCE_TIMING_BUFFER_FULL;
|
|
13
10
|
const BST_RESOURCE = 'bstResource';
|
|
14
11
|
exports.BST_RESOURCE = BST_RESOURCE;
|
|
15
12
|
const RESOURCE = 'resource';
|
|
@@ -25,8 +22,4 @@ exports.FN_END = FN_END;
|
|
|
25
22
|
const BST_TIMER = 'bstTimer';
|
|
26
23
|
exports.BST_TIMER = BST_TIMER;
|
|
27
24
|
const PUSH_STATE = 'pushState';
|
|
28
|
-
exports.PUSH_STATE = PUSH_STATE;
|
|
29
|
-
const ORIG_EVENT = _config.originals.EV;
|
|
30
|
-
exports.ORIG_EVENT = ORIG_EVENT;
|
|
31
|
-
const ADD_EVENT_LISTENER = 'addEventListener';
|
|
32
|
-
exports.ADD_EVENT_LISTENER = ADD_EVENT_LISTENER;
|
|
25
|
+
exports.PUSH_STATE = PUSH_STATE;
|
|
@@ -6,8 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.Instrument = void 0;
|
|
7
7
|
var _handle = require("../../../common/event-emitter/handle");
|
|
8
8
|
var _wrap = require("../../../common/wrap");
|
|
9
|
-
var _supportsPerformanceObserver = require("../../../common/window/supports-performance-observer");
|
|
10
|
-
var _eventListenerOpts = require("../../../common/event-listener/event-listener-opts");
|
|
11
9
|
var _now = require("../../../common/timing/now");
|
|
12
10
|
var _instrumentBase = require("../../utils/instrument-base");
|
|
13
11
|
var CONSTANTS = _interopRequireWildcard(require("../constants"));
|
|
@@ -22,19 +20,15 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
22
20
|
|
|
23
21
|
const {
|
|
24
22
|
BST_RESOURCE,
|
|
23
|
+
RESOURCE,
|
|
25
24
|
BST_TIMER,
|
|
25
|
+
START,
|
|
26
26
|
END,
|
|
27
27
|
FEATURE_NAME,
|
|
28
28
|
FN_END,
|
|
29
29
|
FN_START,
|
|
30
|
-
|
|
31
|
-
PUSH_STATE,
|
|
32
|
-
RESOURCE,
|
|
33
|
-
RESOURCE_TIMING_BUFFER_FULL,
|
|
34
|
-
START,
|
|
35
|
-
ORIG_EVENT: origEvent
|
|
30
|
+
PUSH_STATE
|
|
36
31
|
} = CONSTANTS;
|
|
37
|
-
const CRT = 'clearResourceTimings';
|
|
38
32
|
class Instrument extends _instrumentBase.InstrumentBase {
|
|
39
33
|
static featureName = FEATURE_NAME;
|
|
40
34
|
constructor(agentIdentifier, aggregator) {
|
|
@@ -46,20 +40,14 @@ class Instrument extends _instrumentBase.InstrumentBase {
|
|
|
46
40
|
this.timerEE = (0, _wrap.wrapTimer)(thisInstrumentEE);
|
|
47
41
|
this.rafEE = (0, _wrap.wrapRaf)(thisInstrumentEE);
|
|
48
42
|
(0, _wrap.wrapHistory)(thisInstrumentEE);
|
|
49
|
-
(0, _wrap.wrapEvents)(thisInstrumentEE);
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (evt instanceof origEvent) {
|
|
53
|
-
this.bstStart = (0, _now.now)();
|
|
54
|
-
}
|
|
43
|
+
this.eventsEE = (0, _wrap.wrapEvents)(thisInstrumentEE);
|
|
44
|
+
this.eventsEE.on(FN_START, function (args, target) {
|
|
45
|
+
this.bstStart = (0, _now.now)();
|
|
55
46
|
});
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
// When ajax is disabled, this may fail without making ajax a dependency of session_trace
|
|
61
|
-
(0, _handle.handle)('bst', [evt, target, this.bstStart, (0, _now.now)()], undefined, _features.FEATURE_NAMES.sessionTrace, thisInstrumentEE);
|
|
62
|
-
}
|
|
47
|
+
this.eventsEE.on(FN_END, function (args, target) {
|
|
48
|
+
// ISSUE: when target is XMLHttpRequest, nr@context should have params so we can calculate event origin
|
|
49
|
+
// When ajax is disabled, this may fail without making ajax a dependency of session_trace
|
|
50
|
+
(0, _handle.handle)('bst', [args[0], target, this.bstStart, (0, _now.now)()], undefined, _features.FEATURE_NAMES.sessionTrace, thisInstrumentEE);
|
|
63
51
|
});
|
|
64
52
|
this.timerEE.on(FN_START, function (args, obj, type) {
|
|
65
53
|
this.bstStart = (0, _now.now)();
|
|
@@ -81,54 +69,24 @@ class Instrument extends _instrumentBase.InstrumentBase {
|
|
|
81
69
|
thisInstrumentEE.on(PUSH_STATE + END, function (args) {
|
|
82
70
|
(0, _handle.handle)('bstHist', [location.pathname + location.hash, this.startPath, this.time], undefined, _features.FEATURE_NAMES.sessionTrace, thisInstrumentEE);
|
|
83
71
|
});
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
} else {
|
|
89
|
-
// collect resource timings once when buffer is full
|
|
90
|
-
if (window.performance[CRT] && window.performance[ADD_EVENT_LISTENER]) {
|
|
91
|
-
window.performance.addEventListener(RESOURCE_TIMING_BUFFER_FULL, this.onResourceTimingBufferFull, (0, _eventListenerOpts.eventListenerOpts)(false));
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
function observeResourceTimings() {
|
|
95
|
-
var observer = new PerformanceObserver((list, observer) => {
|
|
72
|
+
let observer;
|
|
73
|
+
try {
|
|
74
|
+
// Capture initial resources and watch for future ones. Don't defer this given there's a default cap on the number of buffered entries.
|
|
75
|
+
observer = new PerformanceObserver(list => {
|
|
96
76
|
// eslint-disable-line no-undef
|
|
97
|
-
|
|
77
|
+
const entries = list.getEntries();
|
|
98
78
|
(0, _handle.handle)(BST_RESOURCE, [entries], undefined, _features.FEATURE_NAMES.sessionTrace, thisInstrumentEE);
|
|
99
79
|
});
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
document.addEventListener('scroll', this.noOp, (0, _eventListenerOpts.eventListenerOpts)(false));
|
|
109
|
-
document.addEventListener('keypress', this.noOp, (0, _eventListenerOpts.eventListenerOpts)(false));
|
|
110
|
-
document.addEventListener('click', this.noOp, (0, _eventListenerOpts.eventListenerOpts)(false));
|
|
111
|
-
this.abortHandler = this.#abort;
|
|
112
|
-
this.importAggregator();
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/** Restoration and resource release tasks to be done if Session trace loader is being aborted. Unwind changes to globals. */
|
|
116
|
-
#abort() {
|
|
117
|
-
window.performance.removeEventListener(RESOURCE_TIMING_BUFFER_FULL, this.onResourceTimingBufferFull, false);
|
|
118
|
-
// The doc interaction noOp listeners are harmless--cannot buffer data into EE.
|
|
119
|
-
this.abortHandler = undefined; // weakly allow this abort op to run only once
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
noOp(e) {/* no-op */}
|
|
123
|
-
onResourceTimingBufferFull(evt) {
|
|
124
|
-
(0, _handle.handle)(BST_RESOURCE, [window.performance.getEntriesByType(RESOURCE)], undefined, _features.FEATURE_NAMES.sessionTrace, this.ee);
|
|
125
|
-
|
|
126
|
-
// stop recording once buffer is full
|
|
127
|
-
if (window.performance[CRT]) {
|
|
128
|
-
try {
|
|
129
|
-
window.performance.removeEventListener(RESOURCE_TIMING_BUFFER_FULL, this.onResourceTimingBufferFull, false);
|
|
130
|
-
} catch (e) {}
|
|
80
|
+
observer.observe({
|
|
81
|
+
type: RESOURCE,
|
|
82
|
+
buffered: true
|
|
83
|
+
});
|
|
84
|
+
} catch (e) {
|
|
85
|
+
// Per NEWRELIC-8525, we don't have a fallback for capturing resources for older versions that don't support PO at this time.
|
|
131
86
|
}
|
|
87
|
+
this.importAggregator({
|
|
88
|
+
resourceObserver: observer
|
|
89
|
+
});
|
|
132
90
|
}
|
|
133
91
|
}
|
|
134
92
|
exports.Instrument = Instrument;
|