@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,11 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Harvest = void 0;
|
|
7
|
-
exports.getSubmitMethod = getSubmitMethod;
|
|
8
|
-
var _mapOwn = require("../util/map-own");
|
|
9
7
|
var _encode = require("../url/encode");
|
|
10
8
|
var _stringify = require("../util/stringify");
|
|
11
|
-
var
|
|
9
|
+
var submitData = _interopRequireWildcard(require("../util/submit-data"));
|
|
12
10
|
var _location = require("../url/location");
|
|
13
11
|
var _config = require("../config/config");
|
|
14
12
|
var _cleanUrl = require("../url/clean-url");
|
|
@@ -18,31 +16,24 @@ var _obfuscate = require("../util/obfuscate");
|
|
|
18
16
|
var _traverse = require("../util/traverse");
|
|
19
17
|
var _sharedContext = require("../context/shared-context");
|
|
20
18
|
var _env = require("../constants/env.npm");
|
|
21
|
-
var
|
|
19
|
+
var _runtime = require("../constants/runtime");
|
|
20
|
+
var _console = require("../util/console");
|
|
21
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
22
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
22
23
|
/*
|
|
23
24
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
24
25
|
* SPDX-License-Identifier: Apache-2.0
|
|
25
26
|
*/
|
|
26
27
|
|
|
28
|
+
const warnings = {};
|
|
29
|
+
|
|
27
30
|
/**
|
|
28
|
-
* @typedef {
|
|
29
|
-
* @
|
|
30
|
-
* @
|
|
31
|
-
* @
|
|
32
|
-
* @
|
|
33
|
-
* @param {string} payload.body.e Special case of body used for browser interactions.
|
|
34
|
-
* @param {object} opts Additional options for sending data
|
|
35
|
-
* @param {boolean} opts.needResponse Specify whether the caller expects a response data.
|
|
36
|
-
* @param {boolean} opts.unload Specify whether the call is a final harvest during page unload.
|
|
37
|
-
* @param {boolean} opts.sendEmptyBody Specify whether the call should be made even if the body is empty. Useful for rum calls.
|
|
38
|
-
* @param {function} submitMethod The submit method to use {@link ../util/submit-data}
|
|
39
|
-
* @param {string} customUrl Override the beacon url the data is sent to; must include protocol if defined
|
|
40
|
-
* @param {boolean} gzip Enabled gzip compression on the body of the request before it is sent
|
|
41
|
-
* @param {boolean} includeBaseParams Enables the use of base query parameters in the beacon url {@see Harvest.baseQueryString}
|
|
31
|
+
* @typedef {import('./types.js').NetworkSendSpec} NetworkSendSpec
|
|
32
|
+
* @typedef {import('./types.js').HarvestEndpointIdentifier} HarvestEndpointIdentifier
|
|
33
|
+
* @typedef {import('./types.js').HarvestPayload} HarvestPayload
|
|
34
|
+
* @typedef {import('./types.js').FeatureHarvestCallback} FeatureHarvestCallback
|
|
35
|
+
* @typedef {import('./types.js').FeatureHarvestCallbackOptions} FeatureHarvestCallbackOptions
|
|
42
36
|
*/
|
|
43
|
-
|
|
44
|
-
const haveSendBeacon = !!navigator.sendBeacon; // only the web window obj has sendBeacon at this time, so 'false' for other envs
|
|
45
|
-
|
|
46
37
|
class Harvest extends _sharedContext.SharedContext {
|
|
47
38
|
constructor(parent) {
|
|
48
39
|
super(parent); // gets any allowed properties from the parent and stores them in `sharedContext`
|
|
@@ -56,20 +47,19 @@ class Harvest extends _sharedContext.SharedContext {
|
|
|
56
47
|
/**
|
|
57
48
|
* Initiate a harvest from multiple sources. An event that corresponds to the endpoint
|
|
58
49
|
* name is emitted, which gives any listeners the opportunity to provide payload data.
|
|
50
|
+
* Note: Used by page_action
|
|
59
51
|
* @param {NetworkSendSpec} spec Specification for sending data
|
|
60
52
|
*/
|
|
61
|
-
sendX(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
opts
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
var options = {
|
|
69
|
-
retry: submitMethod.method === _submitData.submitData.xhr
|
|
53
|
+
sendX() {
|
|
54
|
+
let spec = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
55
|
+
const submitMethod = submitData.getSubmitMethod({
|
|
56
|
+
isFinalHarvest: spec.opts?.unload
|
|
57
|
+
});
|
|
58
|
+
const options = {
|
|
59
|
+
retry: !spec.opts?.unload && submitMethod === submitData.xhr
|
|
70
60
|
};
|
|
71
|
-
const payload = this.createPayload(endpoint, options);
|
|
72
|
-
|
|
61
|
+
const payload = this.createPayload(spec.endpoint, options);
|
|
62
|
+
const caller = this.obfuscator.shouldObfuscate() ? this.obfuscateAndSend.bind(this) : this._send.bind(this);
|
|
73
63
|
return caller({
|
|
74
64
|
...spec,
|
|
75
65
|
payload,
|
|
@@ -81,31 +71,19 @@ class Harvest extends _sharedContext.SharedContext {
|
|
|
81
71
|
* Initiate a harvest call.
|
|
82
72
|
* @param {NetworkSendSpec} spec Specification for sending data
|
|
83
73
|
*/
|
|
84
|
-
send(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
var makeBody = createAccumulator();
|
|
89
|
-
var makeQueryString = createAccumulator();
|
|
90
|
-
if (payload.body) (0, _mapOwn.mapOwn)(payload.body, makeBody);
|
|
91
|
-
if (payload.qs) (0, _mapOwn.mapOwn)(payload.qs, makeQueryString);
|
|
92
|
-
var newPayload = {
|
|
93
|
-
body: makeBody(),
|
|
94
|
-
qs: makeQueryString()
|
|
95
|
-
};
|
|
96
|
-
var caller = this.obfuscator.shouldObfuscate() ? this.obfuscateAndSend.bind(this) : this._send.bind(this);
|
|
97
|
-
return caller({
|
|
98
|
-
...spec,
|
|
99
|
-
payload: newPayload
|
|
100
|
-
});
|
|
74
|
+
send() {
|
|
75
|
+
let spec = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
76
|
+
const caller = this.obfuscator.shouldObfuscate() ? this.obfuscateAndSend.bind(this) : this._send.bind(this);
|
|
77
|
+
return caller(spec);
|
|
101
78
|
}
|
|
102
79
|
|
|
103
80
|
/**
|
|
104
81
|
* Apply obfuscation rules to the payload and then initial the harvest network call.
|
|
105
82
|
* @param {NetworkSendSpec} spec Specification for sending data
|
|
106
83
|
*/
|
|
107
|
-
obfuscateAndSend(
|
|
84
|
+
obfuscateAndSend() {
|
|
108
85
|
var _this = this;
|
|
86
|
+
let spec = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
109
87
|
const {
|
|
110
88
|
payload = {}
|
|
111
89
|
} = spec;
|
|
@@ -117,6 +95,14 @@ class Harvest extends _sharedContext.SharedContext {
|
|
|
117
95
|
payload
|
|
118
96
|
});
|
|
119
97
|
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Initiate a harvest call. Typically used by `sendX` and `send` methods or called directly
|
|
101
|
+
* for raw network calls.
|
|
102
|
+
* @param {NetworkSendSpec} param0 Specification for sending data
|
|
103
|
+
* @returns {boolean} True if the network call succeeded. For final harvest calls, the return
|
|
104
|
+
* value should not be relied upon because network calls will be made asynchronously.
|
|
105
|
+
*/
|
|
120
106
|
_send(_ref) {
|
|
121
107
|
let {
|
|
122
108
|
endpoint,
|
|
@@ -128,10 +114,14 @@ class Harvest extends _sharedContext.SharedContext {
|
|
|
128
114
|
raw,
|
|
129
115
|
includeBaseParams = true
|
|
130
116
|
} = _ref;
|
|
131
|
-
|
|
117
|
+
const info = (0, _config.getInfo)(this.sharedContext.agentIdentifier);
|
|
132
118
|
if (!info.errorBeacon) return false;
|
|
133
|
-
|
|
134
|
-
|
|
119
|
+
const agentRuntime = (0, _config.getRuntime)(this.sharedContext.agentIdentifier);
|
|
120
|
+
let {
|
|
121
|
+
body,
|
|
122
|
+
qs
|
|
123
|
+
} = this.cleanPayload(payload);
|
|
124
|
+
if (Object.keys(body).length === 0 && !opts?.sendEmptyBody) {
|
|
135
125
|
// no payload body? nothing to send, just run onfinish stuff and return
|
|
136
126
|
if (cbFinished) {
|
|
137
127
|
cbFinished({
|
|
@@ -140,27 +130,34 @@ class Harvest extends _sharedContext.SharedContext {
|
|
|
140
130
|
}
|
|
141
131
|
return false;
|
|
142
132
|
}
|
|
143
|
-
let url = '';
|
|
144
|
-
if (customUrl) url = customUrl;
|
|
145
|
-
|
|
146
|
-
|
|
133
|
+
let url = "".concat(this.getScheme(), "://").concat(info.errorBeacon).concat(endpoint !== 'rum' ? "/".concat(endpoint) : '', "/1/").concat(info.licenseKey);
|
|
134
|
+
if (customUrl) url = customUrl;
|
|
135
|
+
if (raw) url = "".concat(this.getScheme(), "://").concat(info.errorBeacon, "/").concat(endpoint);
|
|
136
|
+
const baseParams = !raw && includeBaseParams ? this.baseQueryString() : '';
|
|
137
|
+
let payloadParams = (0, _encode.obj)(qs, agentRuntime.maxBytes);
|
|
147
138
|
if (!submitMethod) {
|
|
148
|
-
submitMethod = getSubmitMethod(
|
|
139
|
+
submitMethod = submitData.getSubmitMethod({
|
|
140
|
+
isFinalHarvest: opts.unload
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
if (baseParams === '' && payloadParams.startsWith('&')) {
|
|
144
|
+
payloadParams = payloadParams.substring(1);
|
|
149
145
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
var body;
|
|
153
|
-
var fullUrl = "".concat(url, "?").concat(baseParams).concat(payloadParams);
|
|
154
|
-
const gzip = payload?.qs?.content_encoding === 'gzip';
|
|
146
|
+
const fullUrl = "".concat(url, "?").concat(baseParams).concat(payloadParams);
|
|
147
|
+
const gzip = !!qs?.attributes?.includes('gzip');
|
|
155
148
|
if (!gzip) {
|
|
156
|
-
if (
|
|
157
|
-
body =
|
|
158
|
-
} else if (useBody) {
|
|
159
|
-
body = (0, _stringify.stringify)(payload.body);
|
|
149
|
+
if (endpoint === 'events') {
|
|
150
|
+
body = body.e;
|
|
160
151
|
} else {
|
|
161
|
-
|
|
152
|
+
body = (0, _stringify.stringify)(body);
|
|
162
153
|
}
|
|
163
|
-
|
|
154
|
+
/** Warn --once per endpoint-- if the agent tries to send large payloads */
|
|
155
|
+
if (body.length > 750000 && (warnings[endpoint] = (warnings?.[endpoint] || 0) + 1) === 1) (0, _console.warn)("The Browser Agent is attempting to send a very large payload to /".concat(endpoint, ". This is usually tied to large amounts of custom attributes. Please check your configurations."));
|
|
156
|
+
}
|
|
157
|
+
if (!body || body.length === 0 || body === '{}' || body === '[]') {
|
|
158
|
+
// If body is null, undefined, or an empty object or array, send an empty string instead
|
|
159
|
+
body = '';
|
|
160
|
+
}
|
|
164
161
|
|
|
165
162
|
// Get bytes harvested per endpoint as a supportability metric. See metrics aggregator (on unload).
|
|
166
163
|
agentRuntime.bytesSent[endpoint] = (agentRuntime.bytesSent[endpoint] || 0) + body?.length || 0;
|
|
@@ -172,122 +169,131 @@ class Harvest extends _sharedContext.SharedContext {
|
|
|
172
169
|
value: 'text/plain'
|
|
173
170
|
});
|
|
174
171
|
|
|
175
|
-
/* Since workers don't support sendBeacon right now,
|
|
172
|
+
/* Since workers don't support sendBeacon right now, they can only use XHR method.
|
|
176
173
|
Because they still do permit synch XHR, the idea is that at final harvest time (worker is closing),
|
|
177
|
-
we just make a BLOCKING request--trivial impact--with the remaining data as a temp fill-in for sendBeacon.
|
|
178
|
-
|
|
179
|
-
|
|
174
|
+
we just make a BLOCKING request--trivial impact--with the remaining data as a temp fill-in for sendBeacon.
|
|
175
|
+
Following the removal of img-element method, IE will also use sync XHR on page dismissal to ensure final analytics are sent. */
|
|
176
|
+
let result = submitMethod({
|
|
180
177
|
url: fullUrl,
|
|
181
178
|
body,
|
|
182
|
-
sync: opts.unload &&
|
|
179
|
+
sync: opts.unload && (_runtime.isWorkerScope || _runtime.isIE),
|
|
183
180
|
headers
|
|
184
181
|
});
|
|
185
|
-
if (cbFinished &&
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
182
|
+
if (!opts.unload && cbFinished && submitMethod === submitData.xhr) {
|
|
183
|
+
const harvestScope = this;
|
|
184
|
+
result.addEventListener('load', function () {
|
|
185
|
+
// `this` refers to the XHR object in this scope, do not change this to a fat arrow
|
|
186
|
+
const cbResult = {
|
|
189
187
|
sent: true,
|
|
190
188
|
status: this.status
|
|
191
189
|
};
|
|
192
190
|
if (this.status === 429) {
|
|
193
|
-
|
|
194
|
-
|
|
191
|
+
cbResult.retry = true;
|
|
192
|
+
cbResult.delay = harvestScope.tooManyRequestsDelay;
|
|
195
193
|
} else if (this.status === 408 || this.status === 500 || this.status === 503) {
|
|
196
|
-
|
|
194
|
+
cbResult.retry = true;
|
|
197
195
|
}
|
|
198
196
|
if (opts.needResponse) {
|
|
199
|
-
|
|
197
|
+
cbResult.responseText = this.responseText;
|
|
200
198
|
}
|
|
201
|
-
cbFinished(
|
|
199
|
+
cbFinished(cbResult);
|
|
202
200
|
}, (0, _eventListenerOpts.eventListenerOpts)(false));
|
|
203
201
|
}
|
|
204
|
-
|
|
205
|
-
// if beacon request failed, retry with an alternative method -- will not happen for workers
|
|
206
|
-
if (!result && method === _submitData.submitData.beacon) {
|
|
207
|
-
method = _submitData.submitData.img;
|
|
208
|
-
result = method({
|
|
209
|
-
url: fullUrl + (0, _encode.obj)(payload.body, agentRuntime.maxBytes)
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
202
|
return result;
|
|
213
203
|
}
|
|
214
204
|
|
|
215
205
|
// The stuff that gets sent every time.
|
|
216
206
|
baseQueryString() {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
207
|
+
const runtime = (0, _config.getRuntime)(this.sharedContext.agentIdentifier);
|
|
208
|
+
const info = (0, _config.getInfo)(this.sharedContext.agentIdentifier);
|
|
209
|
+
const location = (0, _cleanUrl.cleanURL)((0, _location.getLocation)());
|
|
210
|
+
const ref = this.obfuscator.shouldObfuscate() ? this.obfuscator.obfuscateString(location) : location;
|
|
221
211
|
return ['a=' + info.applicationID, (0, _encode.param)('sa', info.sa ? '' + info.sa : ''), (0, _encode.param)('v', _env.VERSION), transactionNameParam(info), (0, _encode.param)('ct', runtime.customTransaction), '&rst=' + (0, _now.now)(), '&ck=0',
|
|
222
212
|
// ck param DEPRECATED - still expected by backend
|
|
223
213
|
'&s=' + (runtime.session?.state.value || '0'),
|
|
224
214
|
// the 0 id encaps all untrackable and default traffic
|
|
225
215
|
(0, _encode.param)('ref', ref), (0, _encode.param)('ptid', runtime.ptid ? '' + runtime.ptid : '')].join('');
|
|
226
216
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Calls and accumulates data from registered harvesting functions based on
|
|
220
|
+
* the endpoint being harvested.
|
|
221
|
+
* @param {HarvestEndpointIdentifier} endpoint BAM endpoint identifier.
|
|
222
|
+
* @param {FeatureHarvestCallbackOptions} options Options to be passed to the
|
|
223
|
+
* feature harvest listener callback.
|
|
224
|
+
* @returns {HarvestPayload} Payload object to transmit to the bam endpoint.
|
|
225
|
+
*/
|
|
226
|
+
createPayload(endpoint, options) {
|
|
227
|
+
const listeners = this._events[endpoint];
|
|
228
|
+
const payload = {
|
|
229
|
+
body: {},
|
|
230
|
+
qs: {}
|
|
231
|
+
};
|
|
232
|
+
if (Array.isArray(listeners) && listeners.length > 0) {
|
|
233
|
+
for (let i = 0; i < listeners.length; i++) {
|
|
234
|
+
const singlePayload = listeners[i](options);
|
|
235
|
+
if (singlePayload) {
|
|
236
|
+
payload.body = {
|
|
237
|
+
...payload.body,
|
|
238
|
+
...(singlePayload.body || {})
|
|
239
|
+
};
|
|
240
|
+
payload.qs = {
|
|
241
|
+
...payload.qs,
|
|
242
|
+
...(singlePayload.qs || {})
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
}
|
|
236
246
|
}
|
|
247
|
+
return payload;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Cleans and returns a payload object containing a body and qs
|
|
252
|
+
* object with key/value pairs. KV pairs where the value is null,
|
|
253
|
+
* undefined, or an empty string are removed to save on transmission
|
|
254
|
+
* size.
|
|
255
|
+
* @param {HarvestPayload} payload Payload to be sent to the endpoint.
|
|
256
|
+
* @returns {HarvestPayload} Cleaned payload payload to be sent to the endpoint.
|
|
257
|
+
*/
|
|
258
|
+
cleanPayload() {
|
|
259
|
+
let payload = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
260
|
+
const clean = input => {
|
|
261
|
+
if (typeof Uint8Array !== 'undefined' && input instanceof Uint8Array || typeof input === 'string') {
|
|
262
|
+
return input.length > 0 ? input : null;
|
|
263
|
+
}
|
|
264
|
+
return Object.entries(input || {}).reduce((accumulator, _ref2) => {
|
|
265
|
+
let [key, value] = _ref2;
|
|
266
|
+
if (typeof value === 'number' || typeof value === 'string' && value.length > 0 || typeof value === 'object' && Object.keys(value || {}).length > 0) {
|
|
267
|
+
accumulator[key] = value;
|
|
268
|
+
}
|
|
269
|
+
return accumulator;
|
|
270
|
+
}, {});
|
|
271
|
+
};
|
|
237
272
|
return {
|
|
238
|
-
body:
|
|
239
|
-
qs:
|
|
273
|
+
body: clean(payload.body),
|
|
274
|
+
qs: clean(payload.qs)
|
|
240
275
|
};
|
|
241
276
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
opts = opts || {};
|
|
255
|
-
var method;
|
|
256
|
-
var useBody;
|
|
257
|
-
if (opts.unload && _globalScope.isBrowserScope) {
|
|
258
|
-
// all the features' final harvest; neither methods work outside window context
|
|
259
|
-
useBody = haveSendBeacon;
|
|
260
|
-
method = haveSendBeacon ? _submitData.submitData.beacon : _submitData.submitData.img; // really only IE doesn't have Beacon API for web browsers
|
|
261
|
-
} else {
|
|
262
|
-
// `submitData.beacon` was removed, there is an upper limit to the
|
|
263
|
-
// number of data allowed before it starts failing, so we save it only for page unloading
|
|
264
|
-
useBody = true;
|
|
265
|
-
method = _submitData.submitData.xhr;
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Registers a function to be called when harvesting is triggered for a specific
|
|
280
|
+
* endpoint.
|
|
281
|
+
* @param {HarvestEndpointIdentifier} endpoint
|
|
282
|
+
* @param {FeatureHarvestCallback} listener
|
|
283
|
+
*/
|
|
284
|
+
on(endpoint, listener) {
|
|
285
|
+
if (!Array.isArray(this._events[endpoint])) {
|
|
286
|
+
this._events[endpoint] = [];
|
|
287
|
+
}
|
|
288
|
+
this._events[endpoint].push(listener);
|
|
266
289
|
}
|
|
267
|
-
return {
|
|
268
|
-
method: method,
|
|
269
|
-
useBody: useBody
|
|
270
|
-
};
|
|
271
290
|
}
|
|
272
291
|
|
|
273
292
|
// Constructs the transaction name param for the beacon URL.
|
|
274
293
|
// Prefers the obfuscated transaction name over the plain text.
|
|
275
294
|
// Falls back to making up a name.
|
|
295
|
+
exports.Harvest = Harvest;
|
|
276
296
|
function transactionNameParam(info) {
|
|
277
297
|
if (info.transactionName) return (0, _encode.param)('to', info.transactionName);
|
|
278
298
|
return (0, _encode.param)('t', info.tNamePlain || 'Unnamed Transaction');
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
// returns a function that can be called to accumulate values to a single object
|
|
282
|
-
// when the function is called without parameters, then the accumulator is returned
|
|
283
|
-
function createAccumulator() {
|
|
284
|
-
var accumulator = {};
|
|
285
|
-
var hasData = false;
|
|
286
|
-
return function (key, val) {
|
|
287
|
-
if (val !== null && val !== undefined && val.toString()?.length) {
|
|
288
|
-
accumulator[key] = val;
|
|
289
|
-
hasData = true;
|
|
290
|
-
}
|
|
291
|
-
if (hasData) return accumulator;
|
|
292
|
-
};
|
|
293
299
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.unused = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* @file Contains types related to harvesting data.
|
|
9
|
+
* @copyright 2023 New Relic Corporation. All rights reserved.
|
|
10
|
+
* @license Apache-2.0
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @typedef {'rum'|'jserrors'|'events'|'ins'|'resources'|'blob'} HarvestEndpointIdentifier
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @typedef {object} HarvestPayload
|
|
19
|
+
* @property {object} qs Map of values that should be sent as part of the request query string.
|
|
20
|
+
* @property {object} body Map of values that should be sent as the body of the request.
|
|
21
|
+
* @property {string} body.e Special case of body used for browser interactions.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @typedef {object} FeatureHarvestCallbackOptions Options for aggregating data for harvesting.
|
|
26
|
+
* @property {boolean} options.retry Indicates if the feature should store the aggregated
|
|
27
|
+
* data in anticipation of a possible need to retry the transmission.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @callback FeatureHarvestCallback
|
|
32
|
+
* @param {FeatureHarvestCallbackOptions} options Options for aggregating data for harvesting.
|
|
33
|
+
* @returns {HarvestPayload} Payload of data to transmit to bam endpoint.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @typedef {object} NetworkSendSpec
|
|
38
|
+
* @property {HarvestEndpointIdentifier} endpoint The endpoint to use (jserrors, events, resources etc.)
|
|
39
|
+
* @property {HarvestPayload} payload Object representing payload.
|
|
40
|
+
* @property {object} opts Additional options for sending data
|
|
41
|
+
* @property {boolean} opts.needResponse Specify whether the caller expects a response data.
|
|
42
|
+
* @property {boolean} opts.unload Specify whether the call is a final harvest during page unload.
|
|
43
|
+
* @property {boolean} opts.sendEmptyBody Specify whether the call should be made even if the body is empty. Useful for rum calls.
|
|
44
|
+
* @property {boolean} opts.retry Indicates if the feature should store the aggregated data in anticipation of a possible need to
|
|
45
|
+
* retry the transmission.
|
|
46
|
+
* @property {import('../util/submit-data.js').NetworkMethods} submitMethod The network method to use {@link ../util/submit-data.js}
|
|
47
|
+
* @property {string} customUrl Override the beacon url the data is sent to; must include protocol if defined
|
|
48
|
+
* @property {boolean} raw If true, disables adding the license key to the url
|
|
49
|
+
* @property {boolean} includeBaseParams Enables the use of base query parameters in the beacon url
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
/* istanbul ignore next */
|
|
53
|
+
const unused = {};
|
|
54
|
+
exports.unused = unused;
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.id = id;
|
|
7
7
|
var _getOrSet = require("../util/get-or-set");
|
|
8
|
-
var
|
|
8
|
+
var _runtime = require("../constants/runtime");
|
|
9
9
|
/*
|
|
10
10
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
11
11
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -31,7 +31,7 @@ function id(obj) {
|
|
|
31
31
|
// We can only tag objects, functions, and arrays with ids.
|
|
32
32
|
// For all primitive values we instead return -1.
|
|
33
33
|
if (!obj || !(type === 'object' || type === 'function')) return -1;
|
|
34
|
-
if (obj ===
|
|
34
|
+
if (obj === _runtime.globalScope) return 0;
|
|
35
35
|
return (0, _getOrSet.getOrSet)(obj, prop, function () {
|
|
36
36
|
return index++;
|
|
37
37
|
});
|
|
@@ -7,7 +7,7 @@ exports.generateRandomHexString = generateRandomHexString;
|
|
|
7
7
|
exports.generateSpanId = generateSpanId;
|
|
8
8
|
exports.generateTraceId = generateTraceId;
|
|
9
9
|
exports.generateUuid = generateUuid;
|
|
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
|
|
@@ -46,7 +46,7 @@ function getRandomValue(valueTable, tableIndex) {
|
|
|
46
46
|
* @returns {string} uuid version 4 string
|
|
47
47
|
*/
|
|
48
48
|
function generateUuid() {
|
|
49
|
-
const crypto =
|
|
49
|
+
const crypto = _runtime.globalScope?.crypto || _runtime.globalScope?.msCrypto;
|
|
50
50
|
let randomValueTable;
|
|
51
51
|
let randomValueIndex = 0;
|
|
52
52
|
if (crypto && crypto.getRandomValues) {
|
|
@@ -73,7 +73,7 @@ function generateUuid() {
|
|
|
73
73
|
* @returns {string} generated hex string
|
|
74
74
|
*/
|
|
75
75
|
function generateRandomHexString(length) {
|
|
76
|
-
const crypto =
|
|
76
|
+
const crypto = _runtime.globalScope?.crypto || _runtime.globalScope?.msCrypto;
|
|
77
77
|
let randomValueTable;
|
|
78
78
|
let randomValueIndex = 0;
|
|
79
79
|
if (crypto && crypto.getRandomValues) {
|
|
@@ -9,7 +9,7 @@ var _console = require("../util/console");
|
|
|
9
9
|
var _stringify = require("../util/stringify");
|
|
10
10
|
var _contextualEe = require("../event-emitter/contextual-ee");
|
|
11
11
|
var _timer = require("../timer/timer");
|
|
12
|
-
var
|
|
12
|
+
var _runtime = require("../constants/runtime");
|
|
13
13
|
var _constants = require("./constants");
|
|
14
14
|
var _interactionTimer = require("../timer/interaction-timer");
|
|
15
15
|
var _wrap = require("../wrap");
|
|
@@ -274,7 +274,7 @@ class SessionEntity {
|
|
|
274
274
|
return Date.now() + futureMs;
|
|
275
275
|
}
|
|
276
276
|
syncCustomAttribute(key, value) {
|
|
277
|
-
if (!
|
|
277
|
+
if (!_runtime.isBrowserScope) return;
|
|
278
278
|
if (value === null) {
|
|
279
279
|
const curr = this.read();
|
|
280
280
|
if (curr.custom) {
|
|
@@ -7,7 +7,7 @@ exports.InteractionTimer = void 0;
|
|
|
7
7
|
var _timer = require("./timer");
|
|
8
8
|
var _pageVisibility = require("../window/page-visibility");
|
|
9
9
|
var _invoke = require("../util/invoke");
|
|
10
|
-
var
|
|
10
|
+
var _runtime = require("../constants/runtime");
|
|
11
11
|
class InteractionTimer extends _timer.Timer {
|
|
12
12
|
constructor(opts, ms) {
|
|
13
13
|
super(opts, ms);
|
|
@@ -25,7 +25,7 @@ class InteractionTimer extends _timer.Timer {
|
|
|
25
25
|
} catch (e) {
|
|
26
26
|
// this try-catch can be removed when IE11 is completely unsupported & gone
|
|
27
27
|
}
|
|
28
|
-
if (
|
|
28
|
+
if (_runtime.isBrowserScope && opts.ee) {
|
|
29
29
|
if (opts.ee) {
|
|
30
30
|
const debouncedRefresh = (0, _invoke.debounce)(this.refresh.bind(this), 500, {
|
|
31
31
|
leading: true
|
|
@@ -4,23 +4,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.subscribeToEOL = subscribeToEOL;
|
|
7
|
-
var _firefoxVersion = require("../browser-version/firefox-version");
|
|
8
7
|
var _eventListenerOpts = require("../event-listener/event-listener-opts");
|
|
9
8
|
var _invoke = require("../util/invoke");
|
|
10
|
-
var
|
|
9
|
+
var _runtime = require("../constants/runtime");
|
|
11
10
|
var _pageVisibility = require("../window/page-visibility");
|
|
12
11
|
/*
|
|
13
12
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
14
13
|
* SPDX-License-Identifier: Apache-2.0
|
|
15
14
|
*/
|
|
16
15
|
|
|
17
|
-
if (
|
|
18
|
-
|
|
16
|
+
if (_runtime.isWorkerScope) {
|
|
17
|
+
_runtime.globalScope.cleanupTasks = []; // create new list on WorkerGlobalScope to track funcs to run before exiting thread
|
|
19
18
|
|
|
20
|
-
const origClose =
|
|
21
|
-
|
|
19
|
+
const origClose = _runtime.globalScope.close;
|
|
20
|
+
_runtime.globalScope.close = () => {
|
|
22
21
|
// on worker's EoL signal, execute all "listeners", e.g. final harvests
|
|
23
|
-
for (let task of
|
|
22
|
+
for (let task of _runtime.globalScope.cleanupTasks) {
|
|
24
23
|
task();
|
|
25
24
|
}
|
|
26
25
|
origClose();
|
|
@@ -34,7 +33,7 @@ if (_globalScope.isWorkerScope) {
|
|
|
34
33
|
* @param {boolean} allowBFCache - (temp) feature flag to gate new v1222 BFC support
|
|
35
34
|
*/
|
|
36
35
|
function subscribeToEOL(cb, allowBFCache) {
|
|
37
|
-
if (
|
|
36
|
+
if (_runtime.isBrowserScope) {
|
|
38
37
|
if (allowBFCache) {
|
|
39
38
|
(0, _pageVisibility.subscribeToVisibilityChange)(cb, true); // when user switches tab or hides window, esp. mobile scenario
|
|
40
39
|
(0, _eventListenerOpts.windowAddEventListener)('pagehide', cb); // when user navigates away, and because safari iOS v14.4- doesn't fully support vis change
|
|
@@ -55,15 +54,15 @@ function subscribeToEOL(cb, allowBFCache) {
|
|
|
55
54
|
// pagehide or unload, whichever comes first, but in Firefox, we need to avoid
|
|
56
55
|
// attempting to submit from pagehide to ensure that we don't slow down loading
|
|
57
56
|
// of the next page.
|
|
58
|
-
if (!
|
|
57
|
+
if (!_runtime.ffVersion || navigator.sendBeacon) {
|
|
59
58
|
(0, _eventListenerOpts.windowAddEventListener)('pagehide', oneCall);
|
|
60
59
|
} else {
|
|
61
60
|
(0, _eventListenerOpts.windowAddEventListener)('beforeunload', oneCall);
|
|
62
61
|
}
|
|
63
62
|
(0, _eventListenerOpts.windowAddEventListener)('unload', oneCall);
|
|
64
63
|
}
|
|
65
|
-
} else if (
|
|
66
|
-
|
|
64
|
+
} else if (_runtime.isWorkerScope) {
|
|
65
|
+
_runtime.globalScope.cleanupTasks.push(cb); // close() should run these tasks before quitting thread
|
|
67
66
|
}
|
|
68
67
|
// By default (for other env), this fn has no effect.
|
|
69
68
|
}
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.canonicalizeUrl = canonicalizeUrl;
|
|
7
|
-
var
|
|
7
|
+
var _runtime = require("../constants/runtime");
|
|
8
8
|
var _cleanUrl = require("./clean-url");
|
|
9
9
|
/*
|
|
10
10
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
@@ -21,7 +21,7 @@ var _cleanUrl = require("./clean-url");
|
|
|
21
21
|
function canonicalizeUrl(url) {
|
|
22
22
|
if (typeof url !== 'string') return '';
|
|
23
23
|
const cleanedUrl = (0, _cleanUrl.cleanURL)(url);
|
|
24
|
-
const cleanedGlobalScopeUrl = (0, _cleanUrl.cleanURL)(
|
|
24
|
+
const cleanedGlobalScopeUrl = (0, _cleanUrl.cleanURL)(_runtime.initialLocation);
|
|
25
25
|
|
|
26
26
|
// If the URL matches the origin URL of the loader, we assume it originated within an inline script.
|
|
27
27
|
if (cleanedUrl === cleanedGlobalScopeUrl) {
|
|
@@ -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;
|