@newrelic/browser-agent 1.252.0 → 1.253.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 +18 -0
- package/README.md +6 -6
- package/dist/cjs/cdn/experimental.js +6 -2
- 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/constants/env.cdn.js +1 -1
- package/dist/cjs/common/constants/env.npm.js +1 -1
- package/dist/cjs/common/context/observation-context-manager.js +56 -0
- package/dist/cjs/common/event-emitter/contextual-ee.js +12 -9
- package/dist/cjs/common/session/constants.js +2 -1
- package/dist/cjs/common/session/session-entity.js +3 -1
- package/dist/cjs/common/timing/nav-timing.js +8 -3
- package/dist/cjs/common/timing/now.js +1 -1
- package/dist/cjs/common/util/feature-flags.js +1 -1
- package/dist/cjs/common/wrap/index.js +0 -7
- package/dist/cjs/common/wrap/wrap-events.js +2 -2
- package/dist/cjs/common/wrap/wrap-fetch.js +2 -1
- package/dist/cjs/common/wrap/wrap-function.js +5 -7
- package/dist/cjs/common/wrap/wrap-promise.js +2 -1
- package/dist/cjs/features/ajax/aggregate/index.js +34 -16
- package/dist/cjs/features/jserrors/aggregate/index.js +77 -66
- package/dist/cjs/features/page_view_event/aggregate/index.js +1 -1
- package/dist/cjs/features/page_view_event/aggregate/initialized-features.js +1 -0
- package/dist/cjs/features/session_replay/aggregate/index.js +96 -94
- 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/recorder.js +5 -4
- package/dist/cjs/features/session_replay/shared/stylesheet-evaluator.js +8 -7
- package/dist/cjs/features/session_replay/shared/utils.js +26 -0
- 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 +263 -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 +4 -4
- package/dist/cjs/features/utils/agent-session.js +2 -1
- package/dist/cjs/features/utils/instrument-base.js +6 -9
- package/dist/cjs/features/utils/lazy-feature-loader.js +2 -0
- package/dist/cjs/loaders/agent-base.js +18 -3
- package/dist/cjs/loaders/agent.js +15 -18
- package/dist/cjs/loaders/api/api-methods.js +9 -0
- package/dist/cjs/loaders/api/api.js +17 -18
- package/dist/cjs/loaders/configure/configure.js +5 -2
- 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/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/constants/env.cdn.js +1 -1
- package/dist/esm/common/constants/env.npm.js +1 -1
- package/dist/esm/common/context/observation-context-manager.js +49 -0
- package/dist/esm/common/event-emitter/contextual-ee.js +12 -9
- package/dist/esm/common/session/constants.js +1 -0
- package/dist/esm/common/session/session-entity.js +3 -1
- package/dist/esm/common/timing/nav-timing.js +8 -3
- package/dist/esm/common/timing/now.js +1 -1
- package/dist/esm/common/util/feature-flags.js +1 -1
- package/dist/esm/common/wrap/index.js +1 -2
- package/dist/esm/common/wrap/wrap-events.js +3 -3
- package/dist/esm/common/wrap/wrap-fetch.js +3 -2
- package/dist/esm/common/wrap/wrap-function.js +4 -5
- package/dist/esm/common/wrap/wrap-promise.js +3 -2
- package/dist/esm/features/ajax/aggregate/index.js +36 -18
- package/dist/esm/features/jserrors/aggregate/index.js +77 -66
- package/dist/esm/features/page_view_event/aggregate/index.js +1 -1
- package/dist/esm/features/page_view_event/aggregate/initialized-features.js +1 -0
- package/dist/esm/features/session_replay/aggregate/index.js +97 -95
- 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/recorder.js +5 -4
- package/dist/esm/features/session_replay/shared/stylesheet-evaluator.js +8 -7
- package/dist/esm/features/session_replay/shared/utils.js +17 -0
- 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 +256 -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 +4 -4
- package/dist/esm/features/utils/agent-session.js +2 -1
- package/dist/esm/features/utils/instrument-base.js +7 -10
- package/dist/esm/features/utils/lazy-feature-loader.js +2 -0
- package/dist/esm/loaders/agent-base.js +18 -3
- package/dist/esm/loaders/agent.js +15 -18
- package/dist/esm/loaders/api/api-methods.js +3 -0
- package/dist/esm/loaders/api/api.js +17 -17
- package/dist/esm/loaders/configure/configure.js +5 -2
- 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/context/event-context.d.ts.map +1 -0
- package/dist/types/common/context/observation-context-manager.d.ts +28 -0
- package/dist/types/common/context/observation-context-manager.d.ts.map +1 -0
- package/dist/types/common/event-emitter/contextual-ee.d.ts +2 -2
- package/dist/types/common/event-emitter/contextual-ee.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/session/session-entity.d.ts +0 -1
- package/dist/types/common/session/session-entity.d.ts.map +1 -1
- package/dist/types/common/timing/nav-timing.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/common/wrap/wrap-fetch.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-function.d.ts +0 -1
- package/dist/types/common/wrap/wrap-function.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-promise.d.ts.map +1 -1
- 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/page_view_event/aggregate/initialized-features.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/recorder.d.ts.map +1 -1
- package/dist/types/features/session_replay/shared/stylesheet-evaluator.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 +36 -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.map +1 -1
- package/dist/types/features/utils/agent-session.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 +3 -0
- package/dist/types/loaders/api/api-methods.d.ts.map +1 -0
- package/dist/types/loaders/api/api.d.ts +3 -6
- 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/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/spa.js +3 -1
- package/src/common/aggregate/aggregator.js +2 -11
- package/src/common/config/state/init.js +3 -1
- package/src/common/context/observation-context-manager.js +55 -0
- package/src/common/event-emitter/contextual-ee.js +20 -10
- package/src/common/session/constants.js +1 -0
- package/src/common/session/session-entity.js +3 -1
- package/src/common/timing/nav-timing.js +7 -3
- package/src/common/timing/now.js +1 -1
- package/src/common/util/feature-flags.js +1 -1
- package/src/common/wrap/index.js +1 -2
- package/src/common/wrap/wrap-events.js +3 -3
- package/src/common/wrap/wrap-fetch.js +3 -2
- package/src/common/wrap/wrap-function.js +4 -6
- package/src/common/wrap/wrap-promise.js +3 -2
- package/src/features/ajax/aggregate/index.js +36 -18
- package/src/features/jserrors/aggregate/index.js +70 -73
- package/src/features/page_view_event/aggregate/index.js +1 -1
- package/src/features/page_view_event/aggregate/initialized-features.js +1 -0
- package/src/features/session_replay/aggregate/index.js +92 -95
- 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/recorder.js +5 -4
- package/src/features/session_replay/shared/stylesheet-evaluator.js +8 -7
- package/src/features/session_replay/shared/utils.js +19 -0
- 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 +254 -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 +5 -4
- package/src/features/utils/agent-session.js +2 -1
- package/src/features/utils/instrument-base.js +7 -10
- package/src/features/utils/lazy-feature-loader.js +2 -0
- package/src/loaders/agent-base.js +18 -3
- package/src/loaders/agent.js +18 -17
- package/src/loaders/api/api-methods.js +12 -0
- package/src/loaders/api/api.js +17 -28
- package/src/loaders/configure/configure.js +4 -1
- 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/esm/common/wrap/wrap-raf.js +0 -48
- package/dist/types/common/event-emitter/event-context.d.ts.map +0 -1
- package/dist/types/common/wrap/wrap-raf.d.ts +0 -16
- package/dist/types/common/wrap/wrap-raf.d.ts.map +0 -1
- package/src/common/wrap/wrap-raf.js +0 -52
- /package/dist/cjs/common/{event-emitter → context}/event-context.js +0 -0
- /package/dist/esm/common/{event-emitter → context}/event-context.js +0 -0
- /package/dist/types/common/{event-emitter → context}/event-context.d.ts +0 -0
- /package/src/common/{event-emitter → context}/event-context.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,24 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.253.0](https://github.com/newrelic/newrelic-browser-agent/compare/v1.252.1...v1.253.0) (2024-03-13)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Apply deny list to ajax metrics ([#898](https://github.com/newrelic/newrelic-browser-agent/issues/898)) ([a5c2adc](https://github.com/newrelic/newrelic-browser-agent/commit/a5c2adc0ecbe322ea9a9dcdf1ed3b072c1212415))
|
|
12
|
+
* Isolate observation context per agent ([#903](https://github.com/newrelic/newrelic-browser-agent/issues/903)) ([85887c8](https://github.com/newrelic/newrelic-browser-agent/commit/85887c8e7f4241076daeeda75077e6ee710a3d00))
|
|
13
|
+
* Preload the Session Replay recorder when properly configured ([#893](https://github.com/newrelic/newrelic-browser-agent/issues/893)) ([bc5ebb5](https://github.com/newrelic/newrelic-browser-agent/commit/bc5ebb5cb255fda7f2c30d5053b5a980a423c2b1))
|
|
14
|
+
* Soft Navigations trial ([#808](https://github.com/newrelic/newrelic-browser-agent/issues/808)) ([7fcb627](https://github.com/newrelic/newrelic-browser-agent/commit/7fcb62791ad932cbd3b9f16a72277b42bca9a75f))
|
|
15
|
+
|
|
16
|
+
## [1.252.1](https://github.com/newrelic/newrelic-browser-agent/compare/v1.252.0...v1.252.1) (2024-02-29)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* Fix webpack imports in npm package ([#905](https://github.com/newrelic/newrelic-browser-agent/issues/905)) ([35810a8](https://github.com/newrelic/newrelic-browser-agent/commit/35810a895b7f61ab60ea5c24adfa49c4a3956191))
|
|
22
|
+
* Page load after session timeouts don't start new session ([#899](https://github.com/newrelic/newrelic-browser-agent/issues/899)) ([5c952a0](https://github.com/newrelic/newrelic-browser-agent/commit/5c952a0a212922d84dfd7e8eb388fdbd566b6c00))
|
|
23
|
+
|
|
6
24
|
## [1.252.0](https://github.com/newrelic/newrelic-browser-agent/compare/v1.251.1...v1.252.0) (2024-02-12)
|
|
7
25
|
|
|
8
26
|
|
package/README.md
CHANGED
|
@@ -24,16 +24,16 @@ $ npm install @newrelic/browser-agent --save
|
|
|
24
24
|
$ yarn add @newrelic/browser-agent
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
## Creating an app in New Relic
|
|
27
|
+
## Creating an app in New Relic
|
|
28
28
|
|
|
29
|
-
Before instrumenting your app using the NPM package, a Browser App should be configured in New Relic
|
|
29
|
+
Before instrumenting your app using the NPM package, a Browser App should be configured in New Relic. This may be done with or without a corresponding APM agent. Once the app has been created, the Copy/Paste JavaScript code on the app's *Application settings* page will contain the configuration values needed to define options when instantiating the agent via the NPM package.
|
|
30
30
|
|
|
31
31
|
1. If a browser app does not already exist, create one:
|
|
32
|
-
- From the *New Relic
|
|
32
|
+
- From the *New Relic* navigation panel, click *Add Data*.
|
|
33
33
|
- Select the *Browser monitoring* data source.
|
|
34
34
|
- Choose the *APM* or *Copy/Paste* method.
|
|
35
35
|
- Select or name your app and click *Enable*.
|
|
36
|
-
2. From the navigation panel, select *Browser* to view
|
|
36
|
+
2. From the navigation panel, select *Browser* to view browser apps.
|
|
37
37
|
3. Select the desired app and navigate to the *Application settings* page.
|
|
38
38
|
4. From the *Copy/Paste JavaScript* box, copy the configuration values assigned to the `NREUM` object (`init`, `info`, and `loader_config`). You will use these configuration values when instantiating the agent using the NPM package.
|
|
39
39
|
|
|
@@ -41,7 +41,7 @@ Before instrumenting your app using the NPM package, a Browser App should be con
|
|
|
41
41
|
|
|
42
42
|
For best results, import and instantiate the `BrowserAgent` class as close to the top of the `head` element of your app's HTML output as possible. The specific location and method will vary based on your application's architecture or framework. See [Library Support](#library-support) for more information.
|
|
43
43
|
|
|
44
|
-
Populate the `options` parameter using configuration values found in the the *Copy/Paste JavaScript* box in your browser app's *Application settings* page in New Relic
|
|
44
|
+
Populate the `options` parameter using configuration values found in the the *Copy/Paste JavaScript* box in your browser app's *Application settings* page in New Relic.
|
|
45
45
|
|
|
46
46
|
```javascript
|
|
47
47
|
import { BrowserAgent } from '@newrelic/browser-agent/loaders/browser-agent'
|
|
@@ -137,7 +137,7 @@ The examples above use the `Agent` class at their core, which is ideal for most
|
|
|
137
137
|
|
|
138
138
|
Using the `MicroAgent` class, it is possible to skip the "auto" instrumentation phases of the other loader types, and provide a *very small* agent designed for capturing data in a controlled manner via the API interfaces. The `MicroAgent` captures a distinct `PageView` event when instantiated, and additional `PageAction` and `JavaScriptError` events may be captured by calling the `noticeError` and `addPageAction` methods.
|
|
139
139
|
|
|
140
|
-
Because it does not wrap the page-level globals in the same way as the base `Agent` class, the `MicroAgent` is not only smaller but can easily be instantiated multiple times on a single page with low overhead, with each instance configured to report to a different Browser App entity in New Relic
|
|
140
|
+
Because it does not wrap the page-level globals in the same way as the base `Agent` class, the `MicroAgent` is not only smaller but can easily be instantiated multiple times on a single page with low overhead, with each instance configured to report to a different Browser App entity in New Relic if desired. This accommodates specialized use cases, such as segmented UI designs (e.g., the micro front-end pattern) or applications requiring subsets of manually-handled data to be reported to different application entities.
|
|
141
141
|
|
|
142
142
|
The example below illustrates how to instantiate and interact with two separate `MicroAgent` instances on one page.
|
|
143
143
|
|
|
@@ -8,7 +8,7 @@ var _instrument4 = require("../features/jserrors/instrument");
|
|
|
8
8
|
var _instrument5 = require("../features/ajax/instrument");
|
|
9
9
|
var _instrument6 = require("../features/session_trace/instrument");
|
|
10
10
|
var _instrument7 = require("../features/session_replay/instrument");
|
|
11
|
-
var _instrument8 = require("../features/
|
|
11
|
+
var _instrument8 = require("../features/soft_navigations/instrument");
|
|
12
12
|
var _instrument9 = require("../features/page_action/instrument");
|
|
13
13
|
/*
|
|
14
14
|
* Copyright 2023 New Relic Corporation. All rights reserved.
|
|
@@ -21,7 +21,11 @@ var _instrument9 = require("../features/page_action/instrument");
|
|
|
21
21
|
* It is not production ready, and is not intended to be imported or implemented in any build of the browser agent
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
+
// import { Instrument as InstrumentSpa } from '../features/spa/instrument'
|
|
25
|
+
|
|
24
26
|
new _agent.Agent({
|
|
25
|
-
features: [_instrument5.Instrument, _instrument.Instrument, _instrument2.Instrument, _instrument6.Instrument, _instrument7.Instrument, _instrument3.Instrument, _instrument9.Instrument, _instrument4.Instrument,
|
|
27
|
+
features: [_instrument5.Instrument, _instrument.Instrument, _instrument2.Instrument, _instrument6.Instrument, _instrument7.Instrument, _instrument3.Instrument, _instrument9.Instrument, _instrument4.Instrument,
|
|
28
|
+
// InstrumentSpa,
|
|
29
|
+
_instrument8.Instrument],
|
|
26
30
|
loaderType: 'experimental'
|
|
27
31
|
});
|
package/dist/cjs/cdn/spa.js
CHANGED
|
@@ -8,13 +8,15 @@ var _instrument4 = require("../features/jserrors/instrument");
|
|
|
8
8
|
var _instrument5 = require("../features/ajax/instrument");
|
|
9
9
|
var _instrument6 = require("../features/session_trace/instrument");
|
|
10
10
|
var _instrument7 = require("../features/session_replay/instrument");
|
|
11
|
-
var _instrument8 = require("../features/
|
|
12
|
-
var _instrument9 = require("../features/
|
|
11
|
+
var _instrument8 = require("../features/soft_navigations/instrument");
|
|
12
|
+
var _instrument9 = require("../features/spa/instrument");
|
|
13
|
+
var _instrument10 = require("../features/page_action/instrument");
|
|
13
14
|
/**
|
|
14
15
|
* @file Creates a "SPA" agent loader bundle composed of the core agent and all available feature modules.
|
|
15
16
|
*/
|
|
16
17
|
|
|
17
18
|
new _agent.Agent({
|
|
18
|
-
features: [_instrument5.Instrument, _instrument.Instrument, _instrument2.Instrument, _instrument6.Instrument, _instrument7.Instrument, _instrument3.Instrument,
|
|
19
|
+
features: [_instrument5.Instrument, _instrument.Instrument, _instrument2.Instrument, _instrument6.Instrument, _instrument7.Instrument, _instrument3.Instrument, _instrument10.Instrument, _instrument4.Instrument, _instrument8.Instrument, _instrument9.Instrument // either the softnav or the old spa will be used (not both), but we still need to pack both to avoid dynamic import for instrument files
|
|
20
|
+
],
|
|
19
21
|
loaderType: 'spa'
|
|
20
22
|
});
|
|
@@ -83,7 +83,7 @@ class Aggregator extends _sharedContext.SharedContext {
|
|
|
83
83
|
var hasData = false;
|
|
84
84
|
for (var i = 0; i < types.length; i++) {
|
|
85
85
|
type = types[i];
|
|
86
|
-
results[type] =
|
|
86
|
+
results[type] = Object.values(this.aggregatedData[type] || {});
|
|
87
87
|
if (results[type].length) hasData = true;
|
|
88
88
|
delete this.aggregatedData[type];
|
|
89
89
|
}
|
|
@@ -158,11 +158,4 @@ function createMetricObject(value) {
|
|
|
158
158
|
sos: value * value,
|
|
159
159
|
c: 1
|
|
160
160
|
};
|
|
161
|
-
}
|
|
162
|
-
function toArray(obj) {
|
|
163
|
-
if (typeof obj !== 'object') return [];
|
|
164
|
-
return (0, _mapOwn.mapOwn)(obj, getValue);
|
|
165
|
-
}
|
|
166
|
-
function getValue(key, value) {
|
|
167
|
-
return value;
|
|
168
161
|
}
|
|
@@ -106,6 +106,8 @@ const model = () => {
|
|
|
106
106
|
autoStart: true,
|
|
107
107
|
enabled: false,
|
|
108
108
|
harvestTimeSeconds: 60,
|
|
109
|
+
preload: false,
|
|
110
|
+
// if true, enables the agent to load rrweb immediately instead of waiting to do so after the window.load event
|
|
109
111
|
sampling_rate: 10,
|
|
110
112
|
// float from 0 - 100
|
|
111
113
|
error_sampling_rate: 100,
|
|
@@ -158,6 +160,11 @@ const model = () => {
|
|
|
158
160
|
enabled: true,
|
|
159
161
|
harvestTimeSeconds: 10,
|
|
160
162
|
autoStart: true
|
|
163
|
+
},
|
|
164
|
+
soft_navigations: {
|
|
165
|
+
enabled: true,
|
|
166
|
+
harvestTimeSeconds: 10,
|
|
167
|
+
autoStart: true
|
|
161
168
|
}
|
|
162
169
|
};
|
|
163
170
|
};
|
|
@@ -12,7 +12,7 @@ exports.VERSION = exports.RRWEB_VERSION = exports.DIST_METHOD = exports.BUILD_EN
|
|
|
12
12
|
/**
|
|
13
13
|
* Exposes the version of the agent
|
|
14
14
|
*/
|
|
15
|
-
const VERSION = exports.VERSION = "1.
|
|
15
|
+
const VERSION = exports.VERSION = "1.253.0";
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Exposes the build type of the agent
|
|
@@ -12,7 +12,7 @@ exports.VERSION = exports.RRWEB_VERSION = exports.DIST_METHOD = exports.BUILD_EN
|
|
|
12
12
|
/**
|
|
13
13
|
* Exposes the version of the agent
|
|
14
14
|
*/
|
|
15
|
-
const VERSION = exports.VERSION = "1.
|
|
15
|
+
const VERSION = exports.VERSION = "1.253.0";
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Exposes the build type of the agent
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ObservationContextManager = void 0;
|
|
7
|
+
var _nreum = require("../window/nreum");
|
|
8
|
+
var _bundleId = require("../ids/bundle-id");
|
|
9
|
+
var _eventContext = require("./event-context");
|
|
10
|
+
class ObservationContextManager {
|
|
11
|
+
// These IDs are provided for backwards compatibility until the agent is fully updated
|
|
12
|
+
// use the observation context class.
|
|
13
|
+
|
|
14
|
+
static contextId = "nr@context:".concat(_bundleId.bundleId);
|
|
15
|
+
static contextOriginalId = "nr@original:".concat(_bundleId.bundleId);
|
|
16
|
+
static contextWrappedId = "nr@wrapped:".concat(ObservationContextManager.contextId);
|
|
17
|
+
static getObservationContextByAgentIdentifier(agentIdentifier) {
|
|
18
|
+
const nr = (0, _nreum.gosNREUM)();
|
|
19
|
+
return Object.keys(nr?.initializedAgents || {}).indexOf(agentIdentifier) > -1 ? nr.initializedAgents[agentIdentifier].observationContext : undefined;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @type {WeakMap<WeakKey, {[key: string]: unknown}>}
|
|
24
|
+
*/
|
|
25
|
+
#observationContext = new WeakMap();
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Returns the observation context tied to the supplied construct. If there has been
|
|
29
|
+
* no observation construct created, an empty object is created and stored as the current
|
|
30
|
+
* context.
|
|
31
|
+
* @param key {unknown} The construct being observed such as an XHR instance
|
|
32
|
+
* @return {EventContext} An object of key:value pairs to track as
|
|
33
|
+
* part of the observation
|
|
34
|
+
*/
|
|
35
|
+
getCreateContext(key) {
|
|
36
|
+
if (!this.#observationContext.has(key)) {
|
|
37
|
+
this.#observationContext.set(key, new _eventContext.EventContext());
|
|
38
|
+
}
|
|
39
|
+
return this.#observationContext.get(key);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Set the observation context for an observed construct. If values of the context
|
|
44
|
+
* need to be updated, they should be done so directly on the context. This function
|
|
45
|
+
* is only for the setting of a whole context.
|
|
46
|
+
* @param key {unknown} The construct being observed such as an XHR instance
|
|
47
|
+
* @param value {EventContext} An object of key:value pairs to track as
|
|
48
|
+
* part of the observation
|
|
49
|
+
* @return {EventContext} The updated observation context
|
|
50
|
+
*/
|
|
51
|
+
setContext(key, value) {
|
|
52
|
+
this.#observationContext.set(key, value);
|
|
53
|
+
return this.#observationContext.get(key);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.ObservationContextManager = ObservationContextManager;
|
|
@@ -3,19 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.ee =
|
|
6
|
+
exports.ee = void 0;
|
|
7
7
|
var _nreum = require("../window/nreum");
|
|
8
8
|
var _getOrSet = require("../util/get-or-set");
|
|
9
9
|
var _config = require("../config/config");
|
|
10
|
-
var _eventContext = require("
|
|
11
|
-
var
|
|
10
|
+
var _eventContext = require("../context/event-context");
|
|
11
|
+
var _observationContextManager = require("../context/observation-context-manager");
|
|
12
12
|
/*
|
|
13
13
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
14
14
|
* SPDX-License-Identifier: Apache-2.0
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
// create a unique id to store event context data for the current agent bundle
|
|
18
|
-
const contextId = exports.contextId = "nr@context:".concat(_bundleId.bundleId);
|
|
19
17
|
// create global emitter instance that can be shared among bundles
|
|
20
18
|
const globalInstance = exports.ee = ee(undefined, 'globalEE');
|
|
21
19
|
|
|
@@ -53,16 +51,17 @@ function ee(old, debugId) {
|
|
|
53
51
|
aborted: false,
|
|
54
52
|
isBuffering,
|
|
55
53
|
debugId,
|
|
56
|
-
backlog: isolatedBacklog ? {} : old && typeof old.backlog === 'object' ? old.backlog : {}
|
|
54
|
+
backlog: isolatedBacklog ? {} : old && typeof old.backlog === 'object' ? old.backlog : {},
|
|
55
|
+
observationContextManager: null
|
|
57
56
|
};
|
|
58
57
|
return emitter;
|
|
59
58
|
function context(contextOrStore) {
|
|
60
59
|
if (contextOrStore && contextOrStore instanceof _eventContext.EventContext) {
|
|
61
60
|
return contextOrStore;
|
|
62
61
|
} else if (contextOrStore) {
|
|
63
|
-
return (0, _getOrSet.getOrSet)(contextOrStore, contextId, () => new _eventContext.EventContext(contextId));
|
|
62
|
+
return (0, _getOrSet.getOrSet)(contextOrStore, _observationContextManager.ObservationContextManager.contextId, () => emitter.observationContextManager ? emitter.observationContextManager.getCreateContext(contextOrStore) : new _eventContext.EventContext(_observationContextManager.ObservationContextManager.contextId));
|
|
64
63
|
} else {
|
|
65
|
-
return new _eventContext.EventContext(contextId);
|
|
64
|
+
return emitter.observationContextManager ? emitter.observationContextManager.getCreateContext({}) : new _eventContext.EventContext(_observationContextManager.ObservationContextManager.contextId);
|
|
66
65
|
}
|
|
67
66
|
}
|
|
68
67
|
function emit(type, args, contextOrStore, force, bubble) {
|
|
@@ -106,7 +105,11 @@ function ee(old, debugId) {
|
|
|
106
105
|
return handlers[type] || [];
|
|
107
106
|
}
|
|
108
107
|
function getOrCreate(name) {
|
|
109
|
-
|
|
108
|
+
const newEventEmitter = emitters[name] = emitters[name] || ee(emitter, name);
|
|
109
|
+
if (!newEventEmitter.observationContextManager && emitter.observationContextManager) {
|
|
110
|
+
newEventEmitter.observationContextManager = emitter.observationContextManager;
|
|
111
|
+
}
|
|
112
|
+
return newEventEmitter;
|
|
110
113
|
}
|
|
111
114
|
function bufferEventsByGroup(types, group) {
|
|
112
115
|
const eventBuffer = getBuffer();
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.SESSION_EVENT_TYPES = exports.SESSION_EVENTS = exports.PREFIX = exports.MODE = exports.DEFAULT_INACTIVE_MS = exports.DEFAULT_EXPIRES_MS = void 0;
|
|
6
|
+
exports.SESSION_EVENT_TYPES = exports.SESSION_EVENTS = exports.PREFIX = exports.MODE = exports.DEFAULT_KEY = exports.DEFAULT_INACTIVE_MS = exports.DEFAULT_EXPIRES_MS = void 0;
|
|
7
7
|
const PREFIX = exports.PREFIX = 'NRBA';
|
|
8
|
+
const DEFAULT_KEY = exports.DEFAULT_KEY = 'SESSION';
|
|
8
9
|
const DEFAULT_EXPIRES_MS = exports.DEFAULT_EXPIRES_MS = 14400000;
|
|
9
10
|
const DEFAULT_INACTIVE_MS = exports.DEFAULT_INACTIVE_MS = 1800000;
|
|
10
11
|
const SESSION_EVENTS = exports.SESSION_EVENTS = {
|
|
@@ -135,7 +135,9 @@ class SessionEntity {
|
|
|
135
135
|
|
|
136
136
|
// The fact that the session is "new" or pre-existing is used in some places in the agent. Session Replay and Trace
|
|
137
137
|
// can use this info to inform whether to trust a new sampling decision vs continue a previous tracking effort.
|
|
138
|
-
|
|
138
|
+
/* [NR-230914] 02/2024 - the logical OR assignment is used so that isNew remains 'true' if it was already set as such. This fixes the expires and inactive timestamps timing out in localStorage
|
|
139
|
+
while no page for a given domain is in-use and the session resetting upon user returning to the page as part of a fresh session. */
|
|
140
|
+
this.isNew ||= !Object.keys(initialRead).length;
|
|
139
141
|
// if its a "new" session, we write to storage API with the default values. These values may change over the lifespan of the agent run.
|
|
140
142
|
// we can use a modeled object here to help us know and manage what values are being used. -- see "model" above
|
|
141
143
|
if (this.isNew) this.write((0, _configurable.getModeledObject)(this.state, model), true);else this.sync(initialRead);
|
|
@@ -32,7 +32,7 @@ var REQUEST = 'request';
|
|
|
32
32
|
var RESPONSE = 'response';
|
|
33
33
|
var LOAD_EVENT = 'loadEvent';
|
|
34
34
|
var DOM_CONTENT_LOAD_EVENT = 'domContentLoadedEvent';
|
|
35
|
-
|
|
35
|
+
const navTimingValues = exports.navTimingValues = [];
|
|
36
36
|
function getPntType(type) {
|
|
37
37
|
if (typeof type === 'number') return type;
|
|
38
38
|
const types = {
|
|
@@ -78,6 +78,11 @@ function addPN(pn, v) {
|
|
|
78
78
|
handleValue(pn.redirectCount, v, 'rc');
|
|
79
79
|
return v;
|
|
80
80
|
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* By side effect, this modifies 'obj' with a mapping of the 'prop' provided to a 'value', and invalid values are not added.
|
|
84
|
+
* On the other hand, the local navTimingValues array gets the value appended if valid and 'undefined' appended if invalid, regardless.
|
|
85
|
+
*/
|
|
81
86
|
function handleValue(value, obj, prop, isOldApi) {
|
|
82
87
|
/*
|
|
83
88
|
For L2 Timing API, the value will already be a relative-to-previous-document DOMHighResTimeStamp.
|
|
@@ -92,6 +97,6 @@ function handleValue(value, obj, prop, isOldApi) {
|
|
|
92
97
|
}
|
|
93
98
|
value = Math.round(value);
|
|
94
99
|
obj[prop] = value;
|
|
95
|
-
|
|
96
|
-
navTimingValues.push(
|
|
100
|
+
navTimingValues.push(value);
|
|
101
|
+
} else navTimingValues.push(undefined);
|
|
97
102
|
}
|
|
@@ -11,5 +11,5 @@ exports.now = now;
|
|
|
11
11
|
|
|
12
12
|
// This is our own layer around performance.now. It's not strictly necessary, but we keep it in case of future mod-ing of the value for refactor purpose.
|
|
13
13
|
function now() {
|
|
14
|
-
return Math.
|
|
14
|
+
return Math.floor(performance.now());
|
|
15
15
|
}
|
|
@@ -18,7 +18,7 @@ const bucketMap = {
|
|
|
18
18
|
stn: [_features.FEATURE_NAMES.sessionTrace],
|
|
19
19
|
err: [_features.FEATURE_NAMES.jserrors, _features.FEATURE_NAMES.metrics],
|
|
20
20
|
ins: [_features.FEATURE_NAMES.pageAction],
|
|
21
|
-
spa: [_features.FEATURE_NAMES.spa],
|
|
21
|
+
spa: [_features.FEATURE_NAMES.spa, _features.FEATURE_NAMES.softNav],
|
|
22
22
|
sr: [_features.FEATURE_NAMES.sessionReplay, _features.FEATURE_NAMES.sessionTrace]
|
|
23
23
|
};
|
|
24
24
|
const sentIds = new Set();
|
|
@@ -39,12 +39,6 @@ Object.defineProperty(exports, "wrapPromise", {
|
|
|
39
39
|
return _wrapPromise.wrapPromise;
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
|
-
Object.defineProperty(exports, "wrapRaf", {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
get: function () {
|
|
45
|
-
return _wrapRaf.wrapRaf;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
42
|
Object.defineProperty(exports, "wrapTimer", {
|
|
49
43
|
enumerable: true,
|
|
50
44
|
get: function () {
|
|
@@ -63,6 +57,5 @@ var _wrapHistory = require("./wrap-history");
|
|
|
63
57
|
var _wrapJsonp = require("./wrap-jsonp");
|
|
64
58
|
var _wrapMutation = require("./wrap-mutation");
|
|
65
59
|
var _wrapPromise = require("./wrap-promise");
|
|
66
|
-
var _wrapRaf = require("./wrap-raf");
|
|
67
60
|
var _wrapTimer = require("./wrap-timer");
|
|
68
61
|
var _wrapXhr = require("./wrap-xhr");
|
|
@@ -9,6 +9,7 @@ var _contextualEe = require("../event-emitter/contextual-ee");
|
|
|
9
9
|
var _wrapFunction = require("./wrap-function");
|
|
10
10
|
var _getOrSet = require("../util/get-or-set");
|
|
11
11
|
var _runtime = require("../constants/runtime");
|
|
12
|
+
var _observationContextManager = require("../context/observation-context-manager");
|
|
12
13
|
/*
|
|
13
14
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
14
15
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -23,7 +24,6 @@ const wrapped = {};
|
|
|
23
24
|
const XHR = _runtime.globalScope.XMLHttpRequest;
|
|
24
25
|
const ADD_EVENT_LISTENER = 'addEventListener';
|
|
25
26
|
const REMOVE_EVENT_LISTENER = 'removeEventListener';
|
|
26
|
-
const flag = "nr@wrapped:".concat(_contextualEe.contextId);
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* Wraps `addEventListener` and `removeEventListener` on: global scope; the prototype of `XMLHttpRequest`, and
|
|
@@ -52,7 +52,7 @@ function wrapEvents(sharedEE) {
|
|
|
52
52
|
if (originalListener === null || typeof originalListener !== 'function' && typeof originalListener !== 'object') {
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
|
-
var wrapped = (0, _getOrSet.getOrSet)(originalListener,
|
|
55
|
+
var wrapped = (0, _getOrSet.getOrSet)(originalListener, _observationContextManager.ObservationContextManager.contextWrappedId, function () {
|
|
56
56
|
var listener = {
|
|
57
57
|
object: wrapHandleEvent,
|
|
58
58
|
function: originalListener
|
|
@@ -7,6 +7,7 @@ exports.scopedEE = scopedEE;
|
|
|
7
7
|
exports.wrapFetch = wrapFetch;
|
|
8
8
|
var _contextualEe = require("../event-emitter/contextual-ee");
|
|
9
9
|
var _runtime = require("../constants/runtime");
|
|
10
|
+
var _observationContextManager = require("../context/observation-context-manager");
|
|
10
11
|
/*
|
|
11
12
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
12
13
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -78,7 +79,7 @@ function wrapFetch(sharedEE) {
|
|
|
78
79
|
// we are wrapping args in an array so we can preserve the reference
|
|
79
80
|
ee.emit(prefix + 'before-start', [args], ctx);
|
|
80
81
|
var dtPayload;
|
|
81
|
-
if (ctx[
|
|
82
|
+
if (ctx[_observationContextManager.ObservationContextManager.contextId] && ctx[_observationContextManager.ObservationContextManager.contextId].dt) dtPayload = ctx[_observationContextManager.ObservationContextManager.contextId].dt;
|
|
82
83
|
var origPromiseFromFetch = fn.apply(this, args);
|
|
83
84
|
ee.emit(prefix + 'start', [args, dtPayload], origPromiseFromFetch);
|
|
84
85
|
|
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createWrapperWithEmitter = createWrapperWithEmitter;
|
|
7
|
-
exports.
|
|
7
|
+
exports.default = void 0;
|
|
8
8
|
var _contextualEe = require("../event-emitter/contextual-ee");
|
|
9
|
-
var
|
|
9
|
+
var _observationContextManager = require("../context/observation-context-manager");
|
|
10
10
|
/*
|
|
11
11
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
12
12
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -15,8 +15,6 @@ var _bundleId = require("../ids/bundle-id");
|
|
|
15
15
|
* @file Provides helper functions for wrapping functions in various scenarios.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
const flag = exports.flag = "nr@original:".concat(_bundleId.bundleId);
|
|
19
|
-
|
|
20
18
|
/**
|
|
21
19
|
* A convenience alias of `hasOwnProperty`.
|
|
22
20
|
* @type {function}
|
|
@@ -46,7 +44,7 @@ function createWrapperWithEmitter(emitter, always) {
|
|
|
46
44
|
* As a property on a wrapped function, contains the original function.
|
|
47
45
|
* @type {string}
|
|
48
46
|
*/
|
|
49
|
-
wrapFn.flag =
|
|
47
|
+
wrapFn.flag = _observationContextManager.ObservationContextManager.contextOriginalId;
|
|
50
48
|
return wrapFn;
|
|
51
49
|
|
|
52
50
|
/**
|
|
@@ -62,7 +60,7 @@ function createWrapperWithEmitter(emitter, always) {
|
|
|
62
60
|
// Unless fn is both wrappable and unwrapped, return it unchanged.
|
|
63
61
|
if (notWrappable(fn)) return fn;
|
|
64
62
|
if (!prefix) prefix = '';
|
|
65
|
-
nrWrapper[
|
|
63
|
+
nrWrapper[_observationContextManager.ObservationContextManager.contextOriginalId] = fn;
|
|
66
64
|
copy(fn, nrWrapper, emitter);
|
|
67
65
|
return nrWrapper;
|
|
68
66
|
|
|
@@ -216,5 +214,5 @@ function copy(from, to, emitter) {
|
|
|
216
214
|
* @returns {boolean} Whether the passed function is ineligible to be wrapped.
|
|
217
215
|
*/
|
|
218
216
|
function notWrappable(fn) {
|
|
219
|
-
return !(fn && typeof fn === 'function' && fn.apply && !fn[
|
|
217
|
+
return !(fn && typeof fn === 'function' && fn.apply && !fn[_observationContextManager.ObservationContextManager.contextOriginalId]);
|
|
220
218
|
}
|
|
@@ -8,6 +8,7 @@ exports.wrapPromise = wrapPromise;
|
|
|
8
8
|
var _wrapFunction = require("./wrap-function");
|
|
9
9
|
var _contextualEe = require("../event-emitter/contextual-ee");
|
|
10
10
|
var _runtime = require("../constants/runtime");
|
|
11
|
+
var _observationContextManager = require("../context/observation-context-manager");
|
|
11
12
|
/*
|
|
12
13
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
13
14
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -125,7 +126,7 @@ function wrapPromise(sharedEE) {
|
|
|
125
126
|
promiseEE.emit('propagate', [originalThis, true], origFnCallWithThis, false, false);
|
|
126
127
|
return origFnCallWithThis;
|
|
127
128
|
};
|
|
128
|
-
prevPromiseObj.prototype.then[
|
|
129
|
+
prevPromiseObj.prototype.then[_observationContextManager.ObservationContextManager.contextOriginalId] = prevPromiseOrigThen;
|
|
129
130
|
promiseEE.on('executor-start', function (args) {
|
|
130
131
|
args[0] = promiseWrapper(args[0], 'resolve-', this, null, false);
|
|
131
132
|
args[1] = promiseWrapper(args[1], 'resolve-', this, null, false);
|
|
@@ -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
|
|
@@ -50,19 +51,23 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
50
51
|
spaAjaxEvents
|
|
51
52
|
};
|
|
52
53
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
delete spaAjaxEvents[interaction.id];
|
|
57
|
-
});
|
|
58
|
-
ee.on('interactionDiscarded', interaction => {
|
|
54
|
+
|
|
55
|
+
// --- v Used by old spa feature
|
|
56
|
+
ee.on('interactionDone', (interaction, wasSaved) => {
|
|
59
57
|
if (!spaAjaxEvents[interaction.id]) return;
|
|
60
|
-
|
|
61
|
-
//
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
if (!wasSaved) {
|
|
59
|
+
// 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
|
|
60
|
+
spaAjaxEvents[interaction.id].forEach(function (item) {
|
|
61
|
+
ajaxEvents.push(item);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
64
|
delete spaAjaxEvents[interaction.id];
|
|
65
65
|
});
|
|
66
|
+
// --- ^
|
|
67
|
+
// --- v Used by new soft nav
|
|
68
|
+
(0, _registerHandler.registerHandler)('returnAjax', event => ajaxEvents.push(event), this.featureName, this.ee);
|
|
69
|
+
// --- ^
|
|
70
|
+
|
|
66
71
|
const scheduler = new _harvestScheduler.HarvestScheduler('events', {
|
|
67
72
|
onFinished: onEventsHarvestFinished,
|
|
68
73
|
getPayload: prepareHarvest
|
|
@@ -83,16 +88,26 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
83
88
|
} else {
|
|
84
89
|
hash = (0, _stringify.stringify)([params.status, params.host, params.pathname]);
|
|
85
90
|
}
|
|
91
|
+
const shouldCollect = (0, _denyList.shouldCollectEvent)(params);
|
|
92
|
+
const ajaxMetricDenyListEnabled = agentInit.feature_flags?.includes('ajax_metrics_deny_list');
|
|
86
93
|
|
|
87
94
|
// store as metric
|
|
88
|
-
|
|
95
|
+
if (shouldCollect || !ajaxMetricDenyListEnabled) {
|
|
96
|
+
aggregator.store('xhr', hash, params, metrics);
|
|
97
|
+
}
|
|
89
98
|
if (!allAjaxIsEnabled) return;
|
|
90
|
-
if (!
|
|
99
|
+
if (!shouldCollect) {
|
|
91
100
|
if (params.hostname === beacon || proxyBeacon && params.hostname === proxyBeacon) {
|
|
92
101
|
// This doesn't make a distinction if the same-domain request is going to a different port or path...
|
|
93
102
|
(0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['Ajax/Events/Excluded/Agent'], undefined, _features.FEATURE_NAMES.metrics, ee);
|
|
103
|
+
if (ajaxMetricDenyListEnabled) {
|
|
104
|
+
(0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['Ajax/Metrics/Excluded/Agent'], undefined, _features.FEATURE_NAMES.metrics, ee);
|
|
105
|
+
}
|
|
94
106
|
} else {
|
|
95
107
|
(0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['Ajax/Events/Excluded/App'], undefined, _features.FEATURE_NAMES.metrics, ee);
|
|
108
|
+
if (ajaxMetricDenyListEnabled) {
|
|
109
|
+
(0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['Ajax/Metrics/Excluded/App'], undefined, _features.FEATURE_NAMES.metrics, ee);
|
|
110
|
+
}
|
|
96
111
|
}
|
|
97
112
|
return;
|
|
98
113
|
}
|
|
@@ -122,10 +137,13 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
122
137
|
query: this?.parsedOrigin?.search
|
|
123
138
|
});
|
|
124
139
|
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
|
-
|
|
140
|
+
const softNavInUse = Boolean((0, _nreum.getNREUMInitializedAgent)(agentIdentifier)?.features?.[_features.FEATURE_NAMES.softNav]);
|
|
141
|
+
if (softNavInUse) {
|
|
142
|
+
// For newer soft nav (when running), pass the event to it for evaluation -- either part of an interaction or is given back
|
|
143
|
+
(0, _handle.handle)('ajax', [event], undefined, _features.FEATURE_NAMES.softNav, ee);
|
|
144
|
+
} else if (this.spaNode) {
|
|
145
|
+
// For old spa (when running), if the ajax happened inside an interaction, hold it until the interaction finishes
|
|
146
|
+
const interactionId = this.spaNode.interaction.id;
|
|
129
147
|
spaAjaxEvents[interactionId] = spaAjaxEvents[interactionId] || [];
|
|
130
148
|
spaAjaxEvents[interactionId].push(event);
|
|
131
149
|
} else {
|