@newrelic/browser-agent 1.264.0 → 1.265.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/CHANGELOG.md +24 -0
- package/dist/cjs/common/aggregate/aggregator.js +1 -2
- package/dist/cjs/common/config/{state/configurable.js → configurable.js} +1 -1
- package/dist/cjs/common/config/{state/info.js → info.js} +1 -1
- package/dist/cjs/common/config/{state/init.js → init.js} +5 -5
- package/dist/cjs/common/config/{state/loader-config.js → loader-config.js} +1 -1
- package/dist/cjs/common/config/{state/runtime.js → runtime.js} +16 -5
- package/dist/cjs/common/constants/agent-constants.js +8 -0
- package/dist/cjs/common/constants/env.cdn.js +1 -1
- package/dist/cjs/common/constants/env.npm.js +1 -1
- package/dist/cjs/common/context/shared-context.js +1 -2
- package/dist/cjs/common/dispatch/global-event.js +1 -2
- package/dist/cjs/common/drain/drain.js +10 -16
- package/dist/cjs/common/event-emitter/contextual-ee.js +3 -4
- package/dist/cjs/common/event-listener/event-listener-opts.js +2 -6
- package/dist/cjs/common/harvest/harvest-scheduler.js +1 -2
- package/dist/cjs/common/harvest/harvest.js +29 -56
- package/dist/cjs/common/serialize/bel-serializer.js +6 -11
- package/dist/cjs/common/session/session-entity.js +9 -12
- package/dist/cjs/common/timing/nav-timing.js +1 -3
- package/dist/cjs/common/timing/time-keeper.js +16 -6
- package/dist/cjs/common/url/encode.js +2 -4
- package/dist/cjs/common/util/console.js +2 -0
- package/dist/cjs/common/util/invoke.js +6 -16
- package/dist/cjs/common/util/obfuscate.js +97 -53
- package/dist/cjs/common/util/submit-data.js +17 -20
- package/dist/cjs/common/util/text.js +9 -0
- package/dist/cjs/common/util/traverse.js +1 -3
- package/dist/cjs/common/vitals/cumulative-layout-shift.js +5 -6
- package/dist/cjs/common/vitals/first-contentful-paint.js +4 -5
- package/dist/cjs/common/vitals/first-input-delay.js +4 -5
- package/dist/cjs/common/vitals/interaction-to-next-paint.js +5 -6
- package/dist/cjs/common/vitals/largest-contentful-paint.js +4 -5
- package/dist/cjs/common/vitals/time-to-first-byte.js +4 -5
- package/dist/cjs/common/vitals/vital-metric.js +6 -8
- package/dist/cjs/common/window/nreum.js +2 -1
- package/dist/cjs/common/window/page-visibility.js +1 -4
- package/dist/cjs/common/wrap/wrap-events.js +1 -4
- package/dist/cjs/common/wrap/wrap-promise.js +1 -4
- package/dist/cjs/common/wrap/wrap-websocket.js +74 -0
- package/dist/cjs/features/ajax/aggregate/chunk.js +4 -3
- package/dist/cjs/features/ajax/aggregate/gql.js +4 -5
- package/dist/cjs/features/ajax/aggregate/index.js +20 -23
- package/dist/cjs/features/ajax/constants.js +2 -3
- package/dist/cjs/features/ajax/instrument/distributed-tracing.js +9 -8
- package/dist/cjs/features/ajax/instrument/index.js +15 -13
- package/dist/cjs/features/generic_events/aggregate/index.js +49 -58
- package/dist/cjs/features/generic_events/constants.js +4 -2
- package/dist/cjs/features/generic_events/instrument/index.js +7 -7
- package/dist/cjs/features/jserrors/aggregate/index.js +24 -44
- package/dist/cjs/features/jserrors/instrument/index.js +5 -5
- package/dist/cjs/features/logging/aggregate/index.js +34 -37
- package/dist/cjs/features/logging/constants.js +2 -3
- package/dist/cjs/features/logging/instrument/index.js +6 -7
- package/dist/cjs/features/logging/shared/log.js +1 -3
- package/dist/cjs/features/logging/shared/utils.js +2 -4
- package/dist/cjs/features/metrics/aggregate/index.js +35 -18
- package/dist/cjs/features/metrics/aggregate/websocket-detection.js +34 -0
- package/dist/cjs/features/metrics/constants.js +4 -2
- package/dist/cjs/features/metrics/instrument/index.js +13 -5
- package/dist/cjs/features/page_action/instrument/index.js +8 -4
- package/dist/cjs/features/page_view_event/aggregate/index.js +20 -40
- package/dist/cjs/features/page_view_event/instrument/index.js +5 -5
- package/dist/cjs/features/page_view_timing/aggregate/index.js +24 -40
- package/dist/cjs/features/page_view_timing/instrument/index.js +5 -5
- package/dist/cjs/features/session_replay/aggregate/index.js +37 -44
- package/dist/cjs/features/session_replay/constants.js +1 -5
- package/dist/cjs/features/session_replay/instrument/index.js +6 -10
- package/dist/cjs/features/session_replay/shared/recorder-events.js +25 -20
- package/dist/cjs/features/session_replay/shared/recorder.js +17 -13
- package/dist/cjs/features/session_replay/shared/stylesheet-evaluator.js +3 -3
- package/dist/cjs/features/session_replay/shared/utils.js +5 -4
- package/dist/cjs/features/session_trace/aggregate/index.js +26 -43
- package/dist/cjs/features/session_trace/aggregate/trace/storage.js +7 -5
- package/dist/cjs/features/session_trace/instrument/index.js +9 -8
- package/dist/cjs/features/soft_navigations/aggregate/ajax-node.js +1 -1
- package/dist/cjs/features/soft_navigations/aggregate/bel-node.js +1 -1
- package/dist/cjs/features/soft_navigations/aggregate/index.js +23 -31
- package/dist/cjs/features/soft_navigations/aggregate/initial-page-load-interaction.js +2 -2
- package/dist/cjs/features/soft_navigations/aggregate/interaction.js +9 -10
- package/dist/cjs/features/soft_navigations/instrument/index.js +15 -14
- package/dist/cjs/features/spa/aggregate/index.js +17 -27
- package/dist/cjs/features/spa/aggregate/interaction.js +7 -6
- package/dist/cjs/features/spa/aggregate/serializer.js +3 -3
- package/dist/cjs/features/spa/constants.js +2 -2
- package/dist/cjs/features/spa/instrument/index.js +21 -20
- package/dist/cjs/features/utils/agent-session.js +6 -4
- package/dist/cjs/features/utils/aggregate-base.js +15 -10
- package/dist/cjs/features/utils/event-buffer.js +132 -0
- package/dist/cjs/features/utils/feature-gates.js +2 -2
- package/dist/cjs/features/utils/instrument-base.js +7 -8
- package/dist/cjs/features/utils/lazy-feature-loader.js +11 -11
- package/dist/cjs/features/utils/nr1-debugger.js +1 -3
- package/dist/cjs/loaders/agent-base.js +4 -8
- package/dist/cjs/loaders/agent.js +7 -2
- package/dist/cjs/loaders/api/api.js +22 -34
- package/dist/cjs/loaders/api/apiAsync.js +9 -12
- package/dist/cjs/loaders/configure/configure.js +12 -12
- package/dist/cjs/loaders/features/enabled-features.js +2 -2
- package/dist/cjs/loaders/micro-agent.js +15 -14
- package/dist/esm/common/aggregate/aggregator.js +1 -2
- package/dist/esm/common/config/{state/configurable.js → configurable.js} +1 -1
- package/dist/esm/common/config/{state/info.js → info.js} +1 -1
- package/dist/esm/common/config/{state/init.js → init.js} +5 -5
- package/dist/esm/common/config/{state/loader-config.js → loader-config.js} +1 -1
- package/dist/esm/common/config/{state/runtime.js → runtime.js} +17 -5
- package/dist/esm/common/constants/agent-constants.js +2 -0
- package/dist/esm/common/constants/env.cdn.js +1 -1
- package/dist/esm/common/constants/env.npm.js +1 -1
- package/dist/esm/common/context/shared-context.js +1 -2
- package/dist/esm/common/dispatch/global-event.js +1 -2
- package/dist/esm/common/drain/drain.js +10 -16
- package/dist/esm/common/event-emitter/contextual-ee.js +2 -3
- package/dist/esm/common/event-listener/event-listener-opts.js +2 -6
- package/dist/esm/common/harvest/harvest-scheduler.js +1 -2
- package/dist/esm/common/harvest/harvest.js +21 -48
- package/dist/esm/common/serialize/bel-serializer.js +6 -11
- package/dist/esm/common/session/session-entity.js +8 -11
- package/dist/esm/common/timing/nav-timing.js +1 -3
- package/dist/esm/common/timing/time-keeper.js +15 -5
- package/dist/esm/common/url/encode.js +2 -4
- package/dist/esm/common/util/console.js +2 -0
- package/dist/esm/common/util/invoke.js +6 -16
- package/dist/esm/common/util/obfuscate.js +96 -49
- package/dist/esm/common/util/submit-data.js +17 -20
- package/dist/esm/common/util/text.js +3 -0
- package/dist/esm/common/util/traverse.js +1 -3
- package/dist/esm/common/vitals/cumulative-layout-shift.js +5 -6
- package/dist/esm/common/vitals/first-contentful-paint.js +4 -5
- package/dist/esm/common/vitals/first-input-delay.js +4 -5
- package/dist/esm/common/vitals/interaction-to-next-paint.js +5 -6
- package/dist/esm/common/vitals/largest-contentful-paint.js +4 -5
- package/dist/esm/common/vitals/time-to-first-byte.js +4 -5
- package/dist/esm/common/vitals/vital-metric.js +6 -8
- package/dist/esm/common/window/nreum.js +2 -1
- package/dist/esm/common/window/page-visibility.js +1 -4
- package/dist/esm/common/wrap/wrap-events.js +1 -4
- package/dist/esm/common/wrap/wrap-promise.js +1 -4
- package/dist/esm/common/wrap/wrap-websocket.js +67 -0
- package/dist/esm/features/ajax/aggregate/chunk.js +3 -2
- package/dist/esm/features/ajax/aggregate/gql.js +4 -5
- package/dist/esm/features/ajax/aggregate/index.js +17 -20
- package/dist/esm/features/ajax/constants.js +1 -2
- package/dist/esm/features/ajax/instrument/distributed-tracing.js +2 -1
- package/dist/esm/features/ajax/instrument/index.js +11 -9
- package/dist/esm/features/generic_events/aggregate/index.js +41 -50
- package/dist/esm/features/generic_events/constants.js +3 -1
- package/dist/esm/features/generic_events/instrument/index.js +5 -5
- package/dist/esm/features/jserrors/aggregate/index.js +19 -39
- package/dist/esm/features/jserrors/instrument/index.js +4 -4
- package/dist/esm/features/logging/aggregate/index.js +32 -35
- package/dist/esm/features/logging/constants.js +1 -2
- package/dist/esm/features/logging/instrument/index.js +5 -6
- package/dist/esm/features/logging/shared/log.js +1 -3
- package/dist/esm/features/logging/shared/utils.js +2 -4
- package/dist/esm/features/metrics/aggregate/index.js +29 -12
- package/dist/esm/features/metrics/aggregate/websocket-detection.js +29 -0
- package/dist/esm/features/metrics/constants.js +3 -1
- package/dist/esm/features/metrics/instrument/index.js +13 -5
- package/dist/esm/features/page_action/instrument/index.js +7 -3
- package/dist/esm/features/page_view_event/aggregate/index.js +18 -38
- package/dist/esm/features/page_view_event/instrument/index.js +4 -4
- package/dist/esm/features/page_view_timing/aggregate/index.js +21 -37
- package/dist/esm/features/page_view_timing/instrument/index.js +4 -4
- package/dist/esm/features/session_replay/aggregate/index.js +27 -34
- package/dist/esm/features/session_replay/constants.js +0 -4
- package/dist/esm/features/session_replay/index.js +1 -7
- package/dist/esm/features/session_replay/instrument/index.js +6 -9
- package/dist/esm/features/session_replay/shared/recorder-events.js +25 -20
- package/dist/esm/features/session_replay/shared/recorder.js +14 -10
- package/dist/esm/features/session_replay/shared/stylesheet-evaluator.js +3 -3
- package/dist/esm/features/session_replay/shared/utils.js +3 -2
- package/dist/esm/features/session_trace/aggregate/index.js +21 -38
- package/dist/esm/features/session_trace/aggregate/trace/storage.js +7 -5
- package/dist/esm/features/session_trace/instrument/index.js +6 -5
- package/dist/esm/features/soft_navigations/aggregate/ajax-node.js +1 -1
- package/dist/esm/features/soft_navigations/aggregate/bel-node.js +1 -1
- package/dist/esm/features/soft_navigations/aggregate/index.js +22 -30
- package/dist/esm/features/soft_navigations/aggregate/initial-page-load-interaction.js +1 -1
- package/dist/esm/features/soft_navigations/aggregate/interaction.js +7 -8
- package/dist/esm/features/soft_navigations/instrument/index.js +12 -11
- package/dist/esm/features/spa/aggregate/index.js +11 -21
- package/dist/esm/features/spa/aggregate/interaction.js +6 -5
- package/dist/esm/features/spa/aggregate/serializer.js +1 -1
- package/dist/esm/features/spa/constants.js +2 -2
- package/dist/esm/features/spa/instrument/index.js +13 -12
- package/dist/esm/features/utils/agent-session.js +3 -1
- package/dist/esm/features/utils/aggregate-base.js +13 -8
- package/dist/esm/features/utils/event-buffer.js +126 -0
- package/dist/esm/features/utils/feature-gates.js +1 -1
- package/dist/esm/features/utils/instrument-base.js +6 -7
- package/dist/esm/features/utils/lazy-feature-loader.js +11 -11
- package/dist/esm/features/utils/nr1-debugger.js +1 -3
- package/dist/esm/loaders/agent-base.js +4 -8
- package/dist/esm/loaders/agent.js +7 -2
- package/dist/esm/loaders/api/api.js +17 -29
- package/dist/esm/loaders/api/apiAsync.js +2 -5
- package/dist/esm/loaders/configure/configure.js +5 -5
- package/dist/esm/loaders/features/enabled-features.js +1 -1
- package/dist/esm/loaders/micro-agent.js +10 -9
- package/dist/types/common/config/configurable.d.ts.map +1 -0
- package/dist/types/common/config/info.d.ts.map +1 -0
- package/dist/types/common/config/init.d.ts.map +1 -0
- package/dist/types/common/config/loader-config.d.ts.map +1 -0
- package/dist/types/common/config/runtime.d.ts.map +1 -0
- package/dist/types/common/constants/agent-constants.d.ts +3 -0
- package/dist/types/common/constants/agent-constants.d.ts.map +1 -0
- package/dist/types/common/drain/drain.d.ts.map +1 -1
- package/dist/types/common/harvest/harvest.d.ts +1 -7
- package/dist/types/common/harvest/harvest.d.ts.map +1 -1
- package/dist/types/common/serialize/bel-serializer.d.ts.map +1 -1
- package/dist/types/common/timing/time-keeper.d.ts +9 -2
- package/dist/types/common/timing/time-keeper.d.ts.map +1 -1
- package/dist/types/common/util/console.d.ts.map +1 -1
- package/dist/types/common/util/obfuscate.d.ts +78 -6
- package/dist/types/common/util/obfuscate.d.ts.map +1 -1
- package/dist/types/common/util/text.d.ts +2 -0
- package/dist/types/common/util/text.d.ts.map +1 -0
- package/dist/types/common/window/nreum.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-websocket.d.ts +4 -0
- package/dist/types/common/wrap/wrap-websocket.d.ts.map +1 -0
- package/dist/types/features/ajax/aggregate/chunk.d.ts.map +1 -1
- package/dist/types/features/ajax/aggregate/index.d.ts +2 -3
- package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/ajax/constants.d.ts +0 -1
- package/dist/types/features/ajax/constants.d.ts.map +1 -1
- package/dist/types/features/ajax/instrument/distributed-tracing.d.ts.map +1 -1
- package/dist/types/features/ajax/instrument/index.d.ts +1 -0
- package/dist/types/features/ajax/instrument/index.d.ts.map +1 -1
- package/dist/types/features/generic_events/aggregate/index.d.ts +6 -8
- package/dist/types/features/generic_events/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/generic_events/constants.d.ts +2 -0
- package/dist/types/features/generic_events/constants.d.ts.map +1 -1
- package/dist/types/features/generic_events/instrument/index.d.ts +1 -0
- package/dist/types/features/generic_events/instrument/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/aggregate/index.d.ts +2 -2
- package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/instrument/index.d.ts +1 -0
- package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -1
- package/dist/types/features/logging/aggregate/index.d.ts +4 -7
- package/dist/types/features/logging/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/logging/constants.d.ts +0 -1
- package/dist/types/features/logging/constants.d.ts.map +1 -1
- package/dist/types/features/logging/instrument/index.d.ts +1 -0
- package/dist/types/features/logging/instrument/index.d.ts.map +1 -1
- package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/metrics/aggregate/websocket-detection.d.ts +12 -0
- package/dist/types/features/metrics/aggregate/websocket-detection.d.ts.map +1 -0
- package/dist/types/features/metrics/constants.d.ts +1 -0
- package/dist/types/features/metrics/constants.d.ts.map +1 -1
- package/dist/types/features/metrics/instrument/index.d.ts +1 -0
- package/dist/types/features/metrics/instrument/index.d.ts.map +1 -1
- package/dist/types/features/page_action/instrument/index.d.ts +4 -0
- package/dist/types/features/page_action/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_event/instrument/index.d.ts +1 -0
- package/dist/types/features/page_view_event/instrument/index.d.ts.map +1 -1
- package/dist/types/features/page_view_timing/aggregate/index.d.ts +2 -2
- package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/page_view_timing/instrument/index.d.ts +1 -0
- package/dist/types/features/page_view_timing/instrument/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/constants.d.ts +0 -4
- package/dist/types/features/session_replay/constants.d.ts.map +1 -1
- package/dist/types/features/session_replay/instrument/index.d.ts +1 -0
- package/dist/types/features/session_replay/instrument/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/shared/recorder-events.d.ts +6 -6
- package/dist/types/features/session_replay/shared/recorder-events.d.ts.map +1 -1
- package/dist/types/features/session_replay/shared/recorder.d.ts +2 -2
- package/dist/types/features/session_replay/shared/recorder.d.ts.map +1 -1
- package/dist/types/features/session_replay/shared/utils.d.ts.map +1 -1
- package/dist/types/features/session_trace/aggregate/index.d.ts +2 -2
- package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_trace/aggregate/trace/storage.d.ts +1 -1
- package/dist/types/features/session_trace/aggregate/trace/storage.d.ts.map +1 -1
- package/dist/types/features/session_trace/instrument/index.d.ts +1 -0
- package/dist/types/features/session_trace/instrument/index.d.ts.map +1 -1
- package/dist/types/features/soft_navigations/aggregate/index.d.ts +3 -3
- package/dist/types/features/soft_navigations/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/soft_navigations/instrument/index.d.ts +1 -0
- package/dist/types/features/soft_navigations/instrument/index.d.ts.map +1 -1
- package/dist/types/features/spa/aggregate/index.d.ts +2 -2
- package/dist/types/features/spa/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/spa/aggregate/interaction.d.ts.map +1 -1
- package/dist/types/features/spa/constants.d.ts.map +1 -1
- package/dist/types/features/spa/instrument/index.d.ts +1 -0
- package/dist/types/features/spa/instrument/index.d.ts.map +1 -1
- package/dist/types/features/utils/agent-session.d.ts.map +1 -1
- package/dist/types/features/utils/aggregate-base.d.ts +1 -0
- package/dist/types/features/utils/aggregate-base.d.ts.map +1 -1
- package/dist/types/features/utils/event-buffer.d.ts +72 -0
- package/dist/types/features/utils/event-buffer.d.ts.map +1 -0
- package/dist/types/features/utils/instrument-base.d.ts +1 -0
- package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
- package/dist/types/loaders/agent-base.d.ts +1 -1
- package/dist/types/loaders/agent.d.ts.map +1 -1
- package/dist/types/loaders/api/api.d.ts.map +1 -1
- package/dist/types/loaders/configure/configure.d.ts.map +1 -1
- package/dist/types/loaders/micro-agent.d.ts.map +1 -1
- package/package.json +55 -59
- package/src/common/config/__mocks__/info.js +3 -0
- package/src/common/config/__mocks__/init.js +3 -0
- package/src/common/config/__mocks__/loader-config.js +2 -0
- package/src/common/config/__mocks__/runtime.js +2 -0
- package/src/common/config/{state/configurable.js → configurable.js} +1 -1
- package/src/common/config/{state/info.js → info.js} +1 -1
- package/src/common/config/{state/init.js → init.js} +5 -5
- package/src/common/config/{state/loader-config.js → loader-config.js} +1 -1
- package/src/common/config/{state/runtime.js → runtime.js} +19 -5
- package/src/common/constants/agent-constants.js +2 -0
- package/src/common/drain/drain.js +5 -2
- package/src/common/event-emitter/contextual-ee.js +1 -1
- package/src/common/harvest/harvest.js +7 -21
- package/src/common/serialize/bel-serializer.js +5 -7
- package/src/common/session/session-entity.js +2 -2
- package/src/common/timing/__mocks__/time-keeper.js +6 -2
- package/src/common/timing/time-keeper.js +15 -5
- package/src/common/util/__mocks__/console.js +1 -0
- package/src/common/util/__mocks__/obfuscate.js +5 -8
- package/src/common/util/console.js +2 -0
- package/src/common/util/obfuscate.js +94 -50
- package/src/common/util/text.js +6 -0
- package/src/common/window/__mocks__/nreum.js +1 -1
- package/src/common/window/nreum.js +2 -1
- package/src/common/wrap/wrap-websocket.js +73 -0
- package/src/features/ajax/aggregate/chunk.js +3 -2
- package/src/features/ajax/aggregate/index.js +20 -19
- package/src/features/ajax/constants.js +0 -2
- package/src/features/ajax/instrument/distributed-tracing.js +2 -1
- package/src/features/ajax/instrument/index.js +9 -5
- package/src/features/generic_events/aggregate/index.js +43 -37
- package/src/features/generic_events/constants.js +2 -0
- package/src/features/generic_events/instrument/index.js +3 -1
- package/src/features/jserrors/aggregate/index.js +14 -4
- package/src/features/jserrors/instrument/index.js +2 -0
- package/src/features/logging/aggregate/index.js +39 -31
- package/src/features/logging/constants.js +0 -2
- package/src/features/logging/instrument/index.js +2 -0
- package/src/features/logging/shared/utils.js +1 -1
- package/src/features/metrics/aggregate/index.js +24 -9
- package/src/features/metrics/aggregate/websocket-detection.js +31 -0
- package/src/features/metrics/constants.js +3 -0
- package/src/features/metrics/instrument/index.js +13 -1
- package/src/features/page_action/instrument/index.js +5 -0
- package/src/features/page_view_event/aggregate/index.js +8 -23
- package/src/features/page_view_event/instrument/index.js +2 -0
- package/src/features/page_view_timing/aggregate/index.js +14 -16
- package/src/features/page_view_timing/instrument/index.js +2 -0
- package/src/features/session_replay/aggregate/index.js +13 -9
- package/src/features/session_replay/constants.js +0 -4
- package/src/features/session_replay/index.js +1 -7
- package/src/features/session_replay/instrument/index.js +3 -4
- package/src/features/session_replay/shared/recorder-events.js +27 -20
- package/src/features/session_replay/shared/recorder.js +13 -6
- package/src/features/session_replay/shared/stylesheet-evaluator.js +2 -2
- package/src/features/session_replay/shared/utils.js +3 -2
- package/src/features/session_trace/aggregate/index.js +16 -7
- package/src/features/session_trace/aggregate/trace/storage.js +6 -1
- package/src/features/session_trace/instrument/index.js +4 -1
- package/src/features/soft_navigations/aggregate/ajax-node.js +1 -1
- package/src/features/soft_navigations/aggregate/index.js +13 -15
- package/src/features/soft_navigations/aggregate/initial-page-load-interaction.js +1 -1
- package/src/features/soft_navigations/aggregate/interaction.js +1 -1
- package/src/features/soft_navigations/instrument/index.js +9 -5
- package/src/features/spa/aggregate/index.js +11 -18
- package/src/features/spa/aggregate/interaction.js +5 -3
- package/src/features/spa/aggregate/serializer.js +1 -1
- package/src/features/spa/constants.js +2 -2
- package/src/features/spa/instrument/index.js +9 -3
- package/src/features/utils/agent-session.js +3 -1
- package/src/features/utils/aggregate-base.js +10 -2
- package/src/features/utils/event-buffer.js +126 -0
- package/src/features/utils/feature-gates.js +1 -1
- package/src/features/utils/instrument-base.js +2 -1
- package/src/loaders/agent-base.js +2 -2
- package/src/loaders/agent.js +7 -2
- package/src/loaders/api/api.js +2 -1
- package/src/loaders/api/apiAsync.js +1 -1
- package/src/loaders/configure/configure.js +4 -1
- package/src/loaders/features/enabled-features.js +1 -1
- package/src/loaders/micro-agent.js +4 -1
- package/dist/cjs/common/config/config.js +0 -76
- package/dist/cjs/common/config/state/originals.js +0 -8
- package/dist/cjs/common/wrap/index.js +0 -61
- package/dist/esm/common/config/config.js +0 -11
- package/dist/esm/common/config/state/originals.js +0 -2
- package/dist/esm/common/wrap/index.js +0 -13
- package/dist/types/common/config/config.d.ts +0 -13
- package/dist/types/common/config/config.d.ts.map +0 -1
- package/dist/types/common/config/state/configurable.d.ts.map +0 -1
- package/dist/types/common/config/state/info.d.ts.map +0 -1
- package/dist/types/common/config/state/init.d.ts.map +0 -1
- package/dist/types/common/config/state/loader-config.d.ts.map +0 -1
- package/dist/types/common/config/state/originals.d.ts +0 -2
- package/dist/types/common/config/state/originals.d.ts.map +0 -1
- package/dist/types/common/config/state/runtime.d.ts.map +0 -1
- package/dist/types/common/wrap/index.d.ts +0 -10
- package/dist/types/common/wrap/index.d.ts.map +0 -1
- package/src/common/config/__mocks__/config.js +0 -11
- package/src/common/config/config.js +0 -12
- package/src/common/config/state/originals.js +0 -3
- package/src/common/wrap/index.js +0 -16
- /package/dist/types/common/config/{state/configurable.d.ts → configurable.d.ts} +0 -0
- /package/dist/types/common/config/{state/info.d.ts → info.d.ts} +0 -0
- /package/dist/types/common/config/{state/init.d.ts → init.d.ts} +0 -0
- /package/dist/types/common/config/{state/loader-config.d.ts → loader-config.d.ts} +0 -0
- /package/dist/types/common/config/{state/runtime.d.ts → runtime.d.ts} +0 -0
|
@@ -8,7 +8,8 @@ var _belSerializer = require("../../../common/serialize/bel-serializer");
|
|
|
8
8
|
var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
|
|
9
9
|
var _registerHandler = require("../../../common/event-emitter/register-handler");
|
|
10
10
|
var _handle = require("../../../common/event-emitter/handle");
|
|
11
|
-
var
|
|
11
|
+
var _info = require("../../../common/config/info");
|
|
12
|
+
var _init = require("../../../common/config/init");
|
|
12
13
|
var _constants = require("../constants");
|
|
13
14
|
var _features = require("../../../loaders/features/features");
|
|
14
15
|
var _aggregateBase = require("../../utils/aggregate-base");
|
|
@@ -22,32 +23,29 @@ var _timeToFirstByte = require("../../../common/vitals/time-to-first-byte");
|
|
|
22
23
|
var _longTask = require("../../../common/vitals/long-task");
|
|
23
24
|
var _pageVisibility = require("../../../common/window/page-visibility");
|
|
24
25
|
var _constants2 = require("../../../common/vitals/constants");
|
|
26
|
+
var _eventBuffer = require("../../utils/event-buffer");
|
|
25
27
|
/*
|
|
26
28
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
27
29
|
* SPDX-License-Identifier: Apache-2.0
|
|
28
30
|
*/
|
|
29
31
|
|
|
30
32
|
class Aggregate extends _aggregateBase.AggregateBase {
|
|
31
|
-
static featureName =
|
|
32
|
-
#handleVitalMetric =
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
} = _ref;
|
|
33
|
+
static featureName = _constants.FEATURE_NAME;
|
|
34
|
+
#handleVitalMetric = ({
|
|
35
|
+
name,
|
|
36
|
+
value,
|
|
37
|
+
attrs
|
|
38
|
+
}) => {
|
|
38
39
|
this.addTiming(name, value, attrs);
|
|
39
40
|
};
|
|
40
41
|
constructor(agentIdentifier, aggregator) {
|
|
41
|
-
var _this;
|
|
42
42
|
super(agentIdentifier, aggregator, _constants.FEATURE_NAME);
|
|
43
|
-
|
|
44
|
-
this.timings = [];
|
|
45
|
-
this.timingsSent = [];
|
|
43
|
+
this.timings = new _eventBuffer.EventBuffer();
|
|
46
44
|
this.curSessEndRecorded = false;
|
|
47
|
-
if ((0,
|
|
45
|
+
if ((0, _init.getConfigurationValue)(this.agentIdentifier, 'page_view_timing.long_task') === true) _longTask.longTask.subscribe(this.#handleVitalMetric);
|
|
48
46
|
(0, _registerHandler.registerHandler)('docHidden', msTimestamp => this.endCurrentSession(msTimestamp), this.featureName, this.ee);
|
|
49
47
|
(0, _registerHandler.registerHandler)('winPagehide', msTimestamp => this.recordPageUnload(msTimestamp), this.featureName, this.ee);
|
|
50
|
-
const harvestTimeSeconds = (0,
|
|
48
|
+
const harvestTimeSeconds = (0, _init.getConfigurationValue)(this.agentIdentifier, 'page_view_timing.harvestTimeSeconds') || 30;
|
|
51
49
|
this.waitForFlags([]).then(() => {
|
|
52
50
|
/* It's important that CWV api, like "onLCP", is called before the **scheduler** is initialized. The reason is because they listen to the same
|
|
53
51
|
on vis change or pagehide events, and we'd want ex. onLCP to record the timing (win the race) before we try to send "final harvest". */
|
|
@@ -56,10 +54,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
56
54
|
_firstInputDelay.firstInputDelay.subscribe(this.#handleVitalMetric);
|
|
57
55
|
_largestContentfulPaint.largestContentfulPaint.subscribe(this.#handleVitalMetric);
|
|
58
56
|
_interactionToNextPaint.interactionToNextPaint.subscribe(this.#handleVitalMetric);
|
|
59
|
-
_timeToFirstByte.timeToFirstByte.subscribe(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
} = _ref2;
|
|
57
|
+
_timeToFirstByte.timeToFirstByte.subscribe(({
|
|
58
|
+
attrs
|
|
59
|
+
}) => {
|
|
63
60
|
this.addTiming('load', Math.round(attrs.navigationEntry.loadEventEnd));
|
|
64
61
|
});
|
|
65
62
|
(0, _pageVisibility.subscribeToVisibilityChange)(() => {
|
|
@@ -76,12 +73,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
76
73
|
}, true); // CLS node should only reports on vis change rather than on every change
|
|
77
74
|
|
|
78
75
|
const scheduler = new _harvestScheduler.HarvestScheduler('events', {
|
|
79
|
-
onFinished:
|
|
80
|
-
|
|
81
|
-
},
|
|
82
|
-
getPayload: function () {
|
|
83
|
-
return _this.prepareHarvest(...arguments);
|
|
84
|
-
}
|
|
76
|
+
onFinished: (...args) => this.onHarvestFinished(...args),
|
|
77
|
+
getPayload: (...args) => this.prepareHarvest(...args)
|
|
85
78
|
}, this);
|
|
86
79
|
scheduler.startTimer(harvestTimeSeconds);
|
|
87
80
|
this.drain();
|
|
@@ -129,7 +122,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
129
122
|
if (name !== _constants2.VITAL_NAMES.CUMULATIVE_LAYOUT_SHIFT && _cumulativeLayoutShift.cumulativeLayoutShift.current.value >= 0) {
|
|
130
123
|
attrs.cls = _cumulativeLayoutShift.cumulativeLayoutShift.current.value;
|
|
131
124
|
}
|
|
132
|
-
this.timings.
|
|
125
|
+
this.timings.add({
|
|
133
126
|
name,
|
|
134
127
|
value,
|
|
135
128
|
attrs
|
|
@@ -137,17 +130,13 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
137
130
|
(0, _handle.handle)('pvtAdded', [name, value, attrs], undefined, _features.FEATURE_NAMES.sessionTrace, this.ee);
|
|
138
131
|
}
|
|
139
132
|
onHarvestFinished(result) {
|
|
140
|
-
if (result.retry && this.
|
|
141
|
-
this.timings.unshift(...this.timingsSent);
|
|
142
|
-
this.timingsSent = [];
|
|
143
|
-
}
|
|
133
|
+
if (result.retry && this.timings.held.hasData) this.timings.unhold();else this.timings.held.clear();
|
|
144
134
|
}
|
|
145
135
|
appendGlobalCustomAttributes(timing) {
|
|
146
136
|
var timingAttributes = timing.attrs || {};
|
|
147
|
-
var customAttributes = (0,
|
|
137
|
+
var customAttributes = (0, _info.getInfo)(this.agentIdentifier).jsAttributes || {};
|
|
148
138
|
var reservedAttributes = ['size', 'eid', 'cls', 'type', 'fid', 'elTag', 'elUrl', 'net-type', 'net-etype', 'net-rtt', 'net-dlink'];
|
|
149
|
-
Object.entries(customAttributes || {}).forEach(
|
|
150
|
-
let [key, val] = _ref3;
|
|
139
|
+
Object.entries(customAttributes || {}).forEach(([key, val]) => {
|
|
151
140
|
if (reservedAttributes.indexOf(key) < 0) {
|
|
152
141
|
timingAttributes[key] = val;
|
|
153
142
|
}
|
|
@@ -156,14 +145,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
156
145
|
|
|
157
146
|
// serialize and return current timing data, clear and save current data for retry
|
|
158
147
|
prepareHarvest(options) {
|
|
159
|
-
if (this.timings.
|
|
160
|
-
var payload = this.getPayload(this.timings);
|
|
161
|
-
if (options.retry)
|
|
162
|
-
for (var i = 0; i < this.timings.length; i++) {
|
|
163
|
-
this.timingsSent.push(this.timings[i]);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
this.timings = [];
|
|
148
|
+
if (!this.timings.hasData) return;
|
|
149
|
+
var payload = this.getPayload(this.timings.buffer);
|
|
150
|
+
if (options.retry) this.timings.hold();else this.timings.clear();
|
|
167
151
|
return {
|
|
168
152
|
body: {
|
|
169
153
|
e: payload
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.Instrument = void 0;
|
|
6
|
+
exports.PageViewTiming = exports.Instrument = void 0;
|
|
7
7
|
var _handle = require("../../../common/event-emitter/handle");
|
|
8
8
|
var _pageVisibility = require("../../../common/window/page-visibility");
|
|
9
9
|
var _eventListenerOpts = require("../../../common/event-listener/event-listener-opts");
|
|
@@ -17,9 +17,8 @@ var _now = require("../../../common/timing/now");
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
class Instrument extends _instrumentBase.InstrumentBase {
|
|
20
|
-
static featureName =
|
|
21
|
-
constructor(agentIdentifier, aggregator) {
|
|
22
|
-
let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
20
|
+
static featureName = _constants.FEATURE_NAME;
|
|
21
|
+
constructor(agentIdentifier, aggregator, auto = true) {
|
|
23
22
|
super(agentIdentifier, aggregator, _constants.FEATURE_NAME, auto);
|
|
24
23
|
if (!_runtime.isBrowserScope) return; // CWV is irrelevant outside web context
|
|
25
24
|
|
|
@@ -31,4 +30,5 @@ class Instrument extends _instrumentBase.InstrumentBase {
|
|
|
31
30
|
this.importAggregator();
|
|
32
31
|
}
|
|
33
32
|
}
|
|
34
|
-
exports.Instrument = Instrument;
|
|
33
|
+
exports.Instrument = Instrument;
|
|
34
|
+
const PageViewTiming = exports.PageViewTiming = Instrument;
|
|
@@ -7,12 +7,14 @@ exports.Aggregate = void 0;
|
|
|
7
7
|
var _registerHandler = require("../../../common/event-emitter/register-handler");
|
|
8
8
|
var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
|
|
9
9
|
var _constants = require("../constants");
|
|
10
|
-
var
|
|
10
|
+
var _info = require("../../../common/config/info");
|
|
11
|
+
var _init = require("../../../common/config/init");
|
|
12
|
+
var _runtime = require("../../../common/config/runtime");
|
|
11
13
|
var _aggregateBase = require("../../utils/aggregate-base");
|
|
12
14
|
var _sharedChannel = require("../../../common/constants/shared-channel");
|
|
13
15
|
var _encode = require("../../../common/url/encode");
|
|
14
16
|
var _console = require("../../../common/util/console");
|
|
15
|
-
var
|
|
17
|
+
var _runtime2 = require("../../../common/constants/runtime");
|
|
16
18
|
var _constants2 = require("../../metrics/constants");
|
|
17
19
|
var _handle = require("../../../common/event-emitter/handle");
|
|
18
20
|
var _features = require("../../../loaders/features/features");
|
|
@@ -23,26 +25,23 @@ var _stylesheetEvaluator = require("../shared/stylesheet-evaluator");
|
|
|
23
25
|
var _drain = require("../../../common/drain/drain");
|
|
24
26
|
var _now = require("../../../common/timing/now");
|
|
25
27
|
var _utils = require("../shared/utils");
|
|
28
|
+
var _agentConstants = require("../../../common/constants/agent-constants");
|
|
26
29
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
27
30
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } /*
|
|
28
31
|
* Copyright 2023 New Relic Corporation. All rights reserved.
|
|
29
32
|
* SPDX-License-Identifier: Apache-2.0
|
|
30
33
|
*/ /**
|
|
31
34
|
* @file Records, aggregates, and harvests session replay data.
|
|
32
|
-
*
|
|
33
|
-
* NOTE: This code is under development and dormant. It will not download to instrumented pages or record any data.
|
|
34
|
-
* It is not production ready, and is not intended to be imported or implemented in any build of the browser agent until
|
|
35
|
-
* functionality is validated and a full user experience is curated.
|
|
36
35
|
*/
|
|
37
36
|
class Aggregate extends _aggregateBase.AggregateBase {
|
|
38
|
-
static featureName =
|
|
39
|
-
mode =
|
|
37
|
+
static featureName = _constants.FEATURE_NAME;
|
|
38
|
+
mode = _constants3.MODE.OFF;
|
|
40
39
|
|
|
41
40
|
// pass the recorder into the aggregator
|
|
42
41
|
constructor(agentIdentifier, aggregator, args) {
|
|
43
42
|
super(agentIdentifier, aggregator, _constants.FEATURE_NAME);
|
|
44
43
|
/** The interval to harvest at. This gets overridden if the size of the payload exceeds certain thresholds */
|
|
45
|
-
this.harvestTimeSeconds = (0,
|
|
44
|
+
this.harvestTimeSeconds = (0, _init.getConfigurationValue)(this.agentIdentifier, 'session_replay.harvestTimeSeconds') || 60;
|
|
46
45
|
/** Set once the recorder has fully initialized after flag checks and sampling */
|
|
47
46
|
this.initialized = false;
|
|
48
47
|
/** Set once the feature has been "aborted" to prevent other side-effects from continuing */
|
|
@@ -78,7 +77,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
78
77
|
// if the mode changed on a different tab, it needs to update this instance to match
|
|
79
78
|
const {
|
|
80
79
|
session
|
|
81
|
-
} = (0,
|
|
80
|
+
} = (0, _runtime.getRuntime)(this.agentIdentifier);
|
|
82
81
|
this.mode = session.state.sessionReplayMode;
|
|
83
82
|
if (!this.initialized || this.mode === _constants3.MODE.OFF) return;
|
|
84
83
|
this.recorder?.startRecording();
|
|
@@ -112,9 +111,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
112
111
|
inline_stylesheet,
|
|
113
112
|
inline_images,
|
|
114
113
|
collect_fonts
|
|
115
|
-
} = (0,
|
|
116
|
-
this.waitForFlags(['srs', 'sr']).then(
|
|
117
|
-
let [srMode, entitled] = _ref;
|
|
114
|
+
} = (0, _init.getConfigurationValue)(this.agentIdentifier, 'session_replay');
|
|
115
|
+
this.waitForFlags(['srs', 'sr']).then(([srMode, entitled]) => {
|
|
118
116
|
this.entitled = !!entitled;
|
|
119
117
|
if (!this.entitled) {
|
|
120
118
|
(0, _drain.deregisterDrain)(this.agentIdentifier, this.featureName);
|
|
@@ -148,7 +146,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
148
146
|
handleError(e) {
|
|
149
147
|
if (this.recorder) this.recorder.currentBufferTarget.hasError = true;
|
|
150
148
|
// run once
|
|
151
|
-
if (this.mode === _constants3.MODE.ERROR &&
|
|
149
|
+
if (this.mode === _constants3.MODE.ERROR && _runtime2.globalScope?.document.visibilityState === 'visible') {
|
|
152
150
|
this.switchToFull();
|
|
153
151
|
}
|
|
154
152
|
}
|
|
@@ -188,7 +186,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
188
186
|
const {
|
|
189
187
|
session,
|
|
190
188
|
timeKeeper
|
|
191
|
-
} = (0,
|
|
189
|
+
} = (0, _runtime.getRuntime)(this.agentIdentifier);
|
|
192
190
|
this.timeKeeper = timeKeeper;
|
|
193
191
|
if (this.recorder?.parent.trigger === _constants.TRIGGERS.API && this.recorder?.recording) {
|
|
194
192
|
this.mode = _constants3.MODE.FULL;
|
|
@@ -206,7 +204,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
206
204
|
// Do not change the webpackChunkName or it will break the webpack nrba-chunking plugin
|
|
207
205
|
const {
|
|
208
206
|
Recorder
|
|
209
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require(
|
|
207
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "recorder" */'../shared/recorder')));
|
|
210
208
|
this.recorder = new Recorder(this);
|
|
211
209
|
this.recorder.currentBufferTarget.hasError = this.errorNoticed;
|
|
212
210
|
} catch (err) {
|
|
@@ -245,17 +243,16 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
245
243
|
const {
|
|
246
244
|
gzipSync,
|
|
247
245
|
strToU8
|
|
248
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require(
|
|
246
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "compressor" */'fflate')));
|
|
249
247
|
this.gzipper = gzipSync;
|
|
250
248
|
this.u8 = strToU8;
|
|
251
249
|
} catch (err) {
|
|
252
250
|
// compressor failed to load, but we can still record without compression as a last ditch effort
|
|
253
251
|
}
|
|
254
252
|
}
|
|
255
|
-
prepareHarvest(
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
253
|
+
prepareHarvest({
|
|
254
|
+
opts
|
|
255
|
+
} = {}) {
|
|
259
256
|
if (!this.recorder || !this.timeKeeper?.ready) return;
|
|
260
257
|
const recorderEvents = this.recorder.getEvents();
|
|
261
258
|
// get the event type and use that to trigger another harvest if needed
|
|
@@ -268,11 +265,10 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
268
265
|
(0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['SessionReplay/Harvest/Attempts'], undefined, _features.FEATURE_NAMES.metrics, this.ee);
|
|
269
266
|
let len = 0;
|
|
270
267
|
if (!!this.gzipper && !!this.u8) {
|
|
271
|
-
payload.body = this.gzipper(this.u8("[".concat(payload.body.map(
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
} = _ref2;
|
|
268
|
+
payload.body = this.gzipper(this.u8("[".concat(payload.body.map(({
|
|
269
|
+
__serialized,
|
|
270
|
+
...e
|
|
271
|
+
}) => {
|
|
276
272
|
if (e.__newrelic && __serialized) return __serialized;
|
|
277
273
|
const output = {
|
|
278
274
|
...e
|
|
@@ -286,11 +282,10 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
286
282
|
len = payload.body.length;
|
|
287
283
|
this.scheduler.opts.gzip = true;
|
|
288
284
|
} else {
|
|
289
|
-
payload.body = payload.body.map(
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
} = _ref3;
|
|
285
|
+
payload.body = payload.body.map(({
|
|
286
|
+
__serialized,
|
|
287
|
+
...node
|
|
288
|
+
}) => {
|
|
294
289
|
if (node.__newrelic) return node;
|
|
295
290
|
const output = {
|
|
296
291
|
...node
|
|
@@ -302,14 +297,14 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
302
297
|
len = (0, _stringify.stringify)(payload.body).length;
|
|
303
298
|
this.scheduler.opts.gzip = false;
|
|
304
299
|
}
|
|
305
|
-
if (len >
|
|
300
|
+
if (len > _agentConstants.MAX_PAYLOAD_SIZE) {
|
|
306
301
|
this.abort(_constants.ABORT_REASONS.TOO_BIG, len);
|
|
307
302
|
return;
|
|
308
303
|
}
|
|
309
304
|
// TODO -- Gracefully handle the buffer for retries.
|
|
310
305
|
const {
|
|
311
306
|
session
|
|
312
|
-
} = (0,
|
|
307
|
+
} = (0, _runtime.getRuntime)(this.agentIdentifier);
|
|
313
308
|
if (!session.state.sessionReplaySentFirstChunk) this.syncWithSessionManager({
|
|
314
309
|
sessionReplaySentFirstChunk: true
|
|
315
310
|
});
|
|
@@ -325,8 +320,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
325
320
|
getHarvestContents(recorderEvents) {
|
|
326
321
|
recorderEvents ??= this.recorder.getEvents();
|
|
327
322
|
let events = recorderEvents.events;
|
|
328
|
-
const agentRuntime = (0,
|
|
329
|
-
const info = (0,
|
|
323
|
+
const agentRuntime = (0, _runtime.getRuntime)(this.agentIdentifier);
|
|
324
|
+
const info = (0, _info.getInfo)(this.agentIdentifier);
|
|
330
325
|
const endUserId = info.jsAttributes?.['enduser.id'];
|
|
331
326
|
|
|
332
327
|
// do not let the first node be a full snapshot node, since this NEEDS to be preceded by a meta node
|
|
@@ -349,8 +344,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
349
344
|
const relativeNow = (0, _now.now)();
|
|
350
345
|
const firstEventTimestamp = this.getCorrectedTimestamp(events[0]); // from rrweb node
|
|
351
346
|
const lastEventTimestamp = this.getCorrectedTimestamp(events[events.length - 1]); // from rrweb node
|
|
352
|
-
|
|
353
|
-
const
|
|
347
|
+
// from rrweb node || from when the harvest cycle started
|
|
348
|
+
const firstTimestamp = firstEventTimestamp || Math.floor(this.timeKeeper.correctAbsoluteTimestamp(this.timeKeeper.correctAbsoluteTimestamp(recorderEvents.cycleTimestamp)));
|
|
349
|
+
const lastTimestamp = lastEventTimestamp || Math.floor(this.timeKeeper.correctAbsoluteTimestamp(this.timeKeeper.convertRelativeTimestamp(relativeNow)));
|
|
354
350
|
const agentMetadata = agentRuntime.appMetadata?.agents?.[0] || {};
|
|
355
351
|
return {
|
|
356
352
|
qs: {
|
|
@@ -387,7 +383,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
387
383
|
'payload.type': recorderEvents.type,
|
|
388
384
|
// customer-defined data should go last so that if it exceeds the query param padding limit it will be truncated instead of important attrs
|
|
389
385
|
...(endUserId && {
|
|
390
|
-
'enduser.id': endUserId
|
|
386
|
+
'enduser.id': this.obfuscator.obfuscateString(endUserId)
|
|
391
387
|
})
|
|
392
388
|
// The Query Param is being arbitrarily limited in length here. It is also applied when estimating the size of the payload in getPayloadSize()
|
|
393
389
|
}, _constants.QUERY_PARAM_PADDING).substring(1) // remove the leading '&'
|
|
@@ -418,9 +414,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
418
414
|
}
|
|
419
415
|
|
|
420
416
|
/** Abort the feature, once aborted it will not resume */
|
|
421
|
-
abort() {
|
|
422
|
-
let reason = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
423
|
-
let data = arguments.length > 1 ? arguments[1] : undefined;
|
|
417
|
+
abort(reason = {}, data) {
|
|
424
418
|
(0, _console.warn)(33, reason.message);
|
|
425
419
|
(0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ["SessionReplay/Abort/".concat(reason.sm), data], undefined, _features.FEATURE_NAMES.metrics, this.ee);
|
|
426
420
|
this.blocked = true;
|
|
@@ -433,11 +427,10 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
433
427
|
this.ee.emit('REPLAY_ABORTED');
|
|
434
428
|
while (this.recorder?.getEvents().events.length) this.recorder?.clearBuffer?.();
|
|
435
429
|
}
|
|
436
|
-
syncWithSessionManager() {
|
|
437
|
-
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
430
|
+
syncWithSessionManager(state = {}) {
|
|
438
431
|
const {
|
|
439
432
|
session
|
|
440
|
-
} = (0,
|
|
433
|
+
} = (0, _runtime.getRuntime)(this.agentIdentifier);
|
|
441
434
|
session.write(state);
|
|
442
435
|
}
|
|
443
436
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.TRIGGERS = exports.SR_EVENT_EMITTER_TYPES = exports.RRWEB_EVENT_TYPES = exports.QUERY_PARAM_PADDING = exports.
|
|
6
|
+
exports.TRIGGERS = exports.SR_EVENT_EMITTER_TYPES = exports.RRWEB_EVENT_TYPES = exports.QUERY_PARAM_PADDING = exports.FEATURE_NAME = exports.CHECKOUT_MS = exports.AVG_COMPRESSION = exports.ABORT_REASONS = void 0;
|
|
7
7
|
var _constants = require("../../common/session/constants");
|
|
8
8
|
var _features = require("../../loaders/features/features");
|
|
9
9
|
const FEATURE_NAME = exports.FEATURE_NAME = _features.FEATURE_NAMES.sessionReplay;
|
|
@@ -22,10 +22,6 @@ const RRWEB_EVENT_TYPES = exports.RRWEB_EVENT_TYPES = {
|
|
|
22
22
|
Meta: 4,
|
|
23
23
|
Custom: 5
|
|
24
24
|
};
|
|
25
|
-
/** Vortex caps payload sizes at 1MB */
|
|
26
|
-
const MAX_PAYLOAD_SIZE = exports.MAX_PAYLOAD_SIZE = 1000000;
|
|
27
|
-
/** Unloading caps around 64kb */
|
|
28
|
-
const IDEAL_PAYLOAD_SIZE = exports.IDEAL_PAYLOAD_SIZE = 64000;
|
|
29
25
|
/** Interval between forcing new full snapshots -- 15 seconds in error mode (x2), 5 minutes in full mode */
|
|
30
26
|
const CHECKOUT_MS = exports.CHECKOUT_MS = {
|
|
31
27
|
[_constants.MODE.ERROR]: 15000,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.Instrument = void 0;
|
|
6
|
+
exports.SessionReplay = exports.Instrument = void 0;
|
|
7
7
|
var _handle = require("../../../common/event-emitter/handle");
|
|
8
8
|
var _constants = require("../../../common/session/constants");
|
|
9
9
|
var _instrumentBase = require("../../utils/instrument-base");
|
|
@@ -15,16 +15,11 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
15
15
|
* SPDX-License-Identifier: Apache-2.0
|
|
16
16
|
*/ /**
|
|
17
17
|
* @file Primes the Session Replay feature for lazy loading.
|
|
18
|
-
*
|
|
19
|
-
* NOTE: This code is under development and dormant. It will not download to instrumented pages or record any data.
|
|
20
|
-
* It is not production ready, and is not intended to be imported or implemented in any build of the browser agent until
|
|
21
|
-
* functionality is validated and a full user experience is curated.
|
|
22
18
|
*/
|
|
23
19
|
class Instrument extends _instrumentBase.InstrumentBase {
|
|
24
|
-
static featureName =
|
|
20
|
+
static featureName = _constants2.FEATURE_NAME;
|
|
25
21
|
#mode;
|
|
26
|
-
constructor(agentIdentifier, aggregator) {
|
|
27
|
-
let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
22
|
+
constructor(agentIdentifier, aggregator, auto = true) {
|
|
28
23
|
super(agentIdentifier, aggregator, _constants2.FEATURE_NAME, auto);
|
|
29
24
|
let session;
|
|
30
25
|
this.replayRunning = false;
|
|
@@ -79,7 +74,7 @@ class Instrument extends _instrumentBase.InstrumentBase {
|
|
|
79
74
|
try {
|
|
80
75
|
const {
|
|
81
76
|
Recorder
|
|
82
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require(
|
|
77
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "recorder" */'../shared/recorder')));
|
|
83
78
|
|
|
84
79
|
// If startReplay() has been used by this point, we must record in full mode regardless of session preload:
|
|
85
80
|
// Note: recorder starts here with w/e the mode is at this time, but this may be changed later (see #apiStartOrRestartReplay else-case)
|
|
@@ -121,4 +116,5 @@ class Instrument extends _instrumentBase.InstrumentBase {
|
|
|
121
116
|
}
|
|
122
117
|
}
|
|
123
118
|
}
|
|
124
|
-
exports.Instrument = Instrument;
|
|
119
|
+
exports.Instrument = Instrument;
|
|
120
|
+
const SessionReplay = exports.SessionReplay = Instrument;
|
|
@@ -4,30 +4,35 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.RecorderEvents = void 0;
|
|
7
|
+
var _eventBuffer = require("../../utils/event-buffer");
|
|
7
8
|
class RecorderEvents {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/** Payload metadata -- Should indicate when a replay blob started recording. Resets each time a harvest occurs.
|
|
9
|
+
/** The buffer to hold recorder event nodes */
|
|
10
|
+
#events = new _eventBuffer.EventBuffer(Infinity);
|
|
11
|
+
/** Payload metadata -- Should indicate when a replay blob started recording. Resets each time a harvest occurs.
|
|
12
12
|
* cycle timestamps are used as fallbacks if event timestamps cannot be used
|
|
13
13
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
/** Payload metadata -- Denotes whether all stylesheet elements were able to be inlined */
|
|
27
|
-
this.inlinedAllStylesheets = true;
|
|
28
|
-
}
|
|
14
|
+
cycleTimestamp = Date.now();
|
|
15
|
+
/** Payload metadata -- Should indicate that the payload being sent has a full DOM snapshot. This can happen
|
|
16
|
+
* -- When the recording library begins recording, it starts by taking a DOM snapshot
|
|
17
|
+
* -- When visibility changes from "hidden" -> "visible", it must capture a full snapshot for the replay to work correctly across tabs
|
|
18
|
+
*/
|
|
19
|
+
hasSnapshot = false;
|
|
20
|
+
/** Payload metadata -- Should indicate that the payload being sent has a meta node. The meta node should always precede a snapshot node. */
|
|
21
|
+
hasMeta = false;
|
|
22
|
+
/** Payload metadata -- Should indicate that the payload being sent contains an error. Used for query/filter purposes in UI */
|
|
23
|
+
hasError = false;
|
|
24
|
+
/** Payload metadata -- Denotes whether all stylesheet elements were able to be inlined */
|
|
25
|
+
inlinedAllStylesheets = true;
|
|
29
26
|
add(event) {
|
|
30
|
-
this
|
|
27
|
+
this.#events.add(event);
|
|
28
|
+
}
|
|
29
|
+
get events() {
|
|
30
|
+
return this.#events.buffer;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** A value which increments with every new mutation node reported. Resets after a harvest is sent */
|
|
34
|
+
get payloadBytesEstimation() {
|
|
35
|
+
return this.#events.bytes;
|
|
31
36
|
}
|
|
32
37
|
}
|
|
33
38
|
exports.RecorderEvents = RecorderEvents;
|
|
@@ -7,7 +7,7 @@ exports.Recorder = void 0;
|
|
|
7
7
|
var _rrweb = require("rrweb");
|
|
8
8
|
var _stringify = require("../../../common/util/stringify");
|
|
9
9
|
var _constants = require("../constants");
|
|
10
|
-
var
|
|
10
|
+
var _init = require("../../../common/config/init");
|
|
11
11
|
var _recorderEvents = require("./recorder-events");
|
|
12
12
|
var _constants2 = require("../../../common/session/constants");
|
|
13
13
|
var _stylesheetEvaluator = require("./stylesheet-evaluator");
|
|
@@ -15,6 +15,7 @@ var _handle = require("../../../common/event-emitter/handle");
|
|
|
15
15
|
var _constants3 = require("../../metrics/constants");
|
|
16
16
|
var _features = require("../../../loaders/features/features");
|
|
17
17
|
var _utils = require("./utils");
|
|
18
|
+
var _agentConstants = require("../../../common/constants/agent-constants");
|
|
18
19
|
class Recorder {
|
|
19
20
|
/** Each page mutation or event will be stored (raw) in this array. This array will be cleared on each harvest */
|
|
20
21
|
#events;
|
|
@@ -37,17 +38,21 @@ class Recorder {
|
|
|
37
38
|
/** The parent class that instantiated the recorder */
|
|
38
39
|
this.parent = parent;
|
|
39
40
|
/** Config to inform to inline stylesheet contents (true default) */
|
|
40
|
-
this.shouldInlineStylesheets = (0,
|
|
41
|
+
this.shouldInlineStylesheets = (0, _init.getConfigurationValue)(this.parent.agentIdentifier, 'session_replay.inline_stylesheet');
|
|
41
42
|
/** A flag that can be set to false by failing conversions to stop the fetching process */
|
|
42
|
-
this.shouldFix = this.shouldInlineStylesheets && (0,
|
|
43
|
+
this.shouldFix = this.shouldInlineStylesheets && (0, _init.getConfigurationValue)(this.parent.agentIdentifier, 'session_replay.fix_stylesheets');
|
|
43
44
|
/** The method to stop recording. This defaults to a noop, but is overwritten once the recording library is imported and initialized */
|
|
44
45
|
this.stopRecording = () => {/* no-op until set by rrweb initializer */};
|
|
45
46
|
}
|
|
46
47
|
getEvents() {
|
|
47
|
-
if (this.#preloaded[0]?.events.length)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
if (this.#preloaded[0]?.events.length) {
|
|
49
|
+
return {
|
|
50
|
+
...this.#preloaded[0],
|
|
51
|
+
events: this.#preloaded[0].events,
|
|
52
|
+
payloadBytesEstimation: this.#preloaded[0].payloadBytesEstimation,
|
|
53
|
+
type: 'preloaded'
|
|
54
|
+
};
|
|
55
|
+
}
|
|
51
56
|
return {
|
|
52
57
|
events: [...this.#backloggedEvents.events, ...this.#events.events].filter(x => x),
|
|
53
58
|
type: 'standard',
|
|
@@ -80,7 +85,7 @@ class Recorder {
|
|
|
80
85
|
inline_stylesheet,
|
|
81
86
|
inline_images,
|
|
82
87
|
collect_fonts
|
|
83
|
-
} = (0,
|
|
88
|
+
} = (0, _init.getConfigurationValue)(this.parent.agentIdentifier, 'session_replay');
|
|
84
89
|
const customMasker = (text, element) => {
|
|
85
90
|
if (element?.type?.toLowerCase() !== 'password' && (element?.dataset.nrUnmask !== undefined || element?.classList.contains('nr-unmask'))) return text;
|
|
86
91
|
return '*'.repeat(text.length);
|
|
@@ -108,7 +113,8 @@ class Recorder {
|
|
|
108
113
|
this.parent.ee.emit('internal-error', [err]);
|
|
109
114
|
/** returning true informs rrweb to swallow the error instead of throwing it to the window */
|
|
110
115
|
return true;
|
|
111
|
-
}
|
|
116
|
+
},
|
|
117
|
+
recordAfter: 'DOMContentLoaded'
|
|
112
118
|
});
|
|
113
119
|
this.stopRecording = () => {
|
|
114
120
|
this.recording = false;
|
|
@@ -186,11 +192,10 @@ class Recorder {
|
|
|
186
192
|
this.currentBufferTarget.hasSnapshot = true;
|
|
187
193
|
}
|
|
188
194
|
this.currentBufferTarget.add(event);
|
|
189
|
-
this.currentBufferTarget.payloadBytesEstimation += eventBytes;
|
|
190
195
|
|
|
191
196
|
// We are making an effort to try to keep payloads manageable for unloading. If they reach the unload limit before their interval,
|
|
192
197
|
// it will send immediately. This often happens on the first snapshot, which can be significantly larger than the other payloads.
|
|
193
|
-
if ((event.type === _constants.RRWEB_EVENT_TYPES.FullSnapshot && this.currentBufferTarget.hasMeta || payloadSize >
|
|
198
|
+
if ((event.type === _constants.RRWEB_EVENT_TYPES.FullSnapshot && this.currentBufferTarget.hasMeta || payloadSize > _agentConstants.IDEAL_PAYLOAD_SIZE) && this.parent.mode === _constants2.MODE.FULL) {
|
|
194
199
|
// if we've made it to the ideal size of ~64kb before the interval timer, we should send early.
|
|
195
200
|
if (this.parent.scheduler) {
|
|
196
201
|
this.parent.scheduler.runHarvest();
|
|
@@ -215,8 +220,7 @@ class Recorder {
|
|
|
215
220
|
}
|
|
216
221
|
|
|
217
222
|
/** Estimate the payload size */
|
|
218
|
-
getPayloadSize() {
|
|
219
|
-
let newBytes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
223
|
+
getPayloadSize(newBytes = 0) {
|
|
220
224
|
// the query param padding constant gives us some padding for the other metadata to be safely injected
|
|
221
225
|
return this.estimateCompression(this.currentBufferTarget.payloadBytesEstimation + newBytes) + _constants.QUERY_PARAM_PADDING;
|
|
222
226
|
}
|
|
@@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.stylesheetEvaluator = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _nreum = require("../../../common/window/nreum");
|
|
8
8
|
var _runtime = require("../../../common/constants/runtime");
|
|
9
9
|
class StylesheetEvaluator {
|
|
10
|
-
#evaluated =
|
|
10
|
+
#evaluated = new WeakSet();
|
|
11
11
|
#fetchProms = [];
|
|
12
12
|
/**
|
|
13
13
|
* Flipped to true if stylesheets that cannot be natively inlined are detected by the stylesheetEvaluator class
|
|
@@ -62,7 +62,7 @@ class StylesheetEvaluator {
|
|
|
62
62
|
async #fetchAndOverride(target) {
|
|
63
63
|
if (!target?.href) return;
|
|
64
64
|
try {
|
|
65
|
-
const stylesheetContents = await
|
|
65
|
+
const stylesheetContents = await (0, _nreum.gosNREUMOriginals)().o.FETCH.bind(window)(target.href);
|
|
66
66
|
if (!stylesheetContents.ok) {
|
|
67
67
|
this.failedToFix++;
|
|
68
68
|
return;
|
|
@@ -6,18 +6,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.buildNRMetaNode = buildNRMetaNode;
|
|
7
7
|
exports.hasReplayPrerequisite = hasReplayPrerequisite;
|
|
8
8
|
exports.isPreloadAllowed = isPreloadAllowed;
|
|
9
|
-
var
|
|
9
|
+
var _nreum = require("../../../common/window/nreum");
|
|
10
|
+
var _init = require("../../../common/config/init");
|
|
10
11
|
var _featureGates = require("../../utils/feature-gates");
|
|
11
12
|
var _runtime = require("../../../common/constants/runtime");
|
|
12
13
|
function hasReplayPrerequisite(agentId) {
|
|
13
|
-
return !!
|
|
14
|
+
return !!(0, _nreum.gosNREUMOriginals)().o.MO &&
|
|
14
15
|
// Session Replay cannot work without Mutation Observer
|
|
15
16
|
(0, _featureGates.canEnableSessionTracking)(agentId) &&
|
|
16
17
|
// requires session tracking to be running (hence "session" replay...)
|
|
17
|
-
(0,
|
|
18
|
+
(0, _init.getConfigurationValue)(agentId, 'session_trace.enabled') === true; // Session Replay as of now is tightly coupled with Session Trace in the UI
|
|
18
19
|
}
|
|
19
20
|
function isPreloadAllowed(agentId) {
|
|
20
|
-
return (0,
|
|
21
|
+
return (0, _init.getConfigurationValue)(agentId, 'session_replay.preload') === true && hasReplayPrerequisite(agentId);
|
|
21
22
|
}
|
|
22
23
|
function buildNRMetaNode(timestamp, timeKeeper) {
|
|
23
24
|
const correctedTimestamp = timeKeeper.correctAbsoluteTimestamp(timestamp);
|