@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
|
@@ -2,16 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
var _faker = require("@faker-js/faker");
|
|
4
4
|
var _testingUtils = require("../../../../tools/testing-utils");
|
|
5
|
-
|
|
5
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
6
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
7
|
+
const globalScopeLocation = 'https://example.com/';
|
|
8
|
+
const mockGlobalScopeLocation = url => {
|
|
9
|
+
jest.doMock('../../../common/util/global-scope', () => ({
|
|
10
|
+
initialLocation: url || globalScopeLocation
|
|
11
|
+
}));
|
|
12
|
+
};
|
|
13
|
+
afterEach(() => {
|
|
14
|
+
jest.resetModules();
|
|
15
|
+
jest.clearAllMocks();
|
|
16
|
+
});
|
|
6
17
|
const baseMockError = {
|
|
7
18
|
toString: 'RangeError: Invalid array length',
|
|
8
19
|
name: 'RangeError',
|
|
9
20
|
constructor: 'function RangeError() { [native code] }',
|
|
10
21
|
message: 'Invalid array length',
|
|
11
|
-
stack: 'RangeError: Invalid array length\n at errorTest (
|
|
22
|
+
stack: 'RangeError: Invalid array length\n' + ' at errorTest (' + globalScopeLocation + '?loader=spa#hello:74:16)\n' + ' at captureError (' + globalScopeLocation + 'js/script.js?loader=spa:17:9)\n' + ' at onload (' + globalScopeLocation + 'js/script.js?loader=spa:70:5)'
|
|
12
23
|
};
|
|
13
|
-
test('parsing should return a failure for a null error object', () => {
|
|
14
|
-
|
|
24
|
+
test('parsing should return a failure for a null error object', async () => {
|
|
25
|
+
mockGlobalScopeLocation();
|
|
26
|
+
const {
|
|
27
|
+
computeStackTrace
|
|
28
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./compute-stack-trace')));
|
|
29
|
+
const result = computeStackTrace(null);
|
|
15
30
|
expect(result).toEqual(expect.objectContaining({
|
|
16
31
|
mode: 'failed',
|
|
17
32
|
stackString: '',
|
|
@@ -19,25 +34,46 @@ test('parsing should return a failure for a null error object', () => {
|
|
|
19
34
|
}));
|
|
20
35
|
});
|
|
21
36
|
describe('errors with stack property', () => {
|
|
22
|
-
test('
|
|
37
|
+
test('should show <inline> for same-page stack string URLs but not sub-paths', async () => {
|
|
38
|
+
const mockError = _testingUtils.browserErrorUtils.constructError({
|
|
39
|
+
...baseMockError
|
|
40
|
+
});
|
|
41
|
+
mockGlobalScopeLocation();
|
|
42
|
+
const {
|
|
43
|
+
computeStackTrace
|
|
44
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./compute-stack-trace')));
|
|
45
|
+
const result = computeStackTrace(mockError);
|
|
46
|
+
expect(result).toEqual(expect.objectContaining({
|
|
47
|
+
stackString:
|
|
48
|
+
// canonicalized
|
|
49
|
+
'RangeError: Invalid array length\n' + ' at errorTest (<inline>:74:16)\n' + ' at captureError (' + globalScopeLocation + 'js/script.js:17:9)\n' + ' at onload (' + globalScopeLocation + 'js/script.js:70:5)'
|
|
50
|
+
}));
|
|
51
|
+
});
|
|
52
|
+
test('parsed name should be unknown when name and constructor are missing', async () => {
|
|
23
53
|
const mockError = _testingUtils.browserErrorUtils.constructError({
|
|
24
54
|
...baseMockError,
|
|
25
55
|
name: null,
|
|
26
56
|
constructor: null
|
|
27
57
|
});
|
|
28
|
-
|
|
58
|
+
mockGlobalScopeLocation();
|
|
59
|
+
const {
|
|
60
|
+
computeStackTrace
|
|
61
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./compute-stack-trace')));
|
|
62
|
+
const result = computeStackTrace(mockError);
|
|
29
63
|
expect(result).toEqual(expect.objectContaining({
|
|
30
64
|
mode: 'stack',
|
|
31
|
-
name: 'unknown'
|
|
32
|
-
message: mockError.message,
|
|
33
|
-
stackString: mockError.stack
|
|
65
|
+
name: 'unknown'
|
|
34
66
|
}));
|
|
35
67
|
});
|
|
36
|
-
test('parsed stack should not contain nrWrapper', () => {
|
|
68
|
+
test('parsed stack should not contain nrWrapper', async () => {
|
|
37
69
|
const alteredError = baseMockError;
|
|
38
|
-
alteredError.stack += '\n at nrWrapper (
|
|
70
|
+
alteredError.stack += '\n at nrWrapper (' + globalScopeLocation + '?loader=spa:60:17)';
|
|
39
71
|
const mockError = _testingUtils.browserErrorUtils.constructError(alteredError);
|
|
40
|
-
|
|
72
|
+
mockGlobalScopeLocation();
|
|
73
|
+
const {
|
|
74
|
+
computeStackTrace
|
|
75
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./compute-stack-trace')));
|
|
76
|
+
const result = computeStackTrace(mockError);
|
|
41
77
|
expect(result).toEqual(expect.objectContaining({
|
|
42
78
|
mode: 'stack',
|
|
43
79
|
name: mockError.name,
|
|
@@ -48,17 +84,21 @@ describe('errors with stack property', () => {
|
|
|
48
84
|
func: 'nrWrapper'
|
|
49
85
|
}));
|
|
50
86
|
});
|
|
51
|
-
test('stack should still parse when column numbers are missing', () => {
|
|
87
|
+
test('stack should still parse when column numbers are missing', async () => {
|
|
52
88
|
const mockError = _testingUtils.browserErrorUtils.constructError({
|
|
53
89
|
...baseMockError,
|
|
54
|
-
stack: 'Error: Blocked a frame with origin "http://bam-test-1.nr-local.net:3334" from accessing a cross-origin frame.\n at errorTest (
|
|
90
|
+
stack: 'RangeError: Invalid array length\n' + 'Error: Blocked a frame with origin "http://bam-test-1.nr-local.net:3334" from accessing a cross-origin frame.\n' + ' at errorTest (' + globalScopeLocation + '?loader=spa:60)\n' + ' at captureError (' + globalScopeLocation + '?loader=spa:17)\n' + ' at onload (' + globalScopeLocation + '?loader=spa:57)'
|
|
55
91
|
});
|
|
56
|
-
|
|
92
|
+
mockGlobalScopeLocation();
|
|
93
|
+
const {
|
|
94
|
+
computeStackTrace
|
|
95
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./compute-stack-trace')));
|
|
96
|
+
const result = computeStackTrace(mockError);
|
|
57
97
|
expect(result).toEqual(expect.objectContaining({
|
|
58
98
|
mode: 'stack',
|
|
59
99
|
name: mockError.name,
|
|
60
100
|
message: mockError.message,
|
|
61
|
-
stackString:
|
|
101
|
+
stackString: 'RangeError: Invalid array length\n' + 'Error: Blocked a frame with origin "http://bam-test-1.nr-local.net:3334" from accessing a cross-origin frame.\n' + ' at errorTest (<inline>:60)\n' + ' at captureError (<inline>:17)\n' + ' at onload (<inline>:57)'
|
|
62
102
|
}));
|
|
63
103
|
expect(result.frames.length).toEqual(3);
|
|
64
104
|
expect(result.frames).toContainEqual(expect.objectContaining({
|
|
@@ -74,12 +114,16 @@ describe('errors with stack property', () => {
|
|
|
74
114
|
column: null
|
|
75
115
|
}));
|
|
76
116
|
});
|
|
77
|
-
test('parser can handle chrome eval stack', () => {
|
|
117
|
+
test('parser can handle chrome eval stack', async () => {
|
|
78
118
|
const mockError = _testingUtils.browserErrorUtils.constructError({
|
|
79
119
|
...baseMockError,
|
|
80
|
-
stack: ' at foobar (eval at foobar (
|
|
120
|
+
stack: ' at foobar (eval at foobar (' + globalScopeLocation + '))'
|
|
81
121
|
});
|
|
82
|
-
|
|
122
|
+
mockGlobalScopeLocation();
|
|
123
|
+
const {
|
|
124
|
+
computeStackTrace
|
|
125
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./compute-stack-trace')));
|
|
126
|
+
const result = computeStackTrace(mockError);
|
|
83
127
|
expect(result).toEqual(expect.objectContaining({
|
|
84
128
|
mode: 'stack',
|
|
85
129
|
name: mockError.name,
|
|
@@ -91,7 +135,7 @@ describe('errors with stack property', () => {
|
|
|
91
135
|
func: 'evaluated code'
|
|
92
136
|
}));
|
|
93
137
|
});
|
|
94
|
-
test('parser can handle ie eval stack', () => {
|
|
138
|
+
test('parser can handle ie eval stack', async () => {
|
|
95
139
|
const mockError = _testingUtils.browserErrorUtils.constructError({
|
|
96
140
|
toString: 'TypeError: Permission denied',
|
|
97
141
|
name: 'TypeError',
|
|
@@ -99,7 +143,11 @@ describe('errors with stack property', () => {
|
|
|
99
143
|
message: 'Permission denied',
|
|
100
144
|
stack: ' at Function code (Function code:23:23)'
|
|
101
145
|
});
|
|
102
|
-
|
|
146
|
+
mockGlobalScopeLocation();
|
|
147
|
+
const {
|
|
148
|
+
computeStackTrace
|
|
149
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./compute-stack-trace')));
|
|
150
|
+
const result = computeStackTrace(mockError);
|
|
103
151
|
expect(result).toEqual(expect.objectContaining({
|
|
104
152
|
mode: 'stack',
|
|
105
153
|
name: mockError.name,
|
|
@@ -111,12 +159,16 @@ describe('errors with stack property', () => {
|
|
|
111
159
|
func: 'evaluated code'
|
|
112
160
|
}));
|
|
113
161
|
});
|
|
114
|
-
test('parser can handle stack with anonymous function', () => {
|
|
162
|
+
test('parser can handle stack with anonymous function', async () => {
|
|
115
163
|
const mockError = _testingUtils.browserErrorUtils.constructError({
|
|
116
164
|
...baseMockError,
|
|
117
165
|
stack: 'anonymous'
|
|
118
166
|
});
|
|
119
|
-
|
|
167
|
+
mockGlobalScopeLocation();
|
|
168
|
+
const {
|
|
169
|
+
computeStackTrace
|
|
170
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./compute-stack-trace')));
|
|
171
|
+
const result = computeStackTrace(mockError);
|
|
120
172
|
expect(result).toEqual(expect.objectContaining({
|
|
121
173
|
mode: 'stack',
|
|
122
174
|
name: mockError.name,
|
|
@@ -133,7 +185,7 @@ describe('errors without stack property and with line property', () => {
|
|
|
133
185
|
/**
|
|
134
186
|
* @deprecated sourceURL is no longer present in errors for any browsers we support
|
|
135
187
|
*/
|
|
136
|
-
test('parsed stack should contain sourceURL and line number', () => {
|
|
188
|
+
test('parsed stack should contain sourceURL and line number', async () => {
|
|
137
189
|
const sourceURL = _faker.faker.internet.url();
|
|
138
190
|
const mockError = _testingUtils.browserErrorUtils.constructError({
|
|
139
191
|
...baseMockError,
|
|
@@ -141,7 +193,11 @@ describe('errors without stack property and with line property', () => {
|
|
|
141
193
|
line: 100,
|
|
142
194
|
sourceURL
|
|
143
195
|
});
|
|
144
|
-
|
|
196
|
+
mockGlobalScopeLocation();
|
|
197
|
+
const {
|
|
198
|
+
computeStackTrace
|
|
199
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./compute-stack-trace')));
|
|
200
|
+
const result = computeStackTrace(mockError);
|
|
145
201
|
expect(result).toEqual(expect.objectContaining({
|
|
146
202
|
mode: 'sourceline',
|
|
147
203
|
name: mockError.name,
|
|
@@ -158,7 +214,7 @@ describe('errors without stack property and with line property', () => {
|
|
|
158
214
|
/**
|
|
159
215
|
* @deprecated sourceURL is no longer present in errors for any browsers we support
|
|
160
216
|
*/
|
|
161
|
-
test('parsed stack should contain sourceURL, line number, and column number', () => {
|
|
217
|
+
test('parsed stack should contain sourceURL, line number, and column number', async () => {
|
|
162
218
|
const sourceURL = _faker.faker.internet.url();
|
|
163
219
|
const mockError = _testingUtils.browserErrorUtils.constructError({
|
|
164
220
|
...baseMockError,
|
|
@@ -167,7 +223,11 @@ describe('errors without stack property and with line property', () => {
|
|
|
167
223
|
stack: undefined,
|
|
168
224
|
sourceURL
|
|
169
225
|
});
|
|
170
|
-
|
|
226
|
+
mockGlobalScopeLocation();
|
|
227
|
+
const {
|
|
228
|
+
computeStackTrace
|
|
229
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./compute-stack-trace')));
|
|
230
|
+
const result = computeStackTrace(mockError);
|
|
171
231
|
expect(result).toEqual(expect.objectContaining({
|
|
172
232
|
mode: 'sourceline',
|
|
173
233
|
name: mockError.name,
|
|
@@ -181,14 +241,18 @@ describe('errors without stack property and with line property', () => {
|
|
|
181
241
|
column: mockError.column
|
|
182
242
|
}));
|
|
183
243
|
});
|
|
184
|
-
test('parsed stack should contain "evaluated code" if sourceURL property is not present', () => {
|
|
244
|
+
test('parsed stack should contain "evaluated code" if sourceURL property is not present', async () => {
|
|
185
245
|
const mockError = _testingUtils.browserErrorUtils.constructError({
|
|
186
246
|
...baseMockError,
|
|
187
247
|
line: 100,
|
|
188
248
|
column: 200,
|
|
189
249
|
stack: undefined
|
|
190
250
|
});
|
|
191
|
-
|
|
251
|
+
mockGlobalScopeLocation();
|
|
252
|
+
const {
|
|
253
|
+
computeStackTrace
|
|
254
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./compute-stack-trace')));
|
|
255
|
+
const result = computeStackTrace(mockError);
|
|
192
256
|
expect(result).toEqual(expect.objectContaining({
|
|
193
257
|
mode: 'sourceline',
|
|
194
258
|
name: mockError.name,
|
|
@@ -201,6 +265,58 @@ describe('errors without stack property and with line property', () => {
|
|
|
201
265
|
}));
|
|
202
266
|
});
|
|
203
267
|
|
|
268
|
+
/**
|
|
269
|
+
* @deprecated sourceURL is no longer present in errors for any browsers we support
|
|
270
|
+
*/
|
|
271
|
+
test('should show <inline> for same-page URLs', async () => {
|
|
272
|
+
const pageLocation = _faker.faker.internet.url();
|
|
273
|
+
const sourceURL = pageLocation + '?abc=123';
|
|
274
|
+
const mockError = _testingUtils.browserErrorUtils.constructError({
|
|
275
|
+
...baseMockError,
|
|
276
|
+
line: 100,
|
|
277
|
+
column: 200,
|
|
278
|
+
stack: undefined,
|
|
279
|
+
sourceURL: sourceURL
|
|
280
|
+
});
|
|
281
|
+
mockGlobalScopeLocation(pageLocation);
|
|
282
|
+
const {
|
|
283
|
+
computeStackTrace
|
|
284
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./compute-stack-trace')));
|
|
285
|
+
const result = computeStackTrace(mockError);
|
|
286
|
+
expect(result).toEqual(expect.objectContaining({
|
|
287
|
+
stackString: "".concat(mockError.name, ": ").concat(mockError.message, "\n at <inline>:").concat(mockError.line, ":").concat(mockError.column)
|
|
288
|
+
}));
|
|
289
|
+
expect(result.frames).toContainEqual(expect.objectContaining({
|
|
290
|
+
url: '<inline>'
|
|
291
|
+
}));
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* @deprecated sourceURL is no longer present in errors for any browsers we support
|
|
296
|
+
*/
|
|
297
|
+
test('should NOT show <inline> for same-domain URLs with a sub-path', async () => {
|
|
298
|
+
const pageLocation = _faker.faker.internet.url();
|
|
299
|
+
const sourceURL = pageLocation + '/path/to/script.js';
|
|
300
|
+
const mockError = _testingUtils.browserErrorUtils.constructError({
|
|
301
|
+
...baseMockError,
|
|
302
|
+
line: 100,
|
|
303
|
+
column: 200,
|
|
304
|
+
stack: undefined,
|
|
305
|
+
sourceURL
|
|
306
|
+
});
|
|
307
|
+
mockGlobalScopeLocation(pageLocation);
|
|
308
|
+
const {
|
|
309
|
+
computeStackTrace
|
|
310
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./compute-stack-trace')));
|
|
311
|
+
const result = computeStackTrace(mockError);
|
|
312
|
+
expect(result).toEqual(expect.objectContaining({
|
|
313
|
+
stackString: "".concat(mockError.name, ": ").concat(mockError.message, "\n at ").concat(sourceURL, ":").concat(mockError.line, ":").concat(mockError.column)
|
|
314
|
+
}));
|
|
315
|
+
expect(result.frames).toContainEqual(expect.objectContaining({
|
|
316
|
+
url: sourceURL
|
|
317
|
+
}));
|
|
318
|
+
});
|
|
319
|
+
|
|
204
320
|
// TODO: computeStackTraceBySourceAndLine does not respect firefox lineNumber and columnNumber properties when stack is empty
|
|
205
321
|
});
|
|
206
322
|
|
|
@@ -209,12 +325,16 @@ describe('errors without stack property and with line property', () => {
|
|
|
209
325
|
* error, including primitives.
|
|
210
326
|
*/
|
|
211
327
|
describe('errors that are messages only or primitives', () => {
|
|
212
|
-
test('parser should get error name from constructor', () => {
|
|
328
|
+
test('parser should get error name from constructor', async () => {
|
|
213
329
|
const mockError = _testingUtils.browserErrorUtils.constructError({
|
|
214
330
|
toString: '0',
|
|
215
331
|
constructor: 'function Number() { [native code] }'
|
|
216
332
|
});
|
|
217
|
-
|
|
333
|
+
mockGlobalScopeLocation();
|
|
334
|
+
const {
|
|
335
|
+
computeStackTrace
|
|
336
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./compute-stack-trace')));
|
|
337
|
+
const result = computeStackTrace(mockError);
|
|
218
338
|
expect(result).toEqual(expect.objectContaining({
|
|
219
339
|
mode: 'nameonly',
|
|
220
340
|
name: 'Number',
|
|
@@ -222,13 +342,17 @@ describe('errors that are messages only or primitives', () => {
|
|
|
222
342
|
frames: []
|
|
223
343
|
}));
|
|
224
344
|
});
|
|
225
|
-
test('parser should get error name from name property', () => {
|
|
345
|
+
test('parser should get error name from name property', async () => {
|
|
226
346
|
const mockError = _testingUtils.browserErrorUtils.constructError({
|
|
227
347
|
toString: '0',
|
|
228
348
|
name: _faker.faker.datatype.uuid(),
|
|
229
349
|
constructor: 'function Number() { [native code] }'
|
|
230
350
|
});
|
|
231
|
-
|
|
351
|
+
mockGlobalScopeLocation();
|
|
352
|
+
const {
|
|
353
|
+
computeStackTrace
|
|
354
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./compute-stack-trace')));
|
|
355
|
+
const result = computeStackTrace(mockError);
|
|
232
356
|
expect(result).toEqual(expect.objectContaining({
|
|
233
357
|
mode: 'nameonly',
|
|
234
358
|
name: mockError.name,
|
|
@@ -236,14 +360,18 @@ describe('errors that are messages only or primitives', () => {
|
|
|
236
360
|
frames: []
|
|
237
361
|
}));
|
|
238
362
|
});
|
|
239
|
-
test('parser should include the message property', () => {
|
|
363
|
+
test('parser should include the message property', async () => {
|
|
240
364
|
const mockError = _testingUtils.browserErrorUtils.constructError({
|
|
241
365
|
toString: '0',
|
|
242
366
|
name: _faker.faker.datatype.uuid(),
|
|
243
367
|
message: _faker.faker.datatype.uuid(),
|
|
244
368
|
constructor: 'function Number() { [native code] }'
|
|
245
369
|
});
|
|
246
|
-
|
|
370
|
+
mockGlobalScopeLocation();
|
|
371
|
+
const {
|
|
372
|
+
computeStackTrace
|
|
373
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./compute-stack-trace')));
|
|
374
|
+
const result = computeStackTrace(mockError);
|
|
247
375
|
expect(result).toEqual(expect.objectContaining({
|
|
248
376
|
mode: 'nameonly',
|
|
249
377
|
name: mockError.name,
|
|
@@ -252,6 +380,4 @@ describe('errors that are messages only or primitives', () => {
|
|
|
252
380
|
frames: []
|
|
253
381
|
}));
|
|
254
382
|
});
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
// describe('')
|
|
383
|
+
});
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.Aggregate = void 0;
|
|
7
7
|
var _canonicalFunctionName = require("./canonical-function-name");
|
|
8
|
-
var _cleanUrl = require("../../../common/url/clean-url");
|
|
9
8
|
var _computeStackTrace = require("./compute-stack-trace");
|
|
10
9
|
var _stringHashCode = require("./string-hash-code");
|
|
11
10
|
var _formatStackTrace = require("./format-stack-trace");
|
|
@@ -20,13 +19,17 @@ var _globalScope = require("../../../common/util/global-scope");
|
|
|
20
19
|
var _constants = require("../constants");
|
|
21
20
|
var _drain = require("../../../common/drain/drain");
|
|
22
21
|
var _features = require("../../../loaders/features/features");
|
|
23
|
-
var
|
|
22
|
+
var _aggregateBase = require("../../utils/aggregate-base");
|
|
24
23
|
/*
|
|
25
24
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
26
25
|
* SPDX-License-Identifier: Apache-2.0
|
|
27
26
|
*/
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
/**
|
|
29
|
+
* @typedef {import('./compute-stack-trace.js').StackInfo} StackInfo
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
class Aggregate extends _aggregateBase.AggregateBase {
|
|
30
33
|
static featureName = _constants.FEATURE_NAME;
|
|
31
34
|
constructor(agentIdentifier, aggregator) {
|
|
32
35
|
var _this;
|
|
@@ -109,49 +112,25 @@ class Aggregate extends _featureBase.FeatureBase {
|
|
|
109
112
|
getBucketName(params, customParams) {
|
|
110
113
|
return this.nameHash(params) + ':' + (0, _stringHashCode.stringHashCode)((0, _stringify.stringify)(customParams));
|
|
111
114
|
}
|
|
112
|
-
canonicalizeURL(url, cleanedOrigin) {
|
|
113
|
-
if (typeof url !== 'string') return '';
|
|
114
|
-
var cleanedURL = (0, _cleanUrl.cleanURL)(url);
|
|
115
|
-
if (cleanedURL === cleanedOrigin) {
|
|
116
|
-
return '<inline>';
|
|
117
|
-
} else {
|
|
118
|
-
return cleanedURL;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
buildCanonicalStackString(stackInfo, cleanedOrigin) {
|
|
122
|
-
var canonicalStack = '';
|
|
123
|
-
for (var i = 0; i < stackInfo.frames.length; i++) {
|
|
124
|
-
var frame = stackInfo.frames[i];
|
|
125
|
-
var func = (0, _canonicalFunctionName.canonicalFunctionName)(frame.func);
|
|
126
|
-
if (canonicalStack) canonicalStack += '\n';
|
|
127
|
-
if (func) canonicalStack += func + '@';
|
|
128
|
-
if (typeof frame.url === 'string') canonicalStack += frame.url;
|
|
129
|
-
if (frame.line) canonicalStack += ':' + frame.line;
|
|
130
|
-
}
|
|
131
|
-
return canonicalStack;
|
|
132
|
-
}
|
|
133
115
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
// for comparing with frame URLs.
|
|
144
|
-
var cleanedOrigin = (0, _cleanUrl.cleanURL)((0, _config.getRuntime)(this.agentIdentifier).origin);
|
|
116
|
+
/**
|
|
117
|
+
* Builds a standardized stack trace string from the frames in the given `stackInfo` object, with each frame separated
|
|
118
|
+
* by a newline character. Lines take the form `<functionName>@<url>:<lineNumber>`.
|
|
119
|
+
*
|
|
120
|
+
* @param {StackInfo} stackInfo - An object specifying a stack string and individual frames.
|
|
121
|
+
* @returns {string} A canonical stack string built from the URLs and function names in the given `stackInfo` object.
|
|
122
|
+
*/
|
|
123
|
+
buildCanonicalStackString(stackInfo) {
|
|
124
|
+
var canonicalStackString = '';
|
|
145
125
|
for (var i = 0; i < stackInfo.frames.length; i++) {
|
|
146
126
|
var frame = stackInfo.frames[i];
|
|
147
|
-
var
|
|
148
|
-
|
|
149
|
-
if (
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
127
|
+
var func = (0, _canonicalFunctionName.canonicalFunctionName)(frame.func);
|
|
128
|
+
if (canonicalStackString) canonicalStackString += '\n';
|
|
129
|
+
if (func) canonicalStackString += func + '@';
|
|
130
|
+
if (typeof frame.url === 'string') canonicalStackString += frame.url;
|
|
131
|
+
if (frame.line) canonicalStackString += ':' + frame.line;
|
|
153
132
|
}
|
|
154
|
-
return
|
|
133
|
+
return canonicalStackString;
|
|
155
134
|
}
|
|
156
135
|
storeError(err, time, internal, customAttributes) {
|
|
157
136
|
// are we in an interaction
|
|
@@ -168,10 +147,10 @@ class Aggregate extends _featureBase.FeatureBase {
|
|
|
168
147
|
// Again as with previous usage, all falsey values would include the error.
|
|
169
148
|
}
|
|
170
149
|
|
|
171
|
-
var stackInfo =
|
|
172
|
-
var
|
|
150
|
+
var stackInfo = (0, _computeStackTrace.computeStackTrace)(err);
|
|
151
|
+
var canonicalStackString = this.buildCanonicalStackString(stackInfo);
|
|
173
152
|
const params = {
|
|
174
|
-
stackHash: (0, _stringHashCode.stringHashCode)(
|
|
153
|
+
stackHash: (0, _stringHashCode.stringHashCode)(canonicalStackString),
|
|
175
154
|
exceptionClass: stackInfo.name,
|
|
176
155
|
request_uri: _globalScope.globalScope?.location.pathname
|
|
177
156
|
};
|
|
@@ -209,10 +188,12 @@ class Aggregate extends _featureBase.FeatureBase {
|
|
|
209
188
|
time: time
|
|
210
189
|
};
|
|
211
190
|
|
|
212
|
-
// stn and spa aggregators listen to this event - stn sends the error in its payload,
|
|
191
|
+
// sr, stn and spa aggregators listen to this event - stn sends the error in its payload,
|
|
213
192
|
// and spa annotates the error with interaction info
|
|
214
|
-
|
|
215
|
-
(0, _handle.handle)('errorAgg',
|
|
193
|
+
const msg = [type, bucketHash, params, newMetrics];
|
|
194
|
+
(0, _handle.handle)('errorAgg', msg, undefined, _features.FEATURE_NAMES.sessionTrace, this.ee);
|
|
195
|
+
(0, _handle.handle)('errorAgg', msg, undefined, _features.FEATURE_NAMES.spa, this.ee);
|
|
196
|
+
(0, _handle.handle)('errorAgg', msg, undefined, _features.FEATURE_NAMES.sessionReplay, this.ee);
|
|
216
197
|
|
|
217
198
|
// still send EE events for other features such as above, but stop this one from aggregating internal data
|
|
218
199
|
if (this.blocked) return;
|
|
@@ -8,7 +8,6 @@ var _handle = require("../../../common/event-emitter/handle");
|
|
|
8
8
|
var _now = require("../../../common/timing/now");
|
|
9
9
|
var _getOrSet = require("../../../common/util/get-or-set");
|
|
10
10
|
var _wrap = require("../../../common/wrap");
|
|
11
|
-
var _lodash = _interopRequireDefault(require("lodash._slice"));
|
|
12
11
|
require("./debug");
|
|
13
12
|
var _instrumentBase = require("../../utils/instrument-base");
|
|
14
13
|
var _constants = require("../constants");
|
|
@@ -17,7 +16,6 @@ var _globalScope = require("../../../common/util/global-scope");
|
|
|
17
16
|
var _eventListenerOpts = require("../../../common/event-listener/event-listener-opts");
|
|
18
17
|
var _config = require("../../../common/config/config");
|
|
19
18
|
var _stringify = require("../../../common/util/stringify");
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
19
|
/*
|
|
22
20
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
23
21
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getFrameworks = getFrameworks;
|
|
7
|
+
var _globalScope = require("../../../common/util/global-scope");
|
|
8
|
+
const FRAMEWORKS = {
|
|
9
|
+
REACT: 'React',
|
|
10
|
+
ANGULAR: 'Angular',
|
|
11
|
+
ANGULARJS: 'AngularJS',
|
|
12
|
+
BACKBONE: 'Backbone',
|
|
13
|
+
EMBER: 'Ember',
|
|
14
|
+
VUE: 'Vue',
|
|
15
|
+
METEOR: 'Meteor',
|
|
16
|
+
ZEPTO: 'Zepto',
|
|
17
|
+
JQUERY: 'Jquery',
|
|
18
|
+
MOOTOOLS: 'MooTools'
|
|
19
|
+
};
|
|
20
|
+
function getFrameworks() {
|
|
21
|
+
if (!_globalScope.isBrowserScope) return []; // don't bother detecting frameworks if not in the main window context
|
|
22
|
+
|
|
23
|
+
const frameworks = [];
|
|
24
|
+
try {
|
|
25
|
+
if (detectReact()) frameworks.push(FRAMEWORKS.REACT);
|
|
26
|
+
if (detectAngularJs()) frameworks.push(FRAMEWORKS.ANGULARJS);
|
|
27
|
+
if (detectAngular()) frameworks.push(FRAMEWORKS.ANGULAR);
|
|
28
|
+
if (Object.prototype.hasOwnProperty.call(window, 'Backbone')) frameworks.push(FRAMEWORKS.BACKBONE);
|
|
29
|
+
if (Object.prototype.hasOwnProperty.call(window, 'Ember')) frameworks.push(FRAMEWORKS.EMBER);
|
|
30
|
+
if (Object.prototype.hasOwnProperty.call(window, 'Vue')) frameworks.push(FRAMEWORKS.VUE);
|
|
31
|
+
if (Object.prototype.hasOwnProperty.call(window, 'Meteor')) frameworks.push(FRAMEWORKS.METEOR);
|
|
32
|
+
if (Object.prototype.hasOwnProperty.call(window, 'Zepto')) frameworks.push(FRAMEWORKS.ZEPTO);
|
|
33
|
+
if (Object.prototype.hasOwnProperty.call(window, 'jQuery')) frameworks.push(FRAMEWORKS.JQUERY);
|
|
34
|
+
if (Object.prototype.hasOwnProperty.call(window, 'MooTools')) frameworks.push(FRAMEWORKS.MOOTOOLS);
|
|
35
|
+
} catch (err) {
|
|
36
|
+
// Possibly not supported
|
|
37
|
+
}
|
|
38
|
+
return frameworks;
|
|
39
|
+
}
|
|
40
|
+
function detectReact() {
|
|
41
|
+
try {
|
|
42
|
+
return Object.prototype.hasOwnProperty.call(window, 'React') || Object.prototype.hasOwnProperty.call(window, 'ReactDOM') || Object.prototype.hasOwnProperty.call(window, 'ReactRedux') || document.querySelector('[data-reactroot], [data-reactid]') || (() => {
|
|
43
|
+
const divs = document.querySelectorAll('body > div');
|
|
44
|
+
for (let i = 0; i < divs.length; i++) {
|
|
45
|
+
if (Object.prototype.hasOwnProperty.call(divs[i], '_reactRootContainer')) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
})();
|
|
50
|
+
} catch (err) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function detectAngularJs() {
|
|
55
|
+
try {
|
|
56
|
+
return Object.prototype.hasOwnProperty.call(window, 'angular') || document.querySelector('.ng-binding, [ng-app], [data-ng-app], [ng-controller], [data-ng-controller], [ng-repeat], [data-ng-repeat]') || document.querySelector('script[src*="angular.js"], script[src*="angular.min.js"]');
|
|
57
|
+
} catch (err) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function detectAngular() {
|
|
62
|
+
try {
|
|
63
|
+
return Object.prototype.hasOwnProperty.call(window, 'ng') || document.querySelector('[ng-version]');
|
|
64
|
+
} catch (err) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
}
|