@newrelic/browser-agent 1.235.0 → 1.237.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -1
- package/dist/cjs/common/config/state/init.js +4 -0
- package/dist/cjs/common/config/state/runtime.js +6 -5
- package/dist/cjs/common/constants/env.cdn.js +2 -2
- package/dist/cjs/common/constants/env.npm.js +1 -1
- package/dist/cjs/common/constants/runtime.js +52 -0
- package/dist/cjs/common/deny-list/deny-list.js +14 -10
- package/dist/cjs/common/event-listener/event-listener-opts.js +3 -3
- package/dist/cjs/common/harvest/harvest-scheduler.js +22 -19
- package/dist/cjs/common/harvest/harvest.js +154 -148
- package/dist/cjs/common/harvest/types.js +54 -0
- package/dist/cjs/common/ids/id.js +2 -2
- package/dist/cjs/common/ids/unique-id.js +3 -3
- package/dist/cjs/common/session/session-entity.js +2 -2
- package/dist/cjs/common/timer/interaction-timer.js +2 -2
- package/dist/cjs/common/unload/eol.js +10 -11
- package/dist/cjs/common/url/canonicalize-url.js +2 -2
- package/dist/cjs/common/url/parse-url.js +3 -3
- package/dist/cjs/common/url/protocol.js +2 -2
- package/dist/cjs/common/util/submit-data.js +31 -81
- package/dist/cjs/common/window/nreum.js +14 -14
- package/dist/cjs/common/wrap/wrap-events.js +3 -3
- package/dist/cjs/common/wrap/wrap-fetch.js +5 -5
- package/dist/cjs/common/wrap/wrap-history.js +2 -2
- package/dist/cjs/common/wrap/wrap-jsonp.js +14 -8
- package/dist/cjs/common/wrap/wrap-mutation.js +2 -2
- package/dist/cjs/common/wrap/wrap-promise.js +2 -2
- package/dist/cjs/common/wrap/wrap-raf.js +2 -2
- package/dist/cjs/common/wrap/wrap-timer.js +4 -4
- package/dist/cjs/common/wrap/wrap-xhr.js +3 -3
- package/dist/cjs/features/ajax/aggregate/index.js +25 -28
- package/dist/cjs/features/ajax/instrument/distributed-tracing.js +2 -2
- package/dist/cjs/features/ajax/instrument/index.js +6 -7
- package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.js +1 -1
- package/dist/cjs/features/jserrors/aggregate/index.js +7 -4
- package/dist/cjs/features/jserrors/constants.js +2 -4
- package/dist/cjs/features/jserrors/instrument/index.js +80 -89
- package/dist/cjs/features/jserrors/instrument/uncaught-error.js +22 -0
- package/dist/cjs/features/metrics/aggregate/framework-detection.js +2 -2
- package/dist/cjs/features/metrics/aggregate/index.js +3 -3
- package/dist/cjs/features/page_action/aggregate/index.js +3 -3
- package/dist/cjs/features/page_view_event/aggregate/index.js +10 -11
- package/dist/cjs/features/page_view_event/aggregate/initialized-features.js +23 -19
- package/dist/cjs/features/page_view_event/instrument/index.js +2 -2
- package/dist/cjs/features/page_view_timing/aggregate/index.js +3 -5
- package/dist/cjs/features/page_view_timing/instrument/index.js +2 -2
- package/dist/cjs/features/session_replay/aggregate/index.js +65 -34
- package/dist/cjs/features/session_replay/replay-mode.js +2 -2
- package/dist/cjs/features/session_trace/aggregate/index.js +3 -4
- package/dist/cjs/features/session_trace/instrument/index.js +2 -2
- package/dist/cjs/features/spa/aggregate/index.js +1 -1
- package/dist/cjs/features/spa/instrument/index.js +2 -2
- package/dist/cjs/features/utils/instrument-base.js +12 -15
- package/dist/cjs/index.js +7 -0
- package/dist/cjs/loaders/agent-base.js +87 -0
- package/dist/cjs/loaders/agent.js +48 -1
- package/dist/cjs/loaders/api/api.js +3 -3
- package/dist/cjs/loaders/api/apiAsync.js +6 -4
- package/dist/cjs/loaders/api/interaction-types.js +87 -0
- package/dist/cjs/loaders/configure/configure.js +4 -3
- package/dist/cjs/loaders/micro-agent.js +32 -39
- package/dist/esm/common/config/state/init.js +4 -0
- package/dist/esm/common/config/state/runtime.js +3 -2
- package/dist/esm/common/constants/env.cdn.js +2 -2
- package/dist/esm/common/constants/env.npm.js +1 -1
- package/dist/esm/common/constants/runtime.js +38 -0
- package/dist/esm/common/deny-list/deny-list.js +14 -10
- package/dist/esm/common/event-listener/event-listener-opts.js +1 -1
- package/dist/esm/common/harvest/harvest-scheduler.js +21 -20
- package/dist/esm/common/harvest/harvest.js +150 -146
- package/dist/esm/common/harvest/types.js +47 -0
- package/dist/esm/common/ids/id.js +1 -1
- package/dist/esm/common/ids/unique-id.js +1 -1
- package/dist/esm/common/session/session-entity.js +1 -1
- package/dist/esm/common/timer/interaction-timer.js +1 -1
- package/dist/esm/common/unload/eol.js +1 -2
- package/dist/esm/common/url/canonicalize-url.js +1 -1
- package/dist/esm/common/url/parse-url.js +1 -1
- package/dist/esm/common/url/protocol.js +1 -1
- package/dist/esm/common/util/submit-data.js +29 -78
- package/dist/esm/common/window/nreum.js +1 -1
- package/dist/esm/common/wrap/wrap-events.js +1 -1
- package/dist/esm/common/wrap/wrap-fetch.js +1 -1
- package/dist/esm/common/wrap/wrap-history.js +1 -1
- package/dist/esm/common/wrap/wrap-jsonp.js +13 -7
- package/dist/esm/common/wrap/wrap-mutation.js +1 -1
- package/dist/esm/common/wrap/wrap-promise.js +1 -1
- package/dist/esm/common/wrap/wrap-raf.js +1 -1
- package/dist/esm/common/wrap/wrap-timer.js +1 -1
- package/dist/esm/common/wrap/wrap-xhr.js +1 -1
- package/dist/esm/features/ajax/aggregate/index.js +26 -29
- package/dist/esm/features/ajax/instrument/distributed-tracing.js +1 -1
- package/dist/esm/features/ajax/instrument/index.js +1 -2
- package/dist/esm/features/jserrors/aggregate/compute-stack-trace.js +1 -1
- package/dist/esm/features/jserrors/aggregate/index.js +6 -3
- package/dist/esm/features/jserrors/constants.js +1 -2
- package/dist/esm/features/jserrors/instrument/index.js +79 -88
- package/dist/esm/features/jserrors/instrument/uncaught-error.js +15 -0
- package/dist/esm/features/metrics/aggregate/framework-detection.js +1 -1
- package/dist/esm/features/metrics/aggregate/index.js +1 -1
- package/dist/esm/features/page_action/aggregate/index.js +1 -1
- package/dist/esm/features/page_view_event/aggregate/index.js +1 -2
- package/dist/esm/features/page_view_event/aggregate/initialized-features.js +23 -19
- package/dist/esm/features/page_view_event/instrument/index.js +1 -1
- package/dist/esm/features/page_view_timing/aggregate/index.js +2 -4
- package/dist/esm/features/page_view_timing/instrument/index.js +1 -1
- package/dist/esm/features/session_replay/aggregate/index.js +65 -34
- package/dist/esm/features/session_replay/replay-mode.js +2 -2
- package/dist/esm/features/session_trace/aggregate/index.js +3 -4
- package/dist/esm/features/session_trace/instrument/index.js +1 -1
- package/dist/esm/features/spa/aggregate/index.js +1 -1
- package/dist/esm/features/spa/instrument/index.js +1 -1
- package/dist/esm/features/utils/instrument-base.js +11 -14
- package/dist/esm/index.js +1 -4
- package/dist/esm/loaders/agent-base.js +80 -0
- package/dist/esm/loaders/agent.js +48 -1
- package/dist/esm/loaders/api/api.js +2 -2
- package/dist/esm/loaders/api/apiAsync.js +3 -3
- package/dist/esm/loaders/api/interaction-types.js +80 -0
- package/dist/esm/loaders/configure/configure.js +4 -3
- package/dist/esm/loaders/micro-agent.js +32 -39
- package/dist/types/common/config/state/init.d.ts.map +1 -1
- package/dist/types/common/config/state/runtime.d.ts.map +1 -1
- package/dist/types/common/constants/runtime.d.ts +29 -0
- package/dist/types/common/constants/runtime.d.ts.map +1 -0
- package/dist/types/common/event-emitter/register-handler.d.ts +1 -1
- package/dist/types/common/harvest/harvest-scheduler.d.ts +1 -1
- package/dist/types/common/harvest/harvest-scheduler.d.ts.map +1 -1
- package/dist/types/common/harvest/harvest.d.ts +49 -38
- package/dist/types/common/harvest/harvest.d.ts.map +1 -1
- package/dist/types/common/harvest/types.d.ts +100 -0
- package/dist/types/common/harvest/types.d.ts.map +1 -0
- package/dist/types/common/session/session-entity.d.ts +6 -6
- package/dist/types/common/unload/eol.d.ts.map +1 -1
- package/dist/types/common/util/submit-data.d.ts +44 -64
- package/dist/types/common/util/submit-data.d.ts.map +1 -1
- package/dist/types/common/window/nreum.d.ts +2 -2
- package/dist/types/common/wrap/wrap-jsonp.d.ts.map +1 -1
- package/dist/types/features/ajax/aggregate/index.d.ts +5 -5
- package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/ajax/instrument/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/aggregate/index.d.ts +1 -1
- package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/constants.d.ts +0 -1
- package/dist/types/features/jserrors/constants.d.ts.map +1 -1
- package/dist/types/features/jserrors/instrument/index.d.ts +0 -13
- package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/instrument/uncaught-error.d.ts +15 -0
- package/dist/types/features/jserrors/instrument/uncaught-error.d.ts.map +1 -0
- package/dist/types/features/metrics/aggregate/endpoint-map.d.ts +5 -5
- package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/page_view_event/aggregate/initialized-features.d.ts.map +1 -1
- package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/aggregate/index.d.ts +16 -30
- package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/loaders/agent-base.d.ts +59 -0
- package/dist/types/loaders/agent-base.d.ts.map +1 -0
- package/dist/types/loaders/agent.d.ts +39 -5
- package/dist/types/loaders/agent.d.ts.map +1 -1
- package/dist/types/loaders/api/interaction-types.d.ts +122 -0
- package/dist/types/loaders/api/interaction-types.d.ts.map +1 -0
- package/dist/types/loaders/configure/configure.d.ts.map +1 -1
- package/dist/types/loaders/features/features.d.ts +9 -9
- package/dist/types/loaders/micro-agent.d.ts +6 -6
- package/dist/types/loaders/micro-agent.d.ts.map +1 -1
- package/package.json +6 -1
- package/src/common/config/__mocks__/config.js +11 -0
- package/src/common/config/state/init.js +2 -1
- package/src/common/config/state/runtime.js +3 -2
- package/src/common/constants/__mocks__/env.js +3 -0
- package/src/common/constants/__mocks__/runtime.js +8 -0
- package/src/common/constants/env.cdn.test.js +7 -0
- package/src/common/constants/env.npm.test.js +7 -0
- package/src/common/constants/env.test.js +7 -0
- package/src/common/constants/runtime.js +71 -0
- package/src/common/constants/runtime.test.js +168 -0
- package/src/common/context/__mocks__/shared-context.js +8 -0
- package/src/common/deny-list/deny-list.js +11 -11
- package/src/common/deny-list/deny-list.test.js +31 -0
- package/src/common/event-listener/__mocks__/event-listener-opts.js +7 -0
- package/src/common/event-listener/event-listener-opts.js +1 -1
- package/src/common/harvest/__mocks__/harvest.js +13 -0
- package/src/common/harvest/harvest-scheduler.js +21 -20
- package/src/common/harvest/harvest-scheduler.test.js +496 -0
- package/src/common/harvest/harvest.js +142 -134
- package/src/common/harvest/harvest.test.js +798 -0
- package/src/common/harvest/types.js +47 -0
- package/src/common/ids/id.js +1 -1
- package/src/common/ids/unique-id.js +1 -1
- package/src/common/session/__mocks__/session-entity.js +25 -0
- package/src/common/session/session-entity.component-test.js +1 -1
- package/src/common/session/session-entity.js +1 -1
- package/src/common/timer/interaction-timer.js +1 -1
- package/src/common/timing/__mocks__/now.js +1 -0
- package/src/common/unload/__mocks__/eol.js +1 -0
- package/src/common/unload/eol.js +1 -2
- package/src/common/url/__mocks__/clean-url.js +1 -0
- package/src/common/url/__mocks__/encode.js +7 -0
- package/src/common/url/__mocks__/location.js +1 -0
- package/src/common/url/canonicalize-url.js +1 -1
- package/src/common/url/canonicalize-url.test.js +2 -2
- package/src/common/url/parse-url.js +1 -1
- package/src/common/url/parse-url.test.js +3 -3
- package/src/common/url/protocol.js +1 -1
- package/src/common/util/__mocks__/obfuscate.js +10 -0
- package/src/common/util/__mocks__/stringify.js +1 -0
- package/src/common/util/__mocks__/submit-data.js +5 -0
- package/src/common/util/__mocks__/traverse.js +1 -0
- package/src/common/util/submit-data.js +22 -58
- package/src/common/util/submit-data.test.js +30 -73
- package/src/common/window/nreum.js +1 -1
- package/src/common/wrap/wrap-events.js +1 -1
- package/src/common/wrap/wrap-fetch.js +1 -1
- package/src/common/wrap/wrap-history.js +1 -1
- package/src/common/wrap/wrap-jsonp.js +12 -7
- package/src/common/wrap/wrap-mutation.js +1 -1
- package/src/common/wrap/wrap-promise.js +1 -1
- package/src/common/wrap/wrap-promise.test.js +2 -2
- package/src/common/wrap/wrap-raf.js +1 -1
- package/src/common/wrap/wrap-timer.js +1 -1
- package/src/common/wrap/wrap-xhr.js +1 -1
- package/src/features/ajax/aggregate/index.js +26 -32
- package/src/features/ajax/instrument/distributed-tracing.js +1 -1
- package/src/features/ajax/instrument/index.js +1 -2
- package/src/features/jserrors/aggregate/compute-stack-trace.js +1 -1
- package/src/features/jserrors/aggregate/compute-stack-trace.test.js +1 -1
- package/src/features/jserrors/aggregate/index.js +7 -3
- package/src/features/jserrors/constants.js +0 -1
- package/src/features/jserrors/instrument/index.js +92 -88
- package/src/features/jserrors/instrument/uncaught-error.js +15 -0
- package/src/features/metrics/aggregate/framework-detection.js +1 -1
- package/src/features/metrics/aggregate/framework-detection.test.js +2 -2
- package/src/features/metrics/aggregate/index.js +1 -1
- package/src/features/page_action/aggregate/index.js +1 -1
- package/src/features/page_view_event/aggregate/index.js +1 -2
- package/src/features/page_view_event/aggregate/initialized-features.js +18 -14
- package/src/features/page_view_event/instrument/index.js +1 -1
- package/src/features/page_view_timing/aggregate/index.js +2 -4
- package/src/features/page_view_timing/instrument/index.js +1 -1
- package/src/features/session_replay/aggregate/index.component-test.js +17 -56
- package/src/features/session_replay/aggregate/index.js +47 -28
- package/src/features/session_replay/replay-mode.js +2 -2
- package/src/features/session_trace/aggregate/index.js +3 -4
- package/src/features/session_trace/instrument/index.js +1 -1
- package/src/features/spa/aggregate/index.js +1 -1
- package/src/features/spa/instrument/index.js +1 -1
- package/src/features/utils/agent-session.test.js +2 -2
- package/src/features/utils/instrument-base.js +11 -14
- package/src/features/utils/instrument-base.test.js +29 -3
- package/src/index.js +1 -3
- package/src/loaders/agent-base.js +81 -0
- package/src/loaders/agent.js +50 -1
- package/src/loaders/api/api.js +2 -2
- package/src/loaders/api/apiAsync.js +3 -3
- package/src/loaders/api/interaction-types.js +80 -0
- package/src/loaders/configure/configure.js +5 -4
- package/src/loaders/micro-agent.js +30 -31
- package/dist/cjs/common/browser-version/firefox-version.js +0 -17
- package/dist/cjs/common/browser-version/ios-version.js +0 -19
- package/dist/cjs/common/event-emitter/contextual-ee.test.js +0 -282
- package/dist/cjs/common/event-emitter/handle.test.js +0 -58
- package/dist/cjs/common/event-emitter/register-handler.test.js +0 -55
- package/dist/cjs/common/harvest/harvest-scheduler.component-test.js +0 -39
- package/dist/cjs/common/harvest/harvest.component-test.js +0 -224
- package/dist/cjs/common/ids/id.test.js +0 -85
- package/dist/cjs/common/ids/unique-id.test.js +0 -49
- package/dist/cjs/common/session/session-entity.component-test.js +0 -497
- package/dist/cjs/common/storage/local-storage.test.js +0 -14
- package/dist/cjs/common/timer/interaction-timer.component-test.js +0 -216
- package/dist/cjs/common/timer/timer.test.js +0 -105
- package/dist/cjs/common/timing/nav-timing.test.js +0 -192
- package/dist/cjs/common/url/canonicalize-url.test.js +0 -38
- package/dist/cjs/common/url/clean-url.test.js +0 -9
- package/dist/cjs/common/url/encode.component-test.js +0 -74
- package/dist/cjs/common/url/location.test.js +0 -13
- package/dist/cjs/common/url/parse-url.test.js +0 -111
- package/dist/cjs/common/url/protocol.component-test.js +0 -15
- package/dist/cjs/common/util/console.test.js +0 -30
- package/dist/cjs/common/util/data-size.test.js +0 -64
- package/dist/cjs/common/util/feature-flags.test.js +0 -84
- package/dist/cjs/common/util/get-or-set.test.js +0 -47
- package/dist/cjs/common/util/global-scope.js +0 -27
- package/dist/cjs/common/util/global-scope.test.js +0 -72
- package/dist/cjs/common/util/invoke.test.js +0 -49
- package/dist/cjs/common/util/map-own.test.js +0 -49
- package/dist/cjs/common/util/obfuscate.component-test.js +0 -129
- package/dist/cjs/common/util/stringify.test.js +0 -48
- package/dist/cjs/common/util/submit-data.test.js +0 -245
- package/dist/cjs/common/util/traverse.test.js +0 -44
- package/dist/cjs/common/wrap/wrap-promise.test.js +0 -119
- package/dist/cjs/features/jserrors/aggregate/canonical-function-name.test.js +0 -31
- package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.test.js +0 -383
- package/dist/cjs/features/jserrors/aggregate/format-stack-trace.test.js +0 -40
- package/dist/cjs/features/jserrors/aggregate/string-hash-code.test.js +0 -27
- package/dist/cjs/features/jserrors/instrument/debug.js +0 -40
- package/dist/cjs/features/metrics/aggregate/framework-detection.test.js +0 -137
- package/dist/cjs/features/metrics/aggregate/polyfill-detection.es5.test.js +0 -17
- package/dist/cjs/features/metrics/aggregate/polyfill-detection.test.js +0 -165
- package/dist/cjs/features/session_replay/aggregate/index.component-test.js +0 -457
- package/dist/cjs/features/spa/aggregate/interaction-node.test.js +0 -16
- package/dist/cjs/features/utils/agent-session.test.js +0 -211
- package/dist/cjs/features/utils/aggregate-base.test.js +0 -110
- package/dist/cjs/features/utils/feature-base.test.js +0 -42
- package/dist/cjs/features/utils/handler-cache.test.js +0 -53
- package/dist/cjs/features/utils/instrument-base.test.js +0 -179
- package/dist/cjs/features/utils/lazy-feature-loader.test.js +0 -30
- package/dist/esm/common/browser-version/firefox-version.js +0 -10
- package/dist/esm/common/browser-version/ios-version.js +0 -11
- package/dist/esm/common/event-emitter/contextual-ee.test.js +0 -278
- package/dist/esm/common/event-emitter/handle.test.js +0 -54
- package/dist/esm/common/event-emitter/register-handler.test.js +0 -51
- package/dist/esm/common/harvest/harvest-scheduler.component-test.js +0 -37
- package/dist/esm/common/harvest/harvest.component-test.js +0 -222
- package/dist/esm/common/ids/id.test.js +0 -81
- package/dist/esm/common/ids/unique-id.test.js +0 -44
- package/dist/esm/common/session/session-entity.component-test.js +0 -495
- package/dist/esm/common/storage/local-storage.test.js +0 -12
- package/dist/esm/common/timer/interaction-timer.component-test.js +0 -214
- package/dist/esm/common/timer/timer.test.js +0 -103
- package/dist/esm/common/timing/nav-timing.test.js +0 -190
- package/dist/esm/common/url/canonicalize-url.test.js +0 -34
- package/dist/esm/common/url/clean-url.test.js +0 -7
- package/dist/esm/common/url/encode.component-test.js +0 -70
- package/dist/esm/common/url/location.test.js +0 -11
- package/dist/esm/common/url/parse-url.test.js +0 -107
- package/dist/esm/common/url/protocol.component-test.js +0 -13
- package/dist/esm/common/util/console.test.js +0 -28
- package/dist/esm/common/util/data-size.test.js +0 -60
- package/dist/esm/common/util/feature-flags.test.js +0 -80
- package/dist/esm/common/util/get-or-set.test.js +0 -45
- package/dist/esm/common/util/global-scope.js +0 -17
- package/dist/esm/common/util/global-scope.test.js +0 -70
- package/dist/esm/common/util/invoke.test.js +0 -47
- package/dist/esm/common/util/map-own.test.js +0 -47
- package/dist/esm/common/util/obfuscate.component-test.js +0 -125
- package/dist/esm/common/util/stringify.test.js +0 -46
- package/dist/esm/common/util/submit-data.test.js +0 -241
- package/dist/esm/common/util/traverse.test.js +0 -42
- package/dist/esm/common/wrap/wrap-promise.test.js +0 -115
- package/dist/esm/features/jserrors/aggregate/canonical-function-name.test.js +0 -29
- package/dist/esm/features/jserrors/aggregate/compute-stack-trace.test.js +0 -379
- package/dist/esm/features/jserrors/aggregate/format-stack-trace.test.js +0 -38
- package/dist/esm/features/jserrors/aggregate/string-hash-code.test.js +0 -25
- package/dist/esm/features/jserrors/instrument/debug.js +0 -38
- package/dist/esm/features/metrics/aggregate/framework-detection.test.js +0 -133
- package/dist/esm/features/metrics/aggregate/polyfill-detection.es5.test.js +0 -15
- package/dist/esm/features/metrics/aggregate/polyfill-detection.test.js +0 -163
- package/dist/esm/features/session_replay/aggregate/index.component-test.js +0 -453
- package/dist/esm/features/spa/aggregate/interaction-node.test.js +0 -14
- package/dist/esm/features/utils/agent-session.test.js +0 -207
- package/dist/esm/features/utils/aggregate-base.test.js +0 -108
- package/dist/esm/features/utils/feature-base.test.js +0 -40
- package/dist/esm/features/utils/handler-cache.test.js +0 -51
- package/dist/esm/features/utils/instrument-base.test.js +0 -175
- package/dist/esm/features/utils/lazy-feature-loader.test.js +0 -29
- package/dist/types/common/browser-version/firefox-version.d.ts +0 -2
- package/dist/types/common/browser-version/firefox-version.d.ts.map +0 -1
- package/dist/types/common/browser-version/ios-version.d.ts +0 -3
- package/dist/types/common/browser-version/ios-version.d.ts.map +0 -1
- package/dist/types/common/harvest/harvest-scheduler.component-test.d.ts +0 -2
- package/dist/types/common/harvest/harvest-scheduler.component-test.d.ts.map +0 -1
- package/dist/types/common/harvest/harvest.component-test.d.ts +0 -2
- package/dist/types/common/harvest/harvest.component-test.d.ts.map +0 -1
- package/dist/types/common/session/session-entity.component-test.d.ts +0 -2
- package/dist/types/common/session/session-entity.component-test.d.ts.map +0 -1
- package/dist/types/common/timer/interaction-timer.component-test.d.ts +0 -2
- package/dist/types/common/timer/interaction-timer.component-test.d.ts.map +0 -1
- package/dist/types/common/url/encode.component-test.d.ts +0 -2
- package/dist/types/common/url/encode.component-test.d.ts.map +0 -1
- package/dist/types/common/url/protocol.component-test.d.ts +0 -2
- package/dist/types/common/url/protocol.component-test.d.ts.map +0 -1
- package/dist/types/common/util/global-scope.d.ts +0 -5
- package/dist/types/common/util/global-scope.d.ts.map +0 -1
- package/dist/types/common/util/obfuscate.component-test.d.ts +0 -2
- package/dist/types/common/util/obfuscate.component-test.d.ts.map +0 -1
- package/dist/types/features/jserrors/instrument/debug.d.ts +0 -2
- package/dist/types/features/jserrors/instrument/debug.d.ts.map +0 -1
- package/dist/types/features/session_replay/aggregate/index.component-test.d.ts +0 -2
- package/dist/types/features/session_replay/aggregate/index.component-test.d.ts.map +0 -1
- package/src/common/browser-version/firefox-version.js +0 -10
- package/src/common/browser-version/ios-version.js +0 -11
- package/src/common/harvest/harvest-scheduler.component-test.js +0 -25
- package/src/common/harvest/harvest.component-test.js +0 -169
- package/src/common/util/global-scope.js +0 -23
- package/src/common/util/global-scope.test.js +0 -87
- package/src/features/jserrors/instrument/debug.js +0 -36
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interactionTimer = require("./interaction-timer");
|
|
4
|
-
jest.useFakeTimers();
|
|
5
|
-
let now;
|
|
6
|
-
beforeEach(() => {
|
|
7
|
-
now = Date.now();
|
|
8
|
-
jest.setSystemTime(now);
|
|
9
|
-
});
|
|
10
|
-
afterEach(() => {
|
|
11
|
-
jest.clearAllMocks();
|
|
12
|
-
});
|
|
13
|
-
describe('constructor', () => {
|
|
14
|
-
test('appropriate properties are set with valid values -- no refresh', () => {
|
|
15
|
-
const timer = new _interactionTimer.InteractionTimer({
|
|
16
|
-
onEnd: jest.fn()
|
|
17
|
-
}, 100);
|
|
18
|
-
const requiredKeys = ['onEnd', 'initialMs', 'startTimestamp', 'timer'];
|
|
19
|
-
expect(requiredKeys.every(rk => !!timer[rk])).toBeTruthy();
|
|
20
|
-
});
|
|
21
|
-
test('appropriate properties are set with valid values -- with refresh', () => {
|
|
22
|
-
const timer = new _interactionTimer.InteractionTimer({
|
|
23
|
-
onEnd: jest.fn()
|
|
24
|
-
}, 100);
|
|
25
|
-
const requiredKeys = ['onEnd', 'refresh', 'initialMs', 'startTimestamp', 'timer'];
|
|
26
|
-
expect(requiredKeys.every(rk => !!timer[rk])).toBeTruthy();
|
|
27
|
-
});
|
|
28
|
-
test('required keys are enforced', () => {
|
|
29
|
-
try {
|
|
30
|
-
new _interactionTimer.InteractionTimer({}, 100);
|
|
31
|
-
} catch (e) {
|
|
32
|
-
expect(e).toEqual(new Error('onEnd handler is required'));
|
|
33
|
-
}
|
|
34
|
-
try {
|
|
35
|
-
new _interactionTimer.InteractionTimer({
|
|
36
|
-
onEnd: jest.fn()
|
|
37
|
-
});
|
|
38
|
-
} catch (e) {
|
|
39
|
-
expect(e).toEqual(new Error('ms duration is required'));
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
test('refresh type timers set event listeners', () => {
|
|
43
|
-
// eslint-disable-next-line
|
|
44
|
-
let ee = {
|
|
45
|
-
on: jest.fn().mockImplementation((evt, cb) => {
|
|
46
|
-
cb([{
|
|
47
|
-
type: 'click'
|
|
48
|
-
}]);
|
|
49
|
-
})
|
|
50
|
-
};
|
|
51
|
-
let it = new _interactionTimer.InteractionTimer({
|
|
52
|
-
onEnd: jest.fn(),
|
|
53
|
-
onRefresh: jest.fn(),
|
|
54
|
-
ee
|
|
55
|
-
}, 100);
|
|
56
|
-
// scroll, keypress, click
|
|
57
|
-
expect(ee.on).toHaveBeenCalledTimes(1);
|
|
58
|
-
expect(it.onRefresh).toHaveBeenCalledTimes(1);
|
|
59
|
-
|
|
60
|
-
// eslint-disable-next-line
|
|
61
|
-
ee = {
|
|
62
|
-
on: jest.fn().mockImplementation((evt, cb) => {
|
|
63
|
-
cb([{
|
|
64
|
-
type: 'scroll'
|
|
65
|
-
}]);
|
|
66
|
-
})
|
|
67
|
-
};
|
|
68
|
-
it = new _interactionTimer.InteractionTimer({
|
|
69
|
-
onEnd: jest.fn(),
|
|
70
|
-
onRefresh: jest.fn(),
|
|
71
|
-
ee
|
|
72
|
-
}, 100);
|
|
73
|
-
// scroll, keypress, click
|
|
74
|
-
expect(ee.on).toHaveBeenCalledTimes(1);
|
|
75
|
-
expect(it.onRefresh).toHaveBeenCalledTimes(1);
|
|
76
|
-
|
|
77
|
-
// eslint-disable-next-line
|
|
78
|
-
ee = {
|
|
79
|
-
on: jest.fn().mockImplementation((evt, cb) => {
|
|
80
|
-
cb([{
|
|
81
|
-
type: 'keydown'
|
|
82
|
-
}]);
|
|
83
|
-
})
|
|
84
|
-
};
|
|
85
|
-
it = new _interactionTimer.InteractionTimer({
|
|
86
|
-
onEnd: jest.fn(),
|
|
87
|
-
onRefresh: jest.fn(),
|
|
88
|
-
ee
|
|
89
|
-
}, 100);
|
|
90
|
-
// scroll, keypress, click
|
|
91
|
-
expect(ee.on).toHaveBeenCalledTimes(1);
|
|
92
|
-
expect(it.onRefresh).toHaveBeenCalledTimes(1);
|
|
93
|
-
const aelSpy = jest.spyOn(document, 'addEventListener');
|
|
94
|
-
// eslint-disable-next-line
|
|
95
|
-
ee = {
|
|
96
|
-
on: jest.fn().mockImplementation((evt, cb) => {
|
|
97
|
-
cb([{
|
|
98
|
-
type: 'keydown'
|
|
99
|
-
}]);
|
|
100
|
-
})
|
|
101
|
-
};
|
|
102
|
-
it = new _interactionTimer.InteractionTimer({
|
|
103
|
-
onEnd: jest.fn(),
|
|
104
|
-
onRefresh: jest.fn(),
|
|
105
|
-
ee
|
|
106
|
-
}, 100);
|
|
107
|
-
// visibility change
|
|
108
|
-
expect(aelSpy).toHaveBeenCalledTimes(1);
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
describe('create()', () => {
|
|
112
|
-
test('Create sets a timeout that can execute a cb', () => {
|
|
113
|
-
const timer = new _interactionTimer.InteractionTimer({
|
|
114
|
-
onEnd: jest.fn()
|
|
115
|
-
}, 100);
|
|
116
|
-
expect(timer.timer).toBeTruthy();
|
|
117
|
-
expect(timer.onEnd).toHaveBeenCalledTimes(0);
|
|
118
|
-
jest.runOnlyPendingTimers();
|
|
119
|
-
expect(timer.onEnd).toHaveBeenCalledTimes(1);
|
|
120
|
-
});
|
|
121
|
-
test('Create can fallback to use defaults', () => {
|
|
122
|
-
let called = 0;
|
|
123
|
-
const timer1 = new _interactionTimer.InteractionTimer({
|
|
124
|
-
onEnd: jest.fn()
|
|
125
|
-
}, 100);
|
|
126
|
-
timer1.create();
|
|
127
|
-
const timer2 = new _interactionTimer.InteractionTimer({
|
|
128
|
-
onEnd: jest.fn()
|
|
129
|
-
}, 100);
|
|
130
|
-
timer2.create(timer2.onEnd);
|
|
131
|
-
const timer3 = new _interactionTimer.InteractionTimer({
|
|
132
|
-
onEnd: jest.fn()
|
|
133
|
-
}, 100);
|
|
134
|
-
timer3.create(undefined, 100);
|
|
135
|
-
jest.runAllTimers(200);
|
|
136
|
-
expect(timer1.onEnd).toHaveBeenCalledTimes(1);
|
|
137
|
-
expect(timer2.onEnd).toHaveBeenCalledTimes(1);
|
|
138
|
-
expect(timer3.onEnd).toHaveBeenCalledTimes(1);
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
describe('refresh()', () => {
|
|
142
|
-
test('refresh prevents the callback from firing', () => {
|
|
143
|
-
const timer = new _interactionTimer.InteractionTimer({
|
|
144
|
-
onEnd: jest.fn(),
|
|
145
|
-
onRefresh: jest.fn()
|
|
146
|
-
}, 100);
|
|
147
|
-
expect(timer.onEnd).toHaveBeenCalledTimes(0);
|
|
148
|
-
jest.advanceTimersByTime(75);
|
|
149
|
-
expect(timer.onEnd).toHaveBeenCalledTimes(0);
|
|
150
|
-
timer.refresh();
|
|
151
|
-
jest.advanceTimersByTime(75);
|
|
152
|
-
expect(timer.onEnd).toHaveBeenCalledTimes(0);
|
|
153
|
-
jest.advanceTimersByTime(100);
|
|
154
|
-
expect(timer.onEnd).toHaveBeenCalledTimes(1);
|
|
155
|
-
});
|
|
156
|
-
test('refresh executes a callback for consumers', () => {
|
|
157
|
-
const timer = new _interactionTimer.InteractionTimer({
|
|
158
|
-
onEnd: jest.fn(),
|
|
159
|
-
onRefresh: jest.fn()
|
|
160
|
-
}, 100);
|
|
161
|
-
timer.refresh();
|
|
162
|
-
expect(timer.onRefresh).toHaveBeenCalledTimes(1);
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
describe('pause()', () => {
|
|
166
|
-
test('pause prevents the callback from firing', () => {
|
|
167
|
-
const timer = new _interactionTimer.InteractionTimer({
|
|
168
|
-
onEnd: jest.fn()
|
|
169
|
-
}, 100);
|
|
170
|
-
expect(timer.onEnd).toHaveBeenCalledTimes(0);
|
|
171
|
-
timer.pause();
|
|
172
|
-
jest.advanceTimersByTime(150);
|
|
173
|
-
expect(timer.onEnd).toHaveBeenCalledTimes(0);
|
|
174
|
-
});
|
|
175
|
-
test('pause sets remainingMs timestamp', () => {
|
|
176
|
-
const timer = new _interactionTimer.InteractionTimer({
|
|
177
|
-
onEnd: jest.fn()
|
|
178
|
-
}, 100);
|
|
179
|
-
expect(timer.remainingMs).toEqual(undefined);
|
|
180
|
-
timer.pause();
|
|
181
|
-
expect(timer.remainingMs).toEqual(timer.initialMs - (now - timer.startTimestamp));
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
describe('clear()', () => {
|
|
185
|
-
test('clear prevents the callback from firing and deletes the pointer', () => {
|
|
186
|
-
const timer = new _interactionTimer.InteractionTimer({
|
|
187
|
-
onEnd: jest.fn()
|
|
188
|
-
}, 100);
|
|
189
|
-
expect(timer.onEnd).toHaveBeenCalledTimes(0);
|
|
190
|
-
timer.clear();
|
|
191
|
-
jest.advanceTimersByTime(150);
|
|
192
|
-
expect(timer.onEnd).toHaveBeenCalledTimes(0);
|
|
193
|
-
expect(timer.timer).toEqual(null);
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
describe('end()', () => {
|
|
197
|
-
test('end clears the callback and calls the onEnd callback', () => {
|
|
198
|
-
const timer = new _interactionTimer.InteractionTimer({
|
|
199
|
-
onEnd: jest.fn()
|
|
200
|
-
}, 100);
|
|
201
|
-
expect(timer.onEnd).toHaveBeenCalledTimes(0);
|
|
202
|
-
timer.end();
|
|
203
|
-
expect(timer.onEnd).toHaveBeenCalledTimes(1);
|
|
204
|
-
expect(timer.timer).toEqual(null);
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
describe('isValid', () => {
|
|
208
|
-
test('isValid validates timeStamps', () => {
|
|
209
|
-
const timer = new _interactionTimer.InteractionTimer({
|
|
210
|
-
onEnd: jest.fn()
|
|
211
|
-
}, 100);
|
|
212
|
-
expect(timer.isValid()).toEqual(true);
|
|
213
|
-
timer.startTimestamp -= 100;
|
|
214
|
-
expect(timer.isValid()).toEqual(false);
|
|
215
|
-
});
|
|
216
|
-
});
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _timer = require("./timer");
|
|
4
|
-
jest.useFakeTimers();
|
|
5
|
-
let now;
|
|
6
|
-
beforeEach(() => {
|
|
7
|
-
now = Date.now();
|
|
8
|
-
jest.setSystemTime(now);
|
|
9
|
-
});
|
|
10
|
-
afterEach(() => {
|
|
11
|
-
jest.clearAllMocks();
|
|
12
|
-
});
|
|
13
|
-
describe('constructor', () => {
|
|
14
|
-
test('appropriate properties are set with valid values -- no refresh', () => {
|
|
15
|
-
const timer = new _timer.Timer({
|
|
16
|
-
onEnd: jest.fn()
|
|
17
|
-
}, 100);
|
|
18
|
-
const requiredKeys = ['onEnd', 'initialMs', 'startTimestamp', 'timer'];
|
|
19
|
-
expect(requiredKeys.every(rk => !!timer[rk])).toBeTruthy();
|
|
20
|
-
});
|
|
21
|
-
test('appropriate properties are set with valid values -- with refresh', () => {
|
|
22
|
-
const timer = new _timer.Timer({
|
|
23
|
-
onEnd: jest.fn()
|
|
24
|
-
}, 100);
|
|
25
|
-
const requiredKeys = ['onEnd', 'initialMs', 'startTimestamp', 'timer'];
|
|
26
|
-
expect(requiredKeys.every(rk => !!timer[rk])).toBeTruthy();
|
|
27
|
-
});
|
|
28
|
-
test('required keys are enforced', () => {
|
|
29
|
-
try {
|
|
30
|
-
new _timer.Timer({}, 100);
|
|
31
|
-
} catch (e) {
|
|
32
|
-
expect(e).toEqual(new Error('onEnd handler is required'));
|
|
33
|
-
}
|
|
34
|
-
try {
|
|
35
|
-
new _timer.Timer({
|
|
36
|
-
onEnd: jest.fn()
|
|
37
|
-
});
|
|
38
|
-
} catch (e) {
|
|
39
|
-
expect(e).toEqual(new Error('ms duration is required'));
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
describe('create()', () => {
|
|
44
|
-
test('Create sets a timeout that can execute a cb', () => {
|
|
45
|
-
const timer = new _timer.Timer({
|
|
46
|
-
onEnd: jest.fn()
|
|
47
|
-
}, 100);
|
|
48
|
-
expect(timer.timer).toBeTruthy();
|
|
49
|
-
expect(timer.onEnd).toHaveBeenCalledTimes(0);
|
|
50
|
-
jest.runOnlyPendingTimers();
|
|
51
|
-
expect(timer.onEnd).toHaveBeenCalledTimes(1);
|
|
52
|
-
});
|
|
53
|
-
test('Create can fallback to use defaults', () => {
|
|
54
|
-
let called = 0;
|
|
55
|
-
const timer1 = new _timer.Timer({
|
|
56
|
-
onEnd: jest.fn()
|
|
57
|
-
}, 100);
|
|
58
|
-
timer1.create();
|
|
59
|
-
const timer2 = new _timer.Timer({
|
|
60
|
-
onEnd: jest.fn()
|
|
61
|
-
}, 100);
|
|
62
|
-
timer2.create(timer2.onEnd);
|
|
63
|
-
const timer3 = new _timer.Timer({
|
|
64
|
-
onEnd: jest.fn()
|
|
65
|
-
}, 100);
|
|
66
|
-
timer3.create(undefined, 100);
|
|
67
|
-
jest.runAllTimers(200);
|
|
68
|
-
expect(timer1.onEnd).toHaveBeenCalledTimes(1);
|
|
69
|
-
expect(timer2.onEnd).toHaveBeenCalledTimes(1);
|
|
70
|
-
expect(timer3.onEnd).toHaveBeenCalledTimes(1);
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
describe('clear()', () => {
|
|
74
|
-
test('clear prevents the callback from firing and deletes the pointer', () => {
|
|
75
|
-
const timer = new _timer.Timer({
|
|
76
|
-
onEnd: jest.fn()
|
|
77
|
-
}, 100);
|
|
78
|
-
expect(timer.onEnd).toHaveBeenCalledTimes(0);
|
|
79
|
-
timer.clear();
|
|
80
|
-
jest.advanceTimersByTime(150);
|
|
81
|
-
expect(timer.onEnd).toHaveBeenCalledTimes(0);
|
|
82
|
-
expect(timer.timer).toEqual(null);
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
describe('end()', () => {
|
|
86
|
-
test('end clears the callback and calls the onEnd callback', () => {
|
|
87
|
-
const timer = new _timer.Timer({
|
|
88
|
-
onEnd: jest.fn()
|
|
89
|
-
}, 100);
|
|
90
|
-
expect(timer.onEnd).toHaveBeenCalledTimes(0);
|
|
91
|
-
timer.end();
|
|
92
|
-
expect(timer.onEnd).toHaveBeenCalledTimes(1);
|
|
93
|
-
expect(timer.timer).toEqual(null);
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
describe('isValid', () => {
|
|
97
|
-
test('isValid validates timeStamps', () => {
|
|
98
|
-
const timer = new _timer.Timer({
|
|
99
|
-
onEnd: jest.fn()
|
|
100
|
-
}, 100);
|
|
101
|
-
expect(timer.isValid()).toEqual(true);
|
|
102
|
-
timer.startTimestamp -= 100;
|
|
103
|
-
expect(timer.isValid()).toEqual(false);
|
|
104
|
-
});
|
|
105
|
-
});
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _navTiming = require("./nav-timing");
|
|
4
|
-
const offset = 123;
|
|
5
|
-
const testValues = {
|
|
6
|
-
unloadEventStart: 1,
|
|
7
|
-
redirectStart: 2,
|
|
8
|
-
unloadEventEnd: 3,
|
|
9
|
-
redirectEnd: 4,
|
|
10
|
-
fetchStart: 5,
|
|
11
|
-
domainLookupStart: 6,
|
|
12
|
-
domainLookupEnd: 7,
|
|
13
|
-
connectStart: 8,
|
|
14
|
-
secureConnectionStart: 9,
|
|
15
|
-
connectEnd: 10,
|
|
16
|
-
requestStart: 11,
|
|
17
|
-
responseStart: 12,
|
|
18
|
-
responseEnd: 13,
|
|
19
|
-
domLoading: 14,
|
|
20
|
-
domInteractive: 15,
|
|
21
|
-
domContentLoadedEventStart: 16,
|
|
22
|
-
domContentLoadedEventEnd: 17,
|
|
23
|
-
domComplete: 18,
|
|
24
|
-
loadEventStart: 19,
|
|
25
|
-
loadEventEnd: 20,
|
|
26
|
-
type: 'reload',
|
|
27
|
-
redirectCount: 22
|
|
28
|
-
};
|
|
29
|
-
const legacyTestValues = {
|
|
30
|
-
unloadEventStart: offset + 1,
|
|
31
|
-
redirectStart: offset + 2,
|
|
32
|
-
unloadEventEnd: offset + 3,
|
|
33
|
-
redirectEnd: offset + 4,
|
|
34
|
-
fetchStart: offset + 5,
|
|
35
|
-
domainLookupStart: offset + 6,
|
|
36
|
-
domainLookupEnd: offset + 7,
|
|
37
|
-
connectStart: offset + 8,
|
|
38
|
-
secureConnectionStart: offset + 9,
|
|
39
|
-
connectEnd: offset + 10,
|
|
40
|
-
requestStart: offset + 11,
|
|
41
|
-
responseStart: offset + 12,
|
|
42
|
-
responseEnd: offset + 13,
|
|
43
|
-
domLoading: offset + 14,
|
|
44
|
-
domInteractive: offset + 15,
|
|
45
|
-
domContentLoadedEventStart: offset + 16,
|
|
46
|
-
domContentLoadedEventEnd: offset + 17,
|
|
47
|
-
domComplete: offset + 18,
|
|
48
|
-
loadEventStart: offset + 19,
|
|
49
|
-
loadEventEnd: offset + 20,
|
|
50
|
-
type: 'reload',
|
|
51
|
-
redirectCount: offset + 22
|
|
52
|
-
};
|
|
53
|
-
const expectedPT = {
|
|
54
|
-
of: offset,
|
|
55
|
-
n: 0,
|
|
56
|
-
u: 1,
|
|
57
|
-
r: 2,
|
|
58
|
-
ue: 3,
|
|
59
|
-
re: 4,
|
|
60
|
-
f: 5,
|
|
61
|
-
dn: 6,
|
|
62
|
-
dne: 7,
|
|
63
|
-
c: 8,
|
|
64
|
-
s: 9,
|
|
65
|
-
ce: 10,
|
|
66
|
-
rq: 11,
|
|
67
|
-
rp: 12,
|
|
68
|
-
rpe: 13,
|
|
69
|
-
dl: 14,
|
|
70
|
-
di: 15,
|
|
71
|
-
ds: 16,
|
|
72
|
-
de: 17,
|
|
73
|
-
dc: 18,
|
|
74
|
-
l: 19,
|
|
75
|
-
le: 20
|
|
76
|
-
};
|
|
77
|
-
const expectedPN = {
|
|
78
|
-
ty: 1,
|
|
79
|
-
rc: 22
|
|
80
|
-
};
|
|
81
|
-
describe('addPT()', () => {
|
|
82
|
-
test('an output object is populated with valid values', () => {
|
|
83
|
-
const output = (0, _navTiming.addPT)(offset, testValues, {});
|
|
84
|
-
expect(output).toEqual(expectedPT);
|
|
85
|
-
});
|
|
86
|
-
test('an object with invalid values is handled', () => {
|
|
87
|
-
const output = (0, _navTiming.addPT)(offset, {
|
|
88
|
-
...testValues,
|
|
89
|
-
invalidValue: 'test'
|
|
90
|
-
}, {});
|
|
91
|
-
expect(output).toEqual(expectedPT);
|
|
92
|
-
const output2 = (0, _navTiming.addPT)(offset, {
|
|
93
|
-
...testValues,
|
|
94
|
-
loadEventEnd: -1
|
|
95
|
-
}, {});
|
|
96
|
-
let expected = {
|
|
97
|
-
...expectedPT
|
|
98
|
-
};
|
|
99
|
-
delete expected.le;
|
|
100
|
-
expect(output2).toEqual(expected);
|
|
101
|
-
const output3 = (0, _navTiming.addPT)(offset, {
|
|
102
|
-
...testValues,
|
|
103
|
-
loadEventEnd: 'test'
|
|
104
|
-
}, {});
|
|
105
|
-
expected = {
|
|
106
|
-
...expectedPT
|
|
107
|
-
};
|
|
108
|
-
delete expected.le;
|
|
109
|
-
expect(output3).toEqual(expected);
|
|
110
|
-
const output4 = (0, _navTiming.addPT)(offset, {
|
|
111
|
-
...testValues,
|
|
112
|
-
loadEventEnd: null
|
|
113
|
-
}, {});
|
|
114
|
-
expected = {
|
|
115
|
-
...expectedPT
|
|
116
|
-
};
|
|
117
|
-
delete expected.le;
|
|
118
|
-
expect(output4).toEqual(expected);
|
|
119
|
-
const legacyoutput = (0, _navTiming.addPT)(offset, {
|
|
120
|
-
...legacyTestValues,
|
|
121
|
-
invalidValue: 'test'
|
|
122
|
-
}, {}, true);
|
|
123
|
-
expect(legacyoutput).toEqual(expectedPT);
|
|
124
|
-
const legacyoutput2 = (0, _navTiming.addPT)(offset, {
|
|
125
|
-
...legacyTestValues,
|
|
126
|
-
loadEventEnd: -1
|
|
127
|
-
}, {}, true);
|
|
128
|
-
let legacyexpected = {
|
|
129
|
-
...expectedPT
|
|
130
|
-
};
|
|
131
|
-
delete legacyexpected.le;
|
|
132
|
-
expect(legacyoutput2).toEqual(expected);
|
|
133
|
-
const legacyoutput3 = (0, _navTiming.addPT)(offset, {
|
|
134
|
-
...legacyTestValues,
|
|
135
|
-
loadEventEnd: 'test'
|
|
136
|
-
}, {}, true);
|
|
137
|
-
legacyexpected = {
|
|
138
|
-
...expectedPT
|
|
139
|
-
};
|
|
140
|
-
delete legacyexpected.le;
|
|
141
|
-
expect(legacyoutput3).toEqual(legacyexpected);
|
|
142
|
-
const legacyoutput4 = (0, _navTiming.addPT)(offset, {
|
|
143
|
-
...legacyTestValues,
|
|
144
|
-
loadEventEnd: null
|
|
145
|
-
}, {}, true);
|
|
146
|
-
legacyexpected = {
|
|
147
|
-
...expectedPT
|
|
148
|
-
};
|
|
149
|
-
delete legacyexpected.le;
|
|
150
|
-
expect(legacyoutput4).toEqual(legacyexpected);
|
|
151
|
-
});
|
|
152
|
-
test('rounds values to integers', () => {
|
|
153
|
-
const output = (0, _navTiming.addPT)(offset, {
|
|
154
|
-
unloadEventStart: 3.14159
|
|
155
|
-
}, {});
|
|
156
|
-
expect(output.u).toEqual(3);
|
|
157
|
-
const legacyoutput = (0, _navTiming.addPT)(0, {
|
|
158
|
-
unloadEventStart: 3.14159
|
|
159
|
-
}, {}, true);
|
|
160
|
-
expect(legacyoutput.u).toEqual(3);
|
|
161
|
-
});
|
|
162
|
-
test('adds entries to navTimingValues', () => {
|
|
163
|
-
const beforeLength = _navTiming.navTimingValues.length;
|
|
164
|
-
(0, _navTiming.addPT)(offset, {
|
|
165
|
-
testValues
|
|
166
|
-
}, {});
|
|
167
|
-
const afterLength = _navTiming.navTimingValues.length;
|
|
168
|
-
expect(afterLength - beforeLength).toEqual(21); // 20 + value of n
|
|
169
|
-
|
|
170
|
-
const legacybeforeLength = _navTiming.navTimingValues.length;
|
|
171
|
-
(0, _navTiming.addPT)(offset, {
|
|
172
|
-
legacyTestValues
|
|
173
|
-
}, {}, true);
|
|
174
|
-
const legacyafterLength = _navTiming.navTimingValues.length;
|
|
175
|
-
expect(legacyafterLength - legacybeforeLength).toEqual(21); // 20 + value of n
|
|
176
|
-
});
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
describe('addPN()', () => {
|
|
180
|
-
test('an output object is populated with valid values', () => {
|
|
181
|
-
const output = (0, _navTiming.addPN)(testValues, {});
|
|
182
|
-
expect(output).toEqual(expectedPN);
|
|
183
|
-
});
|
|
184
|
-
test('adds entries to navTimingValues', () => {
|
|
185
|
-
const beforeLength = _navTiming.navTimingValues.length;
|
|
186
|
-
(0, _navTiming.addPN)(offset, {
|
|
187
|
-
testValues
|
|
188
|
-
}, {});
|
|
189
|
-
const afterLength = _navTiming.navTimingValues.length;
|
|
190
|
-
expect(afterLength - beforeLength).toEqual(2);
|
|
191
|
-
});
|
|
192
|
-
});
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _faker = require("@faker-js/faker");
|
|
4
|
-
var globalScopeModule = _interopRequireWildcard(require("../util/global-scope"));
|
|
5
|
-
var cleanUrlModule = _interopRequireWildcard(require("./clean-url"));
|
|
6
|
-
var _canonicalizeUrl = require("./canonicalize-url");
|
|
7
|
-
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); }
|
|
8
|
-
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; }
|
|
9
|
-
jest.mock('../util/global-scope');
|
|
10
|
-
jest.mock('./clean-url');
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
jest.spyOn(cleanUrlModule, 'cleanURL').mockImplementation(input => input);
|
|
13
|
-
jest.replaceProperty(globalScopeModule, 'initialLocation', _faker.faker.internet.url());
|
|
14
|
-
});
|
|
15
|
-
afterEach(() => {
|
|
16
|
-
jest.resetAllMocks();
|
|
17
|
-
});
|
|
18
|
-
test.each([null, undefined, 34])('returns empty string when url argument is %s', async url => {
|
|
19
|
-
expect((0, _canonicalizeUrl.canonicalizeUrl)(url)).toEqual('');
|
|
20
|
-
});
|
|
21
|
-
test('uses cleanURL to clean the input and initial location URLs', () => {
|
|
22
|
-
const url = _faker.faker.internet.url();
|
|
23
|
-
(0, _canonicalizeUrl.canonicalizeUrl)(url);
|
|
24
|
-
expect(cleanUrlModule.cleanURL).toHaveBeenCalledWith(globalScopeModule.initialLocation);
|
|
25
|
-
expect(cleanUrlModule.cleanURL).toHaveBeenCalledWith(url);
|
|
26
|
-
expect(cleanUrlModule.cleanURL).toHaveBeenCalledTimes(2);
|
|
27
|
-
});
|
|
28
|
-
test('returns <inline> when input and initial page urls are the same', async () => {
|
|
29
|
-
expect((0, _canonicalizeUrl.canonicalizeUrl)(globalScopeModule.initialLocation)).toEqual('<inline>');
|
|
30
|
-
});
|
|
31
|
-
test('returns input url when it does not match initial page url', async () => {
|
|
32
|
-
const url = _faker.faker.internet.url();
|
|
33
|
-
expect((0, _canonicalizeUrl.canonicalizeUrl)(url)).toEqual(url);
|
|
34
|
-
});
|
|
35
|
-
test('does not identify sub-paths of the loader origin as <inline>', async () => {
|
|
36
|
-
const url = globalScopeModule.initialLocation + '/path/to/script.js';
|
|
37
|
-
expect((0, _canonicalizeUrl.canonicalizeUrl)(url)).not.toEqual('<inline>');
|
|
38
|
-
});
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _cleanUrl = require("./clean-url");
|
|
4
|
-
test.each([['http://domain.com/path?query=5', 'http://domain.com/path'], ['http://domain.com/path#fragment', 'http://domain.com/path'], ['http://domain.com/path?query=5#fragment', 'http://domain.com/path'], ['http://domain.com/path?query=5?dumb#fragment', 'http://domain.com/path'], ['http://domain.com/path?query=5#fragment#dumb', 'http://domain.com/path'], ['http://domain.com/path?query=5#fragment#dumb?additional_query', 'http://domain.com/path'], ['http://domain.com/path?query=5#fragment/silly/dumber#dumbest?additional_query=silly#what_is_this_even', 'http://domain.com/path']])('cleanURL should remove hash', (input, expected) => {
|
|
5
|
-
expect((0, _cleanUrl.cleanURL)(input)).toEqual(expected);
|
|
6
|
-
});
|
|
7
|
-
test.each([['http://domain.com/path?query=5', 'http://domain.com/path'], ['http://domain.com/path#fragment', 'http://domain.com/path#fragment'], ['http://domain.com/path?query=5#fragment', 'http://domain.com/path#fragment'], ['http://domain.com/path?query=5?dumb#fragment', 'http://domain.com/path#fragment'], ['http://domain.com/path?query=5#fragment#dumb', 'http://domain.com/path#fragment#dumb'], ['http://domain.com/path?query=5#fragment#dumb?additional_query', 'http://domain.com/path#fragment#dumb'], ['http://domain.com/path?query=5#fragment/silly/dumber#dumbest?additional_query=silly#what_is_this_even', 'http://domain.com/path#fragment/silly/dumber#dumbest']])('cleanURL should retain hash if second argument is true', (input, expected) => {
|
|
8
|
-
expect((0, _cleanUrl.cleanURL)(input, true)).toEqual(expected);
|
|
9
|
-
});
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var encode = _interopRequireWildcard(require("./encode"));
|
|
4
|
-
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); }
|
|
5
|
-
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; }
|
|
6
|
-
describe('query string encoding', () => {
|
|
7
|
-
test('escapes string components except safe characters', () => {
|
|
8
|
-
const input = 'Asdf:, :, /@$;';
|
|
9
|
-
const expected = 'Asdf:,%20:,%20/@$;';
|
|
10
|
-
expect(encode.qs(input)).toEqual(expected);
|
|
11
|
-
});
|
|
12
|
-
test('null and undefined value returns \'null\'', () => {
|
|
13
|
-
expect(encode.qs(null)).toEqual('null');
|
|
14
|
-
expect(encode.qs(undefined)).toEqual('null');
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
describe('fromArray encoding', () => {
|
|
18
|
-
test('cuts cleanly at end of byte', () => {
|
|
19
|
-
const input = ['a', 'b', 'c'];
|
|
20
|
-
const expected = 'ab';
|
|
21
|
-
expect(encode.fromArray(input, 2)).toEqual(expected);
|
|
22
|
-
});
|
|
23
|
-
test('fall back to largest whole chunk', () => {
|
|
24
|
-
const input = ['aa', 'bb', 'cc'];
|
|
25
|
-
const expected = 'aabb';
|
|
26
|
-
expect(encode.fromArray(input, 5)).toEqual(expected);
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
describe('object encoding', () => {
|
|
30
|
-
test('cuts cleanly at end of byte', () => {
|
|
31
|
-
const input = {
|
|
32
|
-
foo: [1, 2, 3]
|
|
33
|
-
};
|
|
34
|
-
const expected = '&foo=%5B1,2%5D';
|
|
35
|
-
expect(encode.obj(input, 12)).toEqual(expected);
|
|
36
|
-
});
|
|
37
|
-
test('fall back to largest whole chunk', () => {
|
|
38
|
-
const input = {
|
|
39
|
-
bar: ['a', 'b', 'c']
|
|
40
|
-
};
|
|
41
|
-
const expected = '&bar=%5B%22a%22,%22b%22%5D';
|
|
42
|
-
expect(encode.obj(input, 30)).toEqual(expected);
|
|
43
|
-
});
|
|
44
|
-
test('handles circular objects', () => {
|
|
45
|
-
const circular = {};
|
|
46
|
-
circular.circular = circular;
|
|
47
|
-
const input = {
|
|
48
|
-
bar: ['a', circular, 'c']
|
|
49
|
-
};
|
|
50
|
-
const expected = '&bar=%5B%22a%22,%7B%7D,%22c%22%5D';
|
|
51
|
-
expect(encode.obj(input, 1000)).toEqual(expected);
|
|
52
|
-
});
|
|
53
|
-
test('handles circular arrays', () => {
|
|
54
|
-
const circular = [];
|
|
55
|
-
circular.push(circular);
|
|
56
|
-
const input = {
|
|
57
|
-
bar: ['a', circular, 'c']
|
|
58
|
-
};
|
|
59
|
-
const expected = '&bar=%5B%22a%22,%5Bnull%5D,%22c%22%5D';
|
|
60
|
-
expect(encode.obj(input, 1000)).toEqual(expected);
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
describe('encode key value pairs as query params', () => {
|
|
64
|
-
test('ignores input when value is null or undefined', () => {
|
|
65
|
-
expect(encode.param('foo', null)).toEqual('');
|
|
66
|
-
expect(encode.param('foo', undefined)).toEqual('');
|
|
67
|
-
});
|
|
68
|
-
test('encodes key value pair correctly', () => {
|
|
69
|
-
expect(encode.param('foo', 'bar')).toEqual('&foo=bar');
|
|
70
|
-
});
|
|
71
|
-
test('ignores input when value is not a string', () => {
|
|
72
|
-
expect(encode.param('foo', {})).toEqual('');
|
|
73
|
-
});
|
|
74
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _faker = require("@faker-js/faker");
|
|
4
|
-
var _location = require("./location");
|
|
5
|
-
test('should always return a string', () => {
|
|
6
|
-
jest.spyOn(window, 'location', 'get').mockReturnValue({});
|
|
7
|
-
expect(typeof (0, _location.getLocation)()).toEqual('string');
|
|
8
|
-
});
|
|
9
|
-
test('should return window location', () => {
|
|
10
|
-
const expected = _faker.faker.internet.url();
|
|
11
|
-
jest.spyOn(window, 'location', 'get').mockReturnValue(expected);
|
|
12
|
-
expect((0, _location.getLocation)()).toEqual(expected);
|
|
13
|
-
});
|