@newrelic/browser-agent 1.235.0 → 1.236.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/README.md +41 -1
- package/dist/cjs/common/config/state/init.js +3 -0
- package/dist/cjs/common/config/state/runtime.js +4 -4
- package/dist/cjs/common/constants/env.cdn.js +2 -2
- package/dist/cjs/common/constants/env.npm.js +1 -1
- package/dist/cjs/common/constants/runtime.js +52 -0
- package/dist/cjs/common/event-listener/event-listener-opts.js +3 -3
- package/dist/cjs/common/harvest/harvest-scheduler.js +22 -19
- package/dist/cjs/common/harvest/harvest.js +163 -144
- package/dist/cjs/common/harvest/types.js +54 -0
- package/dist/cjs/common/ids/id.js +2 -2
- package/dist/cjs/common/ids/unique-id.js +3 -3
- package/dist/cjs/common/session/session-entity.js +2 -2
- package/dist/cjs/common/timer/interaction-timer.js +2 -2
- package/dist/cjs/common/unload/eol.js +10 -11
- package/dist/cjs/common/url/canonicalize-url.js +2 -2
- package/dist/cjs/common/url/parse-url.js +3 -3
- package/dist/cjs/common/url/protocol.js +2 -2
- package/dist/cjs/common/util/submit-data.js +58 -76
- package/dist/cjs/common/window/nreum.js +14 -14
- package/dist/cjs/common/wrap/wrap-events.js +3 -3
- package/dist/cjs/common/wrap/wrap-fetch.js +5 -5
- package/dist/cjs/common/wrap/wrap-history.js +2 -2
- package/dist/cjs/common/wrap/wrap-jsonp.js +2 -2
- package/dist/cjs/common/wrap/wrap-mutation.js +2 -2
- package/dist/cjs/common/wrap/wrap-promise.js +2 -2
- package/dist/cjs/common/wrap/wrap-raf.js +2 -2
- package/dist/cjs/common/wrap/wrap-timer.js +4 -4
- package/dist/cjs/common/wrap/wrap-xhr.js +3 -3
- package/dist/cjs/features/ajax/aggregate/index.js +1 -1
- package/dist/cjs/features/ajax/instrument/distributed-tracing.js +2 -2
- package/dist/cjs/features/ajax/instrument/index.js +6 -7
- package/dist/cjs/features/jserrors/aggregate/index.js +7 -4
- package/dist/cjs/features/jserrors/instrument/index.js +4 -4
- package/dist/cjs/features/metrics/aggregate/framework-detection.js +2 -2
- package/dist/cjs/features/metrics/aggregate/index.js +3 -3
- package/dist/cjs/features/page_action/aggregate/index.js +3 -3
- package/dist/cjs/features/page_view_event/aggregate/index.js +10 -11
- package/dist/cjs/features/page_view_event/instrument/index.js +2 -2
- package/dist/cjs/features/page_view_timing/aggregate/index.js +3 -5
- package/dist/cjs/features/page_view_timing/instrument/index.js +2 -2
- package/dist/cjs/features/session_replay/replay-mode.js +2 -2
- package/dist/cjs/features/session_trace/instrument/index.js +2 -2
- package/dist/cjs/features/spa/aggregate/index.js +1 -1
- package/dist/cjs/features/spa/instrument/index.js +2 -2
- package/dist/cjs/features/utils/instrument-base.js +6 -7
- package/dist/cjs/index.js +7 -0
- package/dist/cjs/loaders/agent.js +7 -0
- package/dist/cjs/loaders/api/api.js +2 -2
- package/dist/cjs/loaders/api/apiAsync.js +6 -4
- package/dist/cjs/loaders/configure/configure.js +2 -2
- package/dist/cjs/loaders/micro-agent.js +29 -38
- package/dist/esm/common/config/state/init.js +3 -0
- package/dist/esm/common/config/state/runtime.js +1 -1
- package/dist/esm/common/constants/env.cdn.js +2 -2
- package/dist/esm/common/constants/env.npm.js +1 -1
- package/dist/esm/common/constants/runtime.js +38 -0
- package/dist/esm/common/event-listener/event-listener-opts.js +1 -1
- package/dist/esm/common/harvest/harvest-scheduler.js +21 -20
- package/dist/esm/common/harvest/harvest.js +160 -142
- package/dist/esm/common/harvest/types.js +47 -0
- package/dist/esm/common/ids/id.js +1 -1
- package/dist/esm/common/ids/unique-id.js +1 -1
- package/dist/esm/common/session/session-entity.js +1 -1
- package/dist/esm/common/timer/interaction-timer.js +1 -1
- package/dist/esm/common/unload/eol.js +1 -2
- package/dist/esm/common/url/canonicalize-url.js +1 -1
- package/dist/esm/common/url/parse-url.js +1 -1
- package/dist/esm/common/url/protocol.js +1 -1
- package/dist/esm/common/util/submit-data.js +55 -73
- package/dist/esm/common/window/nreum.js +1 -1
- package/dist/esm/common/wrap/wrap-events.js +1 -1
- package/dist/esm/common/wrap/wrap-fetch.js +1 -1
- package/dist/esm/common/wrap/wrap-history.js +1 -1
- package/dist/esm/common/wrap/wrap-jsonp.js +1 -1
- package/dist/esm/common/wrap/wrap-mutation.js +1 -1
- package/dist/esm/common/wrap/wrap-promise.js +1 -1
- package/dist/esm/common/wrap/wrap-raf.js +1 -1
- package/dist/esm/common/wrap/wrap-timer.js +1 -1
- package/dist/esm/common/wrap/wrap-xhr.js +1 -1
- package/dist/esm/features/ajax/aggregate/index.js +1 -1
- package/dist/esm/features/ajax/instrument/distributed-tracing.js +1 -1
- package/dist/esm/features/ajax/instrument/index.js +1 -2
- package/dist/esm/features/jserrors/aggregate/index.js +6 -3
- package/dist/esm/features/jserrors/instrument/index.js +1 -1
- package/dist/esm/features/metrics/aggregate/framework-detection.js +1 -1
- package/dist/esm/features/metrics/aggregate/index.js +1 -1
- package/dist/esm/features/page_action/aggregate/index.js +1 -1
- package/dist/esm/features/page_view_event/aggregate/index.js +1 -2
- package/dist/esm/features/page_view_event/instrument/index.js +1 -1
- package/dist/esm/features/page_view_timing/aggregate/index.js +2 -4
- package/dist/esm/features/page_view_timing/instrument/index.js +1 -1
- package/dist/esm/features/session_replay/replay-mode.js +2 -2
- package/dist/esm/features/session_trace/instrument/index.js +1 -1
- package/dist/esm/features/spa/aggregate/index.js +1 -1
- package/dist/esm/features/spa/instrument/index.js +1 -1
- package/dist/esm/features/utils/instrument-base.js +4 -5
- package/dist/esm/index.js +1 -4
- package/dist/esm/loaders/agent.js +7 -0
- package/dist/esm/loaders/api/api.js +1 -1
- package/dist/esm/loaders/api/apiAsync.js +3 -3
- package/dist/esm/loaders/configure/configure.js +1 -1
- package/dist/esm/loaders/micro-agent.js +29 -38
- package/dist/types/common/config/state/init.d.ts.map +1 -1
- package/dist/types/common/constants/runtime.d.ts +29 -0
- package/dist/types/common/constants/runtime.d.ts.map +1 -0
- package/dist/types/common/harvest/harvest-scheduler.d.ts +1 -1
- package/dist/types/common/harvest/harvest-scheduler.d.ts.map +1 -1
- package/dist/types/common/harvest/harvest.d.ts +49 -38
- package/dist/types/common/harvest/harvest.d.ts.map +1 -1
- package/dist/types/common/harvest/types.d.ts +100 -0
- package/dist/types/common/harvest/types.d.ts.map +1 -0
- package/dist/types/common/unload/eol.d.ts.map +1 -1
- package/dist/types/common/util/submit-data.d.ts +62 -64
- package/dist/types/common/util/submit-data.d.ts.map +1 -1
- package/dist/types/features/ajax/instrument/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/aggregate/index.d.ts +1 -1
- package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/instrument/index.d.ts +1 -1
- package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/loaders/agent.d.ts +4 -4
- package/dist/types/loaders/agent.d.ts.map +1 -1
- package/dist/types/loaders/micro-agent.d.ts +3 -4
- package/dist/types/loaders/micro-agent.d.ts.map +1 -1
- package/package.json +6 -1
- package/src/common/config/__mocks__/config.js +11 -0
- package/src/common/config/state/init.js +1 -0
- package/src/common/config/state/runtime.js +1 -1
- package/src/common/constants/__mocks__/env.js +3 -0
- package/src/common/constants/__mocks__/runtime.js +8 -0
- package/src/common/constants/env.cdn.test.js +7 -0
- package/src/common/constants/env.npm.test.js +7 -0
- package/src/common/constants/env.test.js +7 -0
- package/src/common/constants/runtime.js +71 -0
- package/src/common/constants/runtime.test.js +168 -0
- package/src/common/context/__mocks__/shared-context.js +8 -0
- package/src/common/event-listener/__mocks__/event-listener-opts.js +7 -0
- package/src/common/event-listener/event-listener-opts.js +1 -1
- package/src/common/harvest/__mocks__/harvest.js +13 -0
- package/src/common/harvest/harvest-scheduler.js +21 -20
- package/src/common/harvest/harvest-scheduler.test.js +496 -0
- package/src/common/harvest/harvest.js +147 -130
- package/src/common/harvest/harvest.test.js +818 -0
- package/src/common/harvest/types.js +47 -0
- package/src/common/ids/id.js +1 -1
- package/src/common/ids/unique-id.js +1 -1
- package/src/common/session/__mocks__/session-entity.js +25 -0
- package/src/common/session/session-entity.component-test.js +1 -1
- package/src/common/session/session-entity.js +1 -1
- package/src/common/timer/interaction-timer.js +1 -1
- package/src/common/timing/__mocks__/now.js +1 -0
- package/src/common/unload/__mocks__/eol.js +1 -0
- package/src/common/unload/eol.js +1 -2
- package/src/common/url/__mocks__/clean-url.js +1 -0
- package/src/common/url/__mocks__/encode.js +7 -0
- package/src/common/url/__mocks__/location.js +1 -0
- package/src/common/url/canonicalize-url.js +1 -1
- package/src/common/url/canonicalize-url.test.js +2 -2
- package/src/common/url/parse-url.js +1 -1
- package/src/common/url/parse-url.test.js +3 -3
- package/src/common/url/protocol.js +1 -1
- package/src/common/util/__mocks__/obfuscate.js +10 -0
- package/src/common/util/__mocks__/stringify.js +1 -0
- package/src/common/util/__mocks__/submit-data.js +6 -0
- package/src/common/util/__mocks__/traverse.js +1 -0
- package/src/common/util/submit-data.js +39 -53
- package/src/common/util/submit-data.test.js +81 -68
- package/src/common/window/nreum.js +1 -1
- package/src/common/wrap/wrap-events.js +1 -1
- package/src/common/wrap/wrap-fetch.js +1 -1
- package/src/common/wrap/wrap-history.js +1 -1
- package/src/common/wrap/wrap-jsonp.js +1 -1
- package/src/common/wrap/wrap-mutation.js +1 -1
- package/src/common/wrap/wrap-promise.js +1 -1
- package/src/common/wrap/wrap-promise.test.js +2 -2
- package/src/common/wrap/wrap-raf.js +1 -1
- package/src/common/wrap/wrap-timer.js +1 -1
- package/src/common/wrap/wrap-xhr.js +1 -1
- package/src/features/ajax/aggregate/index.js +1 -1
- package/src/features/ajax/instrument/distributed-tracing.js +1 -1
- package/src/features/ajax/instrument/index.js +1 -2
- package/src/features/jserrors/aggregate/compute-stack-trace.test.js +1 -1
- package/src/features/jserrors/aggregate/index.js +7 -3
- package/src/features/jserrors/instrument/index.js +1 -1
- package/src/features/metrics/aggregate/framework-detection.js +1 -1
- package/src/features/metrics/aggregate/framework-detection.test.js +2 -2
- package/src/features/metrics/aggregate/index.js +1 -1
- package/src/features/page_action/aggregate/index.js +1 -1
- package/src/features/page_view_event/aggregate/index.js +1 -2
- package/src/features/page_view_event/instrument/index.js +1 -1
- package/src/features/page_view_timing/aggregate/index.js +2 -4
- package/src/features/page_view_timing/instrument/index.js +1 -1
- package/src/features/session_replay/replay-mode.js +2 -2
- package/src/features/session_trace/instrument/index.js +1 -1
- package/src/features/spa/aggregate/index.js +1 -1
- package/src/features/spa/instrument/index.js +1 -1
- package/src/features/utils/agent-session.test.js +2 -2
- package/src/features/utils/instrument-base.js +5 -5
- package/src/features/utils/instrument-base.test.js +22 -3
- package/src/index.js +1 -3
- package/src/loaders/agent.js +8 -0
- package/src/loaders/api/api.js +1 -1
- package/src/loaders/api/apiAsync.js +3 -3
- package/src/loaders/configure/configure.js +1 -1
- package/src/loaders/micro-agent.js +26 -30
- package/dist/cjs/common/browser-version/firefox-version.js +0 -17
- package/dist/cjs/common/browser-version/ios-version.js +0 -19
- package/dist/cjs/common/event-emitter/contextual-ee.test.js +0 -282
- package/dist/cjs/common/event-emitter/handle.test.js +0 -58
- package/dist/cjs/common/event-emitter/register-handler.test.js +0 -55
- package/dist/cjs/common/harvest/harvest-scheduler.component-test.js +0 -39
- package/dist/cjs/common/harvest/harvest.component-test.js +0 -224
- package/dist/cjs/common/ids/id.test.js +0 -85
- package/dist/cjs/common/ids/unique-id.test.js +0 -49
- package/dist/cjs/common/session/session-entity.component-test.js +0 -497
- package/dist/cjs/common/storage/local-storage.test.js +0 -14
- package/dist/cjs/common/timer/interaction-timer.component-test.js +0 -216
- package/dist/cjs/common/timer/timer.test.js +0 -105
- package/dist/cjs/common/timing/nav-timing.test.js +0 -192
- package/dist/cjs/common/url/canonicalize-url.test.js +0 -38
- package/dist/cjs/common/url/clean-url.test.js +0 -9
- package/dist/cjs/common/url/encode.component-test.js +0 -74
- package/dist/cjs/common/url/location.test.js +0 -13
- package/dist/cjs/common/url/parse-url.test.js +0 -111
- package/dist/cjs/common/url/protocol.component-test.js +0 -15
- package/dist/cjs/common/util/console.test.js +0 -30
- package/dist/cjs/common/util/data-size.test.js +0 -64
- package/dist/cjs/common/util/feature-flags.test.js +0 -84
- package/dist/cjs/common/util/get-or-set.test.js +0 -47
- package/dist/cjs/common/util/global-scope.js +0 -27
- package/dist/cjs/common/util/global-scope.test.js +0 -72
- package/dist/cjs/common/util/invoke.test.js +0 -49
- package/dist/cjs/common/util/map-own.test.js +0 -49
- package/dist/cjs/common/util/obfuscate.component-test.js +0 -129
- package/dist/cjs/common/util/stringify.test.js +0 -48
- package/dist/cjs/common/util/submit-data.test.js +0 -245
- package/dist/cjs/common/util/traverse.test.js +0 -44
- package/dist/cjs/common/wrap/wrap-promise.test.js +0 -119
- package/dist/cjs/features/jserrors/aggregate/canonical-function-name.test.js +0 -31
- package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.test.js +0 -383
- package/dist/cjs/features/jserrors/aggregate/format-stack-trace.test.js +0 -40
- package/dist/cjs/features/jserrors/aggregate/string-hash-code.test.js +0 -27
- package/dist/cjs/features/metrics/aggregate/framework-detection.test.js +0 -137
- package/dist/cjs/features/metrics/aggregate/polyfill-detection.es5.test.js +0 -17
- package/dist/cjs/features/metrics/aggregate/polyfill-detection.test.js +0 -165
- package/dist/cjs/features/session_replay/aggregate/index.component-test.js +0 -457
- package/dist/cjs/features/spa/aggregate/interaction-node.test.js +0 -16
- package/dist/cjs/features/utils/agent-session.test.js +0 -211
- package/dist/cjs/features/utils/aggregate-base.test.js +0 -110
- package/dist/cjs/features/utils/feature-base.test.js +0 -42
- package/dist/cjs/features/utils/handler-cache.test.js +0 -53
- package/dist/cjs/features/utils/instrument-base.test.js +0 -179
- package/dist/cjs/features/utils/lazy-feature-loader.test.js +0 -30
- package/dist/esm/common/browser-version/firefox-version.js +0 -10
- package/dist/esm/common/browser-version/ios-version.js +0 -11
- package/dist/esm/common/event-emitter/contextual-ee.test.js +0 -278
- package/dist/esm/common/event-emitter/handle.test.js +0 -54
- package/dist/esm/common/event-emitter/register-handler.test.js +0 -51
- package/dist/esm/common/harvest/harvest-scheduler.component-test.js +0 -37
- package/dist/esm/common/harvest/harvest.component-test.js +0 -222
- package/dist/esm/common/ids/id.test.js +0 -81
- package/dist/esm/common/ids/unique-id.test.js +0 -44
- package/dist/esm/common/session/session-entity.component-test.js +0 -495
- package/dist/esm/common/storage/local-storage.test.js +0 -12
- package/dist/esm/common/timer/interaction-timer.component-test.js +0 -214
- package/dist/esm/common/timer/timer.test.js +0 -103
- package/dist/esm/common/timing/nav-timing.test.js +0 -190
- package/dist/esm/common/url/canonicalize-url.test.js +0 -34
- package/dist/esm/common/url/clean-url.test.js +0 -7
- package/dist/esm/common/url/encode.component-test.js +0 -70
- package/dist/esm/common/url/location.test.js +0 -11
- package/dist/esm/common/url/parse-url.test.js +0 -107
- package/dist/esm/common/url/protocol.component-test.js +0 -13
- package/dist/esm/common/util/console.test.js +0 -28
- package/dist/esm/common/util/data-size.test.js +0 -60
- package/dist/esm/common/util/feature-flags.test.js +0 -80
- package/dist/esm/common/util/get-or-set.test.js +0 -45
- package/dist/esm/common/util/global-scope.js +0 -17
- package/dist/esm/common/util/global-scope.test.js +0 -70
- package/dist/esm/common/util/invoke.test.js +0 -47
- package/dist/esm/common/util/map-own.test.js +0 -47
- package/dist/esm/common/util/obfuscate.component-test.js +0 -125
- package/dist/esm/common/util/stringify.test.js +0 -46
- package/dist/esm/common/util/submit-data.test.js +0 -241
- package/dist/esm/common/util/traverse.test.js +0 -42
- package/dist/esm/common/wrap/wrap-promise.test.js +0 -115
- package/dist/esm/features/jserrors/aggregate/canonical-function-name.test.js +0 -29
- package/dist/esm/features/jserrors/aggregate/compute-stack-trace.test.js +0 -379
- package/dist/esm/features/jserrors/aggregate/format-stack-trace.test.js +0 -38
- package/dist/esm/features/jserrors/aggregate/string-hash-code.test.js +0 -25
- package/dist/esm/features/metrics/aggregate/framework-detection.test.js +0 -133
- package/dist/esm/features/metrics/aggregate/polyfill-detection.es5.test.js +0 -15
- package/dist/esm/features/metrics/aggregate/polyfill-detection.test.js +0 -163
- package/dist/esm/features/session_replay/aggregate/index.component-test.js +0 -453
- package/dist/esm/features/spa/aggregate/interaction-node.test.js +0 -14
- package/dist/esm/features/utils/agent-session.test.js +0 -207
- package/dist/esm/features/utils/aggregate-base.test.js +0 -108
- package/dist/esm/features/utils/feature-base.test.js +0 -40
- package/dist/esm/features/utils/handler-cache.test.js +0 -51
- package/dist/esm/features/utils/instrument-base.test.js +0 -175
- package/dist/esm/features/utils/lazy-feature-loader.test.js +0 -29
- package/dist/types/common/browser-version/firefox-version.d.ts +0 -2
- package/dist/types/common/browser-version/firefox-version.d.ts.map +0 -1
- package/dist/types/common/browser-version/ios-version.d.ts +0 -3
- package/dist/types/common/browser-version/ios-version.d.ts.map +0 -1
- package/dist/types/common/harvest/harvest-scheduler.component-test.d.ts +0 -2
- package/dist/types/common/harvest/harvest-scheduler.component-test.d.ts.map +0 -1
- package/dist/types/common/harvest/harvest.component-test.d.ts +0 -2
- package/dist/types/common/harvest/harvest.component-test.d.ts.map +0 -1
- package/dist/types/common/session/session-entity.component-test.d.ts +0 -2
- package/dist/types/common/session/session-entity.component-test.d.ts.map +0 -1
- package/dist/types/common/timer/interaction-timer.component-test.d.ts +0 -2
- package/dist/types/common/timer/interaction-timer.component-test.d.ts.map +0 -1
- package/dist/types/common/url/encode.component-test.d.ts +0 -2
- package/dist/types/common/url/encode.component-test.d.ts.map +0 -1
- package/dist/types/common/url/protocol.component-test.d.ts +0 -2
- package/dist/types/common/url/protocol.component-test.d.ts.map +0 -1
- package/dist/types/common/util/global-scope.d.ts +0 -5
- package/dist/types/common/util/global-scope.d.ts.map +0 -1
- package/dist/types/common/util/obfuscate.component-test.d.ts +0 -2
- package/dist/types/common/util/obfuscate.component-test.d.ts.map +0 -1
- package/dist/types/features/session_replay/aggregate/index.component-test.d.ts +0 -2
- package/dist/types/features/session_replay/aggregate/index.component-test.d.ts.map +0 -1
- package/src/common/browser-version/firefox-version.js +0 -10
- package/src/common/browser-version/ios-version.js +0 -11
- package/src/common/harvest/harvest-scheduler.component-test.js +0 -25
- package/src/common/harvest/harvest.component-test.js +0 -169
- package/src/common/util/global-scope.js +0 -23
- package/src/common/util/global-scope.test.js +0 -87
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.parseUrl = parseUrl;
|
|
7
|
-
var
|
|
7
|
+
var _runtime = require("../constants/runtime");
|
|
8
8
|
/*
|
|
9
9
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
10
10
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -23,9 +23,9 @@ function parseUrl(url) {
|
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
let urlEl;
|
|
26
|
-
var location =
|
|
26
|
+
var location = _runtime.globalScope?.location;
|
|
27
27
|
var ret = {};
|
|
28
|
-
if (
|
|
28
|
+
if (_runtime.isBrowserScope) {
|
|
29
29
|
// Use an anchor dom element to resolve the url natively.
|
|
30
30
|
urlEl = document.createElement('a');
|
|
31
31
|
urlEl.href = url;
|
|
@@ -4,12 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.isFileProtocol = isFileProtocol;
|
|
7
|
-
var
|
|
7
|
+
var _runtime = require("../constants/runtime");
|
|
8
8
|
/*
|
|
9
9
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
10
10
|
* SPDX-License-Identifier: Apache-2.0
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
function isFileProtocol() {
|
|
14
|
-
return Boolean(
|
|
14
|
+
return Boolean(_runtime.globalScope?.location?.protocol === 'file:');
|
|
15
15
|
}
|
|
@@ -3,71 +3,38 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
exports.beacon = beacon;
|
|
7
|
+
exports.fetchKeepAlive = fetchKeepAlive;
|
|
8
|
+
exports.getSubmitMethod = getSubmitMethod;
|
|
9
|
+
exports.xhr = xhr;
|
|
10
|
+
var _runtime = require("../constants/runtime");
|
|
11
|
+
/**
|
|
12
|
+
* @file Contains common methods used to transmit harvested data.
|
|
13
|
+
* @copyright 2023 New Relic Corporation. All rights reserved.
|
|
14
|
+
* @license Apache-2.0
|
|
11
15
|
*/
|
|
12
16
|
|
|
13
|
-
const submitData = {};
|
|
14
|
-
|
|
15
17
|
/**
|
|
16
|
-
*
|
|
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}
|
|
21
|
-
* @returns {Element}
|
|
18
|
+
* @typedef {xhr|fetchKeepAlive|beacon} NetworkMethods
|
|
22
19
|
*/
|
|
23
|
-
exports.submitData = submitData;
|
|
24
|
-
submitData.jsonp = function jsonp(_ref) {
|
|
25
|
-
let {
|
|
26
|
-
url,
|
|
27
|
-
jsonp
|
|
28
|
-
} = _ref;
|
|
29
|
-
try {
|
|
30
|
-
if (_globalScope.isWorkerScope) {
|
|
31
|
-
try {
|
|
32
|
-
return importScripts(url + '&jsonp=' + jsonp);
|
|
33
|
-
} catch (e) {
|
|
34
|
-
// for now theres no other way to execute the callback from ingest without jsonp, or unsafe eval / new Function calls
|
|
35
|
-
// future work needs to be conducted to allow ingest to return a more traditional JSON API-like experience for the entitlement flags
|
|
36
|
-
submitData.xhrGet({
|
|
37
|
-
url: url + '&jsonp=' + jsonp
|
|
38
|
-
});
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
} else {
|
|
42
|
-
var element = document.createElement('script');
|
|
43
|
-
element.type = 'text/javascript';
|
|
44
|
-
element.src = url + '&jsonp=' + jsonp;
|
|
45
|
-
var firstScript = document.getElementsByTagName('script')[0];
|
|
46
|
-
firstScript.parentNode.insertBefore(element, firstScript);
|
|
47
|
-
return element;
|
|
48
|
-
}
|
|
49
|
-
} catch (err) {
|
|
50
|
-
// do nothing
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
20
|
|
|
54
21
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* @param {
|
|
58
|
-
*
|
|
59
|
-
* @returns {XMLHttpRequest} - An XMLHttpRequest object.
|
|
22
|
+
* Determines the submit method to use based on options.
|
|
23
|
+
* @param {object} opts Options used to determine submit method.
|
|
24
|
+
* @param {boolean} opts.isFinalHarvest Indicates if the data submission is due to
|
|
25
|
+
* a final harvest within the agent.
|
|
60
26
|
*/
|
|
61
|
-
|
|
27
|
+
function getSubmitMethod() {
|
|
62
28
|
let {
|
|
63
|
-
|
|
64
|
-
} =
|
|
65
|
-
return
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
29
|
+
isFinalHarvest = false
|
|
30
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
31
|
+
return isFinalHarvest && _runtime.isBrowserScope && _runtime.supportsSendBeacon
|
|
32
|
+
// Use sendBeacon for final harvest
|
|
33
|
+
? beacon
|
|
34
|
+
// Only IE does not support sendBeacon for final harvest
|
|
35
|
+
// If not final harvest, or not browserScope, always use xhr post
|
|
36
|
+
: xhr;
|
|
37
|
+
}
|
|
71
38
|
|
|
72
39
|
/**
|
|
73
40
|
* Send via XHR
|
|
@@ -79,7 +46,7 @@ submitData.xhrGet = function xhrGet(_ref2) {
|
|
|
79
46
|
* @param {{key: string, value: string}[]} [args.headers] - The headers to attach.
|
|
80
47
|
* @returns {XMLHttpRequest}
|
|
81
48
|
*/
|
|
82
|
-
|
|
49
|
+
function xhr(_ref) {
|
|
83
50
|
let {
|
|
84
51
|
url,
|
|
85
52
|
body = null,
|
|
@@ -89,8 +56,8 @@ submitData.xhr = function xhr(_ref3) {
|
|
|
89
56
|
key: 'content-type',
|
|
90
57
|
value: 'text/plain'
|
|
91
58
|
}]
|
|
92
|
-
} =
|
|
93
|
-
|
|
59
|
+
} = _ref;
|
|
60
|
+
const request = new XMLHttpRequest();
|
|
94
61
|
request.open(method, url, !sync);
|
|
95
62
|
try {
|
|
96
63
|
// Set cookie
|
|
@@ -103,22 +70,37 @@ submitData.xhr = function xhr(_ref3) {
|
|
|
103
70
|
});
|
|
104
71
|
request.send(body);
|
|
105
72
|
return request;
|
|
106
|
-
}
|
|
73
|
+
}
|
|
107
74
|
|
|
108
75
|
/**
|
|
109
|
-
* Send
|
|
110
|
-
* @param {Object} args - The args
|
|
111
|
-
* @param {string} args.url - The URL to send to
|
|
112
|
-
* @
|
|
76
|
+
* Send via fetch with keepalive true
|
|
77
|
+
* @param {Object} args - The args.
|
|
78
|
+
* @param {string} args.url - The URL to send to.
|
|
79
|
+
* @param {string=} args.body - The Stringified body.
|
|
80
|
+
* @param {string=} [args.method=POST] - The XHR method to use.
|
|
81
|
+
* @param {{key: string, value: string}[]} [args.headers] - The headers to attach.
|
|
82
|
+
* @returns {XMLHttpRequest}
|
|
113
83
|
*/
|
|
114
|
-
|
|
84
|
+
function fetchKeepAlive(_ref2) {
|
|
115
85
|
let {
|
|
116
|
-
url
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
86
|
+
url,
|
|
87
|
+
body = null,
|
|
88
|
+
method = 'POST',
|
|
89
|
+
headers = [{
|
|
90
|
+
key: 'content-type',
|
|
91
|
+
value: 'text/plain'
|
|
92
|
+
}]
|
|
93
|
+
} = _ref2;
|
|
94
|
+
return fetch(url, {
|
|
95
|
+
method,
|
|
96
|
+
headers: headers.reduce((aggregator, header) => {
|
|
97
|
+
aggregator.push([header.key, header.value]);
|
|
98
|
+
return aggregator;
|
|
99
|
+
}, []),
|
|
100
|
+
body,
|
|
101
|
+
keepalive: true
|
|
102
|
+
});
|
|
103
|
+
}
|
|
122
104
|
|
|
123
105
|
/**
|
|
124
106
|
* Send via sendBeacon. Do NOT call this function outside of a guaranteed web window environment.
|
|
@@ -127,11 +109,11 @@ submitData.img = function img(_ref4) {
|
|
|
127
109
|
* @param {string=} args.body - The Stringified body
|
|
128
110
|
* @returns {boolean}
|
|
129
111
|
*/
|
|
130
|
-
|
|
112
|
+
function beacon(_ref3) {
|
|
131
113
|
let {
|
|
132
114
|
url,
|
|
133
115
|
body
|
|
134
|
-
} =
|
|
116
|
+
} = _ref3;
|
|
135
117
|
try {
|
|
136
118
|
// Navigator has to be bound to ensure it does not error in some browsers
|
|
137
119
|
// https://xgwang.me/posts/you-may-not-know-beacon/#it-may-throw-error%2C-be-sure-to-catch
|
|
@@ -140,7 +122,7 @@ submitData.beacon = function (_ref5) {
|
|
|
140
122
|
} catch (err) {
|
|
141
123
|
// if sendBeacon still trys to throw an illegal invocation error,
|
|
142
124
|
// we can catch here and return. The harvest module will fallback to use
|
|
143
|
-
//
|
|
125
|
+
// fetchKeepAlive to try to send
|
|
144
126
|
return false;
|
|
145
127
|
}
|
|
146
|
-
}
|
|
128
|
+
}
|
|
@@ -14,18 +14,18 @@ exports.gosNREUMInitializedAgents = gosNREUMInitializedAgents;
|
|
|
14
14
|
exports.gosNREUMLoaderConfig = gosNREUMLoaderConfig;
|
|
15
15
|
exports.gosNREUMOriginals = gosNREUMOriginals;
|
|
16
16
|
var _now = require("../timing/now");
|
|
17
|
-
var
|
|
17
|
+
var _runtime = require("../constants/runtime");
|
|
18
18
|
const defaults = {
|
|
19
19
|
beacon: 'bam.nr-data.net',
|
|
20
20
|
errorBeacon: 'bam.nr-data.net'
|
|
21
21
|
};
|
|
22
22
|
exports.defaults = defaults;
|
|
23
23
|
function gosNREUM() {
|
|
24
|
-
if (!
|
|
25
|
-
|
|
24
|
+
if (!_runtime.globalScope.NREUM) {
|
|
25
|
+
_runtime.globalScope.NREUM = {};
|
|
26
26
|
}
|
|
27
|
-
if (typeof
|
|
28
|
-
return
|
|
27
|
+
if (typeof _runtime.globalScope.newrelic === 'undefined') _runtime.globalScope.newrelic = _runtime.globalScope.NREUM;
|
|
28
|
+
return _runtime.globalScope.NREUM;
|
|
29
29
|
}
|
|
30
30
|
function gosNREUMInfo() {
|
|
31
31
|
let nr = gosNREUM();
|
|
@@ -57,16 +57,16 @@ function gosNREUMOriginals() {
|
|
|
57
57
|
let nr = gosNREUM();
|
|
58
58
|
if (!nr.o) {
|
|
59
59
|
nr.o = {
|
|
60
|
-
ST:
|
|
61
|
-
SI:
|
|
62
|
-
CT:
|
|
63
|
-
XHR:
|
|
64
|
-
REQ:
|
|
65
|
-
EV:
|
|
66
|
-
PR:
|
|
67
|
-
MO:
|
|
60
|
+
ST: _runtime.globalScope.setTimeout,
|
|
61
|
+
SI: _runtime.globalScope.setImmediate,
|
|
62
|
+
CT: _runtime.globalScope.clearTimeout,
|
|
63
|
+
XHR: _runtime.globalScope.XMLHttpRequest,
|
|
64
|
+
REQ: _runtime.globalScope.Request,
|
|
65
|
+
EV: _runtime.globalScope.Event,
|
|
66
|
+
PR: _runtime.globalScope.Promise,
|
|
67
|
+
MO: _runtime.globalScope.MutationObserver,
|
|
68
68
|
// this'll be undefined if not in a web window
|
|
69
|
-
FETCH:
|
|
69
|
+
FETCH: _runtime.globalScope.fetch
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
72
|
return nr;
|
|
@@ -8,7 +8,7 @@ exports.wrapEvents = wrapEvents;
|
|
|
8
8
|
var _contextualEe = require("../event-emitter/contextual-ee");
|
|
9
9
|
var _wrapFunction = require("./wrap-function");
|
|
10
10
|
var _getOrSet = require("../util/get-or-set");
|
|
11
|
-
var
|
|
11
|
+
var _runtime = require("../constants/runtime");
|
|
12
12
|
/*
|
|
13
13
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
14
14
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -42,8 +42,8 @@ function wrapEvents(sharedEE) {
|
|
|
42
42
|
|
|
43
43
|
// Guard against instrumenting environments w/o necessary features
|
|
44
44
|
if ('getPrototypeOf' in Object) {
|
|
45
|
-
if (
|
|
46
|
-
findEventListenerProtoAndCb(
|
|
45
|
+
if (_runtime.isBrowserScope) findEventListenerProtoAndCb(document, wrapNode);
|
|
46
|
+
findEventListenerProtoAndCb(_runtime.globalScope, wrapNode);
|
|
47
47
|
findEventListenerProtoAndCb(XHR.prototype, wrapNode);
|
|
48
48
|
}
|
|
49
49
|
ee.on(ADD_EVENT_LISTENER + '-start', function (args, target) {
|
|
@@ -6,7 +6,7 @@ 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
|
|
9
|
+
var _runtime = require("../constants/runtime");
|
|
10
10
|
var _wrapFunction = require("./wrap-function");
|
|
11
11
|
/*
|
|
12
12
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
@@ -20,8 +20,8 @@ var _wrapFunction = require("./wrap-function");
|
|
|
20
20
|
var prefix = 'fetch-';
|
|
21
21
|
var bodyPrefix = prefix + 'body-';
|
|
22
22
|
var bodyMethods = ['arrayBuffer', 'blob', 'json', 'text', 'formData'];
|
|
23
|
-
var Req =
|
|
24
|
-
var Res =
|
|
23
|
+
var Req = _runtime.globalScope.Request;
|
|
24
|
+
var Res = _runtime.globalScope.Response;
|
|
25
25
|
var proto = 'prototype';
|
|
26
26
|
var ctxId = 'nr@context';
|
|
27
27
|
const wrapped = {};
|
|
@@ -36,7 +36,7 @@ const wrapped = {};
|
|
|
36
36
|
*/
|
|
37
37
|
function wrapFetch(sharedEE) {
|
|
38
38
|
const ee = scopedEE(sharedEE);
|
|
39
|
-
if (!(Req && Res &&
|
|
39
|
+
if (!(Req && Res && _runtime.globalScope.fetch)) {
|
|
40
40
|
return ee;
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -49,7 +49,7 @@ function wrapFetch(sharedEE) {
|
|
|
49
49
|
wrapPromiseMethod(Req[proto], method, bodyPrefix);
|
|
50
50
|
wrapPromiseMethod(Res[proto], method, bodyPrefix);
|
|
51
51
|
});
|
|
52
|
-
wrapPromiseMethod(
|
|
52
|
+
wrapPromiseMethod(_runtime.globalScope, 'fetch', prefix);
|
|
53
53
|
ee.on(prefix + 'end', function (err, res) {
|
|
54
54
|
var ctx = this;
|
|
55
55
|
if (res) {
|
|
@@ -7,7 +7,7 @@ exports.scopedEE = scopedEE;
|
|
|
7
7
|
exports.wrapHistory = wrapHistory;
|
|
8
8
|
var _contextualEe = require("../event-emitter/contextual-ee");
|
|
9
9
|
var _wrapFunction = require("./wrap-function");
|
|
10
|
-
var
|
|
10
|
+
var _runtime = require("../constants/runtime");
|
|
11
11
|
/*
|
|
12
12
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
13
13
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -32,7 +32,7 @@ function wrapHistory(sharedEE) {
|
|
|
32
32
|
// Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
|
|
33
33
|
// then we increment the count to track # of feats using this at runtime. History API is only
|
|
34
34
|
// available in browser DOM context.
|
|
35
|
-
if (!
|
|
35
|
+
if (!_runtime.isBrowserScope || wrapped[ee.debugId]++) return ee;
|
|
36
36
|
wrapped[ee.debugId] = 1; // otherwise, first feature to wrap history
|
|
37
37
|
|
|
38
38
|
var wrapFn = (0, _wrapFunction.createWrapperWithEmitter)(ee);
|
|
@@ -8,7 +8,7 @@ exports.wrapJsonP = wrapJsonP;
|
|
|
8
8
|
var _eventListenerOpts = require("../event-listener/event-listener-opts");
|
|
9
9
|
var _contextualEe = require("../event-emitter/contextual-ee");
|
|
10
10
|
var _wrapFunction = require("./wrap-function");
|
|
11
|
-
var
|
|
11
|
+
var _runtime = require("../constants/runtime");
|
|
12
12
|
/*
|
|
13
13
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
14
14
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -33,7 +33,7 @@ function wrapJsonP(sharedEE) {
|
|
|
33
33
|
// Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
|
|
34
34
|
// then we increment the count to track # of feats using this at runtime. JSONP deals with DOM
|
|
35
35
|
// tags so browser window env is required.
|
|
36
|
-
if (!
|
|
36
|
+
if (!_runtime.isBrowserScope || wrapped[ee.debugId]) return ee;
|
|
37
37
|
wrapped[ee.debugId] = true; // otherwise, first feature to wrap JSONP
|
|
38
38
|
|
|
39
39
|
var wrapFn = (0, _wrapFunction.createWrapperWithEmitter)(ee);
|
|
@@ -8,7 +8,7 @@ exports.wrapMutation = wrapMutation;
|
|
|
8
8
|
var _contextualEe = require("../event-emitter/contextual-ee");
|
|
9
9
|
var _wrapFunction = require("./wrap-function");
|
|
10
10
|
var _config = require("../config/config");
|
|
11
|
-
var
|
|
11
|
+
var _runtime = require("../constants/runtime");
|
|
12
12
|
/*
|
|
13
13
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
14
14
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -32,7 +32,7 @@ function wrapMutation(sharedEE) {
|
|
|
32
32
|
// Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
|
|
33
33
|
// then we increment the count to track # of feats using this at runtime. Mutations API is only
|
|
34
34
|
// available in browser DOM context.
|
|
35
|
-
if (!
|
|
35
|
+
if (!_runtime.isBrowserScope || wrapped[ee.debugId]) return ee;
|
|
36
36
|
wrapped[ee.debugId] = true; // otherwise, first feature to wrap mutations
|
|
37
37
|
|
|
38
38
|
var wrapFn = (0, _wrapFunction.createWrapperWithEmitter)(ee);
|
|
@@ -8,7 +8,7 @@ exports.wrapPromise = wrapPromise;
|
|
|
8
8
|
var _wrapFunction = require("./wrap-function");
|
|
9
9
|
var _contextualEe = require("../event-emitter/contextual-ee");
|
|
10
10
|
var _config = require("../config/config");
|
|
11
|
-
var
|
|
11
|
+
var _runtime = require("../constants/runtime");
|
|
12
12
|
/*
|
|
13
13
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
14
14
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -43,7 +43,7 @@ function wrapPromise(sharedEE) {
|
|
|
43
43
|
wrap();
|
|
44
44
|
}
|
|
45
45
|
function wrap() {
|
|
46
|
-
|
|
46
|
+
_runtime.globalScope.Promise = WrappedPromise;
|
|
47
47
|
|
|
48
48
|
// Renamed from "WrappedPromise" back to "Promise" & toString() so that we appear "native" to TP libraries...
|
|
49
49
|
Object.defineProperty(WrappedPromise, 'name', {
|
|
@@ -7,7 +7,7 @@ exports.scopedEE = scopedEE;
|
|
|
7
7
|
exports.wrapRaf = wrapRaf;
|
|
8
8
|
var _contextualEe = require("../event-emitter/contextual-ee");
|
|
9
9
|
var _wrapFunction = require("./wrap-function");
|
|
10
|
-
var
|
|
10
|
+
var _runtime = require("../constants/runtime");
|
|
11
11
|
/*
|
|
12
12
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
13
13
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -31,7 +31,7 @@ function wrapRaf(sharedEE) {
|
|
|
31
31
|
|
|
32
32
|
// Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
|
|
33
33
|
// then we increment the count to track # of feats using this at runtime.
|
|
34
|
-
if (!
|
|
34
|
+
if (!_runtime.isBrowserScope || wrapped[ee.debugId]++) return ee;
|
|
35
35
|
wrapped[ee.debugId] = 1; // otherwise, first feature to wrap RAF
|
|
36
36
|
|
|
37
37
|
var wrapFn = (0, _wrapFunction.createWrapperWithEmitter)(ee);
|
|
@@ -7,7 +7,7 @@ exports.scopedEE = scopedEE;
|
|
|
7
7
|
exports.wrapTimer = wrapTimer;
|
|
8
8
|
var _contextualEe = require("../event-emitter/contextual-ee");
|
|
9
9
|
var _wrapFunction = require("./wrap-function");
|
|
10
|
-
var
|
|
10
|
+
var _runtime = require("../constants/runtime");
|
|
11
11
|
/*
|
|
12
12
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
13
13
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -42,9 +42,9 @@ function wrapTimer(sharedEE) {
|
|
|
42
42
|
wrapped[ee.debugId] = 1; // otherwise, first feature to wrap timer
|
|
43
43
|
|
|
44
44
|
var wrapFn = (0, _wrapFunction.createWrapperWithEmitter)(ee);
|
|
45
|
-
wrapFn.inPlace(
|
|
46
|
-
wrapFn.inPlace(
|
|
47
|
-
wrapFn.inPlace(
|
|
45
|
+
wrapFn.inPlace(_runtime.globalScope, TIMER_FNS.slice(0, 2), SET_TIMEOUT + DASH);
|
|
46
|
+
wrapFn.inPlace(_runtime.globalScope, TIMER_FNS.slice(2, 3), SET_INTERVAL + DASH);
|
|
47
|
+
wrapFn.inPlace(_runtime.globalScope, TIMER_FNS.slice(3), CLEAR_TIMEOUT + DASH);
|
|
48
48
|
ee.on(SET_INTERVAL + START, interval);
|
|
49
49
|
ee.on(SET_TIMEOUT + START, timer);
|
|
50
50
|
function interval(args, obj, type) {
|
|
@@ -10,7 +10,7 @@ var _contextualEe = require("../event-emitter/contextual-ee");
|
|
|
10
10
|
var _eventListenerOpts = require("../event-listener/event-listener-opts");
|
|
11
11
|
var _wrapFunction = require("./wrap-function");
|
|
12
12
|
var _config = require("../config/config");
|
|
13
|
-
var
|
|
13
|
+
var _runtime = require("../constants/runtime");
|
|
14
14
|
var _console = require("../util/console");
|
|
15
15
|
/*
|
|
16
16
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
@@ -49,8 +49,8 @@ function wrapXhr(sharedEE) {
|
|
|
49
49
|
var READY_STATE_CHANGE = 'readystatechange';
|
|
50
50
|
var handlers = ['onload', 'onerror', 'onabort', 'onloadstart', 'onloadend', 'onprogress', 'ontimeout'];
|
|
51
51
|
var pendingXhrs = [];
|
|
52
|
-
var activeListeners =
|
|
53
|
-
var XHR =
|
|
52
|
+
var activeListeners = _runtime.globalScope.XMLHttpRequest.listeners;
|
|
53
|
+
var XHR = _runtime.globalScope.XMLHttpRequest = newXHR;
|
|
54
54
|
function newXHR(opts) {
|
|
55
55
|
var xhr = new OrigXHR(opts);
|
|
56
56
|
this.listeners = activeListeners ? [...activeListeners, intercept] : [intercept];
|
|
@@ -165,7 +165,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
165
165
|
}
|
|
166
166
|
function onEventsHarvestFinished(result) {
|
|
167
167
|
if (result.retry && sentAjaxEvents.length > 0 && allAjaxIsEnabled()) {
|
|
168
|
-
ajaxEvents
|
|
168
|
+
ajaxEvents.unshift(...sentAjaxEvents);
|
|
169
169
|
sentAjaxEvents = [];
|
|
170
170
|
}
|
|
171
171
|
}
|
|
@@ -7,7 +7,7 @@ exports.DT = void 0;
|
|
|
7
7
|
var _config = require("../../../common/config/config");
|
|
8
8
|
var _uniqueId = require("../../../common/ids/unique-id");
|
|
9
9
|
var _parseUrl = require("../../../common/url/parse-url");
|
|
10
|
-
var
|
|
10
|
+
var _runtime = require("../../../common/constants/runtime");
|
|
11
11
|
var _stringify = require("../../../common/util/stringify");
|
|
12
12
|
/*
|
|
13
13
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
@@ -65,7 +65,7 @@ class DT {
|
|
|
65
65
|
return trustKey + '@nr=' + version + '-' + parentType + '-' + accountId + '-' + appId + '-' + spanId + '-' + transactionId + '-' + sampled + '-' + priority + '-' + timestamp;
|
|
66
66
|
}
|
|
67
67
|
generateTraceHeader(spanId, traceId, timestamp, accountId, appId, trustKey) {
|
|
68
|
-
var hasBtoa = typeof
|
|
68
|
+
var hasBtoa = typeof _runtime.globalScope?.btoa === 'function';
|
|
69
69
|
if (!hasBtoa) {
|
|
70
70
|
return null;
|
|
71
71
|
}
|
|
@@ -7,7 +7,7 @@ exports.Instrument = void 0;
|
|
|
7
7
|
var _config = require("../../../common/config/config");
|
|
8
8
|
var _handle = require("../../../common/event-emitter/handle");
|
|
9
9
|
var _id = require("../../../common/ids/id");
|
|
10
|
-
var
|
|
10
|
+
var _runtime = require("../../../common/constants/runtime");
|
|
11
11
|
var _dataSize = require("../../../common/util/data-size");
|
|
12
12
|
var _eventListenerOpts = require("../../../common/event-listener/event-listener-opts");
|
|
13
13
|
var _now = require("../../../common/timing/now");
|
|
@@ -18,7 +18,6 @@ var _responseSize = require("./response-size");
|
|
|
18
18
|
var _instrumentBase = require("../../utils/instrument-base");
|
|
19
19
|
var _constants = require("../constants");
|
|
20
20
|
var _features = require("../../../loaders/features/features");
|
|
21
|
-
var _globalScope = require("../../../common/util/global-scope");
|
|
22
21
|
/*
|
|
23
22
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
24
23
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -27,7 +26,7 @@ var _globalScope = require("../../../common/util/global-scope");
|
|
|
27
26
|
var handlers = ['load', 'error', 'abort', 'timeout'];
|
|
28
27
|
var handlersLen = handlers.length;
|
|
29
28
|
var origRequest = _config.originals.REQ;
|
|
30
|
-
var origXHR =
|
|
29
|
+
var origXHR = _runtime.globalScope.XMLHttpRequest;
|
|
31
30
|
class Instrument extends _instrumentBase.InstrumentBase {
|
|
32
31
|
static featureName = _constants.FEATURE_NAME;
|
|
33
32
|
constructor(agentIdentifier, aggregator) {
|
|
@@ -85,7 +84,7 @@ function subscribeToEvents(agentIdentifier, ee, handler, dt) {
|
|
|
85
84
|
// See: https://bugzilla.mozilla.org/show_bug.cgi?id=1227674
|
|
86
85
|
//
|
|
87
86
|
// So we don't use ProgressEvents to measure XHR sizes for FF.
|
|
88
|
-
if (
|
|
87
|
+
if (_runtime.ffVersion) return;
|
|
89
88
|
xhr.addEventListener('progress', function (event) {
|
|
90
89
|
ctx.lastSize = event.loaded;
|
|
91
90
|
}, (0, _eventListenerOpts.eventListenerOpts)(false));
|
|
@@ -201,7 +200,7 @@ function subscribeToEvents(agentIdentifier, ee, handler, dt) {
|
|
|
201
200
|
} else if (args[0] && args[0].url) {
|
|
202
201
|
url = args[0].url;
|
|
203
202
|
// argument is URL object
|
|
204
|
-
} else if (
|
|
203
|
+
} else if (_runtime.globalScope?.URL && args[0] && args[0] instanceof URL) {
|
|
205
204
|
url = args[0].href;
|
|
206
205
|
}
|
|
207
206
|
if (url) {
|
|
@@ -212,7 +211,7 @@ function subscribeToEvents(agentIdentifier, ee, handler, dt) {
|
|
|
212
211
|
if (!payload || !payload.newrelicHeader && !payload.traceContextParentHeader) {
|
|
213
212
|
return;
|
|
214
213
|
}
|
|
215
|
-
if (typeof args[0] === 'string' ||
|
|
214
|
+
if (typeof args[0] === 'string' || _runtime.globalScope?.URL && args[0] && args[0] instanceof URL) {
|
|
216
215
|
var clone = {};
|
|
217
216
|
for (var key in opts) {
|
|
218
217
|
clone[key] = opts[key];
|
|
@@ -261,7 +260,7 @@ function subscribeToEvents(agentIdentifier, ee, handler, dt) {
|
|
|
261
260
|
url = target;
|
|
262
261
|
} else if (typeof target === 'object' && target instanceof origRequest) {
|
|
263
262
|
url = target.url;
|
|
264
|
-
} else if (
|
|
263
|
+
} else if (_runtime.globalScope?.URL && typeof target === 'object' && target instanceof URL) {
|
|
265
264
|
url = target.href;
|
|
266
265
|
}
|
|
267
266
|
addUrl(this, url);
|
|
@@ -15,7 +15,7 @@ var _handle = require("../../../common/event-emitter/handle");
|
|
|
15
15
|
var _mapOwn = require("../../../common/util/map-own");
|
|
16
16
|
var _config = require("../../../common/config/config");
|
|
17
17
|
var _now = require("../../../common/timing/now");
|
|
18
|
-
var
|
|
18
|
+
var _runtime = require("../../../common/constants/runtime");
|
|
19
19
|
var _constants = require("../constants");
|
|
20
20
|
var _drain = require("../../../common/drain/drain");
|
|
21
21
|
var _features = require("../../../loaders/features/features");
|
|
@@ -100,7 +100,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
100
100
|
(0, _mapOwn.mapOwn)(this.currentBody, (key, value) => {
|
|
101
101
|
for (var i = 0; i < value.length; i++) {
|
|
102
102
|
var bucket = value[i];
|
|
103
|
-
var name = this.getBucketName(bucket.params, bucket.custom);
|
|
103
|
+
var name = this.getBucketName(key, bucket.params, bucket.custom);
|
|
104
104
|
this.aggregator.merge(key, name, bucket.metrics, bucket.params, bucket.custom);
|
|
105
105
|
}
|
|
106
106
|
});
|
|
@@ -110,7 +110,10 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
110
110
|
nameHash(params) {
|
|
111
111
|
return (0, _stringHashCode.stringHashCode)("".concat(params.exceptionClass, "_").concat(params.message, "_").concat(params.stack_trace || params.browser_stack_hash));
|
|
112
112
|
}
|
|
113
|
-
getBucketName(params, customParams) {
|
|
113
|
+
getBucketName(objType, params, customParams) {
|
|
114
|
+
if (objType === 'xhr') {
|
|
115
|
+
return (0, _stringHashCode.stringHashCode)((0, _stringify.stringify)(params)) + ':' + (0, _stringHashCode.stringHashCode)((0, _stringify.stringify)(customParams));
|
|
116
|
+
}
|
|
114
117
|
return this.nameHash(params) + ':' + (0, _stringHashCode.stringHashCode)((0, _stringify.stringify)(customParams));
|
|
115
118
|
}
|
|
116
119
|
|
|
@@ -153,7 +156,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
153
156
|
const params = {
|
|
154
157
|
stackHash: (0, _stringHashCode.stringHashCode)(canonicalStackString),
|
|
155
158
|
exceptionClass: stackInfo.name,
|
|
156
|
-
request_uri:
|
|
159
|
+
request_uri: _runtime.globalScope?.location.pathname
|
|
157
160
|
};
|
|
158
161
|
if (stackInfo.message) params.message = '' + stackInfo.message;
|
|
159
162
|
// Notice if filterOutput isn't false|undefined OR our specified object, this func would've returned already (so it's unnecessary to req-check group).
|
|
@@ -12,7 +12,7 @@ require("./debug");
|
|
|
12
12
|
var _instrumentBase = require("../../utils/instrument-base");
|
|
13
13
|
var _constants = require("../constants");
|
|
14
14
|
var _features = require("../../../loaders/features/features");
|
|
15
|
-
var
|
|
15
|
+
var _runtime = require("../../../common/constants/runtime");
|
|
16
16
|
var _eventListenerOpts = require("../../../common/event-listener/event-listener-opts");
|
|
17
17
|
var _config = require("../../../common/config/config");
|
|
18
18
|
var _stringify = require("../../../common/util/stringify");
|
|
@@ -55,9 +55,9 @@ class Instrument extends _instrumentBase.InstrumentBase {
|
|
|
55
55
|
});
|
|
56
56
|
|
|
57
57
|
// Replace global error handler with our own.
|
|
58
|
-
this.origOnerror =
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
this.origOnerror = _runtime.globalScope.onerror;
|
|
59
|
+
_runtime.globalScope.onerror = this.onerrorHandler.bind(this);
|
|
60
|
+
_runtime.globalScope.addEventListener('unhandledrejection', e => {
|
|
61
61
|
/** rejections can contain data of any type -- this is an effort to keep the message human readable */
|
|
62
62
|
const err = castReasonToError(e.reason);
|
|
63
63
|
(0, _handle.handle)('err', [err, (0, _now.now)(), false, {
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getFrameworks = getFrameworks;
|
|
7
|
-
var
|
|
7
|
+
var _runtime = require("../../../common/constants/runtime");
|
|
8
8
|
const FRAMEWORKS = {
|
|
9
9
|
REACT: 'React',
|
|
10
10
|
ANGULAR: 'Angular',
|
|
@@ -18,7 +18,7 @@ const FRAMEWORKS = {
|
|
|
18
18
|
MOOTOOLS: 'MooTools'
|
|
19
19
|
};
|
|
20
20
|
function getFrameworks() {
|
|
21
|
-
if (!
|
|
21
|
+
if (!_runtime.isBrowserScope) return []; // don't bother detecting frameworks if not in the main window context
|
|
22
22
|
|
|
23
23
|
const frameworks = [];
|
|
24
24
|
try {
|