@newrelic/browser-agent 1.235.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 +41 -1
- 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/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 +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 +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 +58 -76
- 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 +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 +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 +7 -4
- package/dist/cjs/features/jserrors/instrument/index.js +4 -4
- 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/replay-mode.js +2 -2
- 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 +6 -7
- package/dist/cjs/index.js +7 -0
- package/dist/cjs/loaders/agent.js +7 -0
- 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/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/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 +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 +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 +55 -73
- 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 +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 +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 +6 -3
- package/dist/esm/features/jserrors/instrument/index.js +1 -1
- 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/replay-mode.js +2 -2
- 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 +4 -5
- package/dist/esm/index.js +1 -4
- package/dist/esm/loaders/agent.js +7 -0
- package/dist/esm/loaders/api/api.js +1 -1
- package/dist/esm/loaders/api/apiAsync.js +3 -3
- package/dist/esm/loaders/configure/configure.js +1 -1
- 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/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/unload/eol.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 +1 -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/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/micro-agent.d.ts +3 -4
- 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 +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/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 +21 -20
- package/src/common/harvest/harvest-scheduler.test.js +496 -0
- package/src/common/harvest/harvest.js +147 -130
- package/src/common/harvest/harvest.test.js +818 -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 +6 -0
- package/src/common/util/__mocks__/traverse.js +1 -0
- package/src/common/util/submit-data.js +39 -53
- package/src/common/util/submit-data.test.js +81 -68
- 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 +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 +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 +7 -3
- package/src/features/jserrors/instrument/index.js +1 -1
- 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/replay-mode.js +2 -2
- 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 +5 -5
- package/src/features/utils/instrument-base.test.js +22 -3
- package/src/index.js +1 -3
- package/src/loaders/agent.js +8 -0
- package/src/loaders/api/api.js +1 -1
- package/src/loaders/api/apiAsync.js +3 -3
- package/src/loaders/configure/configure.js +1 -1
- 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.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/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/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/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
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _polyfillDetection = require("./polyfill-detection");
|
|
4
|
-
/* eslint-disable no-global-assign */
|
|
5
|
-
/* eslint-disable no-extend-native */
|
|
6
|
-
|
|
7
|
-
// DO NOT test Function.prototype.apply, it causes recursion in Jest
|
|
8
|
-
|
|
9
|
-
test('should return an empty array when nothing is polyfilled', () => {
|
|
10
|
-
expect((0, _polyfillDetection.getPolyfills)()).toEqual([]);
|
|
11
|
-
});
|
|
12
|
-
test('should indicate Function.prototype.bind is polyfilled', () => {
|
|
13
|
-
const originalFn = Function.prototype.bind;
|
|
14
|
-
Function.prototype.bind = jest.fn(function () {
|
|
15
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
16
|
-
args[_key] = arguments[_key];
|
|
17
|
-
}
|
|
18
|
-
return originalFn.apply(this, args);
|
|
19
|
-
});
|
|
20
|
-
expect((0, _polyfillDetection.getPolyfills)()).toEqual(['Function.bind']);
|
|
21
|
-
Function.prototype.bind = originalFn;
|
|
22
|
-
});
|
|
23
|
-
test('should indicate Function.prototype.call is polyfilled', () => {
|
|
24
|
-
const originalFn = Function.prototype.call;
|
|
25
|
-
Function.prototype.call = jest.fn(function () {
|
|
26
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
27
|
-
args[_key2] = arguments[_key2];
|
|
28
|
-
}
|
|
29
|
-
return originalFn.apply(this, args);
|
|
30
|
-
});
|
|
31
|
-
expect((0, _polyfillDetection.getPolyfills)()).toEqual(['Function.call']);
|
|
32
|
-
Function.prototype.call = originalFn;
|
|
33
|
-
});
|
|
34
|
-
test('should indicate Array.prototype.includes is polyfilled', () => {
|
|
35
|
-
const originalFn = Array.prototype.includes;
|
|
36
|
-
Array.prototype.includes = jest.fn(function () {
|
|
37
|
-
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
38
|
-
args[_key3] = arguments[_key3];
|
|
39
|
-
}
|
|
40
|
-
return originalFn.apply(this, args);
|
|
41
|
-
});
|
|
42
|
-
expect((0, _polyfillDetection.getPolyfills)()).toEqual(['Array.includes']);
|
|
43
|
-
Array.prototype.includes = originalFn;
|
|
44
|
-
});
|
|
45
|
-
test('should indicate Array.from is polyfilled', () => {
|
|
46
|
-
const originalFn = Array.from;
|
|
47
|
-
Array.from = jest.fn(function () {
|
|
48
|
-
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
49
|
-
args[_key4] = arguments[_key4];
|
|
50
|
-
}
|
|
51
|
-
return originalFn.apply(this, args);
|
|
52
|
-
});
|
|
53
|
-
expect((0, _polyfillDetection.getPolyfills)()).toEqual(['Array.from']);
|
|
54
|
-
Array.from = originalFn;
|
|
55
|
-
});
|
|
56
|
-
test('should indicate Array.prototype.find is polyfilled', () => {
|
|
57
|
-
const originalFn = Array.prototype.find;
|
|
58
|
-
Array.prototype.find = jest.fn(function () {
|
|
59
|
-
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
60
|
-
args[_key5] = arguments[_key5];
|
|
61
|
-
}
|
|
62
|
-
return originalFn.apply(this, args);
|
|
63
|
-
});
|
|
64
|
-
expect((0, _polyfillDetection.getPolyfills)()).toEqual(['Array.find']);
|
|
65
|
-
Array.prototype.find = originalFn;
|
|
66
|
-
});
|
|
67
|
-
test('should indicate Array.prototype.flat is polyfilled', () => {
|
|
68
|
-
const originalFn = Array.prototype.flat;
|
|
69
|
-
Array.prototype.flat = jest.fn(function () {
|
|
70
|
-
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
71
|
-
args[_key6] = arguments[_key6];
|
|
72
|
-
}
|
|
73
|
-
return originalFn.apply(this, args);
|
|
74
|
-
});
|
|
75
|
-
expect((0, _polyfillDetection.getPolyfills)()).toEqual(['Array.flat']);
|
|
76
|
-
Array.prototype.flat = originalFn;
|
|
77
|
-
});
|
|
78
|
-
test('should indicate Array.prototype.flatMap is polyfilled', () => {
|
|
79
|
-
const originalFn = Array.prototype.flatMap;
|
|
80
|
-
Array.prototype.flatMap = jest.fn(function () {
|
|
81
|
-
for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
|
|
82
|
-
args[_key7] = arguments[_key7];
|
|
83
|
-
}
|
|
84
|
-
return originalFn.apply(this, args);
|
|
85
|
-
});
|
|
86
|
-
expect((0, _polyfillDetection.getPolyfills)()).toEqual(['Array.flatMap']);
|
|
87
|
-
Array.prototype.flatMap = originalFn;
|
|
88
|
-
});
|
|
89
|
-
test('should indicate Object.assign is polyfilled', () => {
|
|
90
|
-
const originalFn = Object.assign;
|
|
91
|
-
Object.assign = jest.fn(function () {
|
|
92
|
-
for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
|
|
93
|
-
args[_key8] = arguments[_key8];
|
|
94
|
-
}
|
|
95
|
-
return originalFn.apply(this, args);
|
|
96
|
-
});
|
|
97
|
-
expect((0, _polyfillDetection.getPolyfills)()).toEqual(['Object.assign']);
|
|
98
|
-
Object.assign = originalFn;
|
|
99
|
-
});
|
|
100
|
-
test('should indicate Object.entries is polyfilled', () => {
|
|
101
|
-
const originalFn = Object.entries;
|
|
102
|
-
Object.entries = jest.fn(function () {
|
|
103
|
-
for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
|
|
104
|
-
args[_key9] = arguments[_key9];
|
|
105
|
-
}
|
|
106
|
-
return originalFn.apply(this, args);
|
|
107
|
-
});
|
|
108
|
-
expect((0, _polyfillDetection.getPolyfills)()).toEqual(['Object.entries']);
|
|
109
|
-
Object.entries = originalFn;
|
|
110
|
-
});
|
|
111
|
-
test('should indicate Object.values is polyfilled', () => {
|
|
112
|
-
const originalFn = Object.values;
|
|
113
|
-
Object.values = jest.fn(function () {
|
|
114
|
-
for (var _len10 = arguments.length, args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {
|
|
115
|
-
args[_key10] = arguments[_key10];
|
|
116
|
-
}
|
|
117
|
-
return originalFn.apply(this, args);
|
|
118
|
-
});
|
|
119
|
-
expect((0, _polyfillDetection.getPolyfills)()).toEqual(['Object.values']);
|
|
120
|
-
Object.values = originalFn;
|
|
121
|
-
});
|
|
122
|
-
test('should indicate Map constructor is polyfilled', () => {
|
|
123
|
-
const originalFn = Map;
|
|
124
|
-
Map = jest.fn(function () {
|
|
125
|
-
for (var _len11 = arguments.length, args = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) {
|
|
126
|
-
args[_key11] = arguments[_key11];
|
|
127
|
-
}
|
|
128
|
-
return originalFn.apply(this, args);
|
|
129
|
-
});
|
|
130
|
-
expect((0, _polyfillDetection.getPolyfills)()).toEqual(['Map']);
|
|
131
|
-
Map = originalFn;
|
|
132
|
-
});
|
|
133
|
-
test('should indicate Set constructor is polyfilled', () => {
|
|
134
|
-
const originalFn = Set;
|
|
135
|
-
Set = jest.fn(function () {
|
|
136
|
-
for (var _len12 = arguments.length, args = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) {
|
|
137
|
-
args[_key12] = arguments[_key12];
|
|
138
|
-
}
|
|
139
|
-
return originalFn.apply(this, args);
|
|
140
|
-
});
|
|
141
|
-
expect((0, _polyfillDetection.getPolyfills)()).toEqual(['Set']);
|
|
142
|
-
Set = originalFn;
|
|
143
|
-
});
|
|
144
|
-
test('should indicate WeakMap constructor is polyfilled', () => {
|
|
145
|
-
const originalFn = WeakMap;
|
|
146
|
-
WeakMap = jest.fn(function () {
|
|
147
|
-
for (var _len13 = arguments.length, args = new Array(_len13), _key13 = 0; _key13 < _len13; _key13++) {
|
|
148
|
-
args[_key13] = arguments[_key13];
|
|
149
|
-
}
|
|
150
|
-
return originalFn.apply(this, args);
|
|
151
|
-
});
|
|
152
|
-
expect((0, _polyfillDetection.getPolyfills)()).toEqual(['WeakMap']);
|
|
153
|
-
WeakMap = originalFn;
|
|
154
|
-
});
|
|
155
|
-
test('should indicate WeakSet constructor is polyfilled', () => {
|
|
156
|
-
const originalFn = WeakSet;
|
|
157
|
-
WeakSet = jest.fn(function () {
|
|
158
|
-
for (var _len14 = arguments.length, args = new Array(_len14), _key14 = 0; _key14 < _len14; _key14++) {
|
|
159
|
-
args[_key14] = arguments[_key14];
|
|
160
|
-
}
|
|
161
|
-
return originalFn.apply(this, args);
|
|
162
|
-
});
|
|
163
|
-
expect((0, _polyfillDetection.getPolyfills)()).toEqual(['WeakSet']);
|
|
164
|
-
WeakSet = originalFn;
|
|
165
|
-
});
|
|
@@ -1,457 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _ = require(".");
|
|
4
|
-
var _aggregator = require("../../../common/aggregate/aggregator");
|
|
5
|
-
var _sessionEntity = require("../../../common/session/session-entity");
|
|
6
|
-
var _config = require("../../../common/config/config");
|
|
7
|
-
var _configure = require("../../../loaders/configure/configure");
|
|
8
|
-
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); }
|
|
9
|
-
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; }
|
|
10
|
-
class LocalMemory {
|
|
11
|
-
constructor() {
|
|
12
|
-
let initialState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
13
|
-
this.state = initialState;
|
|
14
|
-
}
|
|
15
|
-
get(key) {
|
|
16
|
-
try {
|
|
17
|
-
return this.state[key];
|
|
18
|
-
} catch (err) {
|
|
19
|
-
return '';
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
set(key, value) {
|
|
23
|
-
try {
|
|
24
|
-
if (value === undefined || value === null) return this.remove(key);
|
|
25
|
-
this.state[key] = value;
|
|
26
|
-
} catch (err) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
remove(key) {
|
|
31
|
-
try {
|
|
32
|
-
delete this.state[key];
|
|
33
|
-
} catch (err) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
let sr, session;
|
|
39
|
-
const agentIdentifier = 'abcd';
|
|
40
|
-
const info = {
|
|
41
|
-
licenseKey: 1234,
|
|
42
|
-
applicationID: 9876
|
|
43
|
-
};
|
|
44
|
-
const init = {
|
|
45
|
-
session_replay: {
|
|
46
|
-
enabled: true,
|
|
47
|
-
sampleRate: 1,
|
|
48
|
-
errorSampleRate: 0
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
describe('Session Replay', () => {
|
|
52
|
-
beforeEach(async () => {
|
|
53
|
-
primeSessionAndReplay();
|
|
54
|
-
});
|
|
55
|
-
afterEach(async () => {
|
|
56
|
-
sr.abort();
|
|
57
|
-
jest.clearAllMocks();
|
|
58
|
-
});
|
|
59
|
-
describe('Session Replay Session Behavior', () => {
|
|
60
|
-
test('When Session Ends', async () => {
|
|
61
|
-
const xhrMockClass = () => ({
|
|
62
|
-
open: jest.fn(),
|
|
63
|
-
send: jest.fn(),
|
|
64
|
-
setRequestHeader: jest.fn(),
|
|
65
|
-
addEventListener: jest.fn()
|
|
66
|
-
});
|
|
67
|
-
global.XMLHttpRequest = jest.fn().mockImplementation(xhrMockClass);
|
|
68
|
-
(0, _config.setConfiguration)(agentIdentifier, {
|
|
69
|
-
...init
|
|
70
|
-
});
|
|
71
|
-
sr.ee.emit('rumresp-sr', [true]);
|
|
72
|
-
await wait(1);
|
|
73
|
-
expect(sr.initialized).toBeTruthy();
|
|
74
|
-
expect(sr.recording).toBeTruthy();
|
|
75
|
-
sr.ee.emit(_sessionEntity.SESSION_EVENTS.RESET);
|
|
76
|
-
expect(global.XMLHttpRequest).toHaveBeenCalled();
|
|
77
|
-
expect(sr.recording).toBeFalsy();
|
|
78
|
-
expect(sr.blocked).toBeTruthy();
|
|
79
|
-
});
|
|
80
|
-
test('When Session Is Paused/Resumed', async () => {
|
|
81
|
-
(0, _config.setConfiguration)(agentIdentifier, {
|
|
82
|
-
...init
|
|
83
|
-
});
|
|
84
|
-
sr.ee.emit('rumresp-sr', [true]);
|
|
85
|
-
await wait(1);
|
|
86
|
-
expect(sr.initialized).toBeTruthy();
|
|
87
|
-
expect(sr.recording).toBeTruthy();
|
|
88
|
-
sr.ee.emit(_sessionEntity.SESSION_EVENTS.PAUSE);
|
|
89
|
-
expect(sr.recording).toBeFalsy();
|
|
90
|
-
sr.ee.emit(_sessionEntity.SESSION_EVENTS.RESUME);
|
|
91
|
-
expect(sr.recording).toBeTruthy();
|
|
92
|
-
});
|
|
93
|
-
test('Session SR mode matches SR mode -- FULL', async () => {
|
|
94
|
-
(0, _config.setConfiguration)(agentIdentifier, {
|
|
95
|
-
...init
|
|
96
|
-
});
|
|
97
|
-
sr.ee.emit('rumresp-sr', [true]);
|
|
98
|
-
await wait(1);
|
|
99
|
-
expect(session.state.sessionReplay).toEqual(sr.mode);
|
|
100
|
-
});
|
|
101
|
-
test('Session SR mode matches SR mode -- ERROR', async () => {
|
|
102
|
-
(0, _config.setConfiguration)(agentIdentifier, {
|
|
103
|
-
session_replay: {
|
|
104
|
-
sampleRate: 0,
|
|
105
|
-
errorSampleRate: 1
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
sr.ee.emit('rumresp-sr', [true]);
|
|
109
|
-
await wait(1);
|
|
110
|
-
expect(session.state.sessionReplay).toEqual(sr.mode);
|
|
111
|
-
return;
|
|
112
|
-
});
|
|
113
|
-
test('Session SR mode matches SR mode -- OFF', async () => {
|
|
114
|
-
(0, _config.setConfiguration)(agentIdentifier, {
|
|
115
|
-
session_replay: {
|
|
116
|
-
sampleRate: 0,
|
|
117
|
-
errorSampleRate: 0
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
sr.ee.emit('rumresp-sr', [true]);
|
|
121
|
-
await wait(1);
|
|
122
|
-
expect(session.state.sessionReplay).toEqual(sr.mode);
|
|
123
|
-
return;
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
describe('Session Replay Initialization Behavior', () => {
|
|
127
|
-
test('Waits for SR', async () => {
|
|
128
|
-
(0, _config.setConfiguration)(agentIdentifier, {
|
|
129
|
-
...init
|
|
130
|
-
});
|
|
131
|
-
// do not emit sr flag
|
|
132
|
-
await wait(1000);
|
|
133
|
-
expect(sr.initialized).toEqual(false);
|
|
134
|
-
expect(sr.recording).toEqual(false);
|
|
135
|
-
|
|
136
|
-
// emit a false flag
|
|
137
|
-
sr.ee.emit('rumresp-sr', [false]);
|
|
138
|
-
await wait(1);
|
|
139
|
-
expect(sr.initialized).toEqual(true);
|
|
140
|
-
expect(sr.recording).toEqual(false);
|
|
141
|
-
return;
|
|
142
|
-
});
|
|
143
|
-
test('Does not run if cookies_enabled is false', async () => {
|
|
144
|
-
(0, _config.setConfiguration)(agentIdentifier, {
|
|
145
|
-
...init,
|
|
146
|
-
privacy: {
|
|
147
|
-
cookies_enabled: false
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
sr = new _.Aggregate(agentIdentifier, new _aggregator.Aggregator({}));
|
|
151
|
-
sr.ee.emit('rumresp-sr', [true]);
|
|
152
|
-
await wait(1);
|
|
153
|
-
expect(sr.initialized).toEqual(false);
|
|
154
|
-
expect(sr.recording).toEqual(false);
|
|
155
|
-
return;
|
|
156
|
-
});
|
|
157
|
-
test('Does not run if session_trace is disabled', async () => {
|
|
158
|
-
(0, _config.setConfiguration)(agentIdentifier, {
|
|
159
|
-
...init,
|
|
160
|
-
session_trace: {
|
|
161
|
-
enabled: false
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
sr = new _.Aggregate(agentIdentifier, new _aggregator.Aggregator({}));
|
|
165
|
-
sr.ee.emit('rumresp-sr', [true]);
|
|
166
|
-
await wait(1);
|
|
167
|
-
expect(sr.initialized).toEqual(false);
|
|
168
|
-
expect(sr.recording).toEqual(false);
|
|
169
|
-
return;
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
describe('Session Replay Sample -> Mode Behaviors', () => {
|
|
173
|
-
test('New Session -- Full 1 Error 1 === FULL', async () => {
|
|
174
|
-
(0, _config.setConfiguration)(agentIdentifier, {
|
|
175
|
-
session_replay: {
|
|
176
|
-
errorSampleRate: 1,
|
|
177
|
-
sampleRate: 1
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
sr.ee.emit('rumresp-sr', [true]);
|
|
181
|
-
await wait(1);
|
|
182
|
-
expect(sr.mode).toEqual(_sessionEntity.MODE.FULL);
|
|
183
|
-
return;
|
|
184
|
-
});
|
|
185
|
-
test('New Session -- Full 1 Error 0 === FULL', async () => {
|
|
186
|
-
(0, _config.setConfiguration)(agentIdentifier, {
|
|
187
|
-
session_replay: {
|
|
188
|
-
errorSampleRate: 0,
|
|
189
|
-
sampleRate: 1
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
sr.ee.emit('rumresp-sr', [true]);
|
|
193
|
-
await wait(1);
|
|
194
|
-
expect(sr.mode).toEqual(_sessionEntity.MODE.FULL);
|
|
195
|
-
return;
|
|
196
|
-
});
|
|
197
|
-
test('New Session -- Full 0 Error 1 === ERROR', async () => {
|
|
198
|
-
(0, _config.setConfiguration)(agentIdentifier, {
|
|
199
|
-
session_replay: {
|
|
200
|
-
errorSampleRate: 1,
|
|
201
|
-
sampleRate: 0
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
sr.ee.emit('rumresp-sr', [true]);
|
|
205
|
-
await wait(1);
|
|
206
|
-
expect(sr.mode).toEqual(_sessionEntity.MODE.ERROR);
|
|
207
|
-
return;
|
|
208
|
-
});
|
|
209
|
-
test('New Session -- Full 0 Error 0 === OFF', async () => {
|
|
210
|
-
(0, _config.setConfiguration)(agentIdentifier, {
|
|
211
|
-
session_replay: {
|
|
212
|
-
errorSampleRate: 0,
|
|
213
|
-
sampleRate: 0
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
sr.ee.emit('rumresp-sr', [true]);
|
|
217
|
-
await wait(1);
|
|
218
|
-
expect(sr.mode).toEqual(_sessionEntity.MODE.OFF);
|
|
219
|
-
return;
|
|
220
|
-
});
|
|
221
|
-
test('Existing Session -- Should inherit mode from session entity and ignore samples', async () => {
|
|
222
|
-
const storage = new LocalMemory({
|
|
223
|
-
NRBA_SESSION: {
|
|
224
|
-
value: 'abcdefghijklmnop',
|
|
225
|
-
expiresAt: Date.now() + 10000,
|
|
226
|
-
inactiveAt: Date.now() + 10000,
|
|
227
|
-
updatedAt: Date.now(),
|
|
228
|
-
sessionReplay: _sessionEntity.MODE.FULL,
|
|
229
|
-
sessionTraceMode: _sessionEntity.MODE.FULL,
|
|
230
|
-
custom: {}
|
|
231
|
-
}
|
|
232
|
-
});
|
|
233
|
-
session = new _sessionEntity.SessionEntity({
|
|
234
|
-
agentIdentifier,
|
|
235
|
-
key: 'SESSION',
|
|
236
|
-
storage
|
|
237
|
-
});
|
|
238
|
-
expect(session.isNew).toBeFalsy();
|
|
239
|
-
primeSessionAndReplay(session);
|
|
240
|
-
// configure to get "error" sample ---> but should inherit FULL from session manager
|
|
241
|
-
(0, _config.setConfiguration)(agentIdentifier, {
|
|
242
|
-
session_replay: {
|
|
243
|
-
errorSampleRate: 1,
|
|
244
|
-
sampleRate: 0
|
|
245
|
-
}
|
|
246
|
-
});
|
|
247
|
-
sr.ee.emit('rumresp-sr', [true]);
|
|
248
|
-
await wait(1);
|
|
249
|
-
expect(sr.mode).toEqual(_sessionEntity.MODE.FULL);
|
|
250
|
-
return;
|
|
251
|
-
});
|
|
252
|
-
});
|
|
253
|
-
describe('Session Replay Error Mode Behaviors', () => {
|
|
254
|
-
test('An error BEFORE rrweb import starts running in FULL from beginning', async () => {
|
|
255
|
-
(0, _config.setConfiguration)(agentIdentifier, {
|
|
256
|
-
session_replay: {
|
|
257
|
-
errorSampleRate: 1,
|
|
258
|
-
sampleRate: 0
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
|
-
sr.ee.emit('errorAgg');
|
|
262
|
-
sr.ee.emit('rumresp-sr', [true]);
|
|
263
|
-
await wait(1);
|
|
264
|
-
expect(sr.mode).toEqual(_sessionEntity.MODE.FULL);
|
|
265
|
-
expect(sr.scheduler.started).toEqual(true);
|
|
266
|
-
return;
|
|
267
|
-
});
|
|
268
|
-
test('An error AFTER rrweb import changes mode and starts harvester', async () => {
|
|
269
|
-
(0, _config.setConfiguration)(agentIdentifier, {
|
|
270
|
-
session_replay: {
|
|
271
|
-
errorSampleRate: 1,
|
|
272
|
-
sampleRate: 0
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
sr.ee.emit('rumresp-sr', [true]);
|
|
276
|
-
await wait(1);
|
|
277
|
-
expect(sr.mode).toEqual(_sessionEntity.MODE.ERROR);
|
|
278
|
-
expect(sr.scheduler.started).toEqual(false);
|
|
279
|
-
sr.ee.emit('errorAgg');
|
|
280
|
-
expect(sr.mode).toEqual(_sessionEntity.MODE.FULL);
|
|
281
|
-
expect(sr.scheduler.started).toEqual(true);
|
|
282
|
-
return;
|
|
283
|
-
});
|
|
284
|
-
});
|
|
285
|
-
describe('Session Replay Payload Validation', () => {
|
|
286
|
-
test('Payload', async () => {
|
|
287
|
-
(0, _config.setConfiguration)(agentIdentifier, {
|
|
288
|
-
...init
|
|
289
|
-
});
|
|
290
|
-
sr.ee.emit('rumresp-sr', [true]);
|
|
291
|
-
await wait(1);
|
|
292
|
-
const harvestContents = sr.getHarvestContents();
|
|
293
|
-
// query attrs
|
|
294
|
-
expect(harvestContents.qs).toMatchObject({
|
|
295
|
-
protocol_version: '0',
|
|
296
|
-
content_encoding: 'gzip',
|
|
297
|
-
browser_monitoring_key: info.licenseKey
|
|
298
|
-
});
|
|
299
|
-
expect(harvestContents.body).toMatchObject({
|
|
300
|
-
type: 'SessionReplay',
|
|
301
|
-
appId: info.applicationID,
|
|
302
|
-
timestamp: expect.any(Number),
|
|
303
|
-
blob: expect.any(String),
|
|
304
|
-
attributes: {
|
|
305
|
-
session: session.state.value,
|
|
306
|
-
hasSnapshot: expect.any(Boolean),
|
|
307
|
-
hasError: expect.any(Boolean),
|
|
308
|
-
agentVersion: expect.any(String),
|
|
309
|
-
isFirstChunk: expect.any(Boolean),
|
|
310
|
-
'nr.rrweb.version': expect.any(String)
|
|
311
|
-
}
|
|
312
|
-
});
|
|
313
|
-
expect(JSON.parse(harvestContents.body.blob).length).toBeGreaterThan(0);
|
|
314
|
-
});
|
|
315
|
-
});
|
|
316
|
-
describe('Session Replay Harvest Behaviors', () => {
|
|
317
|
-
test('Compressed payload is provided to harvester', async () => {
|
|
318
|
-
const {
|
|
319
|
-
gunzipSync,
|
|
320
|
-
strFromU8
|
|
321
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('fflate')));
|
|
322
|
-
(0, _config.setConfiguration)(agentIdentifier, {
|
|
323
|
-
...init
|
|
324
|
-
});
|
|
325
|
-
sr.ee.emit('rumresp-sr', [true]);
|
|
326
|
-
await wait(1);
|
|
327
|
-
const [harvestContents] = sr.prepareHarvest();
|
|
328
|
-
expect(harvestContents.qs).toMatchObject({
|
|
329
|
-
protocol_version: '0',
|
|
330
|
-
content_encoding: 'gzip',
|
|
331
|
-
browser_monitoring_key: info.licenseKey
|
|
332
|
-
});
|
|
333
|
-
expect(harvestContents.body).toEqual(expect.any(Uint8Array));
|
|
334
|
-
expect(JSON.parse(strFromU8(gunzipSync(harvestContents.body)))).toMatchObject({
|
|
335
|
-
type: 'SessionReplay',
|
|
336
|
-
appId: info.applicationID,
|
|
337
|
-
timestamp: expect.any(Number),
|
|
338
|
-
blob: expect.any(String),
|
|
339
|
-
attributes: {
|
|
340
|
-
session: session.state.value,
|
|
341
|
-
hasSnapshot: expect.any(Boolean),
|
|
342
|
-
hasError: expect.any(Boolean),
|
|
343
|
-
agentVersion: expect.any(String),
|
|
344
|
-
isFirstChunk: expect.any(Boolean),
|
|
345
|
-
'nr.rrweb.version': expect.any(String)
|
|
346
|
-
}
|
|
347
|
-
});
|
|
348
|
-
});
|
|
349
|
-
test('Uncompressed payload is provided to harvester', async () => {
|
|
350
|
-
jest.doMock('fflate', () => ({
|
|
351
|
-
__esModule: true,
|
|
352
|
-
gzipSync: jest.fn().mockImplementation(() => {
|
|
353
|
-
throw new Error();
|
|
354
|
-
})
|
|
355
|
-
}));
|
|
356
|
-
(0, _config.setConfiguration)(agentIdentifier, {
|
|
357
|
-
...init
|
|
358
|
-
});
|
|
359
|
-
sr.shouldCompress = false;
|
|
360
|
-
sr.ee.emit('rumresp-sr', [true]);
|
|
361
|
-
await wait(1);
|
|
362
|
-
const [harvestContents] = sr.prepareHarvest();
|
|
363
|
-
expect(harvestContents.qs).toMatchObject({
|
|
364
|
-
protocol_version: '0',
|
|
365
|
-
// content_encoding is omitted when the payload is not compressed
|
|
366
|
-
browser_monitoring_key: info.licenseKey
|
|
367
|
-
});
|
|
368
|
-
expect(harvestContents.qs.content_encoding).toBeUndefined();
|
|
369
|
-
expect(harvestContents.body).toMatchObject({
|
|
370
|
-
type: 'SessionReplay',
|
|
371
|
-
appId: info.applicationID,
|
|
372
|
-
timestamp: expect.any(Number),
|
|
373
|
-
blob: expect.any(String),
|
|
374
|
-
attributes: {
|
|
375
|
-
session: session.state.value,
|
|
376
|
-
hasSnapshot: expect.any(Boolean),
|
|
377
|
-
hasError: expect.any(Boolean),
|
|
378
|
-
agentVersion: expect.any(String),
|
|
379
|
-
isFirstChunk: expect.any(Boolean),
|
|
380
|
-
'nr.rrweb.version': expect.any(String)
|
|
381
|
-
}
|
|
382
|
-
});
|
|
383
|
-
});
|
|
384
|
-
test('Clears the event buffer when staged for harvesting', async () => {
|
|
385
|
-
(0, _config.setConfiguration)(agentIdentifier, {
|
|
386
|
-
...init
|
|
387
|
-
});
|
|
388
|
-
sr.shouldCompress = false;
|
|
389
|
-
sr.ee.emit('rumresp-sr', [true]);
|
|
390
|
-
await wait(1);
|
|
391
|
-
sr.prepareHarvest();
|
|
392
|
-
expect(sr.events.length).toEqual(0);
|
|
393
|
-
});
|
|
394
|
-
test('Harvests early if exceeds limit', async () => {
|
|
395
|
-
let after = 0;
|
|
396
|
-
const spy = jest.spyOn(sr.scheduler, 'runHarvest').mockImplementation(() => {
|
|
397
|
-
after = Date.now();
|
|
398
|
-
});
|
|
399
|
-
(0, _config.setConfiguration)(agentIdentifier, {
|
|
400
|
-
...init
|
|
401
|
-
});
|
|
402
|
-
sr.payloadBytesEstimation = _.IDEAL_PAYLOAD_SIZE / _.AVG_COMPRESSION;
|
|
403
|
-
const before = Date.now();
|
|
404
|
-
sr.ee.emit('rumresp-sr', [true]);
|
|
405
|
-
await wait(1);
|
|
406
|
-
expect(spy).toHaveBeenCalled();
|
|
407
|
-
expect(after - before).toBeLessThan(sr.harvestTimeSeconds * 1000);
|
|
408
|
-
});
|
|
409
|
-
test('Aborts if exceeds total limit', async () => {
|
|
410
|
-
const spy = jest.spyOn(sr.scheduler, 'runHarvest');
|
|
411
|
-
(0, _config.setConfiguration)(agentIdentifier, {
|
|
412
|
-
...init
|
|
413
|
-
});
|
|
414
|
-
sr.payloadBytesEstimation = (_.MAX_PAYLOAD_SIZE + 1) / _.AVG_COMPRESSION;
|
|
415
|
-
const before = Date.now();
|
|
416
|
-
sr.ee.emit('rumresp-sr', [true]);
|
|
417
|
-
await wait(1);
|
|
418
|
-
expect(spy).not.toHaveBeenCalled();
|
|
419
|
-
expect(sr.blocked).toEqual(true);
|
|
420
|
-
expect(sr.mode).toEqual(_sessionEntity.MODE.OFF);
|
|
421
|
-
});
|
|
422
|
-
test('Aborts if 429 response', async () => {
|
|
423
|
-
(0, _config.setConfiguration)(agentIdentifier, {
|
|
424
|
-
...init
|
|
425
|
-
});
|
|
426
|
-
sr.ee.emit('rumresp-sr', [true]);
|
|
427
|
-
await wait(1);
|
|
428
|
-
expect(sr.mode).toEqual(_sessionEntity.MODE.FULL);
|
|
429
|
-
sr.onHarvestFinished({
|
|
430
|
-
status: 429
|
|
431
|
-
});
|
|
432
|
-
expect(sr.blocked).toEqual(true);
|
|
433
|
-
expect(sr.mode).toEqual(_sessionEntity.MODE.OFF);
|
|
434
|
-
});
|
|
435
|
-
});
|
|
436
|
-
});
|
|
437
|
-
function wait() {
|
|
438
|
-
let ms = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
439
|
-
return new Promise(resolve => {
|
|
440
|
-
setTimeout(resolve, ms);
|
|
441
|
-
});
|
|
442
|
-
}
|
|
443
|
-
function primeSessionAndReplay() {
|
|
444
|
-
let sess = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new _sessionEntity.SessionEntity({
|
|
445
|
-
agentIdentifier,
|
|
446
|
-
key: 'SESSION',
|
|
447
|
-
storage: new LocalMemory()
|
|
448
|
-
});
|
|
449
|
-
session = sess;
|
|
450
|
-
(0, _configure.configure)(agentIdentifier, {
|
|
451
|
-
info,
|
|
452
|
-
runtime: {
|
|
453
|
-
session
|
|
454
|
-
}
|
|
455
|
-
}, 'test', true);
|
|
456
|
-
sr = new _.Aggregate(agentIdentifier, new _aggregator.Aggregator({}));
|
|
457
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _faker = require("@faker-js/faker");
|
|
4
|
-
var _interactionNode = require("./interaction-node");
|
|
5
|
-
test('finishing node with cancelled parent should not throw an error', () => {
|
|
6
|
-
const interaction = {
|
|
7
|
-
remaining: 0,
|
|
8
|
-
onNodeAdded: jest.fn(),
|
|
9
|
-
checkFinish: jest.fn()
|
|
10
|
-
};
|
|
11
|
-
const interactionRootNode = new _interactionNode.InteractionNode(interaction, null, 'interaction', _faker.faker.date.past().getUTCSeconds());
|
|
12
|
-
const interactionNode = interactionRootNode.child('test', _faker.faker.date.past().getUTCSeconds(), 'test', false);
|
|
13
|
-
interactionRootNode.cancel();
|
|
14
|
-
interactionNode.finish();
|
|
15
|
-
expect(interactionRootNode.children.length).toEqual(0);
|
|
16
|
-
});
|