@newrelic/browser-agent 1.234.0 → 1.236.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -2
- package/dist/cjs/common/config/state/init.js +3 -0
- package/dist/cjs/common/config/state/runtime.js +4 -4
- package/dist/cjs/common/constants/env.cdn.js +2 -2
- package/dist/cjs/common/constants/env.npm.js +1 -1
- package/dist/cjs/common/constants/runtime.js +52 -0
- package/dist/cjs/common/constants/shared-channel.js +19 -0
- package/dist/cjs/common/event-listener/event-listener-opts.js +3 -3
- package/dist/cjs/common/harvest/harvest-scheduler.js +35 -16
- package/dist/cjs/common/harvest/harvest.js +163 -144
- package/dist/cjs/common/harvest/types.js +54 -0
- package/dist/cjs/common/ids/id.js +2 -2
- package/dist/cjs/common/ids/unique-id.js +3 -3
- package/dist/cjs/common/session/session-entity.js +21 -13
- package/dist/cjs/common/timer/interaction-timer.js +3 -3
- 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/feature-flags.js +23 -12
- package/dist/cjs/common/util/obfuscate.js +2 -2
- package/dist/cjs/common/util/submit-data.js +61 -79
- package/dist/cjs/common/window/nreum.js +14 -14
- package/dist/cjs/common/wrap/wrap-events.js +3 -3
- package/dist/cjs/common/wrap/wrap-fetch.js +5 -5
- package/dist/cjs/common/wrap/wrap-history.js +2 -2
- package/dist/cjs/common/wrap/wrap-jsonp.js +2 -2
- package/dist/cjs/common/wrap/wrap-mutation.js +2 -2
- package/dist/cjs/common/wrap/wrap-promise.js +2 -2
- package/dist/cjs/common/wrap/wrap-raf.js +3 -3
- package/dist/cjs/common/wrap/wrap-timer.js +5 -5
- package/dist/cjs/common/wrap/wrap-xhr.js +3 -3
- package/dist/cjs/features/ajax/aggregate/index.js +1 -1
- package/dist/cjs/features/ajax/instrument/distributed-tracing.js +2 -2
- package/dist/cjs/features/ajax/instrument/index.js +6 -7
- package/dist/cjs/features/jserrors/aggregate/index.js +11 -4
- package/dist/cjs/features/jserrors/instrument/index.js +6 -19
- package/dist/cjs/features/metrics/aggregate/framework-detection.js +2 -2
- package/dist/cjs/features/metrics/aggregate/index.js +3 -3
- package/dist/cjs/features/page_action/aggregate/index.js +3 -3
- package/dist/cjs/features/page_view_event/aggregate/index.js +10 -11
- package/dist/cjs/features/page_view_event/instrument/index.js +2 -2
- package/dist/cjs/features/page_view_timing/aggregate/index.js +3 -5
- package/dist/cjs/features/page_view_timing/instrument/index.js +2 -2
- package/dist/cjs/features/session_replay/aggregate/index.js +99 -82
- package/dist/cjs/features/session_replay/replay-mode.js +28 -0
- package/dist/cjs/features/session_trace/aggregate/index.js +222 -99
- package/dist/cjs/features/session_trace/constants.js +1 -3
- package/dist/cjs/features/session_trace/instrument/index.js +2 -18
- package/dist/cjs/features/spa/aggregate/index.js +1 -1
- package/dist/cjs/features/spa/constants.js +0 -1
- package/dist/cjs/features/spa/instrument/index.js +2 -2
- package/dist/cjs/features/utils/agent-session.js +20 -36
- package/dist/cjs/features/utils/aggregate-base.js +7 -12
- package/dist/cjs/features/utils/handler-cache.js +28 -23
- package/dist/cjs/features/utils/instrument-base.js +58 -40
- package/dist/cjs/index.js +7 -0
- package/dist/cjs/loaders/agent.js +7 -1
- package/dist/cjs/loaders/api/api.js +2 -2
- package/dist/cjs/loaders/api/apiAsync.js +6 -4
- package/dist/cjs/loaders/configure/configure.js +2 -2
- package/dist/cjs/loaders/features/featureDependencies.js +2 -0
- package/dist/cjs/loaders/micro-agent.js +29 -38
- package/dist/esm/common/config/state/init.js +3 -0
- package/dist/esm/common/config/state/runtime.js +1 -1
- package/dist/esm/common/constants/env.cdn.js +2 -2
- package/dist/esm/common/constants/env.npm.js +1 -1
- package/dist/esm/common/constants/runtime.js +38 -0
- package/dist/esm/common/constants/shared-channel.js +12 -0
- package/dist/esm/common/event-listener/event-listener-opts.js +1 -1
- package/dist/esm/common/harvest/harvest-scheduler.js +34 -17
- package/dist/esm/common/harvest/harvest.js +160 -142
- package/dist/esm/common/harvest/types.js +47 -0
- package/dist/esm/common/ids/id.js +1 -1
- package/dist/esm/common/ids/unique-id.js +1 -1
- package/dist/esm/common/session/session-entity.js +18 -12
- package/dist/esm/common/timer/interaction-timer.js +2 -2
- 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/feature-flags.js +23 -12
- package/dist/esm/common/util/obfuscate.js +2 -2
- package/dist/esm/common/util/submit-data.js +58 -76
- package/dist/esm/common/window/nreum.js +1 -1
- package/dist/esm/common/wrap/wrap-events.js +1 -1
- package/dist/esm/common/wrap/wrap-fetch.js +1 -1
- package/dist/esm/common/wrap/wrap-history.js +1 -1
- package/dist/esm/common/wrap/wrap-jsonp.js +1 -1
- package/dist/esm/common/wrap/wrap-mutation.js +1 -1
- package/dist/esm/common/wrap/wrap-promise.js +1 -1
- package/dist/esm/common/wrap/wrap-raf.js +2 -2
- package/dist/esm/common/wrap/wrap-timer.js +2 -2
- package/dist/esm/common/wrap/wrap-xhr.js +1 -1
- package/dist/esm/features/ajax/aggregate/index.js +1 -1
- package/dist/esm/features/ajax/instrument/distributed-tracing.js +1 -1
- package/dist/esm/features/ajax/instrument/index.js +1 -2
- package/dist/esm/features/jserrors/aggregate/index.js +10 -3
- package/dist/esm/features/jserrors/instrument/index.js +3 -16
- package/dist/esm/features/metrics/aggregate/framework-detection.js +1 -1
- package/dist/esm/features/metrics/aggregate/index.js +1 -1
- package/dist/esm/features/page_action/aggregate/index.js +1 -1
- package/dist/esm/features/page_view_event/aggregate/index.js +1 -2
- package/dist/esm/features/page_view_event/instrument/index.js +1 -1
- package/dist/esm/features/page_view_timing/aggregate/index.js +2 -4
- package/dist/esm/features/page_view_timing/instrument/index.js +1 -1
- package/dist/esm/features/session_replay/aggregate/index.js +92 -78
- package/dist/esm/features/session_replay/replay-mode.js +23 -0
- package/dist/esm/features/session_trace/aggregate/index.js +223 -100
- package/dist/esm/features/session_trace/constants.js +0 -1
- package/dist/esm/features/session_trace/instrument/index.js +2 -18
- package/dist/esm/features/spa/aggregate/index.js +1 -1
- package/dist/esm/features/spa/constants.js +0 -1
- package/dist/esm/features/spa/instrument/index.js +1 -1
- package/dist/esm/features/utils/agent-session.js +21 -37
- package/dist/esm/features/utils/aggregate-base.js +7 -12
- package/dist/esm/features/utils/handler-cache.js +28 -23
- package/dist/esm/features/utils/instrument-base.js +57 -39
- package/dist/esm/index.js +1 -4
- package/dist/esm/loaders/agent.js +7 -1
- package/dist/esm/loaders/api/api.js +2 -2
- package/dist/esm/loaders/api/apiAsync.js +3 -3
- package/dist/esm/loaders/configure/configure.js +1 -1
- package/dist/esm/loaders/features/featureDependencies.js +2 -0
- package/dist/esm/loaders/micro-agent.js +29 -38
- package/dist/types/common/config/state/init.d.ts.map +1 -1
- package/dist/types/common/constants/runtime.d.ts +29 -0
- package/dist/types/common/constants/runtime.d.ts.map +1 -0
- package/dist/types/common/constants/shared-channel.d.ts +5 -0
- package/dist/types/common/constants/shared-channel.d.ts.map +1 -0
- package/dist/types/common/harvest/harvest-scheduler.d.ts +5 -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 +9 -5
- package/dist/types/common/session/session-entity.d.ts.map +1 -1
- package/dist/types/common/unload/eol.d.ts.map +1 -1
- package/dist/types/common/util/feature-flags.d.ts +1 -0
- package/dist/types/common/util/feature-flags.d.ts.map +1 -1
- package/dist/types/common/util/submit-data.d.ts +62 -64
- package/dist/types/common/util/submit-data.d.ts.map +1 -1
- package/dist/types/features/ajax/instrument/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/aggregate/index.d.ts +2 -1
- package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/instrument/index.d.ts +1 -1
- package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -1
- package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/aggregate/index.d.ts +14 -5
- package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/instrument/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/replay-mode.d.ts +9 -0
- package/dist/types/features/session_replay/replay-mode.d.ts.map +1 -0
- package/dist/types/features/session_trace/aggregate/index.d.ts +21 -3
- package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_trace/constants.d.ts +0 -1
- package/dist/types/features/session_trace/constants.d.ts.map +1 -1
- package/dist/types/features/session_trace/instrument/index.d.ts +0 -2
- package/dist/types/features/session_trace/instrument/index.d.ts.map +1 -1
- package/dist/types/features/spa/constants.d.ts.map +1 -1
- package/dist/types/features/utils/agent-session.d.ts.map +1 -1
- package/dist/types/features/utils/aggregate-base.d.ts +6 -1
- package/dist/types/features/utils/aggregate-base.d.ts.map +1 -1
- package/dist/types/features/utils/handler-cache.d.ts +12 -11
- package/dist/types/features/utils/handler-cache.d.ts.map +1 -1
- package/dist/types/features/utils/instrument-base.d.ts +17 -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.d.ts +4 -4
- package/dist/types/loaders/agent.d.ts.map +1 -1
- package/dist/types/loaders/features/featureDependencies.d.ts.map +1 -1
- package/dist/types/loaders/micro-agent.d.ts +3 -4
- package/dist/types/loaders/micro-agent.d.ts.map +1 -1
- package/package.json +14 -7
- package/src/common/config/__mocks__/config.js +11 -0
- package/src/common/config/state/init.js +1 -0
- package/src/common/config/state/runtime.js +1 -1
- package/src/common/constants/__mocks__/env.js +3 -0
- package/src/common/constants/__mocks__/runtime.js +8 -0
- package/src/common/constants/env.cdn.test.js +7 -0
- package/src/common/constants/env.npm.test.js +7 -0
- package/src/common/constants/env.test.js +7 -0
- package/src/common/constants/runtime.js +71 -0
- package/src/common/constants/runtime.test.js +168 -0
- package/src/common/constants/shared-channel.js +13 -0
- package/src/common/context/__mocks__/shared-context.js +8 -0
- package/src/common/event-listener/__mocks__/event-listener-opts.js +7 -0
- package/src/common/event-listener/event-listener-opts.js +1 -1
- package/src/common/harvest/__mocks__/harvest.js +13 -0
- package/src/common/harvest/harvest-scheduler.js +31 -19
- package/src/common/harvest/harvest-scheduler.test.js +491 -20
- package/src/common/harvest/harvest.js +147 -130
- package/src/common/harvest/harvest.test.js +788 -139
- 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.test.js → session-entity.component-test.js} +71 -48
- package/src/common/session/session-entity.js +16 -13
- package/src/common/timer/interaction-timer.js +2 -2
- 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 +32 -21
- package/src/common/url/parse-url.js +1 -1
- package/src/common/url/parse-url.test.js +3 -3
- package/src/common/url/protocol.js +1 -1
- package/src/common/util/__mocks__/obfuscate.js +10 -0
- package/src/common/util/__mocks__/stringify.js +1 -0
- package/src/common/util/__mocks__/submit-data.js +6 -0
- package/src/common/util/__mocks__/traverse.js +1 -0
- package/src/common/util/data-size.test.js +27 -20
- package/src/common/util/feature-flags.js +24 -12
- package/src/common/util/feature-flags.test.js +98 -0
- package/src/common/util/obfuscate.component-test.js +173 -0
- package/src/common/util/obfuscate.js +2 -2
- package/src/common/util/submit-data.js +42 -56
- package/src/common/util/submit-data.test.js +158 -137
- package/src/common/window/nreum.js +1 -1
- package/src/common/wrap/wrap-events.js +1 -1
- package/src/common/wrap/wrap-fetch.js +1 -1
- package/src/common/wrap/wrap-history.js +1 -1
- package/src/common/wrap/wrap-jsonp.js +1 -1
- package/src/common/wrap/wrap-mutation.js +1 -1
- package/src/common/wrap/wrap-promise.js +1 -1
- package/src/common/wrap/wrap-promise.test.js +2 -2
- package/src/common/wrap/wrap-raf.js +2 -2
- package/src/common/wrap/wrap-timer.js +2 -2
- package/src/common/wrap/wrap-xhr.js +1 -1
- package/src/features/ajax/aggregate/index.js +1 -1
- package/src/features/ajax/instrument/distributed-tracing.js +1 -1
- package/src/features/ajax/instrument/index.js +1 -2
- package/src/features/jserrors/aggregate/compute-stack-trace.test.js +1 -1
- package/src/features/jserrors/aggregate/index.js +12 -3
- package/src/features/jserrors/instrument/index.js +3 -16
- package/src/features/metrics/aggregate/framework-detection.js +1 -1
- package/src/features/metrics/aggregate/framework-detection.test.js +2 -2
- package/src/features/metrics/aggregate/index.js +1 -1
- package/src/features/page_action/aggregate/index.js +1 -1
- package/src/features/page_view_event/aggregate/index.js +1 -2
- package/src/features/page_view_event/instrument/index.js +1 -1
- package/src/features/page_view_timing/aggregate/index.js +2 -4
- package/src/features/page_view_timing/instrument/index.js +1 -1
- package/src/features/session_replay/aggregate/index.component-test.js +368 -0
- package/src/features/session_replay/aggregate/index.js +96 -71
- package/src/features/session_replay/instrument/index.js +0 -1
- package/src/features/session_replay/replay-mode.js +23 -0
- package/src/features/session_trace/aggregate/index.js +198 -79
- package/src/features/session_trace/constants.js +0 -1
- package/src/features/session_trace/instrument/index.js +3 -20
- package/src/features/spa/aggregate/index.js +1 -1
- package/src/features/spa/constants.js +0 -1
- package/src/features/spa/instrument/index.js +1 -1
- package/src/features/utils/agent-session.js +22 -34
- package/src/features/utils/agent-session.test.js +194 -0
- package/src/features/utils/aggregate-base.js +12 -9
- package/src/features/utils/aggregate-base.test.js +122 -0
- package/src/features/utils/feature-base.test.js +45 -0
- package/src/features/utils/handler-cache.js +29 -23
- package/src/features/utils/handler-cache.test.js +72 -0
- package/src/features/utils/instrument-base.js +45 -29
- package/src/features/utils/instrument-base.test.js +209 -0
- package/src/features/utils/lazy-feature-loader.test.js +37 -0
- package/src/index.js +1 -3
- package/src/loaders/agent.js +8 -1
- package/src/loaders/api/api.js +2 -2
- package/src/loaders/api/apiAsync.js +3 -3
- package/src/loaders/configure/configure.js +1 -1
- package/src/loaders/features/featureDependencies.js +2 -0
- package/src/loaders/micro-agent.js +26 -30
- package/dist/cjs/common/browser-version/firefox-version.js +0 -17
- package/dist/cjs/common/browser-version/ios-version.js +0 -19
- package/dist/cjs/common/event-emitter/contextual-ee.test.js +0 -282
- package/dist/cjs/common/event-emitter/handle.test.js +0 -58
- package/dist/cjs/common/event-emitter/register-handler.test.js +0 -55
- package/dist/cjs/common/harvest/harvest-scheduler.test.js +0 -39
- package/dist/cjs/common/harvest/harvest.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.test.js +0 -460
- package/dist/cjs/common/storage/local-memory.js +0 -35
- package/dist/cjs/common/storage/local-memory.test.js +0 -20
- package/dist/cjs/common/storage/local-storage.test.js +0 -14
- package/dist/cjs/common/timer/interaction-timer.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 -42
- package/dist/cjs/common/url/clean-url.test.js +0 -9
- package/dist/cjs/common/url/encode.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.test.js +0 -15
- package/dist/cjs/common/util/console.test.js +0 -30
- package/dist/cjs/common/util/data-size.test.js +0 -47
- package/dist/cjs/common/util/get-or-set.test.js +0 -47
- package/dist/cjs/common/util/global-scope.js +0 -58
- 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/stringify.test.js +0 -48
- package/dist/cjs/common/util/submit-data.test.js +0 -221
- package/dist/cjs/common/util/traverse.test.js +0 -44
- package/dist/cjs/common/wrap/wrap-promise.test.js +0 -119
- package/dist/cjs/features/jserrors/aggregate/canonical-function-name.test.js +0 -31
- package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.test.js +0 -383
- package/dist/cjs/features/jserrors/aggregate/format-stack-trace.test.js +0 -40
- package/dist/cjs/features/jserrors/aggregate/string-hash-code.test.js +0 -27
- package/dist/cjs/features/metrics/aggregate/framework-detection.test.js +0 -137
- package/dist/cjs/features/metrics/aggregate/polyfill-detection.es5.test.js +0 -17
- package/dist/cjs/features/metrics/aggregate/polyfill-detection.test.js +0 -165
- package/dist/cjs/features/spa/aggregate/interaction-node.test.js +0 -16
- 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.test.js +0 -37
- package/dist/esm/common/harvest/harvest.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.test.js +0 -458
- package/dist/esm/common/storage/local-memory.js +0 -28
- package/dist/esm/common/storage/local-memory.test.js +0 -18
- package/dist/esm/common/storage/local-storage.test.js +0 -12
- package/dist/esm/common/timer/interaction-timer.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 -38
- package/dist/esm/common/url/clean-url.test.js +0 -7
- package/dist/esm/common/url/encode.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.test.js +0 -13
- package/dist/esm/common/util/console.test.js +0 -28
- package/dist/esm/common/util/data-size.test.js +0 -45
- package/dist/esm/common/util/get-or-set.test.js +0 -45
- package/dist/esm/common/util/global-scope.js +0 -45
- 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/stringify.test.js +0 -46
- package/dist/esm/common/util/submit-data.test.js +0 -219
- package/dist/esm/common/util/traverse.test.js +0 -42
- package/dist/esm/common/wrap/wrap-promise.test.js +0 -115
- package/dist/esm/features/jserrors/aggregate/canonical-function-name.test.js +0 -29
- package/dist/esm/features/jserrors/aggregate/compute-stack-trace.test.js +0 -379
- package/dist/esm/features/jserrors/aggregate/format-stack-trace.test.js +0 -38
- package/dist/esm/features/jserrors/aggregate/string-hash-code.test.js +0 -25
- package/dist/esm/features/metrics/aggregate/framework-detection.test.js +0 -133
- package/dist/esm/features/metrics/aggregate/polyfill-detection.es5.test.js +0 -15
- package/dist/esm/features/metrics/aggregate/polyfill-detection.test.js +0 -163
- package/dist/esm/features/spa/aggregate/interaction-node.test.js +0 -14
- 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/storage/local-memory.d.ts +0 -8
- package/dist/types/common/storage/local-memory.d.ts.map +0 -1
- package/dist/types/common/util/global-scope.d.ts +0 -14
- package/dist/types/common/util/global-scope.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/storage/local-memory.js +0 -30
- package/src/common/storage/local-memory.test.js +0 -19
- package/src/common/util/global-scope.js +0 -49
- /package/src/common/timer/{interaction-timer.test.js → interaction-timer.component-test.js} +0 -0
- /package/src/common/url/{encode.test.js → encode.component-test.js} +0 -0
- /package/src/common/url/{protocol.test.js → protocol.component-test.js} +0 -0
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _traverse = require("./traverse");
|
|
4
|
-
test.each(['not an object', null, undefined])('should return input unchanged when input is %p', input => {
|
|
5
|
-
const result = (0, _traverse.applyFnToProps)(input, jest.fn());
|
|
6
|
-
expect(result).toEqual(input);
|
|
7
|
-
});
|
|
8
|
-
test('should apply the provided function only to properties of the specified type', () => {
|
|
9
|
-
const obj = {
|
|
10
|
-
stringProp: 'Hello',
|
|
11
|
-
numberProp: 42,
|
|
12
|
-
arrayProp: [1, 2, 3],
|
|
13
|
-
objectProp: {
|
|
14
|
-
foo: 'bar'
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
const fn = jest.fn(value => value.toUpperCase());
|
|
18
|
-
const result = (0, _traverse.applyFnToProps)(obj, fn, 'string');
|
|
19
|
-
expect(result.stringProp).toBe('HELLO');
|
|
20
|
-
expect(result.numberProp).toBe(42);
|
|
21
|
-
expect(result.arrayProp).toEqual([1, 2, 3]);
|
|
22
|
-
expect(result.objectProp).toEqual({
|
|
23
|
-
foo: 'BAR'
|
|
24
|
-
});
|
|
25
|
-
expect(fn).toHaveBeenCalledTimes(2);
|
|
26
|
-
expect(fn).toHaveBeenCalledWith('Hello');
|
|
27
|
-
expect(fn).toHaveBeenCalledWith('bar');
|
|
28
|
-
});
|
|
29
|
-
test('should ignore properties specified in ignoreKeys', () => {
|
|
30
|
-
const obj = {
|
|
31
|
-
a: 1,
|
|
32
|
-
b: 2,
|
|
33
|
-
c: 3
|
|
34
|
-
};
|
|
35
|
-
const fn = jest.fn(value => value + 1);
|
|
36
|
-
const ignoreKeys = ['c'];
|
|
37
|
-
const result = (0, _traverse.applyFnToProps)(obj, fn, 'number', ignoreKeys);
|
|
38
|
-
expect(result.a).toBe(2);
|
|
39
|
-
expect(result.b).toBe(3);
|
|
40
|
-
expect(result.c).toBe(3);
|
|
41
|
-
expect(fn).toHaveBeenCalledTimes(2);
|
|
42
|
-
expect(fn).toHaveBeenCalledWith(1);
|
|
43
|
-
expect(fn).toHaveBeenCalledWith(2);
|
|
44
|
-
});
|
|
@@ -1,119 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _canonicalFunctionName = require("./canonical-function-name");
|
|
4
|
-
test.each([{
|
|
5
|
-
input: null,
|
|
6
|
-
expected: undefined,
|
|
7
|
-
title: 'Return undefined if no function name'
|
|
8
|
-
}, {
|
|
9
|
-
input: 'test',
|
|
10
|
-
expected: 'test',
|
|
11
|
-
title: 'Simple function name'
|
|
12
|
-
}, {
|
|
13
|
-
input: 'scope1/scope2/func',
|
|
14
|
-
expected: 'func',
|
|
15
|
-
title: 'Remove Firefox scopes'
|
|
16
|
-
}, {
|
|
17
|
-
input: 'scope1.func',
|
|
18
|
-
expected: 'func',
|
|
19
|
-
title: 'Remove Chrome scopes'
|
|
20
|
-
}, {
|
|
21
|
-
input: '<anonymous>',
|
|
22
|
-
expected: undefined,
|
|
23
|
-
title: 'Return undefined ending is non-alphanumeric'
|
|
24
|
-
}])('$title', _ref => {
|
|
25
|
-
let {
|
|
26
|
-
input,
|
|
27
|
-
expected
|
|
28
|
-
} = _ref;
|
|
29
|
-
const result = (0, _canonicalFunctionName.canonicalFunctionName)(input);
|
|
30
|
-
expect(result).toEqual(expected);
|
|
31
|
-
});
|
|
@@ -1,383 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _faker = require("@faker-js/faker");
|
|
4
|
-
var _testingUtils = require("../../../../tools/testing-utils");
|
|
5
|
-
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); }
|
|
6
|
-
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; }
|
|
7
|
-
const globalScopeLocation = 'https://example.com/';
|
|
8
|
-
const mockGlobalScopeLocation = url => {
|
|
9
|
-
jest.doMock('../../../common/util/global-scope', () => ({
|
|
10
|
-
initialLocation: url || globalScopeLocation
|
|
11
|
-
}));
|
|
12
|
-
};
|
|
13
|
-
afterEach(() => {
|
|
14
|
-
jest.resetModules();
|
|
15
|
-
jest.clearAllMocks();
|
|
16
|
-
});
|
|
17
|
-
const baseMockError = {
|
|
18
|
-
toString: 'RangeError: Invalid array length',
|
|
19
|
-
name: 'RangeError',
|
|
20
|
-
constructor: 'function RangeError() { [native code] }',
|
|
21
|
-
message: 'Invalid array length',
|
|
22
|
-
stack: 'RangeError: Invalid array length\n' + ' at errorTest (' + globalScopeLocation + '?loader=spa#hello:74:16)\n' + ' at captureError (' + globalScopeLocation + 'js/script.js?loader=spa:17:9)\n' + ' at onload (' + globalScopeLocation + 'js/script.js?loader=spa:70:5)'
|
|
23
|
-
};
|
|
24
|
-
test('parsing should return a failure for a null error object', async () => {
|
|
25
|
-
mockGlobalScopeLocation();
|
|
26
|
-
const {
|
|
27
|
-
computeStackTrace
|
|
28
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./compute-stack-trace')));
|
|
29
|
-
const result = computeStackTrace(null);
|
|
30
|
-
expect(result).toEqual(expect.objectContaining({
|
|
31
|
-
mode: 'failed',
|
|
32
|
-
stackString: '',
|
|
33
|
-
frames: []
|
|
34
|
-
}));
|
|
35
|
-
});
|
|
36
|
-
describe('errors with stack property', () => {
|
|
37
|
-
test('should show <inline> for same-page stack string URLs but not sub-paths', async () => {
|
|
38
|
-
const mockError = _testingUtils.browserErrorUtils.constructError({
|
|
39
|
-
...baseMockError
|
|
40
|
-
});
|
|
41
|
-
mockGlobalScopeLocation();
|
|
42
|
-
const {
|
|
43
|
-
computeStackTrace
|
|
44
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./compute-stack-trace')));
|
|
45
|
-
const result = computeStackTrace(mockError);
|
|
46
|
-
expect(result).toEqual(expect.objectContaining({
|
|
47
|
-
stackString:
|
|
48
|
-
// canonicalized
|
|
49
|
-
'RangeError: Invalid array length\n' + ' at errorTest (<inline>:74:16)\n' + ' at captureError (' + globalScopeLocation + 'js/script.js:17:9)\n' + ' at onload (' + globalScopeLocation + 'js/script.js:70:5)'
|
|
50
|
-
}));
|
|
51
|
-
});
|
|
52
|
-
test('parsed name should be unknown when name and constructor are missing', async () => {
|
|
53
|
-
const mockError = _testingUtils.browserErrorUtils.constructError({
|
|
54
|
-
...baseMockError,
|
|
55
|
-
name: null,
|
|
56
|
-
constructor: null
|
|
57
|
-
});
|
|
58
|
-
mockGlobalScopeLocation();
|
|
59
|
-
const {
|
|
60
|
-
computeStackTrace
|
|
61
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./compute-stack-trace')));
|
|
62
|
-
const result = computeStackTrace(mockError);
|
|
63
|
-
expect(result).toEqual(expect.objectContaining({
|
|
64
|
-
mode: 'stack',
|
|
65
|
-
name: 'unknown'
|
|
66
|
-
}));
|
|
67
|
-
});
|
|
68
|
-
test('parsed stack should not contain nrWrapper', async () => {
|
|
69
|
-
const alteredError = baseMockError;
|
|
70
|
-
alteredError.stack += '\n at nrWrapper (' + globalScopeLocation + '?loader=spa:60:17)';
|
|
71
|
-
const mockError = _testingUtils.browserErrorUtils.constructError(alteredError);
|
|
72
|
-
mockGlobalScopeLocation();
|
|
73
|
-
const {
|
|
74
|
-
computeStackTrace
|
|
75
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./compute-stack-trace')));
|
|
76
|
-
const result = computeStackTrace(mockError);
|
|
77
|
-
expect(result).toEqual(expect.objectContaining({
|
|
78
|
-
mode: 'stack',
|
|
79
|
-
name: mockError.name,
|
|
80
|
-
message: mockError.message,
|
|
81
|
-
stackString: expect.not.stringContaining('nrWrapper')
|
|
82
|
-
}));
|
|
83
|
-
expect(result.frames).not.toContainEqual(expect.objectContaining({
|
|
84
|
-
func: 'nrWrapper'
|
|
85
|
-
}));
|
|
86
|
-
});
|
|
87
|
-
test('stack should still parse when column numbers are missing', async () => {
|
|
88
|
-
const mockError = _testingUtils.browserErrorUtils.constructError({
|
|
89
|
-
...baseMockError,
|
|
90
|
-
stack: 'RangeError: Invalid array length\n' + 'Error: Blocked a frame with origin "http://bam-test-1.nr-local.net:3334" from accessing a cross-origin frame.\n' + ' at errorTest (' + globalScopeLocation + '?loader=spa:60)\n' + ' at captureError (' + globalScopeLocation + '?loader=spa:17)\n' + ' at onload (' + globalScopeLocation + '?loader=spa:57)'
|
|
91
|
-
});
|
|
92
|
-
mockGlobalScopeLocation();
|
|
93
|
-
const {
|
|
94
|
-
computeStackTrace
|
|
95
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./compute-stack-trace')));
|
|
96
|
-
const result = computeStackTrace(mockError);
|
|
97
|
-
expect(result).toEqual(expect.objectContaining({
|
|
98
|
-
mode: 'stack',
|
|
99
|
-
name: mockError.name,
|
|
100
|
-
message: mockError.message,
|
|
101
|
-
stackString: 'RangeError: Invalid array length\n' + 'Error: Blocked a frame with origin "http://bam-test-1.nr-local.net:3334" from accessing a cross-origin frame.\n' + ' at errorTest (<inline>:60)\n' + ' at captureError (<inline>:17)\n' + ' at onload (<inline>:57)'
|
|
102
|
-
}));
|
|
103
|
-
expect(result.frames.length).toEqual(3);
|
|
104
|
-
expect(result.frames).toContainEqual(expect.objectContaining({
|
|
105
|
-
func: 'errorTest',
|
|
106
|
-
column: null
|
|
107
|
-
}));
|
|
108
|
-
expect(result.frames).toContainEqual(expect.objectContaining({
|
|
109
|
-
func: 'captureError',
|
|
110
|
-
column: null
|
|
111
|
-
}));
|
|
112
|
-
expect(result.frames).toContainEqual(expect.objectContaining({
|
|
113
|
-
func: 'onload',
|
|
114
|
-
column: null
|
|
115
|
-
}));
|
|
116
|
-
});
|
|
117
|
-
test('parser can handle chrome eval stack', async () => {
|
|
118
|
-
const mockError = _testingUtils.browserErrorUtils.constructError({
|
|
119
|
-
...baseMockError,
|
|
120
|
-
stack: ' at foobar (eval at foobar (' + globalScopeLocation + '))'
|
|
121
|
-
});
|
|
122
|
-
mockGlobalScopeLocation();
|
|
123
|
-
const {
|
|
124
|
-
computeStackTrace
|
|
125
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./compute-stack-trace')));
|
|
126
|
-
const result = computeStackTrace(mockError);
|
|
127
|
-
expect(result).toEqual(expect.objectContaining({
|
|
128
|
-
mode: 'stack',
|
|
129
|
-
name: mockError.name,
|
|
130
|
-
message: mockError.message,
|
|
131
|
-
stackString: mockError.stack
|
|
132
|
-
}));
|
|
133
|
-
expect(result.frames.length).toEqual(1);
|
|
134
|
-
expect(result.frames).toContainEqual(expect.objectContaining({
|
|
135
|
-
func: 'evaluated code'
|
|
136
|
-
}));
|
|
137
|
-
});
|
|
138
|
-
test('parser can handle ie eval stack', async () => {
|
|
139
|
-
const mockError = _testingUtils.browserErrorUtils.constructError({
|
|
140
|
-
toString: 'TypeError: Permission denied',
|
|
141
|
-
name: 'TypeError',
|
|
142
|
-
constructor: '\nfunction TypeError() {\n [native code]\n}\n',
|
|
143
|
-
message: 'Permission denied',
|
|
144
|
-
stack: ' at Function code (Function code:23:23)'
|
|
145
|
-
});
|
|
146
|
-
mockGlobalScopeLocation();
|
|
147
|
-
const {
|
|
148
|
-
computeStackTrace
|
|
149
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./compute-stack-trace')));
|
|
150
|
-
const result = computeStackTrace(mockError);
|
|
151
|
-
expect(result).toEqual(expect.objectContaining({
|
|
152
|
-
mode: 'stack',
|
|
153
|
-
name: mockError.name,
|
|
154
|
-
message: mockError.message,
|
|
155
|
-
stackString: mockError.stack
|
|
156
|
-
}));
|
|
157
|
-
expect(result.frames.length).toEqual(1);
|
|
158
|
-
expect(result.frames).toContainEqual(expect.objectContaining({
|
|
159
|
-
func: 'evaluated code'
|
|
160
|
-
}));
|
|
161
|
-
});
|
|
162
|
-
test('parser can handle stack with anonymous function', async () => {
|
|
163
|
-
const mockError = _testingUtils.browserErrorUtils.constructError({
|
|
164
|
-
...baseMockError,
|
|
165
|
-
stack: 'anonymous'
|
|
166
|
-
});
|
|
167
|
-
mockGlobalScopeLocation();
|
|
168
|
-
const {
|
|
169
|
-
computeStackTrace
|
|
170
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./compute-stack-trace')));
|
|
171
|
-
const result = computeStackTrace(mockError);
|
|
172
|
-
expect(result).toEqual(expect.objectContaining({
|
|
173
|
-
mode: 'stack',
|
|
174
|
-
name: mockError.name,
|
|
175
|
-
message: mockError.message,
|
|
176
|
-
stackString: mockError.stack
|
|
177
|
-
}));
|
|
178
|
-
expect(result.frames.length).toEqual(1);
|
|
179
|
-
expect(result.frames).toContainEqual(expect.objectContaining({
|
|
180
|
-
func: 'evaluated code'
|
|
181
|
-
}));
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
describe('errors without stack property and with line property', () => {
|
|
185
|
-
/**
|
|
186
|
-
* @deprecated sourceURL is no longer present in errors for any browsers we support
|
|
187
|
-
*/
|
|
188
|
-
test('parsed stack should contain sourceURL and line number', async () => {
|
|
189
|
-
const sourceURL = _faker.faker.internet.url();
|
|
190
|
-
const mockError = _testingUtils.browserErrorUtils.constructError({
|
|
191
|
-
...baseMockError,
|
|
192
|
-
stack: undefined,
|
|
193
|
-
line: 100,
|
|
194
|
-
sourceURL
|
|
195
|
-
});
|
|
196
|
-
mockGlobalScopeLocation();
|
|
197
|
-
const {
|
|
198
|
-
computeStackTrace
|
|
199
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./compute-stack-trace')));
|
|
200
|
-
const result = computeStackTrace(mockError);
|
|
201
|
-
expect(result).toEqual(expect.objectContaining({
|
|
202
|
-
mode: 'sourceline',
|
|
203
|
-
name: mockError.name,
|
|
204
|
-
message: mockError.message,
|
|
205
|
-
stackString: "".concat(mockError.name, ": ").concat(mockError.message, "\n at ").concat(sourceURL, ":").concat(mockError.line)
|
|
206
|
-
}));
|
|
207
|
-
expect(result.frames.length).toEqual(1);
|
|
208
|
-
expect(result.frames).toContainEqual(expect.objectContaining({
|
|
209
|
-
url: sourceURL,
|
|
210
|
-
line: mockError.line
|
|
211
|
-
}));
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* @deprecated sourceURL is no longer present in errors for any browsers we support
|
|
216
|
-
*/
|
|
217
|
-
test('parsed stack should contain sourceURL, line number, and column number', async () => {
|
|
218
|
-
const sourceURL = _faker.faker.internet.url();
|
|
219
|
-
const mockError = _testingUtils.browserErrorUtils.constructError({
|
|
220
|
-
...baseMockError,
|
|
221
|
-
line: 100,
|
|
222
|
-
column: 200,
|
|
223
|
-
stack: undefined,
|
|
224
|
-
sourceURL
|
|
225
|
-
});
|
|
226
|
-
mockGlobalScopeLocation();
|
|
227
|
-
const {
|
|
228
|
-
computeStackTrace
|
|
229
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./compute-stack-trace')));
|
|
230
|
-
const result = computeStackTrace(mockError);
|
|
231
|
-
expect(result).toEqual(expect.objectContaining({
|
|
232
|
-
mode: 'sourceline',
|
|
233
|
-
name: mockError.name,
|
|
234
|
-
message: mockError.message,
|
|
235
|
-
stackString: "".concat(mockError.name, ": ").concat(mockError.message, "\n at ").concat(sourceURL, ":").concat(mockError.line, ":").concat(mockError.column)
|
|
236
|
-
}));
|
|
237
|
-
expect(result.frames.length).toEqual(1);
|
|
238
|
-
expect(result.frames).toContainEqual(expect.objectContaining({
|
|
239
|
-
url: sourceURL,
|
|
240
|
-
line: mockError.line,
|
|
241
|
-
column: mockError.column
|
|
242
|
-
}));
|
|
243
|
-
});
|
|
244
|
-
test('parsed stack should contain "evaluated code" if sourceURL property is not present', async () => {
|
|
245
|
-
const mockError = _testingUtils.browserErrorUtils.constructError({
|
|
246
|
-
...baseMockError,
|
|
247
|
-
line: 100,
|
|
248
|
-
column: 200,
|
|
249
|
-
stack: undefined
|
|
250
|
-
});
|
|
251
|
-
mockGlobalScopeLocation();
|
|
252
|
-
const {
|
|
253
|
-
computeStackTrace
|
|
254
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./compute-stack-trace')));
|
|
255
|
-
const result = computeStackTrace(mockError);
|
|
256
|
-
expect(result).toEqual(expect.objectContaining({
|
|
257
|
-
mode: 'sourceline',
|
|
258
|
-
name: mockError.name,
|
|
259
|
-
message: mockError.message,
|
|
260
|
-
stackString: "RangeError: ".concat(mockError.message, "\n in evaluated code")
|
|
261
|
-
}));
|
|
262
|
-
expect(result.frames.length).toEqual(1);
|
|
263
|
-
expect(result.frames).toContainEqual(expect.objectContaining({
|
|
264
|
-
func: 'evaluated code'
|
|
265
|
-
}));
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* @deprecated sourceURL is no longer present in errors for any browsers we support
|
|
270
|
-
*/
|
|
271
|
-
test('should show <inline> for same-page URLs', async () => {
|
|
272
|
-
const pageLocation = _faker.faker.internet.url();
|
|
273
|
-
const sourceURL = pageLocation + '?abc=123';
|
|
274
|
-
const mockError = _testingUtils.browserErrorUtils.constructError({
|
|
275
|
-
...baseMockError,
|
|
276
|
-
line: 100,
|
|
277
|
-
column: 200,
|
|
278
|
-
stack: undefined,
|
|
279
|
-
sourceURL: sourceURL
|
|
280
|
-
});
|
|
281
|
-
mockGlobalScopeLocation(pageLocation);
|
|
282
|
-
const {
|
|
283
|
-
computeStackTrace
|
|
284
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./compute-stack-trace')));
|
|
285
|
-
const result = computeStackTrace(mockError);
|
|
286
|
-
expect(result).toEqual(expect.objectContaining({
|
|
287
|
-
stackString: "".concat(mockError.name, ": ").concat(mockError.message, "\n at <inline>:").concat(mockError.line, ":").concat(mockError.column)
|
|
288
|
-
}));
|
|
289
|
-
expect(result.frames).toContainEqual(expect.objectContaining({
|
|
290
|
-
url: '<inline>'
|
|
291
|
-
}));
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
* @deprecated sourceURL is no longer present in errors for any browsers we support
|
|
296
|
-
*/
|
|
297
|
-
test('should NOT show <inline> for same-domain URLs with a sub-path', async () => {
|
|
298
|
-
const pageLocation = _faker.faker.internet.url();
|
|
299
|
-
const sourceURL = pageLocation + '/path/to/script.js';
|
|
300
|
-
const mockError = _testingUtils.browserErrorUtils.constructError({
|
|
301
|
-
...baseMockError,
|
|
302
|
-
line: 100,
|
|
303
|
-
column: 200,
|
|
304
|
-
stack: undefined,
|
|
305
|
-
sourceURL
|
|
306
|
-
});
|
|
307
|
-
mockGlobalScopeLocation(pageLocation);
|
|
308
|
-
const {
|
|
309
|
-
computeStackTrace
|
|
310
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./compute-stack-trace')));
|
|
311
|
-
const result = computeStackTrace(mockError);
|
|
312
|
-
expect(result).toEqual(expect.objectContaining({
|
|
313
|
-
stackString: "".concat(mockError.name, ": ").concat(mockError.message, "\n at ").concat(sourceURL, ":").concat(mockError.line, ":").concat(mockError.column)
|
|
314
|
-
}));
|
|
315
|
-
expect(result.frames).toContainEqual(expect.objectContaining({
|
|
316
|
-
url: sourceURL
|
|
317
|
-
}));
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
// TODO: computeStackTraceBySourceAndLine does not respect firefox lineNumber and columnNumber properties when stack is empty
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* These tests are here because JS allows you to throw absolutely anything as an
|
|
325
|
-
* error, including primitives.
|
|
326
|
-
*/
|
|
327
|
-
describe('errors that are messages only or primitives', () => {
|
|
328
|
-
test('parser should get error name from constructor', async () => {
|
|
329
|
-
const mockError = _testingUtils.browserErrorUtils.constructError({
|
|
330
|
-
toString: '0',
|
|
331
|
-
constructor: 'function Number() { [native code] }'
|
|
332
|
-
});
|
|
333
|
-
mockGlobalScopeLocation();
|
|
334
|
-
const {
|
|
335
|
-
computeStackTrace
|
|
336
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./compute-stack-trace')));
|
|
337
|
-
const result = computeStackTrace(mockError);
|
|
338
|
-
expect(result).toEqual(expect.objectContaining({
|
|
339
|
-
mode: 'nameonly',
|
|
340
|
-
name: 'Number',
|
|
341
|
-
stackString: 'Number: undefined',
|
|
342
|
-
frames: []
|
|
343
|
-
}));
|
|
344
|
-
});
|
|
345
|
-
test('parser should get error name from name property', async () => {
|
|
346
|
-
const mockError = _testingUtils.browserErrorUtils.constructError({
|
|
347
|
-
toString: '0',
|
|
348
|
-
name: _faker.faker.datatype.uuid(),
|
|
349
|
-
constructor: 'function Number() { [native code] }'
|
|
350
|
-
});
|
|
351
|
-
mockGlobalScopeLocation();
|
|
352
|
-
const {
|
|
353
|
-
computeStackTrace
|
|
354
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./compute-stack-trace')));
|
|
355
|
-
const result = computeStackTrace(mockError);
|
|
356
|
-
expect(result).toEqual(expect.objectContaining({
|
|
357
|
-
mode: 'nameonly',
|
|
358
|
-
name: mockError.name,
|
|
359
|
-
stackString: "".concat(mockError.name, ": undefined"),
|
|
360
|
-
frames: []
|
|
361
|
-
}));
|
|
362
|
-
});
|
|
363
|
-
test('parser should include the message property', async () => {
|
|
364
|
-
const mockError = _testingUtils.browserErrorUtils.constructError({
|
|
365
|
-
toString: '0',
|
|
366
|
-
name: _faker.faker.datatype.uuid(),
|
|
367
|
-
message: _faker.faker.datatype.uuid(),
|
|
368
|
-
constructor: 'function Number() { [native code] }'
|
|
369
|
-
});
|
|
370
|
-
mockGlobalScopeLocation();
|
|
371
|
-
const {
|
|
372
|
-
computeStackTrace
|
|
373
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./compute-stack-trace')));
|
|
374
|
-
const result = computeStackTrace(mockError);
|
|
375
|
-
expect(result).toEqual(expect.objectContaining({
|
|
376
|
-
mode: 'nameonly',
|
|
377
|
-
name: mockError.name,
|
|
378
|
-
message: mockError.message,
|
|
379
|
-
stackString: "".concat(mockError.name, ": ").concat(mockError.message),
|
|
380
|
-
frames: []
|
|
381
|
-
}));
|
|
382
|
-
});
|
|
383
|
-
});
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _faker = require("@faker-js/faker");
|
|
4
|
-
var _formatStackTrace = require("./format-stack-trace");
|
|
5
|
-
describe('formatStackTrace', () => {
|
|
6
|
-
test.each([{
|
|
7
|
-
input: ['line 1', 'line 2', 'line 3', 'line 4'],
|
|
8
|
-
expected: 'line 1\nline 2\nline 3\nline 4',
|
|
9
|
-
title: 'Appends all stack lines together'
|
|
10
|
-
}, {
|
|
11
|
-
input: ['', 'line 1', 'line 2'],
|
|
12
|
-
expected: 'line 1\nline 2',
|
|
13
|
-
title: 'Strips leading empty stack frame'
|
|
14
|
-
}, {
|
|
15
|
-
input: ['line 1', 'line 2', ''],
|
|
16
|
-
expected: 'line 1\nline 2',
|
|
17
|
-
title: 'Strips ending empty stack frame'
|
|
18
|
-
}])('$title', _ref => {
|
|
19
|
-
let {
|
|
20
|
-
input,
|
|
21
|
-
expected
|
|
22
|
-
} = _ref;
|
|
23
|
-
const result = (0, _formatStackTrace.formatStackTrace)(input);
|
|
24
|
-
expect(result).toEqual(expected);
|
|
25
|
-
});
|
|
26
|
-
test('truncates the middle of the stack lines when more than 100', () => {
|
|
27
|
-
const input = Array.apply(null, Array(200)).map(() => _faker.faker.datatype.uuid());
|
|
28
|
-
const expected = input.slice(0, 50).join('\n') + "\n< ...truncated ".concat(input.length - 100, " lines... >\n") + input.slice(-50).join('\n');
|
|
29
|
-
const result = (0, _formatStackTrace.formatStackTrace)(input);
|
|
30
|
-
expect(result).toEqual(expected);
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
describe('truncateSize', () => {
|
|
34
|
-
test('should truncate stack string to max limit', () => {
|
|
35
|
-
const maxSize = 65530;
|
|
36
|
-
const input = _faker.faker.datatype.string(maxSize + 1);
|
|
37
|
-
const result = (0, _formatStackTrace.truncateSize)(input);
|
|
38
|
-
expect(result).toEqual(input.slice(0, maxSize));
|
|
39
|
-
});
|
|
40
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _stringHashCode = require("./string-hash-code");
|
|
4
|
-
test.each([{
|
|
5
|
-
input: undefined,
|
|
6
|
-
expected: 0,
|
|
7
|
-
title: 'Return 0 for undefined input'
|
|
8
|
-
}, {
|
|
9
|
-
input: null,
|
|
10
|
-
expected: 0,
|
|
11
|
-
title: 'Return 0 for null input'
|
|
12
|
-
}, {
|
|
13
|
-
input: '',
|
|
14
|
-
expected: 0,
|
|
15
|
-
title: 'Return 0 for empty string input'
|
|
16
|
-
}, {
|
|
17
|
-
input: 'lksjdflksjdf',
|
|
18
|
-
expected: 32668720,
|
|
19
|
-
title: 'Return valid hash of string'
|
|
20
|
-
}])('$title', _ref => {
|
|
21
|
-
let {
|
|
22
|
-
input,
|
|
23
|
-
expected
|
|
24
|
-
} = _ref;
|
|
25
|
-
const result = (0, _stringHashCode.stringHashCode)(input);
|
|
26
|
-
expect(result).toEqual(expected);
|
|
27
|
-
});
|