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