@newrelic/browser-agent 1.263.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 +32 -0
- package/README.md +2 -2
- package/dist/cjs/cdn/experimental.js +3 -7
- package/dist/cjs/cdn/pro.js +2 -2
- package/dist/cjs/cdn/spa.js +2 -2
- package/dist/cjs/common/aggregate/aggregator.js +2 -3
- 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} +11 -8
- 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/constants/runtime.js +1 -3
- 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 +12 -18
- 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 +30 -57
- package/dist/cjs/common/serialize/bel-serializer.js +6 -11
- package/dist/cjs/common/session/session-entity.js +10 -13
- 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 +3 -7
- 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 -21
- 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 +5 -7
- 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 +19 -22
- 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 +14 -12
- package/dist/cjs/features/generic_events/aggregate/index.js +128 -0
- package/dist/cjs/features/generic_events/constants.js +10 -0
- package/dist/cjs/features/generic_events/index.js +12 -0
- package/dist/cjs/features/generic_events/instrument/index.js +27 -0
- package/dist/cjs/features/jserrors/aggregate/index.js +25 -44
- package/dist/cjs/features/jserrors/instrument/index.js +4 -4
- package/dist/cjs/features/logging/aggregate/index.js +33 -36
- package/dist/cjs/features/logging/constants.js +2 -3
- package/dist/cjs/features/logging/instrument/index.js +5 -6
- 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 +34 -17
- 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 +12 -4
- package/dist/cjs/features/page_action/instrument/index.js +14 -10
- package/dist/cjs/features/page_view_event/aggregate/index.js +19 -39
- package/dist/cjs/features/page_view_event/aggregate/initialized-features.js +1 -1
- package/dist/cjs/features/page_view_event/instrument/index.js +4 -4
- package/dist/cjs/features/page_view_timing/aggregate/index.js +23 -39
- package/dist/cjs/features/page_view_timing/instrument/index.js +4 -4
- package/dist/cjs/features/session_replay/aggregate/index.js +35 -42
- package/dist/cjs/features/session_replay/constants.js +1 -5
- package/dist/cjs/features/session_replay/instrument/index.js +5 -9
- 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 +2 -2
- package/dist/cjs/features/session_replay/shared/utils.js +5 -4
- package/dist/cjs/features/session_trace/aggregate/index.js +25 -42
- package/dist/cjs/features/session_trace/aggregate/trace/storage.js +5 -3
- package/dist/cjs/features/session_trace/instrument/index.js +8 -7
- package/dist/cjs/features/soft_navigations/aggregate/ajax-node.js +1 -1
- package/dist/cjs/features/soft_navigations/aggregate/index.js +22 -30
- package/dist/cjs/features/soft_navigations/aggregate/initial-page-load-interaction.js +2 -2
- package/dist/cjs/features/soft_navigations/aggregate/interaction.js +4 -5
- package/dist/cjs/features/soft_navigations/instrument/index.js +14 -13
- package/dist/cjs/features/spa/aggregate/index.js +17 -28
- package/dist/cjs/features/spa/aggregate/interaction.js +7 -6
- package/dist/cjs/features/spa/aggregate/serializer.js +4 -5
- package/dist/cjs/features/spa/constants.js +2 -2
- package/dist/cjs/features/spa/instrument/index.js +20 -19
- package/dist/cjs/features/utils/agent-session.js +6 -4
- package/dist/cjs/features/utils/aggregate-base.js +17 -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 +12 -12
- package/dist/cjs/features/utils/nr1-debugger.js +1 -3
- package/dist/cjs/index.js +21 -0
- package/dist/cjs/loaders/agent-base.js +4 -12
- package/dist/cjs/loaders/agent.js +7 -2
- package/dist/cjs/loaders/api/api.js +23 -35
- package/dist/cjs/loaders/api/apiAsync.js +10 -13
- package/dist/cjs/loaders/browser-agent.js +4 -3
- package/dist/cjs/loaders/configure/configure.js +16 -15
- package/dist/cjs/loaders/features/enabled-features.js +2 -2
- package/dist/cjs/loaders/features/features.js +8 -4
- package/dist/cjs/loaders/micro-agent.js +16 -15
- package/dist/esm/cdn/experimental.js +2 -5
- package/dist/esm/cdn/pro.js +2 -2
- package/dist/esm/cdn/spa.js +2 -2
- package/dist/esm/common/aggregate/aggregator.js +2 -3
- 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} +11 -8
- 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/constants/runtime.js +0 -2
- 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 +12 -18
- 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 +24 -51
- package/dist/esm/common/serialize/bel-serializer.js +6 -11
- package/dist/esm/common/session/session-entity.js +10 -13
- 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 +3 -7
- 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 -21
- 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 +5 -7
- 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 +16 -19
- 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 +10 -8
- package/dist/esm/features/generic_events/aggregate/index.js +120 -0
- package/dist/esm/features/generic_events/constants.js +4 -0
- package/dist/esm/features/generic_events/index.js +1 -0
- package/dist/esm/features/generic_events/instrument/index.js +20 -0
- package/dist/esm/features/jserrors/aggregate/index.js +20 -39
- package/dist/esm/features/jserrors/instrument/index.js +3 -3
- package/dist/esm/features/logging/aggregate/index.js +31 -34
- package/dist/esm/features/logging/constants.js +1 -2
- package/dist/esm/features/logging/instrument/index.js +4 -5
- 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 +28 -11
- 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 +12 -4
- package/dist/esm/features/page_action/instrument/index.js +14 -9
- package/dist/esm/features/page_view_event/aggregate/index.js +17 -37
- package/dist/esm/features/page_view_event/aggregate/initialized-features.js +1 -1
- package/dist/esm/features/page_view_event/instrument/index.js +3 -3
- package/dist/esm/features/page_view_timing/aggregate/index.js +20 -36
- package/dist/esm/features/page_view_timing/instrument/index.js +3 -3
- package/dist/esm/features/session_replay/aggregate/index.js +25 -32
- 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 +5 -8
- 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 +2 -2
- package/dist/esm/features/session_replay/shared/utils.js +3 -2
- package/dist/esm/features/session_trace/aggregate/index.js +20 -37
- package/dist/esm/features/session_trace/aggregate/trace/storage.js +5 -3
- package/dist/esm/features/session_trace/instrument/index.js +5 -4
- package/dist/esm/features/soft_navigations/aggregate/ajax-node.js +1 -1
- package/dist/esm/features/soft_navigations/aggregate/index.js +21 -29
- package/dist/esm/features/soft_navigations/aggregate/initial-page-load-interaction.js +1 -1
- package/dist/esm/features/soft_navigations/aggregate/interaction.js +2 -3
- package/dist/esm/features/soft_navigations/instrument/index.js +11 -10
- package/dist/esm/features/spa/aggregate/index.js +11 -22
- package/dist/esm/features/spa/aggregate/interaction.js +6 -5
- package/dist/esm/features/spa/aggregate/serializer.js +2 -3
- package/dist/esm/features/spa/constants.js +2 -2
- package/dist/esm/features/spa/instrument/index.js +12 -11
- package/dist/esm/features/utils/agent-session.js +3 -1
- package/dist/esm/features/utils/aggregate-base.js +16 -9
- 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 +12 -12
- package/dist/esm/features/utils/nr1-debugger.js +1 -3
- package/dist/esm/index.js +3 -0
- package/dist/esm/loaders/agent-base.js +4 -12
- package/dist/esm/loaders/agent.js +7 -2
- package/dist/esm/loaders/api/api.js +18 -30
- package/dist/esm/loaders/api/apiAsync.js +3 -6
- package/dist/esm/loaders/browser-agent.js +3 -2
- package/dist/esm/loaders/configure/configure.js +9 -8
- package/dist/esm/loaders/features/enabled-features.js +1 -1
- package/dist/esm/loaders/features/features.js +8 -4
- package/dist/esm/loaders/micro-agent.js +11 -10
- package/dist/types/common/aggregate/aggregator.d.ts.map +1 -1
- 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/constants/runtime.d.ts +0 -1
- package/dist/types/common/constants/runtime.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/url/encode.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/submit-data.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/{page_action → generic_events}/aggregate/index.d.ts +10 -10
- package/dist/types/features/generic_events/aggregate/index.d.ts.map +1 -0
- package/dist/types/features/generic_events/constants.d.ts +4 -0
- package/dist/types/features/generic_events/constants.d.ts.map +1 -0
- package/dist/types/features/generic_events/index.d.ts +2 -0
- package/dist/types/features/generic_events/index.d.ts.map +1 -0
- package/dist/types/features/generic_events/instrument/index.d.ts +7 -0
- package/dist/types/features/generic_events/instrument/index.d.ts.map +1 -0
- 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 +9 -4
- 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/aggregate/serializer.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/index.d.ts +3 -0
- package/dist/types/loaders/agent-base.d.ts +1 -2
- package/dist/types/loaders/agent-base.d.ts.map +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/browser-agent.d.ts.map +1 -1
- package/dist/types/loaders/configure/configure.d.ts.map +1 -1
- package/dist/types/loaders/features/features.d.ts +1 -0
- package/dist/types/loaders/features/features.d.ts.map +1 -1
- package/dist/types/loaders/micro-agent.d.ts.map +1 -1
- package/package.json +67 -52
- package/src/cdn/experimental.js +2 -4
- package/src/cdn/pro.js +2 -2
- package/src/cdn/spa.js +2 -2
- package/src/common/aggregate/aggregator.js +2 -3
- 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} +7 -6
- 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/constants/runtime.js +0 -2
- package/src/common/drain/drain.js +8 -6
- package/src/common/event-emitter/contextual-ee.js +1 -1
- package/src/common/harvest/harvest.js +10 -24
- package/src/common/serialize/bel-serializer.js +6 -9
- package/src/common/session/session-entity.js +4 -4
- package/src/common/timing/__mocks__/time-keeper.js +6 -2
- package/src/common/timing/time-keeper.js +15 -5
- package/src/common/url/encode.js +2 -3
- 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/submit-data.js +0 -1
- 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 +139 -0
- package/src/features/generic_events/constants.js +5 -0
- package/src/features/generic_events/index.js +1 -0
- package/src/features/generic_events/instrument/index.js +24 -0
- package/src/features/jserrors/aggregate/index.js +18 -9
- 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 +11 -6
- package/src/features/page_view_event/aggregate/index.js +8 -23
- package/src/features/page_view_event/aggregate/initialized-features.js +1 -1
- package/src/features/page_view_event/instrument/index.js +2 -0
- package/src/features/page_view_timing/aggregate/index.js +15 -18
- 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 +12 -20
- package/src/features/spa/aggregate/interaction.js +6 -5
- package/src/features/spa/aggregate/serializer.js +2 -3
- 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 +13 -3
- 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/features/utils/lazy-feature-loader.js +2 -2
- package/src/index.js +3 -0
- package/src/loaders/agent-base.js +2 -6
- package/src/loaders/agent.js +7 -2
- package/src/loaders/api/api.js +3 -2
- package/src/loaders/api/apiAsync.js +2 -2
- package/src/loaders/browser-agent.js +5 -3
- package/src/loaders/configure/configure.js +9 -2
- package/src/loaders/features/enabled-features.js +1 -1
- package/src/loaders/features/features.js +8 -4
- package/src/loaders/micro-agent.js +5 -2
- package/dist/cjs/cdn/polyfills/lite.js +0 -16
- package/dist/cjs/cdn/polyfills/pro.js +0 -21
- package/dist/cjs/cdn/polyfills/spa.js +0 -22
- package/dist/cjs/cdn/polyfills.js +0 -24
- package/dist/cjs/common/config/config.js +0 -76
- package/dist/cjs/common/config/state/originals.js +0 -8
- package/dist/cjs/common/util/map-own.js +0 -31
- package/dist/cjs/common/wrap/index.js +0 -61
- package/dist/cjs/features/page_action/aggregate/index.js +0 -121
- package/dist/esm/cdn/polyfills/lite.js +0 -14
- package/dist/esm/cdn/polyfills/pro.js +0 -19
- package/dist/esm/cdn/polyfills/spa.js +0 -20
- package/dist/esm/cdn/polyfills.js +0 -27
- package/dist/esm/common/config/config.js +0 -11
- package/dist/esm/common/config/state/originals.js +0 -2
- package/dist/esm/common/util/map-own.js +0 -24
- package/dist/esm/common/wrap/index.js +0 -13
- package/dist/esm/features/page_action/aggregate/index.js +0 -114
- package/dist/types/cdn/polyfills/lite.d.ts +0 -2
- package/dist/types/cdn/polyfills/lite.d.ts.map +0 -1
- package/dist/types/cdn/polyfills/pro.d.ts +0 -2
- package/dist/types/cdn/polyfills/pro.d.ts.map +0 -1
- package/dist/types/cdn/polyfills/spa.d.ts +0 -2
- package/dist/types/cdn/polyfills/spa.d.ts.map +0 -1
- package/dist/types/cdn/polyfills.d.ts +0 -2
- package/dist/types/cdn/polyfills.d.ts.map +0 -1
- 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/util/map-own.d.ts +0 -3
- package/dist/types/common/util/map-own.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/dist/types/features/page_action/aggregate/index.d.ts.map +0 -1
- package/src/cdn/polyfills/lite.js +0 -20
- package/src/cdn/polyfills/pro.js +0 -30
- package/src/cdn/polyfills/spa.js +0 -32
- package/src/cdn/polyfills.js +0 -27
- 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/util/map-own.js +0 -22
- package/src/common/wrap/index.js +0 -16
- package/src/features/page_action/aggregate/index.js +0 -114
- /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
|
@@ -4,16 +4,14 @@
|
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* @file Records, aggregates, and harvests session replay data.
|
|
7
|
-
*
|
|
8
|
-
* NOTE: This code is under development and dormant. It will not download to instrumented pages or record any data.
|
|
9
|
-
* It is not production ready, and is not intended to be imported or implemented in any build of the browser agent until
|
|
10
|
-
* functionality is validated and a full user experience is curated.
|
|
11
7
|
*/
|
|
12
8
|
|
|
13
9
|
import { registerHandler } from '../../../common/event-emitter/register-handler';
|
|
14
10
|
import { HarvestScheduler } from '../../../common/harvest/harvest-scheduler';
|
|
15
|
-
import { ABORT_REASONS, FEATURE_NAME,
|
|
16
|
-
import {
|
|
11
|
+
import { ABORT_REASONS, FEATURE_NAME, QUERY_PARAM_PADDING, RRWEB_EVENT_TYPES, SR_EVENT_EMITTER_TYPES, TRIGGERS } from '../constants';
|
|
12
|
+
import { getInfo } from '../../../common/config/info';
|
|
13
|
+
import { getConfigurationValue } from '../../../common/config/init';
|
|
14
|
+
import { getRuntime } from '../../../common/config/runtime';
|
|
17
15
|
import { AggregateBase } from '../../utils/aggregate-base';
|
|
18
16
|
import { sharedChannel } from '../../../common/constants/shared-channel';
|
|
19
17
|
import { obj as encodeObj } from '../../../common/url/encode';
|
|
@@ -29,6 +27,7 @@ import { stylesheetEvaluator } from '../shared/stylesheet-evaluator';
|
|
|
29
27
|
import { deregisterDrain } from '../../../common/drain/drain';
|
|
30
28
|
import { now } from '../../../common/timing/now';
|
|
31
29
|
import { buildNRMetaNode } from '../shared/utils';
|
|
30
|
+
import { MAX_PAYLOAD_SIZE } from '../../../common/constants/agent-constants';
|
|
32
31
|
export class Aggregate extends AggregateBase {
|
|
33
32
|
static featureName = FEATURE_NAME;
|
|
34
33
|
mode = MODE.OFF;
|
|
@@ -108,8 +107,7 @@ export class Aggregate extends AggregateBase {
|
|
|
108
107
|
inline_images,
|
|
109
108
|
collect_fonts
|
|
110
109
|
} = getConfigurationValue(this.agentIdentifier, 'session_replay');
|
|
111
|
-
this.waitForFlags(['srs', 'sr']).then(
|
|
112
|
-
let [srMode, entitled] = _ref;
|
|
110
|
+
this.waitForFlags(['srs', 'sr']).then(([srMode, entitled]) => {
|
|
113
111
|
this.entitled = !!entitled;
|
|
114
112
|
if (!this.entitled) {
|
|
115
113
|
deregisterDrain(this.agentIdentifier, this.featureName);
|
|
@@ -201,7 +199,7 @@ export class Aggregate extends AggregateBase {
|
|
|
201
199
|
// Do not change the webpackChunkName or it will break the webpack nrba-chunking plugin
|
|
202
200
|
const {
|
|
203
201
|
Recorder
|
|
204
|
-
} = await import(
|
|
202
|
+
} = await import(/* webpackChunkName: "recorder" */'../shared/recorder');
|
|
205
203
|
this.recorder = new Recorder(this);
|
|
206
204
|
this.recorder.currentBufferTarget.hasError = this.errorNoticed;
|
|
207
205
|
} catch (err) {
|
|
@@ -240,17 +238,16 @@ export class Aggregate extends AggregateBase {
|
|
|
240
238
|
const {
|
|
241
239
|
gzipSync,
|
|
242
240
|
strToU8
|
|
243
|
-
} = await import(
|
|
241
|
+
} = await import(/* webpackChunkName: "compressor" */'fflate');
|
|
244
242
|
this.gzipper = gzipSync;
|
|
245
243
|
this.u8 = strToU8;
|
|
246
244
|
} catch (err) {
|
|
247
245
|
// compressor failed to load, but we can still record without compression as a last ditch effort
|
|
248
246
|
}
|
|
249
247
|
}
|
|
250
|
-
prepareHarvest(
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
248
|
+
prepareHarvest({
|
|
249
|
+
opts
|
|
250
|
+
} = {}) {
|
|
254
251
|
if (!this.recorder || !this.timeKeeper?.ready) return;
|
|
255
252
|
const recorderEvents = this.recorder.getEvents();
|
|
256
253
|
// get the event type and use that to trigger another harvest if needed
|
|
@@ -263,11 +260,10 @@ export class Aggregate extends AggregateBase {
|
|
|
263
260
|
handle(SUPPORTABILITY_METRIC_CHANNEL, ['SessionReplay/Harvest/Attempts'], undefined, FEATURE_NAMES.metrics, this.ee);
|
|
264
261
|
let len = 0;
|
|
265
262
|
if (!!this.gzipper && !!this.u8) {
|
|
266
|
-
payload.body = this.gzipper(this.u8("[".concat(payload.body.map(
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
} = _ref2;
|
|
263
|
+
payload.body = this.gzipper(this.u8("[".concat(payload.body.map(({
|
|
264
|
+
__serialized,
|
|
265
|
+
...e
|
|
266
|
+
}) => {
|
|
271
267
|
if (e.__newrelic && __serialized) return __serialized;
|
|
272
268
|
const output = {
|
|
273
269
|
...e
|
|
@@ -281,11 +277,10 @@ export class Aggregate extends AggregateBase {
|
|
|
281
277
|
len = payload.body.length;
|
|
282
278
|
this.scheduler.opts.gzip = true;
|
|
283
279
|
} else {
|
|
284
|
-
payload.body = payload.body.map(
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
} = _ref3;
|
|
280
|
+
payload.body = payload.body.map(({
|
|
281
|
+
__serialized,
|
|
282
|
+
...node
|
|
283
|
+
}) => {
|
|
289
284
|
if (node.__newrelic) return node;
|
|
290
285
|
const output = {
|
|
291
286
|
...node
|
|
@@ -344,8 +339,9 @@ export class Aggregate extends AggregateBase {
|
|
|
344
339
|
const relativeNow = now();
|
|
345
340
|
const firstEventTimestamp = this.getCorrectedTimestamp(events[0]); // from rrweb node
|
|
346
341
|
const lastEventTimestamp = this.getCorrectedTimestamp(events[events.length - 1]); // from rrweb node
|
|
347
|
-
|
|
348
|
-
const
|
|
342
|
+
// from rrweb node || from when the harvest cycle started
|
|
343
|
+
const firstTimestamp = firstEventTimestamp || Math.floor(this.timeKeeper.correctAbsoluteTimestamp(this.timeKeeper.correctAbsoluteTimestamp(recorderEvents.cycleTimestamp)));
|
|
344
|
+
const lastTimestamp = lastEventTimestamp || Math.floor(this.timeKeeper.correctAbsoluteTimestamp(this.timeKeeper.convertRelativeTimestamp(relativeNow)));
|
|
349
345
|
const agentMetadata = agentRuntime.appMetadata?.agents?.[0] || {};
|
|
350
346
|
return {
|
|
351
347
|
qs: {
|
|
@@ -382,7 +378,7 @@ export class Aggregate extends AggregateBase {
|
|
|
382
378
|
'payload.type': recorderEvents.type,
|
|
383
379
|
// customer-defined data should go last so that if it exceeds the query param padding limit it will be truncated instead of important attrs
|
|
384
380
|
...(endUserId && {
|
|
385
|
-
'enduser.id': endUserId
|
|
381
|
+
'enduser.id': this.obfuscator.obfuscateString(endUserId)
|
|
386
382
|
})
|
|
387
383
|
// The Query Param is being arbitrarily limited in length here. It is also applied when estimating the size of the payload in getPayloadSize()
|
|
388
384
|
}, QUERY_PARAM_PADDING).substring(1) // remove the leading '&'
|
|
@@ -413,9 +409,7 @@ export class Aggregate extends AggregateBase {
|
|
|
413
409
|
}
|
|
414
410
|
|
|
415
411
|
/** Abort the feature, once aborted it will not resume */
|
|
416
|
-
abort() {
|
|
417
|
-
let reason = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
418
|
-
let data = arguments.length > 1 ? arguments[1] : undefined;
|
|
412
|
+
abort(reason = {}, data) {
|
|
419
413
|
warn(33, reason.message);
|
|
420
414
|
handle(SUPPORTABILITY_METRIC_CHANNEL, ["SessionReplay/Abort/".concat(reason.sm), data], undefined, FEATURE_NAMES.metrics, this.ee);
|
|
421
415
|
this.blocked = true;
|
|
@@ -428,8 +422,7 @@ export class Aggregate extends AggregateBase {
|
|
|
428
422
|
this.ee.emit('REPLAY_ABORTED');
|
|
429
423
|
while (this.recorder?.getEvents().events.length) this.recorder?.clearBuffer?.();
|
|
430
424
|
}
|
|
431
|
-
syncWithSessionManager() {
|
|
432
|
-
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
425
|
+
syncWithSessionManager(state = {}) {
|
|
433
426
|
const {
|
|
434
427
|
session
|
|
435
428
|
} = getRuntime(this.agentIdentifier);
|
|
@@ -16,10 +16,6 @@ export const RRWEB_EVENT_TYPES = {
|
|
|
16
16
|
Meta: 4,
|
|
17
17
|
Custom: 5
|
|
18
18
|
};
|
|
19
|
-
/** Vortex caps payload sizes at 1MB */
|
|
20
|
-
export const MAX_PAYLOAD_SIZE = 1000000;
|
|
21
|
-
/** Unloading caps around 64kb */
|
|
22
|
-
export const IDEAL_PAYLOAD_SIZE = 64000;
|
|
23
19
|
/** Interval between forcing new full snapshots -- 15 seconds in error mode (x2), 5 minutes in full mode */
|
|
24
20
|
export const CHECKOUT_MS = {
|
|
25
21
|
[MODE.ERROR]: 15000,
|
|
@@ -2,11 +2,5 @@
|
|
|
2
2
|
* Copyright 2023 New Relic Corporation. All rights reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
* @file The top-level entry point for the eventual Session Replay feature.
|
|
7
|
-
*
|
|
8
|
-
* NOTE: This code is under development and dormant. It will not download to instrumented pages or record any data.
|
|
9
|
-
* It is not production ready, and is not intended to be imported or implemented in any build of the browser agent until
|
|
10
|
-
* functionality is validated and a full user experience is curated.
|
|
11
|
-
*/
|
|
5
|
+
|
|
12
6
|
export { Instrument as SessionReplay } from './instrument/index';
|
|
@@ -4,11 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* @file Primes the Session Replay feature for lazy loading.
|
|
7
|
-
*
|
|
8
|
-
* NOTE: This code is under development and dormant. It will not download to instrumented pages or record any data.
|
|
9
|
-
* It is not production ready, and is not intended to be imported or implemented in any build of the browser agent until
|
|
10
|
-
* functionality is validated and a full user experience is curated.
|
|
11
7
|
*/
|
|
8
|
+
|
|
12
9
|
import { handle } from '../../../common/event-emitter/handle';
|
|
13
10
|
import { DEFAULT_KEY, MODE, PREFIX } from '../../../common/session/constants';
|
|
14
11
|
import { InstrumentBase } from '../../utils/instrument-base';
|
|
@@ -17,8 +14,7 @@ import { FEATURE_NAME, SR_EVENT_EMITTER_TYPES, TRIGGERS } from '../constants';
|
|
|
17
14
|
export class Instrument extends InstrumentBase {
|
|
18
15
|
static featureName = FEATURE_NAME;
|
|
19
16
|
#mode;
|
|
20
|
-
constructor(agentIdentifier, aggregator) {
|
|
21
|
-
let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
17
|
+
constructor(agentIdentifier, aggregator, auto = true) {
|
|
22
18
|
super(agentIdentifier, aggregator, FEATURE_NAME, auto);
|
|
23
19
|
let session;
|
|
24
20
|
this.replayRunning = false;
|
|
@@ -73,7 +69,7 @@ export class Instrument extends InstrumentBase {
|
|
|
73
69
|
try {
|
|
74
70
|
const {
|
|
75
71
|
Recorder
|
|
76
|
-
} = await import(
|
|
72
|
+
} = await import(/* webpackChunkName: "recorder" */'../shared/recorder');
|
|
77
73
|
|
|
78
74
|
// If startReplay() has been used by this point, we must record in full mode regardless of session preload:
|
|
79
75
|
// Note: recorder starts here with w/e the mode is at this time, but this may be changed later (see #apiStartOrRestartReplay else-case)
|
|
@@ -114,4 +110,5 @@ export class Instrument extends InstrumentBase {
|
|
|
114
110
|
}
|
|
115
111
|
}
|
|
116
112
|
}
|
|
117
|
-
}
|
|
113
|
+
}
|
|
114
|
+
export const SessionReplay = Instrument;
|
|
@@ -1,26 +1,31 @@
|
|
|
1
|
+
import { EventBuffer } from '../../utils/event-buffer';
|
|
1
2
|
export class RecorderEvents {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/** Payload metadata -- Should indicate when a replay blob started recording. Resets each time a harvest occurs.
|
|
3
|
+
/** The buffer to hold recorder event nodes */
|
|
4
|
+
#events = new EventBuffer(Infinity);
|
|
5
|
+
/** Payload metadata -- Should indicate when a replay blob started recording. Resets each time a harvest occurs.
|
|
6
6
|
* cycle timestamps are used as fallbacks if event timestamps cannot be used
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
/** Payload metadata -- Denotes whether all stylesheet elements were able to be inlined */
|
|
21
|
-
this.inlinedAllStylesheets = true;
|
|
22
|
-
}
|
|
8
|
+
cycleTimestamp = Date.now();
|
|
9
|
+
/** Payload metadata -- Should indicate that the payload being sent has a full DOM snapshot. This can happen
|
|
10
|
+
* -- When the recording library begins recording, it starts by taking a DOM snapshot
|
|
11
|
+
* -- When visibility changes from "hidden" -> "visible", it must capture a full snapshot for the replay to work correctly across tabs
|
|
12
|
+
*/
|
|
13
|
+
hasSnapshot = false;
|
|
14
|
+
/** Payload metadata -- Should indicate that the payload being sent has a meta node. The meta node should always precede a snapshot node. */
|
|
15
|
+
hasMeta = false;
|
|
16
|
+
/** Payload metadata -- Should indicate that the payload being sent contains an error. Used for query/filter purposes in UI */
|
|
17
|
+
hasError = false;
|
|
18
|
+
/** Payload metadata -- Denotes whether all stylesheet elements were able to be inlined */
|
|
19
|
+
inlinedAllStylesheets = true;
|
|
23
20
|
add(event) {
|
|
24
|
-
this
|
|
21
|
+
this.#events.add(event);
|
|
22
|
+
}
|
|
23
|
+
get events() {
|
|
24
|
+
return this.#events.buffer;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** A value which increments with every new mutation node reported. Resets after a harvest is sent */
|
|
28
|
+
get payloadBytesEstimation() {
|
|
29
|
+
return this.#events.bytes;
|
|
25
30
|
}
|
|
26
31
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { record as recorder } from 'rrweb';
|
|
2
2
|
import { stringify } from '../../../common/util/stringify';
|
|
3
|
-
import { AVG_COMPRESSION, CHECKOUT_MS,
|
|
4
|
-
import { getConfigurationValue } from '../../../common/config/
|
|
3
|
+
import { AVG_COMPRESSION, CHECKOUT_MS, QUERY_PARAM_PADDING, RRWEB_EVENT_TYPES, SR_EVENT_EMITTER_TYPES } from '../constants';
|
|
4
|
+
import { getConfigurationValue } from '../../../common/config/init';
|
|
5
5
|
import { RecorderEvents } from './recorder-events';
|
|
6
6
|
import { MODE } from '../../../common/session/constants';
|
|
7
7
|
import { stylesheetEvaluator } from './stylesheet-evaluator';
|
|
@@ -9,6 +9,7 @@ import { handle } from '../../../common/event-emitter/handle';
|
|
|
9
9
|
import { SUPPORTABILITY_METRIC_CHANNEL } from '../../metrics/constants';
|
|
10
10
|
import { FEATURE_NAMES } from '../../../loaders/features/features';
|
|
11
11
|
import { buildNRMetaNode } from './utils';
|
|
12
|
+
import { IDEAL_PAYLOAD_SIZE } from '../../../common/constants/agent-constants';
|
|
12
13
|
export class Recorder {
|
|
13
14
|
/** Each page mutation or event will be stored (raw) in this array. This array will be cleared on each harvest */
|
|
14
15
|
#events;
|
|
@@ -38,10 +39,14 @@ export class Recorder {
|
|
|
38
39
|
this.stopRecording = () => {/* no-op until set by rrweb initializer */};
|
|
39
40
|
}
|
|
40
41
|
getEvents() {
|
|
41
|
-
if (this.#preloaded[0]?.events.length)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
if (this.#preloaded[0]?.events.length) {
|
|
43
|
+
return {
|
|
44
|
+
...this.#preloaded[0],
|
|
45
|
+
events: this.#preloaded[0].events,
|
|
46
|
+
payloadBytesEstimation: this.#preloaded[0].payloadBytesEstimation,
|
|
47
|
+
type: 'preloaded'
|
|
48
|
+
};
|
|
49
|
+
}
|
|
45
50
|
return {
|
|
46
51
|
events: [...this.#backloggedEvents.events, ...this.#events.events].filter(x => x),
|
|
47
52
|
type: 'standard',
|
|
@@ -102,7 +107,8 @@ export class Recorder {
|
|
|
102
107
|
this.parent.ee.emit('internal-error', [err]);
|
|
103
108
|
/** returning true informs rrweb to swallow the error instead of throwing it to the window */
|
|
104
109
|
return true;
|
|
105
|
-
}
|
|
110
|
+
},
|
|
111
|
+
recordAfter: 'DOMContentLoaded'
|
|
106
112
|
});
|
|
107
113
|
this.stopRecording = () => {
|
|
108
114
|
this.recording = false;
|
|
@@ -180,7 +186,6 @@ export class Recorder {
|
|
|
180
186
|
this.currentBufferTarget.hasSnapshot = true;
|
|
181
187
|
}
|
|
182
188
|
this.currentBufferTarget.add(event);
|
|
183
|
-
this.currentBufferTarget.payloadBytesEstimation += eventBytes;
|
|
184
189
|
|
|
185
190
|
// We are making an effort to try to keep payloads manageable for unloading. If they reach the unload limit before their interval,
|
|
186
191
|
// it will send immediately. This often happens on the first snapshot, which can be significantly larger than the other payloads.
|
|
@@ -209,8 +214,7 @@ export class Recorder {
|
|
|
209
214
|
}
|
|
210
215
|
|
|
211
216
|
/** Estimate the payload size */
|
|
212
|
-
getPayloadSize() {
|
|
213
|
-
let newBytes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
217
|
+
getPayloadSize(newBytes = 0) {
|
|
214
218
|
// the query param padding constant gives us some padding for the other metadata to be safely injected
|
|
215
219
|
return this.estimateCompression(this.currentBufferTarget.payloadBytesEstimation + newBytes) + QUERY_PARAM_PADDING;
|
|
216
220
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { gosNREUMOriginals } from '../../../common/window/nreum';
|
|
2
2
|
import { isBrowserScope } from '../../../common/constants/runtime';
|
|
3
3
|
class StylesheetEvaluator {
|
|
4
4
|
#evaluated = new WeakSet();
|
|
@@ -56,7 +56,7 @@ class StylesheetEvaluator {
|
|
|
56
56
|
async #fetchAndOverride(target) {
|
|
57
57
|
if (!target?.href) return;
|
|
58
58
|
try {
|
|
59
|
-
const stylesheetContents = await
|
|
59
|
+
const stylesheetContents = await gosNREUMOriginals().o.FETCH.bind(window)(target.href);
|
|
60
60
|
if (!stylesheetContents.ok) {
|
|
61
61
|
this.failedToFix++;
|
|
62
62
|
return;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { gosNREUMOriginals } from '../../../common/window/nreum';
|
|
2
|
+
import { getConfigurationValue } from '../../../common/config/init';
|
|
2
3
|
import { canEnableSessionTracking } from '../../utils/feature-gates';
|
|
3
4
|
import { originTime } from '../../../common/constants/runtime';
|
|
4
5
|
export function hasReplayPrerequisite(agentId) {
|
|
5
|
-
return !!
|
|
6
|
+
return !!gosNREUMOriginals().o.MO &&
|
|
6
7
|
// Session Replay cannot work without Mutation Observer
|
|
7
8
|
canEnableSessionTracking(agentId) &&
|
|
8
9
|
// requires session tracking to be running (hence "session" replay...)
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { registerHandler } from '../../../common/event-emitter/register-handler';
|
|
2
2
|
import { HarvestScheduler } from '../../../common/harvest/harvest-scheduler';
|
|
3
|
-
import {
|
|
3
|
+
import { getInfo } from '../../../common/config/info';
|
|
4
|
+
import { getConfigurationValue } from '../../../common/config/init';
|
|
5
|
+
import { getRuntime } from '../../../common/config/runtime';
|
|
4
6
|
import { FEATURE_NAME } from '../constants';
|
|
5
7
|
import { AggregateBase } from '../../utils/aggregate-base';
|
|
6
8
|
import { TraceStorage } from './trace/storage';
|
|
@@ -8,6 +10,7 @@ import { obj as encodeObj } from '../../../common/url/encode';
|
|
|
8
10
|
import { deregisterDrain } from '../../../common/drain/drain';
|
|
9
11
|
import { globalScope } from '../../../common/constants/runtime';
|
|
10
12
|
import { MODE, SESSION_EVENTS } from '../../../common/session/constants';
|
|
13
|
+
import { applyFnToProps } from '../../../common/util/traverse';
|
|
11
14
|
const ERROR_MODE_SECONDS_WINDOW = 30 * 1000; // sliding window of nodes to track when simply monitoring (but not harvesting) in error mode
|
|
12
15
|
/** Reserved room for query param attrs */
|
|
13
16
|
const QUERY_PARAM_PADDING = 5000;
|
|
@@ -30,15 +33,11 @@ export class Aggregate extends AggregateBase {
|
|
|
30
33
|
/** TraceStorage is the mechanism that holds, normalizes and aggregates ST nodes. It will be accessed and purged when harvests occur */
|
|
31
34
|
this.traceStorage = new TraceStorage(this);
|
|
32
35
|
/** This agg needs information about sampling (sts) and entitlements (st) to make the appropriate decisions on running */
|
|
33
|
-
this.waitForFlags(['sts', 'st']).then(
|
|
34
|
-
let [stMode, stEntitled] = _ref;
|
|
35
|
-
return this.initialize(stMode, stEntitled);
|
|
36
|
-
});
|
|
36
|
+
this.waitForFlags(['sts', 'st']).then(([stMode, stEntitled]) => this.initialize(stMode, stEntitled));
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/** Sets up event listeners, and initializes this module to run in the correct "mode". Can be triggered from a few places, but makes an effort to only set up listeners once */
|
|
40
40
|
initialize(stMode, stEntitled, ignoreSession) {
|
|
41
|
-
var _this = this;
|
|
42
41
|
this.entitled ??= stEntitled;
|
|
43
42
|
if (this.blocked || !this.entitled) return deregisterDrain(this.agentIdentifier, this.featureName);
|
|
44
43
|
if (!this.initialized) {
|
|
@@ -78,31 +77,17 @@ export class Aggregate extends AggregateBase {
|
|
|
78
77
|
}, this);
|
|
79
78
|
|
|
80
79
|
/** The handlers set up by the Inst file */
|
|
81
|
-
registerHandler('bst',
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
registerHandler('
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
registerHandler('
|
|
88
|
-
return _this.traceStorage.storeHist(...arguments);
|
|
89
|
-
}, this.featureName, this.ee);
|
|
90
|
-
registerHandler('bstXhrAgg', function () {
|
|
91
|
-
return _this.traceStorage.storeXhrAgg(...arguments);
|
|
92
|
-
}, this.featureName, this.ee);
|
|
93
|
-
registerHandler('bstApi', function () {
|
|
94
|
-
return _this.traceStorage.storeSTN(...arguments);
|
|
95
|
-
}, this.featureName, this.ee);
|
|
96
|
-
registerHandler('trace-jserror', function () {
|
|
97
|
-
return _this.traceStorage.storeErrorAgg(...arguments);
|
|
98
|
-
}, this.featureName, this.ee);
|
|
99
|
-
registerHandler('pvtAdded', function () {
|
|
100
|
-
return _this.traceStorage.processPVT(...arguments);
|
|
101
|
-
}, this.featureName, this.ee);
|
|
80
|
+
registerHandler('bst', (...args) => this.traceStorage.storeEvent(...args), this.featureName, this.ee);
|
|
81
|
+
registerHandler('bstResource', (...args) => this.traceStorage.storeResources(...args), this.featureName, this.ee);
|
|
82
|
+
registerHandler('bstHist', (...args) => this.traceStorage.storeHist(...args), this.featureName, this.ee);
|
|
83
|
+
registerHandler('bstXhrAgg', (...args) => this.traceStorage.storeXhrAgg(...args), this.featureName, this.ee);
|
|
84
|
+
registerHandler('bstApi', (...args) => this.traceStorage.storeSTN(...args), this.featureName, this.ee);
|
|
85
|
+
registerHandler('trace-jserror', (...args) => this.traceStorage.storeErrorAgg(...args), this.featureName, this.ee);
|
|
86
|
+
registerHandler('pvtAdded', (...args) => this.traceStorage.processPVT(...args), this.featureName, this.ee);
|
|
102
87
|
if (typeof PerformanceNavigationTiming !== 'undefined') {
|
|
103
88
|
this.traceStorage.storeTiming(globalScope.performance?.getEntriesByType?.('navigation')[0]);
|
|
104
89
|
} else {
|
|
105
|
-
this.traceStorage.storeTiming(globalScope.performance?.timing);
|
|
90
|
+
this.traceStorage.storeTiming(globalScope.performance?.timing, true);
|
|
106
91
|
}
|
|
107
92
|
|
|
108
93
|
/** Only start actually harvesting if running in full mode at init time */
|
|
@@ -126,8 +111,7 @@ export class Aggregate extends AggregateBase {
|
|
|
126
111
|
}
|
|
127
112
|
|
|
128
113
|
/** Called by the harvest scheduler at harvest time to retrieve the payload. This will only actually return a payload if running in full mode */
|
|
129
|
-
prepareHarvest() {
|
|
130
|
-
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
114
|
+
prepareHarvest(options = {}) {
|
|
131
115
|
this.traceStorage.prevStoredEvents.clear(); // release references to past events for GC
|
|
132
116
|
if (!this.timeKeeper?.ready) return; // this should likely never happen, but just to be safe, we should never harvest if we cant correct time
|
|
133
117
|
if (this.blocked || this.mode !== MODE.FULL || this.traceStorage.nodeCount === 0) return;
|
|
@@ -166,7 +150,7 @@ export class Aggregate extends AggregateBase {
|
|
|
166
150
|
type: 'BrowserSessionChunk',
|
|
167
151
|
app_id: this.agentInfo.applicationID,
|
|
168
152
|
protocol_version: '0',
|
|
169
|
-
timestamp: this.timeKeeper.convertRelativeTimestamp(earliestTimeStamp),
|
|
153
|
+
timestamp: Math.floor(this.timeKeeper.correctAbsoluteTimestamp(this.timeKeeper.convertRelativeTimestamp(earliestTimeStamp))),
|
|
170
154
|
attributes: encodeObj({
|
|
171
155
|
...(agentMetadata.entityGuid && {
|
|
172
156
|
entityGuid: agentMetadata.entityGuid
|
|
@@ -175,8 +159,8 @@ export class Aggregate extends AggregateBase {
|
|
|
175
159
|
// this section of attributes must be controllable and stay below the query param padding limit -- see QUERY_PARAM_PADDING
|
|
176
160
|
// if not, data could be lost to truncation at time of sending, potentially breaking parsing / API behavior in NR1
|
|
177
161
|
// trace payload metadata
|
|
178
|
-
'trace.firstTimestamp': this.timeKeeper.convertRelativeTimestamp(earliestTimeStamp),
|
|
179
|
-
'trace.lastTimestamp': this.timeKeeper.convertRelativeTimestamp(latestTimeStamp),
|
|
162
|
+
'trace.firstTimestamp': Math.floor(this.timeKeeper.correctAbsoluteTimestamp(this.timeKeeper.convertRelativeTimestamp(earliestTimeStamp))),
|
|
163
|
+
'trace.lastTimestamp': Math.floor(this.timeKeeper.correctAbsoluteTimestamp(this.timeKeeper.convertRelativeTimestamp(latestTimeStamp))),
|
|
180
164
|
'trace.nodes': stns.length,
|
|
181
165
|
'trace.originTimestamp': this.timeKeeper.correctedOriginTime,
|
|
182
166
|
// other payload metadata
|
|
@@ -191,12 +175,12 @@ export class Aggregate extends AggregateBase {
|
|
|
191
175
|
session: "".concat(this.sessionId),
|
|
192
176
|
// customer-defined data should go last so that if it exceeds the query param padding limit it will be truncated instead of important attrs
|
|
193
177
|
...(endUserId && {
|
|
194
|
-
'enduser.id': endUserId
|
|
178
|
+
'enduser.id': this.obfuscator.obfuscateString(endUserId)
|
|
195
179
|
})
|
|
196
180
|
// The Query Param is being arbitrarily limited in length here. It is also applied when estimating the size of the payload in getPayloadSize()
|
|
197
181
|
}, QUERY_PARAM_PADDING).substring(1) // remove the leading '&'
|
|
198
182
|
},
|
|
199
|
-
body: stns
|
|
183
|
+
body: applyFnToProps(stns, this.obfuscator.obfuscateString.bind(this.obfuscator), 'string')
|
|
200
184
|
};
|
|
201
185
|
}
|
|
202
186
|
|
|
@@ -206,8 +190,7 @@ export class Aggregate extends AggregateBase {
|
|
|
206
190
|
onHarvestFinished(result) {
|
|
207
191
|
if (result.sent && result.retry && this.sentTrace) {
|
|
208
192
|
// merge previous trace back into buffer to retry for next harvest
|
|
209
|
-
Object.entries(this.sentTrace).forEach(
|
|
210
|
-
let [name, listOfSTNodes] = _ref2;
|
|
193
|
+
Object.entries(this.sentTrace).forEach(([name, listOfSTNodes]) => {
|
|
211
194
|
this.traceStorage.restoreNode(name, listOfSTNodes);
|
|
212
195
|
});
|
|
213
196
|
this.sentTrace = null;
|
|
@@ -91,8 +91,7 @@ export class TraceStorage {
|
|
|
91
91
|
// if PO isn't supported, this checks resourcetiming buffer every harvest.
|
|
92
92
|
this.storeResources(globalScope.performance?.getEntriesByType?.('resource'));
|
|
93
93
|
}
|
|
94
|
-
const stns = Object.entries(this.trace).flatMap(
|
|
95
|
-
let [name, listOfSTNodes] = _ref;
|
|
94
|
+
const stns = Object.entries(this.trace).flatMap(([name, listOfSTNodes]) => {
|
|
96
95
|
// basically take the "this.trace" map-obj and concat all the list-type values
|
|
97
96
|
if (!(name in toAggregate)) return listOfSTNodes;
|
|
98
97
|
// Special processing for event nodes dealing with user inputs:
|
|
@@ -150,7 +149,7 @@ export class TraceStorage {
|
|
|
150
149
|
return name === 'fi' && !!attrs && typeof attrs.fid === 'number';
|
|
151
150
|
}
|
|
152
151
|
}
|
|
153
|
-
storeTiming(timingEntry) {
|
|
152
|
+
storeTiming(timingEntry, isAbsoluteTimestamp = false) {
|
|
154
153
|
if (!timingEntry) return;
|
|
155
154
|
|
|
156
155
|
// loop iterates through prototype also (for FF)
|
|
@@ -165,6 +164,9 @@ export class TraceStorage {
|
|
|
165
164
|
// that are in the future (Microsoft Edge seems to sometimes produce these)
|
|
166
165
|
if (!(typeof val === 'number' && val >= 0)) continue;
|
|
167
166
|
val = Math.round(val);
|
|
167
|
+
if (this.parent.timeKeeper && this.parent.timeKeeper.ready && isAbsoluteTimestamp) {
|
|
168
|
+
val = this.parent.timeKeeper.convertAbsoluteTimestamp(Math.floor(this.parent.timeKeeper.correctAbsoluteTimestamp(val)));
|
|
169
|
+
}
|
|
168
170
|
this.storeSTN(new TraceNode(key, val, val, 'document', 'timing'));
|
|
169
171
|
}
|
|
170
172
|
}
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
import { handle } from '../../../common/event-emitter/handle';
|
|
6
|
-
import { wrapHistory
|
|
6
|
+
import { wrapHistory } from '../../../common/wrap/wrap-history';
|
|
7
|
+
import { wrapEvents } from '../../../common/wrap/wrap-events';
|
|
7
8
|
import { InstrumentBase } from '../../utils/instrument-base';
|
|
8
9
|
import * as CONSTANTS from '../constants';
|
|
9
10
|
import { FEATURE_NAMES } from '../../../loaders/features/features';
|
|
@@ -22,8 +23,7 @@ const {
|
|
|
22
23
|
} = CONSTANTS;
|
|
23
24
|
export class Instrument extends InstrumentBase {
|
|
24
25
|
static featureName = FEATURE_NAME;
|
|
25
|
-
constructor(agentIdentifier, aggregator) {
|
|
26
|
-
let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
26
|
+
constructor(agentIdentifier, aggregator, auto = true) {
|
|
27
27
|
super(agentIdentifier, aggregator, FEATURE_NAME, auto);
|
|
28
28
|
const canTrackSession = canEnableSessionTracking(this.agentIdentifier);
|
|
29
29
|
if (!canTrackSession) {
|
|
@@ -67,4 +67,5 @@ export class Instrument extends InstrumentBase {
|
|
|
67
67
|
resourceObserver: observer
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
|
-
}
|
|
70
|
+
}
|
|
71
|
+
export const SessionTrace = Instrument;
|
|
@@ -16,7 +16,7 @@ export class AjaxNode extends BelNode {
|
|
|
16
16
|
this.traceId = ajaxEvent.traceId;
|
|
17
17
|
this.spanTimestamp = ajaxEvent.spanTimestamp;
|
|
18
18
|
this.gql = ajaxEvent.gql;
|
|
19
|
-
this.start = ajaxEvent.startTime;
|
|
19
|
+
this.start = ajaxEvent.startTime; // 5000 --- 5500 --> 10500
|
|
20
20
|
this.end = ajaxEvent.endTime;
|
|
21
21
|
}
|
|
22
22
|
serialize(parentStartTimestamp) {
|