@newrelic/browser-agent 1.235.0 → 1.237.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 +4 -0
- package/dist/cjs/common/config/state/runtime.js +6 -5
- 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/deny-list/deny-list.js +14 -10
- 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 +154 -148
- 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 +31 -81
- 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 +14 -8
- 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 +25 -28
- 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/compute-stack-trace.js +1 -1
- package/dist/cjs/features/jserrors/aggregate/index.js +7 -4
- package/dist/cjs/features/jserrors/constants.js +2 -4
- package/dist/cjs/features/jserrors/instrument/index.js +80 -89
- package/dist/cjs/features/jserrors/instrument/uncaught-error.js +22 -0
- 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/aggregate/initialized-features.js +23 -19
- 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/aggregate/index.js +65 -34
- package/dist/cjs/features/session_replay/replay-mode.js +2 -2
- package/dist/cjs/features/session_trace/aggregate/index.js +3 -4
- 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 +12 -15
- package/dist/cjs/index.js +7 -0
- package/dist/cjs/loaders/agent-base.js +87 -0
- package/dist/cjs/loaders/agent.js +48 -1
- package/dist/cjs/loaders/api/api.js +3 -3
- package/dist/cjs/loaders/api/apiAsync.js +6 -4
- package/dist/cjs/loaders/api/interaction-types.js +87 -0
- package/dist/cjs/loaders/configure/configure.js +4 -3
- package/dist/cjs/loaders/micro-agent.js +32 -39
- package/dist/esm/common/config/state/init.js +4 -0
- package/dist/esm/common/config/state/runtime.js +3 -2
- 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/deny-list/deny-list.js +14 -10
- 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 +150 -146
- 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 +29 -78
- 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 +13 -7
- 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 +26 -29
- 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/compute-stack-trace.js +1 -1
- package/dist/esm/features/jserrors/aggregate/index.js +6 -3
- package/dist/esm/features/jserrors/constants.js +1 -2
- package/dist/esm/features/jserrors/instrument/index.js +79 -88
- package/dist/esm/features/jserrors/instrument/uncaught-error.js +15 -0
- 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/aggregate/initialized-features.js +23 -19
- 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/aggregate/index.js +65 -34
- package/dist/esm/features/session_replay/replay-mode.js +2 -2
- package/dist/esm/features/session_trace/aggregate/index.js +3 -4
- 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 +11 -14
- package/dist/esm/index.js +1 -4
- package/dist/esm/loaders/agent-base.js +80 -0
- package/dist/esm/loaders/agent.js +48 -1
- package/dist/esm/loaders/api/api.js +2 -2
- package/dist/esm/loaders/api/apiAsync.js +3 -3
- package/dist/esm/loaders/api/interaction-types.js +80 -0
- package/dist/esm/loaders/configure/configure.js +4 -3
- package/dist/esm/loaders/micro-agent.js +32 -39
- 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/constants/runtime.d.ts +29 -0
- package/dist/types/common/constants/runtime.d.ts.map +1 -0
- package/dist/types/common/event-emitter/register-handler.d.ts +1 -1
- 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/session/session-entity.d.ts +6 -6
- package/dist/types/common/unload/eol.d.ts.map +1 -1
- package/dist/types/common/util/submit-data.d.ts +44 -64
- package/dist/types/common/util/submit-data.d.ts.map +1 -1
- package/dist/types/common/window/nreum.d.ts +2 -2
- package/dist/types/common/wrap/wrap-jsonp.d.ts.map +1 -1
- package/dist/types/features/ajax/aggregate/index.d.ts +5 -5
- package/dist/types/features/ajax/aggregate/index.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/constants.d.ts +0 -1
- package/dist/types/features/jserrors/constants.d.ts.map +1 -1
- package/dist/types/features/jserrors/instrument/index.d.ts +0 -13
- package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/instrument/uncaught-error.d.ts +15 -0
- package/dist/types/features/jserrors/instrument/uncaught-error.d.ts.map +1 -0
- package/dist/types/features/metrics/aggregate/endpoint-map.d.ts +5 -5
- package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/page_view_event/aggregate/initialized-features.d.ts.map +1 -1
- package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/aggregate/index.d.ts +16 -30
- package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/loaders/agent-base.d.ts +59 -0
- package/dist/types/loaders/agent-base.d.ts.map +1 -0
- package/dist/types/loaders/agent.d.ts +39 -5
- package/dist/types/loaders/agent.d.ts.map +1 -1
- package/dist/types/loaders/api/interaction-types.d.ts +122 -0
- package/dist/types/loaders/api/interaction-types.d.ts.map +1 -0
- package/dist/types/loaders/configure/configure.d.ts.map +1 -1
- package/dist/types/loaders/features/features.d.ts +9 -9
- package/dist/types/loaders/micro-agent.d.ts +6 -6
- 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 +2 -1
- package/src/common/config/state/runtime.js +3 -2
- 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/deny-list/deny-list.js +11 -11
- package/src/common/deny-list/deny-list.test.js +31 -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 +142 -134
- package/src/common/harvest/harvest.test.js +798 -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 +5 -0
- package/src/common/util/__mocks__/traverse.js +1 -0
- package/src/common/util/submit-data.js +22 -58
- package/src/common/util/submit-data.test.js +30 -73
- 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 +12 -7
- 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 +26 -32
- 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.js +1 -1
- 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/constants.js +0 -1
- package/src/features/jserrors/instrument/index.js +92 -88
- package/src/features/jserrors/instrument/uncaught-error.js +15 -0
- 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/aggregate/initialized-features.js +18 -14
- 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/aggregate/index.component-test.js +17 -56
- package/src/features/session_replay/aggregate/index.js +47 -28
- package/src/features/session_replay/replay-mode.js +2 -2
- package/src/features/session_trace/aggregate/index.js +3 -4
- 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 +11 -14
- package/src/features/utils/instrument-base.test.js +29 -3
- package/src/index.js +1 -3
- package/src/loaders/agent-base.js +81 -0
- package/src/loaders/agent.js +50 -1
- package/src/loaders/api/api.js +2 -2
- package/src/loaders/api/apiAsync.js +3 -3
- package/src/loaders/api/interaction-types.js +80 -0
- package/src/loaders/configure/configure.js +5 -4
- package/src/loaders/micro-agent.js +30 -31
- 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/jserrors/instrument/debug.js +0 -40
- 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/jserrors/instrument/debug.js +0 -38
- 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/jserrors/instrument/debug.d.ts +0 -2
- package/dist/types/features/jserrors/instrument/debug.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
- package/src/features/jserrors/instrument/debug.js +0 -36
|
@@ -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,37 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
exports.beacon = beacon;
|
|
7
|
+
exports.getSubmitMethod = getSubmitMethod;
|
|
8
|
+
exports.xhr = xhr;
|
|
9
|
+
var _runtime = require("../constants/runtime");
|
|
10
|
+
/**
|
|
11
|
+
* @file Contains common methods used to transmit harvested data.
|
|
12
|
+
* @copyright 2023 New Relic Corporation. All rights reserved.
|
|
13
|
+
* @license Apache-2.0
|
|
11
14
|
*/
|
|
12
15
|
|
|
13
|
-
const submitData = {};
|
|
14
|
-
|
|
15
16
|
/**
|
|
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}
|
|
17
|
+
* @typedef {xhr|beacon} NetworkMethods
|
|
22
18
|
*/
|
|
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
19
|
|
|
54
20
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* @param {
|
|
58
|
-
*
|
|
59
|
-
* @returns {XMLHttpRequest} - An XMLHttpRequest object.
|
|
21
|
+
* Determines the submit method to use based on options.
|
|
22
|
+
* @param {object} opts Options used to determine submit method.
|
|
23
|
+
* @param {boolean} opts.isFinalHarvest Indicates if the data submission is due to
|
|
24
|
+
* a final harvest within the agent.
|
|
60
25
|
*/
|
|
61
|
-
|
|
26
|
+
function getSubmitMethod() {
|
|
62
27
|
let {
|
|
63
|
-
|
|
64
|
-
} =
|
|
65
|
-
return
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
28
|
+
isFinalHarvest = false
|
|
29
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
30
|
+
return isFinalHarvest && _runtime.isBrowserScope && _runtime.supportsSendBeacon
|
|
31
|
+
// Use sendBeacon for final harvest
|
|
32
|
+
? beacon
|
|
33
|
+
// Only IE does not support sendBeacon for final harvest
|
|
34
|
+
// If not final harvest, or not browserScope, always use xhr post
|
|
35
|
+
: xhr;
|
|
36
|
+
}
|
|
71
37
|
|
|
72
38
|
/**
|
|
73
39
|
* Send via XHR
|
|
@@ -79,7 +45,7 @@ submitData.xhrGet = function xhrGet(_ref2) {
|
|
|
79
45
|
* @param {{key: string, value: string}[]} [args.headers] - The headers to attach.
|
|
80
46
|
* @returns {XMLHttpRequest}
|
|
81
47
|
*/
|
|
82
|
-
|
|
48
|
+
function xhr(_ref) {
|
|
83
49
|
let {
|
|
84
50
|
url,
|
|
85
51
|
body = null,
|
|
@@ -89,8 +55,8 @@ submitData.xhr = function xhr(_ref3) {
|
|
|
89
55
|
key: 'content-type',
|
|
90
56
|
value: 'text/plain'
|
|
91
57
|
}]
|
|
92
|
-
} =
|
|
93
|
-
|
|
58
|
+
} = _ref;
|
|
59
|
+
const request = new XMLHttpRequest();
|
|
94
60
|
request.open(method, url, !sync);
|
|
95
61
|
try {
|
|
96
62
|
// Set cookie
|
|
@@ -103,22 +69,7 @@ submitData.xhr = function xhr(_ref3) {
|
|
|
103
69
|
});
|
|
104
70
|
request.send(body);
|
|
105
71
|
return request;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Send by appending an <img> element to the page. Do NOT call this function outside of a guaranteed web window environment.
|
|
110
|
-
* @param {Object} args - The args
|
|
111
|
-
* @param {string} args.url - The URL to send to
|
|
112
|
-
* @returns {HTMLImageElement}
|
|
113
|
-
*/
|
|
114
|
-
submitData.img = function img(_ref4) {
|
|
115
|
-
let {
|
|
116
|
-
url
|
|
117
|
-
} = _ref4;
|
|
118
|
-
var element = new Image();
|
|
119
|
-
element.src = url;
|
|
120
|
-
return element;
|
|
121
|
-
};
|
|
72
|
+
}
|
|
122
73
|
|
|
123
74
|
/**
|
|
124
75
|
* Send via sendBeacon. Do NOT call this function outside of a guaranteed web window environment.
|
|
@@ -127,11 +78,11 @@ submitData.img = function img(_ref4) {
|
|
|
127
78
|
* @param {string=} args.body - The Stringified body
|
|
128
79
|
* @returns {boolean}
|
|
129
80
|
*/
|
|
130
|
-
|
|
81
|
+
function beacon(_ref2) {
|
|
131
82
|
let {
|
|
132
83
|
url,
|
|
133
84
|
body
|
|
134
|
-
} =
|
|
85
|
+
} = _ref2;
|
|
135
86
|
try {
|
|
136
87
|
// Navigator has to be bound to ensure it does not error in some browsers
|
|
137
88
|
// https://xgwang.me/posts/you-may-not-know-beacon/#it-may-throw-error%2C-be-sure-to-catch
|
|
@@ -139,8 +90,7 @@ submitData.beacon = function (_ref5) {
|
|
|
139
90
|
return send(url, body);
|
|
140
91
|
} catch (err) {
|
|
141
92
|
// if sendBeacon still trys to throw an illegal invocation error,
|
|
142
|
-
// we can catch here and return
|
|
143
|
-
// .img to try to send
|
|
93
|
+
// we can catch here and return
|
|
144
94
|
return false;
|
|
145
95
|
}
|
|
146
|
-
}
|
|
96
|
+
}
|
|
@@ -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);
|
|
@@ -93,13 +93,19 @@ function wrapJsonP(sharedEE) {
|
|
|
93
93
|
var matches = src.match(CALLBACK_REGEX);
|
|
94
94
|
return matches ? matches[1] : null;
|
|
95
95
|
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Traverse a nested object using a '.'-delimited string wherein each substring piece maps to each subsequent object property layer.
|
|
99
|
+
* @param {string} longKey
|
|
100
|
+
* @param {object} obj
|
|
101
|
+
* @returns The final nested object referred to by initial longKey.
|
|
102
|
+
*/
|
|
96
103
|
function discoverValue(longKey, obj) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
104
|
+
if (!longKey) return obj; // end of object recursion depth when no more key levels
|
|
105
|
+
const matches = longKey.match(VALUE_REGEX);
|
|
106
|
+
// if 'longKey' was not undefined, that is it at least had 1 level left, then the regexp would've at least matched 1st group
|
|
107
|
+
const key = matches[1];
|
|
108
|
+
const remaining = matches[3];
|
|
103
109
|
return discoverValue(remaining, obj[key]);
|
|
104
110
|
}
|
|
105
111
|
function discoverParent(key) {
|
|
@@ -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];
|
|
@@ -25,13 +25,22 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
25
25
|
static featureName = _constants.FEATURE_NAME;
|
|
26
26
|
constructor(agentIdentifier, aggregator) {
|
|
27
27
|
super(agentIdentifier, aggregator, _constants.FEATURE_NAME);
|
|
28
|
+
const agentInit = (0, _config.getConfiguration)(agentIdentifier);
|
|
29
|
+
const allAjaxIsEnabled = agentInit.ajax.enabled !== false;
|
|
30
|
+
(0, _registerHandler.registerHandler)('xhr', storeXhr, this.featureName, this.ee);
|
|
31
|
+
if (!allAjaxIsEnabled) {
|
|
32
|
+
(0, _drain.drain)(this.agentIdentifier, this.featureName);
|
|
33
|
+
return; // feature will only collect timeslice metrics & ajax trace nodes if it's not fully enabled
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const denyList = (0, _config.getRuntime)(agentIdentifier).denyList;
|
|
37
|
+
(0, _denyList.setDenyList)(denyList);
|
|
28
38
|
let ajaxEvents = [];
|
|
29
39
|
let spaAjaxEvents = {};
|
|
30
40
|
let sentAjaxEvents = [];
|
|
31
|
-
let scheduler;
|
|
32
41
|
const ee = this.ee;
|
|
33
|
-
const harvestTimeSeconds =
|
|
34
|
-
const MAX_PAYLOAD_SIZE =
|
|
42
|
+
const harvestTimeSeconds = agentInit.ajax.harvestTimeSeconds || 10;
|
|
43
|
+
const MAX_PAYLOAD_SIZE = agentInit.ajax.maxPayloadSize || 1000000;
|
|
35
44
|
|
|
36
45
|
// Exposes these methods to browser test files -- future TO DO: can be removed once these fns are extracted from the constructor into class func
|
|
37
46
|
this.storeXhr = storeXhr;
|
|
@@ -48,24 +57,22 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
48
57
|
delete spaAjaxEvents[interaction.id];
|
|
49
58
|
});
|
|
50
59
|
ee.on('interactionDiscarded', interaction => {
|
|
51
|
-
if (!spaAjaxEvents[interaction.id]
|
|
60
|
+
if (!spaAjaxEvents[interaction.id]) return;
|
|
52
61
|
spaAjaxEvents[interaction.id].forEach(function (item) {
|
|
53
62
|
// move it from the spaAjaxEvents buffer to the ajaxEvents buffer for harvesting here
|
|
54
63
|
ajaxEvents.push(item);
|
|
55
64
|
});
|
|
56
65
|
delete spaAjaxEvents[interaction.id];
|
|
57
66
|
});
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
});
|
|
68
|
-
}
|
|
67
|
+
const scheduler = new _harvestScheduler.HarvestScheduler('events', {
|
|
68
|
+
onFinished: onEventsHarvestFinished,
|
|
69
|
+
getPayload: prepareHarvest
|
|
70
|
+
}, this);
|
|
71
|
+
ee.on("drain-".concat(this.featureName), () => {
|
|
72
|
+
scheduler.startTimer(harvestTimeSeconds);
|
|
73
|
+
});
|
|
74
|
+
(0, _drain.drain)(this.agentIdentifier, this.featureName);
|
|
75
|
+
return;
|
|
69
76
|
function storeXhr(params, metrics, startTime, endTime, type) {
|
|
70
77
|
metrics.time = startTime;
|
|
71
78
|
|
|
@@ -80,9 +87,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
80
87
|
|
|
81
88
|
// store as metric
|
|
82
89
|
aggregator.store('xhr', hash, params, metrics);
|
|
83
|
-
if (!allAjaxIsEnabled
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
90
|
+
if (!allAjaxIsEnabled) return;
|
|
86
91
|
if (!(0, _denyList.shouldCollectEvent)(params)) {
|
|
87
92
|
if (params.hostname === (0, _config.getInfo)(agentIdentifier).errorBeacon) {
|
|
88
93
|
(0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['Ajax/Events/Excluded/Agent'], undefined, _features.FEATURE_NAMES.metrics, ee);
|
|
@@ -164,8 +169,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
164
169
|
return tooBig ? getPayload(events, maxPayloadSize, ++chunks) : payload;
|
|
165
170
|
}
|
|
166
171
|
function onEventsHarvestFinished(result) {
|
|
167
|
-
if (result.retry && sentAjaxEvents.length > 0
|
|
168
|
-
ajaxEvents
|
|
172
|
+
if (result.retry && sentAjaxEvents.length > 0) {
|
|
173
|
+
ajaxEvents.unshift(...sentAjaxEvents);
|
|
169
174
|
sentAjaxEvents = [];
|
|
170
175
|
}
|
|
171
176
|
}
|
|
@@ -213,14 +218,6 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
213
218
|
return this.payload.length * 2 > maxPayloadSize;
|
|
214
219
|
};
|
|
215
220
|
}
|
|
216
|
-
function allAjaxIsEnabled() {
|
|
217
|
-
var enabled = (0, _config.getConfigurationValue)(agentIdentifier, 'ajax.enabled');
|
|
218
|
-
if (enabled === false) {
|
|
219
|
-
return false;
|
|
220
|
-
}
|
|
221
|
-
return true;
|
|
222
|
-
}
|
|
223
|
-
(0, _drain.drain)(this.agentIdentifier, this.featureName);
|
|
224
221
|
}
|
|
225
222
|
}
|
|
226
223
|
exports.Aggregate = Aggregate;
|
|
@@ -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);
|
|
@@ -229,7 +229,7 @@ function computeStackTraceBySourceAndLine(ex) {
|
|
|
229
229
|
mode: 'sourceline',
|
|
230
230
|
name: className,
|
|
231
231
|
message: ex.message,
|
|
232
|
-
stackString:
|
|
232
|
+
stackString: className + ': ' + ex.message + '\n in evaluated code',
|
|
233
233
|
frames: [{
|
|
234
234
|
func: 'evaluated code'
|
|
235
235
|
}]
|