@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
|
@@ -7,11 +7,17 @@ export const submitData = {};
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Send via JSONP. Do NOT call this function outside of a guaranteed web window environment.
|
|
10
|
-
* @param {
|
|
11
|
-
* @param {string}
|
|
10
|
+
* @param {Object} args - The args
|
|
11
|
+
* @param {string} args.url - The URL to send to
|
|
12
|
+
* @param {string} args.jsonp - The string name of the jsonp cb method
|
|
13
|
+
* @returns {XMLHttpRequest}
|
|
12
14
|
* @returns {Element}
|
|
13
15
|
*/
|
|
14
|
-
submitData.jsonp = function jsonp(
|
|
16
|
+
submitData.jsonp = function jsonp(_ref) {
|
|
17
|
+
let {
|
|
18
|
+
url,
|
|
19
|
+
jsonp
|
|
20
|
+
} = _ref;
|
|
15
21
|
try {
|
|
16
22
|
if (isWorkerScope) {
|
|
17
23
|
try {
|
|
@@ -19,7 +25,9 @@ submitData.jsonp = function jsonp(url, jsonp) {
|
|
|
19
25
|
} catch (e) {
|
|
20
26
|
// for now theres no other way to execute the callback from ingest without jsonp, or unsafe eval / new Function calls
|
|
21
27
|
// future work needs to be conducted to allow ingest to return a more traditional JSON API-like experience for the entitlement flags
|
|
22
|
-
submitData.xhrGet(
|
|
28
|
+
submitData.xhrGet({
|
|
29
|
+
url: url + '&jsonp=' + jsonp
|
|
30
|
+
});
|
|
23
31
|
return false;
|
|
24
32
|
}
|
|
25
33
|
} else {
|
|
@@ -34,19 +42,38 @@ submitData.jsonp = function jsonp(url, jsonp) {
|
|
|
34
42
|
// do nothing
|
|
35
43
|
}
|
|
36
44
|
};
|
|
37
|
-
submitData.xhrGet = function xhrGet(
|
|
38
|
-
|
|
45
|
+
submitData.xhrGet = function xhrGet(_ref2) {
|
|
46
|
+
let {
|
|
47
|
+
url
|
|
48
|
+
} = _ref2;
|
|
49
|
+
return submitData.xhr({
|
|
50
|
+
url,
|
|
51
|
+
sync: false,
|
|
52
|
+
method: 'GET'
|
|
53
|
+
});
|
|
39
54
|
};
|
|
40
55
|
|
|
41
56
|
/**
|
|
42
57
|
* Send via XHR
|
|
43
|
-
* @param {
|
|
44
|
-
* @param {string}
|
|
45
|
-
* @param {
|
|
58
|
+
* @param {Object} args - The args
|
|
59
|
+
* @param {string} args.url - The URL to send to
|
|
60
|
+
* @param {string=} args.body - The Stringified body
|
|
61
|
+
* @param {boolean=} args.sync - Run XHR as Synchronous
|
|
62
|
+
* @param {string=} [args.method=POST] - The XHR method to use
|
|
63
|
+
* @param {{key: string, value: string}[]} [args.headers] - The headers to attach
|
|
46
64
|
* @returns {XMLHttpRequest}
|
|
47
65
|
*/
|
|
48
|
-
submitData.xhr = function xhr(
|
|
49
|
-
let
|
|
66
|
+
submitData.xhr = function xhr(_ref3) {
|
|
67
|
+
let {
|
|
68
|
+
url,
|
|
69
|
+
body,
|
|
70
|
+
sync,
|
|
71
|
+
method = 'POST',
|
|
72
|
+
headers = [{
|
|
73
|
+
key: 'content-type',
|
|
74
|
+
value: 'text/plain'
|
|
75
|
+
}]
|
|
76
|
+
} = _ref3;
|
|
50
77
|
var request = new XMLHttpRequest();
|
|
51
78
|
request.open(method, url, !sync);
|
|
52
79
|
try {
|
|
@@ -55,7 +82,9 @@ submitData.xhr = function xhr(url, body, sync) {
|
|
|
55
82
|
} catch (e) {
|
|
56
83
|
// do nothing
|
|
57
84
|
}
|
|
58
|
-
|
|
85
|
+
headers.forEach(header => {
|
|
86
|
+
request.setRequestHeader(header.key, header.value);
|
|
87
|
+
});
|
|
59
88
|
request.send(body);
|
|
60
89
|
return request;
|
|
61
90
|
};
|
|
@@ -69,10 +98,15 @@ submitData.xhr = function xhr(url, body, sync) {
|
|
|
69
98
|
|
|
70
99
|
/**
|
|
71
100
|
* Send by appending an <img> element to the page. Do NOT call this function outside of a guaranteed web window environment.
|
|
72
|
-
* @param {
|
|
73
|
-
* @
|
|
101
|
+
* @param {Object} args - The args
|
|
102
|
+
* @param {string} args.url - The URL to send to
|
|
103
|
+
* @returns {HTMLImageElement}
|
|
74
104
|
*/
|
|
75
|
-
submitData.img = function img(
|
|
105
|
+
submitData.img = function img(_ref4) {
|
|
106
|
+
let {
|
|
107
|
+
url
|
|
108
|
+
} = _ref4;
|
|
109
|
+
console.log('img url', url);
|
|
76
110
|
var element = new Image();
|
|
77
111
|
element.src = url;
|
|
78
112
|
return element;
|
|
@@ -80,11 +114,16 @@ submitData.img = function img(url) {
|
|
|
80
114
|
|
|
81
115
|
/**
|
|
82
116
|
* Send via sendBeacon. Do NOT call this function outside of a guaranteed web window environment.
|
|
83
|
-
* @param {
|
|
84
|
-
* @param {string}
|
|
117
|
+
* @param {Object} args - The args
|
|
118
|
+
* @param {string} args.url - The URL to send to
|
|
119
|
+
* @param {string=} args.body - The Stringified body
|
|
85
120
|
* @returns {boolean}
|
|
86
121
|
*/
|
|
87
|
-
submitData.beacon = function (
|
|
122
|
+
submitData.beacon = function (_ref5) {
|
|
123
|
+
let {
|
|
124
|
+
url,
|
|
125
|
+
body
|
|
126
|
+
} = _ref5;
|
|
88
127
|
// Navigator has to be bound to ensure it does not error in some browsers
|
|
89
128
|
// https://xgwang.me/posts/you-may-not-know-beacon/#it-may-throw-error%2C-be-sure-to-catch
|
|
90
129
|
const send = window.navigator.sendBeacon.bind(window.navigator);
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
* This module is used by: ajax, spa.
|
|
8
8
|
*/
|
|
9
9
|
import { ee as baseEE } from '../event-emitter/contextual-ee';
|
|
10
|
-
import slice from 'lodash._slice';
|
|
11
10
|
import { globalScope } from '../util/global-scope';
|
|
12
11
|
import { flag } from './wrap-function';
|
|
13
12
|
var prefix = 'fetch-';
|
|
@@ -68,7 +67,7 @@ export function wrapFetch(sharedEE) {
|
|
|
68
67
|
var fn = target[name];
|
|
69
68
|
if (typeof fn === 'function') {
|
|
70
69
|
target[name] = function () {
|
|
71
|
-
var args =
|
|
70
|
+
var args = [...arguments];
|
|
72
71
|
var ctx = {};
|
|
73
72
|
// we are wrapping args in an array so we can preserve the reference
|
|
74
73
|
ee.emit(prefix + 'before-start', [args], ctx);
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { ee } from '../event-emitter/contextual-ee';
|
|
10
|
-
import slice from 'lodash._slice';
|
|
11
10
|
export const flag = 'nr@original';
|
|
12
11
|
|
|
13
12
|
/**
|
|
@@ -72,7 +71,7 @@ export function createWrapperWithEmitter(emitter, always) {
|
|
|
72
71
|
var result;
|
|
73
72
|
try {
|
|
74
73
|
originalThis = this;
|
|
75
|
-
args =
|
|
74
|
+
args = [...arguments];
|
|
76
75
|
if (typeof getContext === 'function') {
|
|
77
76
|
ctx = getContext(args, originalThis);
|
|
78
77
|
} else {
|
|
@@ -69,7 +69,7 @@ export function wrapPromise(sharedEE) {
|
|
|
69
69
|
WrappedPromise[method] = function (subPromises) {
|
|
70
70
|
// use our own wrapped version of "Promise.all" and ".race" static fns
|
|
71
71
|
let finalized = false;
|
|
72
|
-
|
|
72
|
+
[...(subPromises || [])].forEach(sub => {
|
|
73
73
|
this.resolve(sub).then(setNrId(method === 'all'), setNrId(false));
|
|
74
74
|
});
|
|
75
75
|
const origFnCallWithThis = prevStaticFn.apply(this, arguments);
|
|
@@ -13,8 +13,8 @@ import { FEATURE_NAME } from '../constants';
|
|
|
13
13
|
import { drain } from '../../../common/drain/drain';
|
|
14
14
|
import { FEATURE_NAMES } from '../../../loaders/features/features';
|
|
15
15
|
import { SUPPORTABILITY_METRIC_CHANNEL } from '../../metrics/constants';
|
|
16
|
-
import {
|
|
17
|
-
export class Aggregate extends
|
|
16
|
+
import { AggregateBase } from '../../utils/aggregate-base';
|
|
17
|
+
export class Aggregate extends AggregateBase {
|
|
18
18
|
static featureName = FEATURE_NAME;
|
|
19
19
|
constructor(agentIdentifier, aggregator) {
|
|
20
20
|
super(agentIdentifier, aggregator, FEATURE_NAME);
|
|
@@ -91,7 +91,7 @@ function subscribeToEvents(agentIdentifier, ee, handler, dt) {
|
|
|
91
91
|
}
|
|
92
92
|
function onOpenXhrEnd(args, xhr) {
|
|
93
93
|
var loader_config = getLoaderConfig(agentIdentifier);
|
|
94
|
-
if (
|
|
94
|
+
if (loader_config.xpid && this.sameOrigin) {
|
|
95
95
|
xhr.setRequestHeader('X-NewRelic-ID', loader_config.xpid);
|
|
96
96
|
}
|
|
97
97
|
var payload = dt.generateTracePayload(this.parsedOrigin);
|
|
@@ -3,10 +3,18 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const canonicalFunctionNameRe = /([a-z0-9]+)$/i;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Given a function name string, extracts only an alphanumeric segment at the end of the string (if one exists).
|
|
10
|
+
* This is useful for stack traces, where functions might not be named (e.g., anonymous, computed).
|
|
11
|
+
*
|
|
12
|
+
* @param {string} functionNameString - The original function name string.
|
|
13
|
+
* @returns {string|undefined} The canonical function name, or undefined if the input is falsy or no alphanumeric segments are found.
|
|
14
|
+
*/
|
|
15
|
+
export function canonicalFunctionName(functionNameString) {
|
|
16
|
+
if (!functionNameString) return;
|
|
17
|
+
const match = functionNameString.match(canonicalFunctionNameRe);
|
|
10
18
|
if (match) return match[1];
|
|
11
19
|
return;
|
|
12
20
|
}
|
|
@@ -57,12 +57,31 @@
|
|
|
57
57
|
// ex.message = ...
|
|
58
58
|
// ex.name = ReferenceError
|
|
59
59
|
import { formatStackTrace } from './format-stack-trace';
|
|
60
|
+
import { canonicalizeUrl } from '../../../common/url/canonicalize-url';
|
|
60
61
|
var debug = false;
|
|
61
62
|
var classNameRegex = /function (.+?)\s*\(/;
|
|
62
63
|
var chrome = /^\s*at (?:((?:\[object object\])?(?:[^(]*\([^)]*\))*[^()]*(?: \[as \S+\])?) )?\(?((?:file|http|https|chrome-extension):.*?)?:(\d+)(?::(\d+))?\)?\s*$/i;
|
|
63
64
|
var gecko = /^\s*(?:(\S*|global code)(?:\(.*?\))?@)?((?:file|http|https|chrome|safari-extension).*?):(\d+)(?::(\d+))?\s*$/i;
|
|
64
65
|
var chrome_eval = /^\s*at .+ \(eval at \S+ \((?:(?:file|http|https):[^)]+)?\)(?:, [^:]*:\d+:\d+)?\)$/i;
|
|
65
66
|
var ie_eval = /^\s*at Function code \(Function code:\d+:\d+\)\s*/i;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Represents an error with a stack trace.
|
|
70
|
+
* @typedef {Object} StackInfo
|
|
71
|
+
* @property {string} name - The name of the error (e.g. 'TypeError').
|
|
72
|
+
* @property {string} message - The error message.
|
|
73
|
+
* @property {string} stackString - The stack trace as a string.
|
|
74
|
+
* @property {Array<Object>} frames - An array of frames in the stack trace.
|
|
75
|
+
* @property {string} frames.url - The URL of the file containing the code for the frame.
|
|
76
|
+
* @property {string} frames.func - The name of the function associated with the frame.
|
|
77
|
+
* @property {number} frames.line - The line number of the code in the frame.
|
|
78
|
+
*/
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Attempts to compute a stack trace for the given exception.
|
|
82
|
+
* @param {Error} ex - The exception for which to compute the stack trace.
|
|
83
|
+
* @returns {StackInfo} A stack trace object containing information about the frames on the stack.
|
|
84
|
+
*/
|
|
66
85
|
export function computeStackTrace(ex) {
|
|
67
86
|
var stack = null;
|
|
68
87
|
try {
|
|
@@ -103,9 +122,9 @@ export function computeStackTrace(ex) {
|
|
|
103
122
|
}
|
|
104
123
|
|
|
105
124
|
/**
|
|
106
|
-
* Computes stack trace information from the stack property.
|
|
107
|
-
*
|
|
108
|
-
* @param {Error} ex
|
|
125
|
+
* Computes stack trace information from the stack property. Chrome and Gecko use this property.
|
|
126
|
+
*
|
|
127
|
+
* @param {Error} ex - The error object to compute the stack trace for.
|
|
109
128
|
* @return {?Object.<string, *>} Stack trace information.
|
|
110
129
|
*/
|
|
111
130
|
function computeStackTraceFromStackProp(ex) {
|
|
@@ -126,17 +145,48 @@ function computeStackTraceFromStackProp(ex) {
|
|
|
126
145
|
frames: errorInfo.frames
|
|
127
146
|
};
|
|
128
147
|
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Parses a line from a JavaScript error stack trace and adds it to the given `info` object.
|
|
151
|
+
* Ignores all stack entries thrown from one of our wrapper functions.
|
|
152
|
+
*
|
|
153
|
+
* @param {object} info - The `info` object to add the parsed line to.
|
|
154
|
+
* @param {string} line - The line to parse.
|
|
155
|
+
* @returns {object} The `info` object with the parsed line added.
|
|
156
|
+
*/
|
|
129
157
|
function parseStackProp(info, line) {
|
|
130
|
-
|
|
158
|
+
let element = getStackElement(line);
|
|
159
|
+
|
|
160
|
+
// This catches lines that aren't frames (like the first line stating the error).
|
|
131
161
|
if (!element) {
|
|
132
162
|
info.stackLines.push(line);
|
|
133
163
|
return info;
|
|
134
164
|
}
|
|
135
|
-
|
|
136
|
-
|
|
165
|
+
|
|
166
|
+
// Once we've seen a wrapper, ignore all subsequent stack entries.
|
|
167
|
+
if (isNrWrapper(element.func)) info.wrapperSeen = true;
|
|
168
|
+
if (!info.wrapperSeen) {
|
|
169
|
+
// Query strings and fragments should be removed, and URLs matching the loader's origin should be "<inline>".
|
|
170
|
+
let canonicalUrl = canonicalizeUrl(element.url);
|
|
171
|
+
if (canonicalUrl !== element.url) {
|
|
172
|
+
line = line.replace(element.url, canonicalUrl);
|
|
173
|
+
element.url = canonicalUrl;
|
|
174
|
+
}
|
|
175
|
+
info.stackLines.push(line);
|
|
176
|
+
info.frames.push(element);
|
|
177
|
+
}
|
|
137
178
|
return info;
|
|
138
179
|
}
|
|
139
|
-
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Parses a line from a JavaScript error stack trace to extract information about a stack trace element, such as the
|
|
183
|
+
* URL, function name, line number, and column number.
|
|
184
|
+
*
|
|
185
|
+
* @param {string} line - A single line from a JavaScript error stack trace.
|
|
186
|
+
* @returns {object} An object containing information about the stack trace element, including the URL, function
|
|
187
|
+
* name, line number, and column number (if available).
|
|
188
|
+
*/
|
|
189
|
+
function getStackElement(line) {
|
|
140
190
|
var parts = line.match(gecko);
|
|
141
191
|
if (!parts) parts = line.match(chrome);
|
|
142
192
|
if (parts) {
|
|
@@ -153,6 +203,15 @@ function getElement(line) {
|
|
|
153
203
|
};
|
|
154
204
|
}
|
|
155
205
|
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Computes a stack trace object from an error object, by extracting the source and line number from the error object,
|
|
209
|
+
* and using them to create a single stack frame.
|
|
210
|
+
*
|
|
211
|
+
* @param {Error} ex - The error object to compute the stack trace for.
|
|
212
|
+
* @returns {Object|null} - An object representing the computed stack trace, or null if the
|
|
213
|
+
* input error object does not contain a line number.
|
|
214
|
+
*/
|
|
156
215
|
function computeStackTraceBySourceAndLine(ex) {
|
|
157
216
|
if (!('line' in ex)) return null;
|
|
158
217
|
var className = ex.name || getClassName(ex);
|
|
@@ -169,7 +228,10 @@ function computeStackTraceBySourceAndLine(ex) {
|
|
|
169
228
|
}]
|
|
170
229
|
};
|
|
171
230
|
}
|
|
172
|
-
|
|
231
|
+
|
|
232
|
+
// Remove any query string and fragment
|
|
233
|
+
var canonicalUrl = canonicalizeUrl(ex.sourceURL);
|
|
234
|
+
var stackString = className + ': ' + ex.message + '\n at ' + canonicalUrl;
|
|
173
235
|
if (ex.line) {
|
|
174
236
|
stackString += ':' + ex.line;
|
|
175
237
|
if (ex.column) {
|
|
@@ -182,12 +244,19 @@ function computeStackTraceBySourceAndLine(ex) {
|
|
|
182
244
|
message: ex.message,
|
|
183
245
|
stackString: stackString,
|
|
184
246
|
frames: [{
|
|
185
|
-
url:
|
|
247
|
+
url: canonicalUrl,
|
|
186
248
|
line: ex.line,
|
|
187
249
|
column: ex.column
|
|
188
250
|
}]
|
|
189
251
|
};
|
|
190
252
|
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* For exceptions with no stack and only a message, derives a stack trace by extracting the class name and message.
|
|
256
|
+
*
|
|
257
|
+
* @param {Error} ex - The exception for which to compute the stack trace.
|
|
258
|
+
* @returns {StackTrace} A stack trace object containing the name and message of the exception.
|
|
259
|
+
*/
|
|
191
260
|
function computeStackTraceWithMessageOnly(ex) {
|
|
192
261
|
var className = ex.name || getClassName(ex);
|
|
193
262
|
if (!className) return null;
|
|
@@ -199,10 +268,24 @@ function computeStackTraceWithMessageOnly(ex) {
|
|
|
199
268
|
frames: []
|
|
200
269
|
};
|
|
201
270
|
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Attempts to extract the name of the constructor function (the class) of the given object.
|
|
274
|
+
*
|
|
275
|
+
* @param {Object} obj - The object for which to extract the constructor function name.
|
|
276
|
+
* @returns {string} The name of the constructor function, or 'unknown' if the name cannot be determined.
|
|
277
|
+
*/
|
|
202
278
|
function getClassName(obj) {
|
|
203
279
|
var results = classNameRegex.exec(String(obj.constructor));
|
|
204
280
|
return results && results.length > 1 ? results[1] : 'unknown';
|
|
205
281
|
}
|
|
206
|
-
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Checks whether the given function name is a New Relic wrapper function.
|
|
285
|
+
*
|
|
286
|
+
* @param {string} functionName - The name of the function to check.
|
|
287
|
+
* @returns {boolean} True if the function name includes the string 'nrWrapper', false otherwise.
|
|
288
|
+
*/
|
|
289
|
+
function isNrWrapper(functionName) {
|
|
207
290
|
return functionName && functionName.indexOf('nrWrapper') >= 0;
|
|
208
291
|
}
|