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