@newrelic/browser-agent 0.1.230 → 1.232.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 +27 -3
- package/dist/cjs/common/browser-version/ios-version.js +4 -3
- package/dist/cjs/common/config/state/configurable.js +27 -21
- package/dist/cjs/common/config/state/info.js +1 -1
- package/dist/cjs/common/config/state/init.js +9 -1
- package/dist/cjs/common/config/state/loader-config.js +1 -1
- package/dist/cjs/common/config/state/runtime.js +26 -28
- package/dist/cjs/common/constants/env.cdn.js +29 -0
- package/dist/cjs/common/constants/env.js +32 -0
- package/dist/cjs/common/constants/env.npm.js +30 -0
- package/dist/cjs/common/context/shared-context.js +2 -1
- package/dist/cjs/common/event-emitter/contextual-ee.test.js +282 -0
- package/dist/cjs/common/event-emitter/handle.test.js +58 -0
- package/dist/cjs/common/event-emitter/register-handler.test.js +55 -0
- package/dist/cjs/common/event-listener/event-listener-opts.js +4 -2
- package/dist/cjs/common/harvest/harvest-scheduler.js +14 -11
- package/dist/cjs/common/harvest/harvest.js +5 -3
- package/dist/cjs/common/ids/id.js +14 -6
- package/dist/cjs/common/ids/id.test.js +85 -0
- package/dist/cjs/common/ids/unique-id.js +75 -51
- package/dist/cjs/common/ids/unique-id.test.js +49 -0
- package/dist/cjs/common/session/constants.js +12 -0
- package/dist/cjs/common/session/session-entity.js +278 -0
- package/dist/cjs/common/session/session-entity.test.js +436 -0
- package/dist/cjs/common/storage/first-party-cookies.js +35 -0
- package/dist/cjs/common/storage/local-memory.js +35 -0
- package/dist/cjs/common/storage/local-memory.test.js +20 -0
- package/dist/cjs/common/storage/local-storage.js +33 -0
- package/dist/cjs/common/storage/local-storage.test.js +14 -0
- package/dist/cjs/common/timer/interaction-timer.js +78 -0
- package/dist/cjs/common/timer/interaction-timer.test.js +216 -0
- package/dist/cjs/common/timer/timer.js +32 -0
- package/dist/cjs/common/timer/timer.test.js +105 -0
- package/dist/cjs/common/timing/nav-timing.js +51 -30
- package/dist/cjs/common/timing/nav-timing.test.js +192 -0
- package/dist/cjs/common/unload/eol.js +2 -2
- package/dist/cjs/common/url/clean-url.test.js +9 -0
- package/dist/cjs/common/url/encode.test.js +74 -0
- package/dist/cjs/common/url/location.js +4 -0
- package/dist/cjs/common/url/location.test.js +13 -0
- package/dist/cjs/common/url/parse-url.test.js +111 -0
- package/dist/cjs/common/url/protocol.js +2 -12
- package/dist/cjs/common/url/protocol.test.js +16 -0
- package/dist/cjs/common/util/console.js +1 -1
- package/dist/cjs/common/util/data-size.js +6 -0
- package/dist/cjs/common/util/data-size.test.js +47 -0
- package/dist/cjs/common/util/invoke.js +73 -0
- package/dist/cjs/common/util/invoke.test.js +49 -0
- package/dist/cjs/common/util/map-own.test.js +3 -3
- package/dist/cjs/common/util/obfuscate.js +1 -5
- package/dist/cjs/common/window/page-visibility.js +5 -2
- package/dist/cjs/common/wrap/index.js +0 -7
- package/dist/cjs/common/wrap/wrap-events.js +6 -9
- package/dist/cjs/common/wrap/wrap-fetch.js +6 -6
- package/dist/cjs/common/wrap/wrap-history.js +7 -6
- package/dist/cjs/common/wrap/wrap-jsonp.js +7 -6
- package/dist/cjs/common/wrap/wrap-mutation.js +7 -6
- package/dist/cjs/common/wrap/wrap-promise.js +7 -6
- package/dist/cjs/common/wrap/wrap-promise.test.js +119 -0
- package/dist/cjs/common/wrap/wrap-raf.js +6 -6
- package/dist/cjs/common/wrap/wrap-timer.js +7 -7
- package/dist/cjs/common/wrap/wrap-xhr.js +5 -6
- package/dist/cjs/features/ajax/aggregate/index.js +3 -3
- package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.test.js +5 -5
- package/dist/cjs/features/jserrors/aggregate/format-stack-trace.test.js +1 -1
- package/dist/cjs/features/jserrors/aggregate/index.js +6 -6
- package/dist/cjs/features/jserrors/instrument/index.js +2 -2
- package/dist/cjs/features/metrics/aggregate/index.js +19 -9
- package/dist/cjs/features/metrics/instrument/index.js +0 -25
- package/dist/cjs/features/metrics/instrument/workers-helper.js +5 -5
- package/dist/cjs/features/page_action/aggregate/index.js +3 -3
- package/dist/cjs/features/page_view_event/aggregate/index.js +23 -9
- package/dist/cjs/features/page_view_timing/aggregate/index.js +40 -30
- package/dist/cjs/features/session_trace/aggregate/index.js +18 -15
- package/dist/cjs/features/spa/aggregate/index.js +6 -5
- package/dist/cjs/features/utils/agent-session.js +73 -0
- package/dist/cjs/features/utils/feature-base.js +1 -1
- package/dist/cjs/features/utils/instrument-base.js +12 -3
- package/dist/cjs/features/utils/lazy-loader.js +2 -2
- package/dist/cjs/loaders/agent.js +2 -2
- package/dist/cjs/loaders/api/api.js +9 -9
- package/dist/cjs/loaders/api/apiAsync.js +3 -2
- package/dist/cjs/loaders/configure/configure.js +0 -6
- package/dist/cjs/loaders/features/enabled-features.js +1 -1
- package/dist/cjs/loaders/micro-agent.js +2 -1
- package/dist/esm/common/browser-version/ios-version.js +4 -3
- package/dist/esm/common/config/state/configurable.js +26 -20
- package/dist/esm/common/config/state/info.js +1 -1
- package/dist/esm/common/config/state/init.js +9 -1
- package/dist/esm/common/config/state/loader-config.js +1 -1
- package/dist/esm/common/config/state/runtime.js +26 -28
- package/dist/esm/common/constants/env.cdn.js +20 -0
- package/dist/esm/common/constants/env.js +23 -0
- package/dist/esm/common/constants/env.npm.js +21 -0
- package/dist/esm/common/context/shared-context.js +2 -1
- package/dist/esm/common/event-emitter/contextual-ee.test.js +278 -0
- package/dist/esm/common/event-emitter/handle.test.js +54 -0
- package/dist/esm/common/event-emitter/register-handler.test.js +51 -0
- package/dist/esm/common/event-listener/event-listener-opts.js +4 -2
- package/dist/esm/common/harvest/harvest-scheduler.js +14 -11
- package/dist/esm/common/harvest/harvest.js +4 -2
- package/dist/esm/common/ids/id.js +16 -6
- package/dist/esm/common/ids/id.test.js +81 -0
- package/dist/esm/common/ids/unique-id.js +75 -51
- package/dist/esm/common/ids/unique-id.test.js +44 -0
- package/dist/esm/common/session/constants.js +3 -0
- package/dist/esm/common/session/session-entity.js +271 -0
- package/dist/esm/common/session/session-entity.test.js +434 -0
- package/dist/esm/common/storage/first-party-cookies.js +28 -0
- package/dist/esm/common/storage/local-memory.js +28 -0
- package/dist/esm/common/storage/local-memory.test.js +18 -0
- package/dist/esm/common/storage/local-storage.js +26 -0
- package/dist/esm/common/storage/local-storage.test.js +12 -0
- package/dist/esm/common/timer/interaction-timer.js +71 -0
- package/dist/esm/common/timer/interaction-timer.test.js +214 -0
- package/dist/esm/common/timer/timer.js +25 -0
- package/dist/esm/common/timer/timer.test.js +103 -0
- package/dist/esm/common/timing/nav-timing.js +51 -29
- package/dist/esm/common/timing/nav-timing.test.js +190 -0
- package/dist/esm/common/unload/eol.js +1 -1
- package/dist/esm/common/url/clean-url.test.js +7 -0
- package/dist/esm/common/url/encode.test.js +70 -0
- package/dist/esm/common/url/location.js +4 -0
- package/dist/esm/common/url/location.test.js +11 -0
- package/dist/esm/common/url/parse-url.test.js +107 -0
- package/dist/esm/common/url/protocol.js +3 -12
- package/dist/esm/common/url/protocol.test.js +14 -0
- package/dist/esm/common/util/console.js +1 -1
- package/dist/esm/common/util/data-size.js +7 -0
- package/dist/esm/common/util/data-size.test.js +45 -0
- package/dist/esm/common/util/invoke.js +66 -0
- package/dist/esm/common/util/invoke.test.js +47 -0
- package/dist/esm/common/util/map-own.test.js +3 -3
- package/dist/esm/common/util/obfuscate.js +2 -6
- package/dist/esm/common/window/page-visibility.js +5 -2
- package/dist/esm/common/wrap/index.js +1 -2
- package/dist/esm/common/wrap/wrap-events.js +6 -9
- package/dist/esm/common/wrap/wrap-fetch.js +6 -6
- package/dist/esm/common/wrap/wrap-history.js +7 -6
- package/dist/esm/common/wrap/wrap-jsonp.js +7 -6
- package/dist/esm/common/wrap/wrap-mutation.js +7 -6
- package/dist/esm/common/wrap/wrap-promise.js +7 -6
- package/dist/esm/common/wrap/wrap-promise.test.js +115 -0
- package/dist/esm/common/wrap/wrap-raf.js +6 -6
- package/dist/esm/common/wrap/wrap-timer.js +7 -7
- package/dist/esm/common/wrap/wrap-xhr.js +5 -6
- package/dist/esm/features/ajax/aggregate/index.js +3 -3
- package/dist/esm/features/jserrors/aggregate/compute-stack-trace.test.js +5 -5
- package/dist/esm/features/jserrors/aggregate/format-stack-trace.test.js +1 -1
- package/dist/esm/features/jserrors/aggregate/index.js +6 -6
- package/dist/esm/features/jserrors/instrument/index.js +2 -2
- package/dist/esm/features/metrics/aggregate/index.js +21 -11
- package/dist/esm/features/metrics/instrument/index.js +0 -25
- package/dist/esm/features/metrics/instrument/workers-helper.js +5 -5
- package/dist/esm/features/page_action/aggregate/index.js +3 -3
- package/dist/esm/features/page_view_event/aggregate/index.js +23 -9
- package/dist/esm/features/page_view_timing/aggregate/index.js +40 -30
- package/dist/esm/features/session_trace/aggregate/index.js +18 -15
- package/dist/esm/features/spa/aggregate/index.js +6 -5
- package/dist/esm/features/utils/agent-session.js +67 -0
- package/dist/esm/features/utils/feature-base.js +1 -1
- package/dist/esm/features/utils/instrument-base.js +7 -2
- package/dist/esm/features/utils/lazy-loader.js +2 -2
- package/dist/esm/loaders/agent.js +2 -2
- package/dist/esm/loaders/api/api.js +6 -9
- package/dist/esm/loaders/api/apiAsync.js +2 -1
- package/dist/esm/loaders/configure/configure.js +2 -8
- package/dist/esm/loaders/features/enabled-features.js +1 -1
- package/dist/types/common/config/state/configurable.d.ts.map +1 -1
- package/dist/types/common/config/state/init.d.ts.map +1 -1
- package/dist/types/common/config/state/runtime.d.ts.map +1 -1
- package/dist/types/common/constants/env.cdn.d.ts +18 -0
- package/dist/types/common/constants/env.cdn.d.ts.map +1 -0
- package/dist/types/common/constants/env.d.ts +13 -0
- package/dist/types/common/constants/env.d.ts.map +1 -0
- package/dist/types/common/constants/env.npm.d.ts +19 -0
- package/dist/types/common/constants/env.npm.d.ts.map +1 -0
- package/dist/types/common/context/shared-context.d.ts.map +1 -1
- package/dist/types/common/event-listener/event-listener-opts.d.ts +2 -2
- package/dist/types/common/event-listener/event-listener-opts.d.ts.map +1 -1
- package/dist/types/common/harvest/harvest-scheduler.d.ts +1 -0
- package/dist/types/common/harvest/harvest-scheduler.d.ts.map +1 -1
- package/dist/types/common/harvest/harvest.d.ts.map +1 -1
- package/dist/types/common/ids/id.d.ts +11 -1
- package/dist/types/common/ids/id.d.ts.map +1 -1
- package/dist/types/common/ids/unique-id.d.ts +24 -1
- package/dist/types/common/ids/unique-id.d.ts.map +1 -1
- package/dist/types/common/session/constants.d.ts +4 -0
- package/dist/types/common/session/constants.d.ts.map +1 -0
- package/dist/types/common/session/session-entity.d.ts +72 -0
- package/dist/types/common/session/session-entity.d.ts.map +1 -0
- package/dist/types/common/storage/first-party-cookies.d.ts +8 -0
- package/dist/types/common/storage/first-party-cookies.d.ts.map +1 -0
- package/dist/types/common/storage/local-memory.d.ts +8 -0
- package/dist/types/common/storage/local-memory.d.ts.map +1 -0
- package/dist/types/common/storage/local-storage.d.ts +6 -0
- package/dist/types/common/storage/local-storage.d.ts.map +1 -0
- package/dist/types/common/timer/interaction-timer.d.ts +11 -0
- package/dist/types/common/timer/interaction-timer.d.ts.map +1 -0
- package/dist/types/common/timer/timer.d.ts +12 -0
- package/dist/types/common/timer/timer.d.ts.map +1 -0
- package/dist/types/common/timing/nav-timing.d.ts +1 -2
- package/dist/types/common/timing/nav-timing.d.ts.map +1 -1
- package/dist/types/common/unload/eol.d.ts.map +1 -1
- package/dist/types/common/url/location.d.ts +4 -0
- package/dist/types/common/url/location.d.ts.map +1 -1
- package/dist/types/common/url/parse-url.d.ts.map +1 -1
- package/dist/types/common/url/protocol.d.ts +1 -6
- package/dist/types/common/url/protocol.d.ts.map +1 -1
- package/dist/types/common/util/data-size.d.ts +7 -1
- package/dist/types/common/util/data-size.d.ts.map +1 -1
- package/dist/types/common/util/global-scope.d.ts.map +1 -1
- package/dist/types/common/util/invoke.d.ts +35 -0
- package/dist/types/common/util/invoke.d.ts.map +1 -0
- package/dist/types/common/util/obfuscate.d.ts.map +1 -1
- package/dist/types/common/window/page-visibility.d.ts +1 -1
- package/dist/types/common/window/page-visibility.d.ts.map +1 -1
- package/dist/types/common/wrap/index.d.ts +1 -2
- package/dist/types/common/wrap/index.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-fetch.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-history.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-jsonp.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-mutation.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-promise.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-raf.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-timer.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-xhr.d.ts.map +1 -1
- package/dist/types/features/ajax/aggregate/index.d.ts +2 -2
- package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/aggregate/index.d.ts +2 -2
- package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -1
- package/dist/types/features/metrics/aggregate/index.d.ts +2 -2
- package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/metrics/instrument/index.d.ts +0 -1
- package/dist/types/features/metrics/instrument/index.d.ts.map +1 -1
- package/dist/types/features/metrics/instrument/workers-helper.d.ts.map +1 -1
- package/dist/types/features/page_action/aggregate/index.d.ts +2 -2
- package/dist/types/features/page_action/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/page_view_event/aggregate/index.d.ts +2 -2
- package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/page_view_timing/aggregate/index.d.ts +3 -4
- package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_trace/aggregate/index.d.ts +3 -3
- package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_trace/instrument/index.d.ts.map +1 -1
- package/dist/types/features/spa/aggregate/index.d.ts +2 -2
- package/dist/types/features/spa/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/spa/instrument/index.d.ts.map +1 -1
- package/dist/types/features/utils/agent-session.d.ts +2 -0
- package/dist/types/features/utils/agent-session.d.ts.map +1 -0
- package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
- package/dist/types/features/utils/lazy-loader.d.ts +2 -2
- package/dist/types/features/utils/lazy-loader.d.ts.map +1 -1
- package/dist/types/loaders/api/api.d.ts.map +1 -1
- package/dist/types/loaders/api/apiAsync.d.ts.map +1 -1
- package/dist/types/loaders/configure/configure.d.ts.map +1 -1
- package/package.json +12 -32
- package/src/common/browser-version/ios-version.js +4 -3
- package/src/common/config/state/configurable.js +26 -19
- package/src/common/config/state/init.js +7 -0
- package/src/common/config/state/runtime.js +7 -10
- package/src/common/constants/env.cdn.js +20 -0
- package/src/common/constants/env.js +23 -0
- package/src/common/constants/env.npm.js +21 -0
- package/src/common/context/shared-context.js +2 -1
- package/src/common/event-emitter/contextual-ee.test.js +310 -0
- package/src/common/event-emitter/handle.test.js +56 -0
- package/src/common/event-emitter/register-handler.test.js +61 -0
- package/src/common/event-listener/event-listener-opts.js +4 -4
- package/src/common/harvest/harvest-scheduler.js +12 -8
- package/src/common/harvest/harvest.js +5 -3
- package/src/common/ids/id.js +15 -6
- package/src/common/ids/id.test.js +92 -0
- package/src/common/ids/unique-id.js +77 -54
- package/src/common/ids/unique-id.test.js +58 -0
- package/src/common/session/constants.js +3 -0
- package/src/common/session/session-entity.js +271 -0
- package/src/common/session/session-entity.test.js +317 -0
- package/src/common/storage/first-party-cookies.js +31 -0
- package/src/common/storage/local-memory.js +30 -0
- package/src/common/storage/local-memory.test.js +19 -0
- package/src/common/storage/local-storage.js +28 -0
- package/src/common/storage/local-storage.test.js +17 -0
- package/src/common/timer/interaction-timer.js +75 -0
- package/src/common/timer/interaction-timer.test.js +167 -0
- package/src/common/timer/timer.js +31 -0
- package/src/common/timer/timer.test.js +100 -0
- package/src/common/timing/nav-timing.js +50 -30
- package/src/common/timing/nav-timing.test.js +161 -0
- package/src/common/unload/eol.js +2 -3
- package/src/common/url/clean-url.test.js +25 -0
- package/src/common/url/encode.test.js +80 -0
- package/src/common/url/location.js +4 -0
- package/src/common/url/location.test.js +15 -0
- package/src/common/url/parse-url.js +1 -2
- package/src/common/url/parse-url.test.js +110 -0
- package/src/common/url/protocol.js +3 -13
- package/src/common/url/protocol.test.js +18 -0
- package/src/common/util/data-size.js +6 -0
- package/src/common/util/data-size.test.js +50 -0
- package/src/common/util/global-scope.js +1 -2
- package/src/common/util/invoke.js +55 -0
- package/src/common/util/invoke.test.js +65 -0
- package/src/common/util/obfuscate.js +2 -6
- package/src/common/window/page-visibility.js +3 -3
- package/src/common/wrap/index.js +1 -2
- package/src/common/wrap/wrap-events.js +5 -5
- package/src/common/wrap/wrap-fetch.js +4 -3
- package/src/common/wrap/wrap-history.js +6 -3
- package/src/common/wrap/wrap-jsonp.js +5 -3
- package/src/common/wrap/wrap-mutation.js +6 -3
- package/src/common/wrap/wrap-promise.js +7 -6
- package/src/common/wrap/wrap-promise.test.js +140 -0
- package/src/common/wrap/wrap-raf.js +5 -3
- package/src/common/wrap/wrap-timer.js +6 -4
- package/src/common/wrap/wrap-xhr.js +4 -3
- package/src/features/ajax/aggregate/index.js +2 -2
- package/src/features/ajax/instrument/index.js +1 -1
- package/src/features/jserrors/aggregate/index.js +3 -3
- package/src/features/jserrors/instrument/index.js +4 -2
- package/src/features/metrics/aggregate/index.js +21 -7
- package/src/features/metrics/instrument/index.js +0 -30
- package/src/features/metrics/instrument/workers-helper.js +9 -6
- package/src/features/page_action/aggregate/index.js +2 -2
- package/src/features/page_view_event/aggregate/index.js +21 -9
- package/src/features/page_view_timing/aggregate/index.js +40 -29
- package/src/features/page_view_timing/long-tasks.js +10 -10
- package/src/features/session_trace/aggregate/index.js +17 -14
- package/src/features/session_trace/instrument/index.js +3 -2
- package/src/features/spa/aggregate/index.js +5 -5
- package/src/features/spa/instrument/index.js +4 -2
- package/src/features/utils/agent-session.js +68 -0
- package/src/features/utils/feature-base.js +1 -1
- package/src/features/utils/instrument-base.js +5 -2
- package/src/features/utils/lazy-loader.js +1 -1
- package/src/loaders/agent.js +1 -1
- package/src/loaders/api/api.js +3 -6
- package/src/loaders/api/apiAsync.js +2 -1
- package/src/loaders/configure/configure.js +2 -7
- package/dist/cjs/common/constants/environment-variables.js +0 -20
- package/dist/cjs/common/util/single.js +0 -23
- package/dist/cjs/common/window/session-storage.js +0 -87
- package/dist/cjs/common/wrap/wrap-console.js +0 -54
- package/dist/cjs/features/utils/aggregate-base.js +0 -13
- package/dist/esm/common/constants/environment-variables.js +0 -11
- package/dist/esm/common/util/single.js +0 -16
- package/dist/esm/common/window/session-storage.js +0 -77
- package/dist/esm/common/wrap/wrap-console.js +0 -46
- package/dist/esm/features/utils/aggregate-base.js +0 -6
- package/dist/types/common/constants/environment-variables.d.ts +0 -4
- package/dist/types/common/constants/environment-variables.d.ts.map +0 -1
- package/dist/types/common/util/single.d.ts +0 -2
- package/dist/types/common/util/single.d.ts.map +0 -1
- package/dist/types/common/window/session-storage.d.ts +0 -18
- package/dist/types/common/window/session-storage.d.ts.map +0 -1
- package/dist/types/common/wrap/wrap-console.d.ts +0 -16
- package/dist/types/common/wrap/wrap-console.d.ts.map +0 -1
- package/dist/types/features/utils/aggregate-base.d.ts +0 -4
- package/dist/types/features/utils/aggregate-base.d.ts.map +0 -1
- package/src/common/constants/environment-variables.js +0 -11
- package/src/common/util/single.js +0 -18
- package/src/common/window/session-storage.js +0 -75
- package/src/common/wrap/wrap-console.js +0 -47
- package/src/features/utils/aggregate-base.js +0 -7
|
@@ -10,7 +10,7 @@ test('enumerates the object properties', () => {
|
|
|
10
10
|
expect(callback).toHaveBeenCalledWith('foo', 'bar');
|
|
11
11
|
});
|
|
12
12
|
test('return array of results from callback invocation', () => {
|
|
13
|
-
const callback = jest.fn((key, value) =>
|
|
13
|
+
const callback = jest.fn((key, value) => "".concat(key, ":").concat(value));
|
|
14
14
|
const input = {
|
|
15
15
|
foo: 'bar',
|
|
16
16
|
biz: 'baz'
|
|
@@ -21,7 +21,7 @@ test('return array of results from callback invocation', () => {
|
|
|
21
21
|
expect(result).toContain('biz:baz');
|
|
22
22
|
});
|
|
23
23
|
test('does not iterate symbol properties', () => {
|
|
24
|
-
const callback = jest.fn((key, value) =>
|
|
24
|
+
const callback = jest.fn((key, value) => "".concat(key, ":").concat(value));
|
|
25
25
|
const input = {
|
|
26
26
|
foo: 'bar',
|
|
27
27
|
[Symbol.for('biz')]: 'baz'
|
|
@@ -34,7 +34,7 @@ test('does not iterate inherited properties', () => {
|
|
|
34
34
|
F.prototype = {
|
|
35
35
|
biz: 'baz'
|
|
36
36
|
};
|
|
37
|
-
const callback = jest.fn((key, value) =>
|
|
37
|
+
const callback = jest.fn((key, value) => "".concat(key, ":").concat(value));
|
|
38
38
|
const input = new F();
|
|
39
39
|
input.foo = 'bar';
|
|
40
40
|
const result = (0, _mapOwn.mapOwn)(input, callback);
|
|
@@ -15,10 +15,6 @@ var fileProtocolRule = {
|
|
|
15
15
|
replacement: 'file://OBFUSCATED'
|
|
16
16
|
};
|
|
17
17
|
class Obfuscator extends _sharedContext.SharedContext {
|
|
18
|
-
constructor(parent) {
|
|
19
|
-
super(parent); // gets any allowed properties from the parent and stores them in `sharedContext`
|
|
20
|
-
}
|
|
21
|
-
|
|
22
18
|
shouldObfuscate() {
|
|
23
19
|
return getRules(this.sharedContext.agentIdentifier).length > 0;
|
|
24
20
|
}
|
|
@@ -46,7 +42,7 @@ function getRules(agentIdentifier) {
|
|
|
46
42
|
var rules = [];
|
|
47
43
|
var configRules = (0, _config.getConfigurationValue)(agentIdentifier, 'obfuscate') || [];
|
|
48
44
|
rules = rules.concat(configRules);
|
|
49
|
-
if (_protocol.
|
|
45
|
+
if ((0, _protocol.isFileProtocol)()) rules.push(fileProtocolRule);
|
|
50
46
|
// could add additional runtime/environment-specific rules here
|
|
51
47
|
|
|
52
48
|
return rules;
|
|
@@ -17,12 +17,15 @@ var _eventListenerOpts = require("../event-listener/event-listener-opts");
|
|
|
17
17
|
*/
|
|
18
18
|
function subscribeToVisibilityChange(cb) {
|
|
19
19
|
let toHiddenOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
20
|
-
|
|
20
|
+
let capture = arguments.length > 2 ? arguments[2] : undefined;
|
|
21
|
+
let abortSignal = arguments.length > 3 ? arguments[3] : undefined;
|
|
22
|
+
(0, _eventListenerOpts.documentAddEventListener)('visibilitychange', handleVisibilityChange, capture, abortSignal);
|
|
21
23
|
return;
|
|
22
24
|
function handleVisibilityChange() {
|
|
23
25
|
if (toHiddenOnly) {
|
|
24
26
|
// trigger cb on change to hidden state only
|
|
25
|
-
if (document.visibilityState == 'hidden') cb();
|
|
27
|
+
if (document.visibilityState == 'hidden') cb();
|
|
28
|
+
return;
|
|
26
29
|
}
|
|
27
30
|
cb(document.visibilityState);
|
|
28
31
|
}
|
|
@@ -3,12 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
Object.defineProperty(exports, "wrapConsole", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _wrapConsole.wrapConsole;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
6
|
Object.defineProperty(exports, "wrapEvents", {
|
|
13
7
|
enumerable: true,
|
|
14
8
|
get: function () {
|
|
@@ -63,7 +57,6 @@ Object.defineProperty(exports, "wrapXhr", {
|
|
|
63
57
|
return _wrapXhr.wrapXhr;
|
|
64
58
|
}
|
|
65
59
|
});
|
|
66
|
-
var _wrapConsole = require("./wrap-console");
|
|
67
60
|
var _wrapEvents = require("./wrap-events");
|
|
68
61
|
var _wrapFetch = require("./wrap-fetch");
|
|
69
62
|
var _wrapHistory = require("./wrap-history");
|
|
@@ -33,19 +33,16 @@ const REMOVE_EVENT_LISTENER = 'removeEventListener';
|
|
|
33
33
|
*/
|
|
34
34
|
function wrapEvents(sharedEE) {
|
|
35
35
|
var ee = scopedEE(sharedEE);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
wrapped[ee.debugId] = 1;
|
|
36
|
+
|
|
37
|
+
// Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
|
|
38
|
+
// then we increment the count to track # of feats using this at runtime.
|
|
39
|
+
if (wrapped[ee.debugId]++) return ee;
|
|
40
|
+
wrapped[ee.debugId] = 1; // otherwise, first feature to wrap events
|
|
42
41
|
var wrapFn = (0, _wrapFunction.createWrapperWithEmitter)(ee, true);
|
|
43
42
|
|
|
44
43
|
// Guard against instrumenting environments w/o necessary features
|
|
45
44
|
if ('getPrototypeOf' in Object) {
|
|
46
|
-
if (_globalScope.isBrowserScope)
|
|
47
|
-
findEventListenerProtoAndCb(document, wrapNode);
|
|
48
|
-
}
|
|
45
|
+
if (_globalScope.isBrowserScope) findEventListenerProtoAndCb(document, wrapNode);
|
|
49
46
|
findEventListenerProtoAndCb(_globalScope.globalScope, wrapNode);
|
|
50
47
|
findEventListenerProtoAndCb(XHR.prototype, wrapNode);
|
|
51
48
|
}
|
|
@@ -41,12 +41,12 @@ function wrapFetch(sharedEE) {
|
|
|
41
41
|
if (!(Req && Res && _globalScope.globalScope.fetch)) {
|
|
42
42
|
return ee;
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
|
|
45
|
+
// Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
|
|
46
|
+
// then we increment the count to track # of feats using this at runtime.
|
|
47
|
+
if (wrapped[ee.debugId]++) return ee;
|
|
48
|
+
wrapped[ee.debugId] = 1; // otherwise, first feature to wrap fetch
|
|
49
|
+
|
|
50
50
|
bodyMethods.forEach(method => {
|
|
51
51
|
wrapPromiseMethod(Req[proto], method, bodyPrefix);
|
|
52
52
|
wrapPromiseMethod(Res[proto], method, bodyPrefix);
|
|
@@ -28,12 +28,13 @@ const HISTORY_FNS = ['pushState', 'replaceState'];
|
|
|
28
28
|
*/
|
|
29
29
|
function wrapHistory(sharedEE) {
|
|
30
30
|
const ee = scopedEE(sharedEE);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
wrapped[ee.debugId] = 1;
|
|
31
|
+
|
|
32
|
+
// Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
|
|
33
|
+
// then we increment the count to track # of feats using this at runtime. History API is only
|
|
34
|
+
// available in browser DOM context.
|
|
35
|
+
if (!_globalScope.isBrowserScope || wrapped[ee.debugId]++) return ee;
|
|
36
|
+
wrapped[ee.debugId] = 1; // otherwise, first feature to wrap history
|
|
37
|
+
|
|
37
38
|
var wrapFn = (0, _wrapFunction.createWrapperWithEmitter)(ee);
|
|
38
39
|
/*
|
|
39
40
|
* For objects that will be instantiated more than once, we wrap the object's prototype methods. The history object
|
|
@@ -29,12 +29,13 @@ const domInsertMethods = ['appendChild', 'insertBefore', 'replaceChild'];
|
|
|
29
29
|
*/
|
|
30
30
|
function wrapJsonP(sharedEE) {
|
|
31
31
|
const ee = scopedEE(sharedEE);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
wrapped[ee.debugId] = true;
|
|
32
|
+
|
|
33
|
+
// Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
|
|
34
|
+
// then we increment the count to track # of feats using this at runtime. JSONP deals with DOM
|
|
35
|
+
// tags so browser window env is required.
|
|
36
|
+
if (!_globalScope.isBrowserScope || wrapped[ee.debugId]) return ee;
|
|
37
|
+
wrapped[ee.debugId] = true; // otherwise, first feature to wrap JSONP
|
|
38
|
+
|
|
38
39
|
var wrapFn = (0, _wrapFunction.createWrapperWithEmitter)(ee);
|
|
39
40
|
var CALLBACK_REGEX = /[?&](?:callback|cb)=([^&#]+)/;
|
|
40
41
|
var PARENT_REGEX = /(.*)\.([^.]+)/;
|
|
@@ -28,12 +28,13 @@ const wrapped = {};
|
|
|
28
28
|
*/
|
|
29
29
|
function wrapMutation(sharedEE) {
|
|
30
30
|
const ee = scopedEE(sharedEE);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
wrapped[ee.debugId] = true;
|
|
31
|
+
|
|
32
|
+
// Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
|
|
33
|
+
// then we increment the count to track # of feats using this at runtime. Mutations API is only
|
|
34
|
+
// available in browser DOM context.
|
|
35
|
+
if (!_globalScope.isBrowserScope || wrapped[ee.debugId]) return ee;
|
|
36
|
+
wrapped[ee.debugId] = true; // otherwise, first feature to wrap mutations
|
|
37
|
+
|
|
37
38
|
var wrapFn = (0, _wrapFunction.createWrapperWithEmitter)(ee);
|
|
38
39
|
var OriginalObserver = _config.originals.MO;
|
|
39
40
|
if (OriginalObserver) {
|
|
@@ -29,10 +29,12 @@ const wrapped = {};
|
|
|
29
29
|
*/
|
|
30
30
|
function wrapPromise(sharedEE) {
|
|
31
31
|
const promiseEE = scopedEE(sharedEE);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
wrapped[promiseEE.debugId]
|
|
32
|
+
|
|
33
|
+
// Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
|
|
34
|
+
// then we increment the count to track # of feats using this at runtime.
|
|
35
|
+
if (wrapped[promiseEE.debugId]) return promiseEE;
|
|
36
|
+
wrapped[promiseEE.debugId] = true; // otherwise, first feature to wrap promise
|
|
37
|
+
|
|
36
38
|
var getContext = _contextualEe.getOrSetContext;
|
|
37
39
|
var promiseWrapper = (0, _wrapFunction.createWrapperWithEmitter)(promiseEE);
|
|
38
40
|
var prevPromiseObj = _config.originals.PR;
|
|
@@ -74,8 +76,7 @@ function wrapPromise(sharedEE) {
|
|
|
74
76
|
WrappedPromise[method] = function (subPromises) {
|
|
75
77
|
// use our own wrapped version of "Promise.all" and ".race" static fns
|
|
76
78
|
let finalized = false;
|
|
77
|
-
subPromises
|
|
78
|
-
// eslint-disable-next-line
|
|
79
|
+
Array.from(subPromises || []).forEach(sub => {
|
|
79
80
|
this.resolve(sub).then(setNrId(method === 'all'), setNrId(false));
|
|
80
81
|
});
|
|
81
82
|
const origFnCallWithThis = prevStaticFn.apply(this, arguments);
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _faker = require("@faker-js/faker");
|
|
4
|
+
var _globalScope = require("../util/global-scope");
|
|
5
|
+
var _config = require("../config/config");
|
|
6
|
+
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); }
|
|
7
|
+
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; }
|
|
8
|
+
jest.mock('./wrap-function', () => ({
|
|
9
|
+
__esModule: true,
|
|
10
|
+
createWrapperWithEmitter: jest.fn(() => fn => function () {
|
|
11
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
12
|
+
args[_key] = arguments[_key];
|
|
13
|
+
}
|
|
14
|
+
return fn.apply(null, args);
|
|
15
|
+
})
|
|
16
|
+
}));
|
|
17
|
+
jest.mock('../event-emitter/contextual-ee', () => ({
|
|
18
|
+
__esModule: true,
|
|
19
|
+
getOrSetContext: jest.fn(() => ({})),
|
|
20
|
+
ee: {
|
|
21
|
+
get: jest.fn(name => ({
|
|
22
|
+
debugId: name,
|
|
23
|
+
on: jest.fn(),
|
|
24
|
+
context: jest.fn(() => ({})),
|
|
25
|
+
emit: jest.fn()
|
|
26
|
+
}))
|
|
27
|
+
}
|
|
28
|
+
}));
|
|
29
|
+
jest.mock('../config/config', () => ({
|
|
30
|
+
__esModule: true,
|
|
31
|
+
originals: {}
|
|
32
|
+
}));
|
|
33
|
+
jest.mock('../util/global-scope', () => ({
|
|
34
|
+
__esModule: true,
|
|
35
|
+
globalScope: {
|
|
36
|
+
NREUM: {}
|
|
37
|
+
}
|
|
38
|
+
}));
|
|
39
|
+
let promiseConstructorCalls;
|
|
40
|
+
beforeEach(async () => {
|
|
41
|
+
promiseConstructorCalls = [];
|
|
42
|
+
|
|
43
|
+
// Proxy the global Promise to prevent the wrapping from
|
|
44
|
+
// messing with Jest internal promises
|
|
45
|
+
_config.originals.PR = new Proxy(class extends Promise {}, {
|
|
46
|
+
construct(target, args) {
|
|
47
|
+
promiseConstructorCalls.push(args);
|
|
48
|
+
return Reflect.construct(target, args);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
(await Promise.resolve().then(() => _interopRequireWildcard(require('./wrap-promise')))).wrapPromise();
|
|
52
|
+
});
|
|
53
|
+
afterEach(() => {
|
|
54
|
+
jest.resetModules();
|
|
55
|
+
});
|
|
56
|
+
test('should wrap promise constructor', async () => {
|
|
57
|
+
const promiseInstance = new _globalScope.globalScope.Promise(jest.fn());
|
|
58
|
+
expect(promiseInstance).toBeInstanceOf(Promise);
|
|
59
|
+
expect(promiseConstructorCalls.length).toEqual(1);
|
|
60
|
+
expect(_globalScope.globalScope.Promise.toString()).toMatch(/\[native code\]/);
|
|
61
|
+
expect(_globalScope.globalScope.Promise.name).toEqual('Promise');
|
|
62
|
+
});
|
|
63
|
+
describe('all', () => {
|
|
64
|
+
test('should work with acceptable iterables', async () => {
|
|
65
|
+
const resolveValue = _faker.faker.datatype.uuid();
|
|
66
|
+
const customIterable = new CustomIterable([new _globalScope.globalScope.Promise(resolve => resolve(resolveValue))]);
|
|
67
|
+
const arrayIterable = [new _globalScope.globalScope.Promise(resolve => resolve(resolveValue))];
|
|
68
|
+
const setIterable = new Set();
|
|
69
|
+
setIterable.add(new _globalScope.globalScope.Promise(resolve => resolve(resolveValue)));
|
|
70
|
+
await expect(_globalScope.globalScope.Promise.all(customIterable)).resolves.toEqual([resolveValue]);
|
|
71
|
+
await expect(_globalScope.globalScope.Promise.all(arrayIterable)).resolves.toEqual([resolveValue]);
|
|
72
|
+
await expect(_globalScope.globalScope.Promise.all(setIterable)).resolves.toEqual([resolveValue]);
|
|
73
|
+
});
|
|
74
|
+
test.each([null, undefined])('should not try to iterate a non-iterable %s', async input => {
|
|
75
|
+
jest.spyOn(_globalScope.globalScope.Promise, 'resolve');
|
|
76
|
+
await expect(_globalScope.globalScope.Promise.all(input)).rejects.toThrow();
|
|
77
|
+
expect(_globalScope.globalScope.Promise.resolve).not.toHaveBeenCalled();
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
describe('race', () => {
|
|
81
|
+
test('should work with acceptable iterables', async () => {
|
|
82
|
+
jest.spyOn(_globalScope.globalScope.Promise, 'resolve');
|
|
83
|
+
const resolveValue = _faker.faker.datatype.uuid();
|
|
84
|
+
const customIterable = new CustomIterable([new _globalScope.globalScope.Promise(resolve => resolve(resolveValue))]);
|
|
85
|
+
const arrayIterable = [new _globalScope.globalScope.Promise(resolve => resolve(resolveValue))];
|
|
86
|
+
const setIterable = new Set();
|
|
87
|
+
setIterable.add(new _globalScope.globalScope.Promise(resolve => resolve(resolveValue)));
|
|
88
|
+
await expect(_globalScope.globalScope.Promise.race(customIterable)).resolves.toEqual(resolveValue);
|
|
89
|
+
await expect(_globalScope.globalScope.Promise.race(arrayIterable)).resolves.toEqual(resolveValue);
|
|
90
|
+
await expect(_globalScope.globalScope.Promise.race(setIterable)).resolves.toEqual(resolveValue);
|
|
91
|
+
expect(_globalScope.globalScope.Promise.resolve).toHaveBeenCalled();
|
|
92
|
+
});
|
|
93
|
+
test.each([null, undefined])('should not try to iterate a non-iterable %s', async input => {
|
|
94
|
+
jest.spyOn(_globalScope.globalScope.Promise, 'resolve');
|
|
95
|
+
await expect(_globalScope.globalScope.Promise.race(input)).rejects.toThrow();
|
|
96
|
+
expect(_globalScope.globalScope.Promise.resolve).not.toHaveBeenCalled();
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
class CustomIterable {
|
|
100
|
+
#iterables = [];
|
|
101
|
+
constructor(iterables) {
|
|
102
|
+
this.#iterables = iterables;
|
|
103
|
+
}
|
|
104
|
+
[Symbol.iterator]() {
|
|
105
|
+
return {
|
|
106
|
+
index: 0,
|
|
107
|
+
iterables: this.#iterables,
|
|
108
|
+
next() {
|
|
109
|
+
return {
|
|
110
|
+
done: this.index >= this.iterables.length,
|
|
111
|
+
value: this.iterables[this.index++] || undefined
|
|
112
|
+
};
|
|
113
|
+
},
|
|
114
|
+
[Symbol.iterator]() {
|
|
115
|
+
return this;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -28,12 +28,12 @@ const RAF_NAME = 'requestAnimationFrame';
|
|
|
28
28
|
*/
|
|
29
29
|
function wrapRaf(sharedEE) {
|
|
30
30
|
const ee = scopedEE(sharedEE);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
|
|
32
|
+
// Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
|
|
33
|
+
// then we increment the count to track # of feats using this at runtime.
|
|
34
|
+
if (!_globalScope.isBrowserScope || wrapped[ee.debugId]++) return ee;
|
|
35
|
+
wrapped[ee.debugId] = 1; // otherwise, first feature to wrap RAF
|
|
36
|
+
|
|
37
37
|
var wrapFn = (0, _wrapFunction.createWrapperWithEmitter)(ee);
|
|
38
38
|
wrapFn.inPlace(window, [RAF_NAME], 'raf-');
|
|
39
39
|
ee.on('raf-start', function (args) {
|
|
@@ -32,15 +32,15 @@ const TIMER_FNS = [SET_TIMEOUT, 'setImmediate', SET_INTERVAL, CLEAR_TIMEOUT, 'cl
|
|
|
32
32
|
* @param {Object} sharedEE - The shared event emitter on which a new scoped event emitter will be based.
|
|
33
33
|
* @returns {Object} Scoped event emitter with a debug ID of `timer`.
|
|
34
34
|
*/
|
|
35
|
-
//eslint-disable-next-line
|
|
35
|
+
// eslint-disable-next-line
|
|
36
36
|
function wrapTimer(sharedEE) {
|
|
37
37
|
const ee = scopedEE(sharedEE);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
|
|
39
|
+
// Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
|
|
40
|
+
// then we increment the count to track # of feats using this at runtime.
|
|
41
|
+
if (wrapped[ee.debugId]++) return ee;
|
|
42
|
+
wrapped[ee.debugId] = 1; // otherwise, first feature to wrap timer
|
|
43
|
+
|
|
44
44
|
var wrapFn = (0, _wrapFunction.createWrapperWithEmitter)(ee);
|
|
45
45
|
wrapFn.inPlace(_globalScope.globalScope, TIMER_FNS.slice(0, 2), SET_TIMEOUT + DASH);
|
|
46
46
|
wrapFn.inPlace(_globalScope.globalScope, TIMER_FNS.slice(2, 3), SET_INTERVAL + DASH);
|
|
@@ -34,12 +34,11 @@ const XHR_PROPS = ['open', 'send']; // these are the specific funcs being wrappe
|
|
|
34
34
|
function wrapXhr(sharedEE) {
|
|
35
35
|
var baseEE = sharedEE || _contextualEe.ee;
|
|
36
36
|
const ee = scopedEE(baseEE);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
wrapped[ee.debugId] = 1; // <- otherwise, first feature to wrap XHR
|
|
37
|
+
|
|
38
|
+
// Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
|
|
39
|
+
// then we increment the count to track # of feats using this at runtime.
|
|
40
|
+
if (wrapped[ee.debugId]++) return ee;
|
|
41
|
+
wrapped[ee.debugId] = 1; // otherwise, first feature to wrap XHR
|
|
43
42
|
|
|
44
43
|
(0, _wrapEvents.wrapEvents)(baseEE); // wrap-events patches XMLHttpRequest.prototype.addEventListener for us
|
|
45
44
|
var wrapFn = (0, _wrapFunction.createWrapperWithEmitter)(ee);
|
|
@@ -11,17 +11,17 @@ var _handle = require("../../../common/event-emitter/handle");
|
|
|
11
11
|
var _config = require("../../../common/config/config");
|
|
12
12
|
var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
|
|
13
13
|
var _denyList = require("../../../common/deny-list/deny-list");
|
|
14
|
-
var _aggregateBase = require("../../utils/aggregate-base");
|
|
15
14
|
var _constants = require("../constants");
|
|
16
15
|
var _drain = require("../../../common/drain/drain");
|
|
17
16
|
var _features = require("../../../loaders/features/features");
|
|
18
17
|
var _constants2 = require("../../metrics/constants");
|
|
18
|
+
var _featureBase = require("../../utils/feature-base");
|
|
19
19
|
/*
|
|
20
20
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
21
21
|
* SPDX-License-Identifier: Apache-2.0
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
class Aggregate extends
|
|
24
|
+
class Aggregate extends _featureBase.FeatureBase {
|
|
25
25
|
static featureName = _constants.FEATURE_NAME;
|
|
26
26
|
constructor(agentIdentifier, aggregator) {
|
|
27
27
|
super(agentIdentifier, aggregator, _constants.FEATURE_NAME);
|
|
@@ -62,7 +62,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
62
62
|
onFinished: onEventsHarvestFinished,
|
|
63
63
|
getPayload: prepareHarvest
|
|
64
64
|
}, this);
|
|
65
|
-
ee.on(
|
|
65
|
+
ee.on("drain-".concat(this.featureName), () => {
|
|
66
66
|
scheduler.startTimer(harvestTimeSeconds);
|
|
67
67
|
});
|
|
68
68
|
}
|
|
@@ -146,7 +146,7 @@ describe('errors without stack property and with line property', () => {
|
|
|
146
146
|
mode: 'sourceline',
|
|
147
147
|
name: mockError.name,
|
|
148
148
|
message: mockError.message,
|
|
149
|
-
stackString:
|
|
149
|
+
stackString: "".concat(mockError.name, ": ").concat(mockError.message, "\n at ").concat(sourceURL, ":").concat(mockError.line)
|
|
150
150
|
}));
|
|
151
151
|
expect(result.frames.length).toEqual(1);
|
|
152
152
|
expect(result.frames).toContainEqual(expect.objectContaining({
|
|
@@ -172,7 +172,7 @@ describe('errors without stack property and with line property', () => {
|
|
|
172
172
|
mode: 'sourceline',
|
|
173
173
|
name: mockError.name,
|
|
174
174
|
message: mockError.message,
|
|
175
|
-
stackString:
|
|
175
|
+
stackString: "".concat(mockError.name, ": ").concat(mockError.message, "\n at ").concat(sourceURL, ":").concat(mockError.line, ":").concat(mockError.column)
|
|
176
176
|
}));
|
|
177
177
|
expect(result.frames.length).toEqual(1);
|
|
178
178
|
expect(result.frames).toContainEqual(expect.objectContaining({
|
|
@@ -193,7 +193,7 @@ describe('errors without stack property and with line property', () => {
|
|
|
193
193
|
mode: 'sourceline',
|
|
194
194
|
name: mockError.name,
|
|
195
195
|
message: mockError.message,
|
|
196
|
-
stackString:
|
|
196
|
+
stackString: "RangeError: ".concat(mockError.message, "\n in evaluated code")
|
|
197
197
|
}));
|
|
198
198
|
expect(result.frames.length).toEqual(1);
|
|
199
199
|
expect(result.frames).toContainEqual(expect.objectContaining({
|
|
@@ -232,7 +232,7 @@ describe('errors that are messages only or primitives', () => {
|
|
|
232
232
|
expect(result).toEqual(expect.objectContaining({
|
|
233
233
|
mode: 'nameonly',
|
|
234
234
|
name: mockError.name,
|
|
235
|
-
stackString:
|
|
235
|
+
stackString: "".concat(mockError.name, ": undefined"),
|
|
236
236
|
frames: []
|
|
237
237
|
}));
|
|
238
238
|
});
|
|
@@ -248,7 +248,7 @@ describe('errors that are messages only or primitives', () => {
|
|
|
248
248
|
mode: 'nameonly',
|
|
249
249
|
name: mockError.name,
|
|
250
250
|
message: mockError.message,
|
|
251
|
-
stackString:
|
|
251
|
+
stackString: "".concat(mockError.name, ": ").concat(mockError.message),
|
|
252
252
|
frames: []
|
|
253
253
|
}));
|
|
254
254
|
});
|
|
@@ -25,7 +25,7 @@ describe('formatStackTrace', () => {
|
|
|
25
25
|
});
|
|
26
26
|
test('truncates the middle of the stack lines when more than 100', () => {
|
|
27
27
|
const input = Array.apply(null, Array(200)).map(() => _faker.faker.datatype.uuid());
|
|
28
|
-
const expected = input.slice(0, 50).join('\n') +
|
|
28
|
+
const expected = input.slice(0, 50).join('\n') + "\n< ...truncated ".concat(input.length - 100, " lines... >\n") + input.slice(-50).join('\n');
|
|
29
29
|
const result = (0, _formatStackTrace.formatStackTrace)(input);
|
|
30
30
|
expect(result).toEqual(expected);
|
|
31
31
|
});
|
|
@@ -17,16 +17,16 @@ var _mapOwn = require("../../../common/util/map-own");
|
|
|
17
17
|
var _config = require("../../../common/config/config");
|
|
18
18
|
var _now = require("../../../common/timing/now");
|
|
19
19
|
var _globalScope = require("../../../common/util/global-scope");
|
|
20
|
-
var _aggregateBase = require("../../utils/aggregate-base");
|
|
21
20
|
var _constants = require("../constants");
|
|
22
21
|
var _drain = require("../../../common/drain/drain");
|
|
23
22
|
var _features = require("../../../loaders/features/features");
|
|
23
|
+
var _featureBase = require("../../utils/feature-base");
|
|
24
24
|
/*
|
|
25
25
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
26
26
|
* SPDX-License-Identifier: Apache-2.0
|
|
27
27
|
*/
|
|
28
28
|
|
|
29
|
-
class Aggregate extends
|
|
29
|
+
class Aggregate extends _featureBase.FeatureBase {
|
|
30
30
|
static featureName = _constants.FEATURE_NAME;
|
|
31
31
|
constructor(agentIdentifier, aggregator) {
|
|
32
32
|
var _this;
|
|
@@ -60,7 +60,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
// Don't start harvesting until "drain" for this feat has been called (which currently requires RUM response).
|
|
63
|
-
this.ee.on(
|
|
63
|
+
this.ee.on("drain-".concat(this.featureName), () => {
|
|
64
64
|
if (!this.blocked) scheduler.startTimer(harvestTimeSeconds); // and only if ingest will accept jserror payloads
|
|
65
65
|
});
|
|
66
66
|
|
|
@@ -104,7 +104,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
nameHash(params) {
|
|
107
|
-
return (0, _stringHashCode.stringHashCode)(
|
|
107
|
+
return (0, _stringHashCode.stringHashCode)("".concat(params.exceptionClass, "_").concat(params.message, "_").concat(params.stack_trace || params.browser_stack_hash));
|
|
108
108
|
}
|
|
109
109
|
getBucketName(params, customParams) {
|
|
110
110
|
return this.nameHash(params) + ':' + (0, _stringHashCode.stringHashCode)((0, _stringify.stringify)(customParams));
|
|
@@ -186,7 +186,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
186
186
|
* the canonical stack trace excludes items like the column number increasing the hit-rate of different errors potentially
|
|
187
187
|
* bucketing and ultimately resulting in the loss of data in NR1.
|
|
188
188
|
*/
|
|
189
|
-
var bucketHash = (0, _stringHashCode.stringHashCode)(
|
|
189
|
+
var bucketHash = (0, _stringHashCode.stringHashCode)("".concat(stackInfo.name, "_").concat(stackInfo.message, "_").concat(stackInfo.stackString));
|
|
190
190
|
if (!this.stackReported[bucketHash]) {
|
|
191
191
|
this.stackReported[bucketHash] = true;
|
|
192
192
|
params.stack_trace = (0, _formatStackTrace.truncateSize)(stackInfo.stackString);
|
|
@@ -216,6 +216,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
216
216
|
|
|
217
217
|
// still send EE events for other features such as above, but stop this one from aggregating internal data
|
|
218
218
|
if (this.blocked) return;
|
|
219
|
+
var att = (0, _config.getInfo)(this.agentIdentifier).jsAttributes;
|
|
219
220
|
if (params._interactionId != null) {
|
|
220
221
|
// hold on to the error until the interaction finishes
|
|
221
222
|
this.errorCache[params._interactionId] = this.errorCache[params._interactionId] || [];
|
|
@@ -223,7 +224,6 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
223
224
|
} else {
|
|
224
225
|
// store custom attributes
|
|
225
226
|
var customParams = {};
|
|
226
|
-
var att = (0, _config.getInfo)(this.agentIdentifier).jsAttributes;
|
|
227
227
|
(0, _mapOwn.mapOwn)(att, setCustom);
|
|
228
228
|
if (customAttributes) {
|
|
229
229
|
(0, _mapOwn.mapOwn)(customAttributes, setCustom);
|
|
@@ -32,9 +32,9 @@ class Instrument extends _instrumentBase.InstrumentBase {
|
|
|
32
32
|
// errors that will be the same as caught errors.
|
|
33
33
|
this.skipNext = 0;
|
|
34
34
|
try {
|
|
35
|
+
// this try-catch can be removed when IE11 is completely unsupported & gone
|
|
35
36
|
this.removeOnAbort = new AbortController();
|
|
36
|
-
}
|
|
37
|
-
catch (e) {}
|
|
37
|
+
} catch (e) {}
|
|
38
38
|
const thisInstrument = this;
|
|
39
39
|
thisInstrument.ee.on('fn-start', function (args, obj, methodName) {
|
|
40
40
|
if (thisInstrument.abortHandler) thisInstrument.skipNext += 1;
|