@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
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getInfo } from '../../../common/config/info'
|
|
2
|
+
import { getConfigurationValue } from '../../../common/config/init'
|
|
3
|
+
import { getRuntime } from '../../../common/config/runtime'
|
|
2
4
|
import { handle } from '../../../common/event-emitter/handle'
|
|
3
5
|
import { registerHandler } from '../../../common/event-emitter/register-handler'
|
|
4
6
|
import { HarvestScheduler } from '../../../common/harvest/harvest-scheduler'
|
|
@@ -6,9 +8,12 @@ import { warn } from '../../../common/util/console'
|
|
|
6
8
|
import { stringify } from '../../../common/util/stringify'
|
|
7
9
|
import { SUPPORTABILITY_METRIC_CHANNEL } from '../../metrics/constants'
|
|
8
10
|
import { AggregateBase } from '../../utils/aggregate-base'
|
|
9
|
-
import { FEATURE_NAME, LOGGING_EVENT_EMITTER_CHANNEL, LOG_LEVELS
|
|
11
|
+
import { FEATURE_NAME, LOGGING_EVENT_EMITTER_CHANNEL, LOG_LEVELS } from '../constants'
|
|
10
12
|
import { Log } from '../shared/log'
|
|
11
13
|
import { isValidLogLevel } from '../shared/utils'
|
|
14
|
+
import { applyFnToProps } from '../../../common/util/traverse'
|
|
15
|
+
import { MAX_PAYLOAD_SIZE } from '../../../common/constants/agent-constants'
|
|
16
|
+
import { EventBuffer } from '../../utils/event-buffer'
|
|
12
17
|
|
|
13
18
|
export class Aggregate extends AggregateBase {
|
|
14
19
|
static featureName = FEATURE_NAME
|
|
@@ -18,11 +23,7 @@ export class Aggregate extends AggregateBase {
|
|
|
18
23
|
super(agentIdentifier, aggregator, FEATURE_NAME)
|
|
19
24
|
|
|
20
25
|
/** held logs before sending */
|
|
21
|
-
this.bufferedLogs =
|
|
22
|
-
/** held logs during sending, for retries */
|
|
23
|
-
this.outgoingLogs = []
|
|
24
|
-
/** the estimated bytes of log data waiting to be sent -- triggers a harvest if adding a new log will exceed limit */
|
|
25
|
-
this.estimatedBytes = 0
|
|
26
|
+
this.bufferedLogs = new EventBuffer()
|
|
26
27
|
|
|
27
28
|
this.#agentRuntime = getRuntime(this.agentIdentifier)
|
|
28
29
|
this.#agentInfo = getInfo(this.agentIdentifier)
|
|
@@ -36,11 +37,11 @@ export class Aggregate extends AggregateBase {
|
|
|
36
37
|
getPayload: this.prepareHarvest.bind(this),
|
|
37
38
|
raw: true
|
|
38
39
|
}, this)
|
|
39
|
-
/** harvest immediately once started to purge pre-load logs collected */
|
|
40
|
-
this.scheduler.startTimer(this.harvestTimeSeconds, 0)
|
|
41
40
|
/** emitted by instrument class (wrapped loggers) or the api methods directly */
|
|
42
41
|
registerHandler(LOGGING_EVENT_EMITTER_CHANNEL, this.handleLog.bind(this), this.featureName, this.ee)
|
|
43
42
|
this.drain()
|
|
43
|
+
/** harvest immediately once started to purge pre-load logs collected */
|
|
44
|
+
this.scheduler.startTimer(this.harvestTimeSeconds, 0)
|
|
44
45
|
})
|
|
45
46
|
}
|
|
46
47
|
|
|
@@ -67,38 +68,36 @@ export class Aggregate extends AggregateBase {
|
|
|
67
68
|
return
|
|
68
69
|
}
|
|
69
70
|
if (typeof message !== 'string' || !message) return warn(32)
|
|
70
|
-
if (message.length > MAX_PAYLOAD_SIZE) {
|
|
71
|
-
handle(SUPPORTABILITY_METRIC_CHANNEL, ['Logging/Harvest/Failed/Seen', message.length])
|
|
72
|
-
return warn(31, message.slice(0, 25) + '...')
|
|
73
|
-
}
|
|
74
71
|
|
|
75
72
|
const log = new Log(
|
|
76
|
-
this.#agentRuntime.timeKeeper.
|
|
73
|
+
Math.floor(this.#agentRuntime.timeKeeper.correctAbsoluteTimestamp(
|
|
74
|
+
this.#agentRuntime.timeKeeper.convertRelativeTimestamp(timestamp)
|
|
75
|
+
)),
|
|
77
76
|
message,
|
|
78
77
|
attributes,
|
|
79
78
|
level
|
|
80
79
|
)
|
|
81
80
|
const logBytes = log.message.length + stringify(log.attributes).length + log.level.length + 10 // timestamp == 10 chars
|
|
82
|
-
if (logBytes > MAX_PAYLOAD_SIZE) {
|
|
83
|
-
handle(SUPPORTABILITY_METRIC_CHANNEL, ['Logging/Harvest/Failed/Seen', logBytes])
|
|
84
|
-
return warn(31, log.message.slice(0, 25) + '...')
|
|
85
|
-
}
|
|
86
81
|
|
|
87
|
-
if (this.
|
|
88
|
-
|
|
89
|
-
|
|
82
|
+
if (!this.bufferedLogs.canMerge(logBytes)) {
|
|
83
|
+
if (this.bufferedLogs.hasData) {
|
|
84
|
+
handle(SUPPORTABILITY_METRIC_CHANNEL, ['Logging/Harvest/Early/Seen', this.bufferedLogs.bytes + logBytes])
|
|
85
|
+
this.scheduler.runHarvest({})
|
|
86
|
+
if (logBytes < MAX_PAYLOAD_SIZE) this.bufferedLogs.add(log)
|
|
87
|
+
} else {
|
|
88
|
+
handle(SUPPORTABILITY_METRIC_CHANNEL, ['Logging/Harvest/Failed/Seen', logBytes])
|
|
89
|
+
warn(31, log.message.slice(0, 25) + '...')
|
|
90
|
+
}
|
|
91
|
+
return
|
|
90
92
|
}
|
|
91
|
-
|
|
92
|
-
this.bufferedLogs.
|
|
93
|
+
|
|
94
|
+
this.bufferedLogs.add(log)
|
|
93
95
|
}
|
|
94
96
|
|
|
95
|
-
prepareHarvest () {
|
|
96
|
-
if (this.blocked || !
|
|
97
|
-
/** populate outgoing array while also clearing main buffer */
|
|
98
|
-
this.outgoingLogs.push(...this.bufferedLogs.splice(0))
|
|
99
|
-
this.estimatedBytes = 0
|
|
97
|
+
prepareHarvest (options = {}) {
|
|
98
|
+
if (this.blocked || !this.bufferedLogs.hasData) return
|
|
100
99
|
/** see https://source.datanerd.us/agents/rum-specs/blob/main/browser/Log for logging spec */
|
|
101
|
-
|
|
100
|
+
const payload = {
|
|
102
101
|
qs: {
|
|
103
102
|
browser_monitoring_key: this.#agentInfo.licenseKey
|
|
104
103
|
},
|
|
@@ -117,12 +116,21 @@ export class Aggregate extends AggregateBase {
|
|
|
117
116
|
}
|
|
118
117
|
},
|
|
119
118
|
/** logs section contains individual unique log entries */
|
|
120
|
-
logs:
|
|
119
|
+
logs: applyFnToProps(
|
|
120
|
+
this.bufferedLogs.buffer,
|
|
121
|
+
this.obfuscator.obfuscateString.bind(this.obfuscator), 'string'
|
|
122
|
+
)
|
|
121
123
|
}]
|
|
122
124
|
}
|
|
125
|
+
|
|
126
|
+
if (options.retry) this.bufferedLogs.hold()
|
|
127
|
+
else this.bufferedLogs.clear()
|
|
128
|
+
|
|
129
|
+
return payload
|
|
123
130
|
}
|
|
124
131
|
|
|
125
132
|
onHarvestFinished (result) {
|
|
126
|
-
if (
|
|
133
|
+
if (result.retry) this.bufferedLogs.unhold()
|
|
134
|
+
else this.bufferedLogs.held.clear()
|
|
127
135
|
}
|
|
128
136
|
}
|
|
@@ -22,5 +22,5 @@ export function bufferLog (ee, message, customAttributes = {}, level = LOG_LEVEL
|
|
|
22
22
|
*/
|
|
23
23
|
export function isValidLogLevel (level) {
|
|
24
24
|
if (typeof level !== 'string') return false
|
|
25
|
-
return Object.values(LOG_LEVELS).some(logLevel => logLevel === level)
|
|
25
|
+
return Object.values(LOG_LEVELS).some(logLevel => logLevel === level.toUpperCase().trim())
|
|
26
26
|
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getConfiguration } from '../../../common/config/init'
|
|
2
|
+
import { getRuntime } from '../../../common/config/runtime'
|
|
2
3
|
import { registerHandler } from '../../../common/event-emitter/register-handler'
|
|
3
4
|
import { HarvestScheduler } from '../../../common/harvest/harvest-scheduler'
|
|
4
|
-
import { FEATURE_NAME, SUPPORTABILITY_METRIC, CUSTOM_METRIC, SUPPORTABILITY_METRIC_CHANNEL, CUSTOM_METRIC_CHANNEL } from '../constants'
|
|
5
|
+
import { FEATURE_NAME, SUPPORTABILITY_METRIC, CUSTOM_METRIC, SUPPORTABILITY_METRIC_CHANNEL, CUSTOM_METRIC_CHANNEL, WATCHABLE_WEB_SOCKET_EVENTS } from '../constants'
|
|
5
6
|
import { getFrameworks } from './framework-detection'
|
|
6
7
|
import { isFileProtocol } from '../../../common/url/protocol'
|
|
7
|
-
import { getRules, validateRules } from '../../../common/util/obfuscate'
|
|
8
8
|
import { onDOMContentLoaded } from '../../../common/window/load'
|
|
9
9
|
import { windowAddEventListener } from '../../../common/event-listener/event-listener-opts'
|
|
10
10
|
import { isBrowserScope, isWorkerScope } from '../../../common/constants/runtime'
|
|
11
11
|
import { AggregateBase } from '../../utils/aggregate-base'
|
|
12
12
|
import { deregisterDrain } from '../../../common/drain/drain'
|
|
13
|
+
import { WEBSOCKET_TAG } from '../../../common/wrap/wrap-websocket'
|
|
14
|
+
import { handleWebsocketEvents } from './websocket-detection'
|
|
13
15
|
|
|
14
16
|
export class Aggregate extends AggregateBase {
|
|
15
17
|
static featureName = FEATURE_NAME
|
|
@@ -89,25 +91,38 @@ export class Aggregate extends AggregateBase {
|
|
|
89
91
|
}
|
|
90
92
|
|
|
91
93
|
// Capture SMs to assess customer engagement with the obfuscation config
|
|
92
|
-
const
|
|
93
|
-
if (
|
|
94
|
-
|
|
94
|
+
const ruleValidations = this.obfuscator.ruleValidationCache
|
|
95
|
+
if (ruleValidations.length > 0) {
|
|
96
|
+
this.storeSupportabilityMetrics('Generic/Obfuscate/Detected')
|
|
97
|
+
if (ruleValidations.filter(ruleValidation => !ruleValidation.isValid).length > 0) this.storeSupportabilityMetrics('Generic/Obfuscate/Invalid')
|
|
98
|
+
}
|
|
95
99
|
|
|
96
100
|
// Check if proxy for either chunks or beacon is being used
|
|
97
101
|
if (proxy.assets) this.storeSupportabilityMetrics('Config/AssetsUrl/Changed')
|
|
98
102
|
if (proxy.beacon) this.storeSupportabilityMetrics('Config/BeaconUrl/Changed')
|
|
99
103
|
|
|
100
104
|
if (isBrowserScope && window.MutationObserver) {
|
|
101
|
-
this.storeSupportabilityMetrics('Generic/
|
|
105
|
+
if (window.self !== window.top) { this.storeSupportabilityMetrics('Generic/Runtime/IFrame/Detected') }
|
|
106
|
+
const preExistingVideos = window.document.querySelectorAll('video').length
|
|
107
|
+
if (preExistingVideos) this.storeSupportabilityMetrics('Generic/VideoElement/Added', preExistingVideos)
|
|
108
|
+
const preExistingIframes = window.document.querySelectorAll('iframe').length
|
|
109
|
+
if (preExistingIframes) this.storeSupportabilityMetrics('Generic/IFrame/Added', preExistingIframes)
|
|
102
110
|
const mo = new MutationObserver(records => {
|
|
103
111
|
records.forEach(record => {
|
|
104
112
|
record.addedNodes.forEach(addedNode => {
|
|
105
113
|
if (addedNode instanceof HTMLVideoElement) { this.storeSupportabilityMetrics('Generic/VideoElement/Added', 1) }
|
|
114
|
+
if (addedNode instanceof HTMLIFrameElement) { this.storeSupportabilityMetrics('Generic/IFrame/Added', 1) }
|
|
106
115
|
})
|
|
107
116
|
})
|
|
108
117
|
})
|
|
109
118
|
mo.observe(window.document.body, { childList: true, subtree: true })
|
|
110
119
|
}
|
|
120
|
+
|
|
121
|
+
WATCHABLE_WEB_SOCKET_EVENTS.forEach(tag => {
|
|
122
|
+
registerHandler('buffered-' + WEBSOCKET_TAG + tag, (...args) => {
|
|
123
|
+
handleWebsocketEvents(this.storeSupportabilityMetrics.bind(this), tag, ...args)
|
|
124
|
+
}, this.featureName, this.ee)
|
|
125
|
+
})
|
|
111
126
|
}
|
|
112
127
|
|
|
113
128
|
eachSessionChecks () {
|
|
@@ -147,8 +162,8 @@ export class Aggregate extends AggregateBase {
|
|
|
147
162
|
if (typeof performance !== 'undefined') {
|
|
148
163
|
const markers = performance.getEntriesByType('mark')
|
|
149
164
|
const measures = performance.getEntriesByType('measure')
|
|
150
|
-
this.storeSupportabilityMetrics('Generic/Performance/Mark/Seen', markers.length)
|
|
151
|
-
this.storeSupportabilityMetrics('Generic/Performance/Measure/Seen', measures.length)
|
|
165
|
+
if (markers.length) this.storeSupportabilityMetrics('Generic/Performance/Mark/Seen', markers.length)
|
|
166
|
+
if (measures.length) this.storeSupportabilityMetrics('Generic/Performance/Measure/Seen', measures.length)
|
|
152
167
|
}
|
|
153
168
|
} catch (e) {
|
|
154
169
|
// do nothing
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { dataSize } from '../../../common/util/data-size'
|
|
2
|
+
import { toTitleCase } from '../../../common/util/text'
|
|
3
|
+
import { ADD_EVENT_LISTENER_TAG } from '../../../common/wrap/wrap-websocket'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A SM handler for web socket events, which converts them to a shape suitable for SMs and reports them.
|
|
7
|
+
* @param {Function} reporter a function that reports data as a supportability metric
|
|
8
|
+
* @param {string} tag the unique tag to assign to the sm
|
|
9
|
+
* @param {number} timestamp ms from page origin
|
|
10
|
+
* @param {number} timeSinceInit ms from class init
|
|
11
|
+
* @param {boolean} isLoaded whether the even was observed before the page load event
|
|
12
|
+
* @param {string} socketId a unique id assigned to the observed socket
|
|
13
|
+
* @param {*} data the data reported alongside the socket event
|
|
14
|
+
*/
|
|
15
|
+
export function handleWebsocketEvents (reporter, tag, timestamp, timeSinceInit, isLoaded, socketId, data) {
|
|
16
|
+
// socketId is unused in the SMs
|
|
17
|
+
const useDataType = tag === ADD_EVENT_LISTENER_TAG
|
|
18
|
+
let metricTag = toTitleCase(useDataType ? data.eventType : tag)
|
|
19
|
+
if (metricTag === 'Close') {
|
|
20
|
+
if (data?.event.code === 1000 || data?.event.wasClean) metricTag += '-Clean'
|
|
21
|
+
else metricTag += '-Dirty'
|
|
22
|
+
}
|
|
23
|
+
const bytes = (metricTag === 'Message' && dataSize(data?.event?.data)) || (metricTag === 'Send' && dataSize(data))
|
|
24
|
+
reporter(buildSMTag(metricTag, 'Ms'), timestamp)
|
|
25
|
+
reporter(buildSMTag(metricTag, 'MsSinceClassInit'), timeSinceInit)
|
|
26
|
+
if (bytes) reporter(buildSMTag(metricTag, 'Bytes'), bytes)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function buildSMTag (tag, category) {
|
|
30
|
+
return 'WebSocket/' + tag + '/' + category
|
|
31
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ADD_EVENT_LISTENER_TAG } from '../../common/wrap/wrap-websocket'
|
|
1
2
|
import { FEATURE_NAMES } from '../../loaders/features/features'
|
|
2
3
|
|
|
3
4
|
export const FEATURE_NAME = FEATURE_NAMES.metrics
|
|
@@ -5,3 +6,5 @@ export const SUPPORTABILITY_METRIC = 'sm'
|
|
|
5
6
|
export const CUSTOM_METRIC = 'cm'
|
|
6
7
|
export const SUPPORTABILITY_METRIC_CHANNEL = 'storeSupportabilityMetrics'
|
|
7
8
|
export const CUSTOM_METRIC_CHANNEL = 'storeEventMetrics'
|
|
9
|
+
|
|
10
|
+
export const WATCHABLE_WEB_SOCKET_EVENTS = ['new', 'send', 'close', ADD_EVENT_LISTENER_TAG]
|
|
@@ -1,10 +1,22 @@
|
|
|
1
|
+
import { handle } from '../../../common/event-emitter/handle'
|
|
2
|
+
import { WEBSOCKET_TAG, wrapWebSocket } from '../../../common/wrap/wrap-websocket'
|
|
1
3
|
import { InstrumentBase } from '../../utils/instrument-base'
|
|
2
|
-
import { FEATURE_NAME } from '../constants'
|
|
4
|
+
import { FEATURE_NAME, WATCHABLE_WEB_SOCKET_EVENTS } from '../constants'
|
|
3
5
|
|
|
4
6
|
export class Instrument extends InstrumentBase {
|
|
5
7
|
static featureName = FEATURE_NAME
|
|
6
8
|
constructor (agentIdentifier, aggregator, auto = true) {
|
|
7
9
|
super(agentIdentifier, aggregator, FEATURE_NAME, auto)
|
|
10
|
+
wrapWebSocket(this.ee)
|
|
11
|
+
|
|
12
|
+
WATCHABLE_WEB_SOCKET_EVENTS.forEach((suffix) => {
|
|
13
|
+
this.ee.on(WEBSOCKET_TAG + suffix, (...args) => {
|
|
14
|
+
handle('buffered-' + WEBSOCKET_TAG + suffix, [...args], undefined, this.featureName, this.ee)
|
|
15
|
+
})
|
|
16
|
+
})
|
|
17
|
+
|
|
8
18
|
this.importAggregator()
|
|
9
19
|
}
|
|
10
20
|
}
|
|
21
|
+
|
|
22
|
+
export const Metrics = Instrument
|
|
@@ -3,13 +3,18 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import { FEATURE_NAME } from '../constants'
|
|
6
|
+
import { GenericEvents } from '../../generic_events'
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated This feature has been replaced by Generic Events. Use/Import `GenericEvents` instead. This wrapper will be removed in a future release
|
|
10
|
+
*/
|
|
11
|
+
export class Instrument extends GenericEvents {
|
|
11
12
|
constructor (agentIdentifier, aggregator, auto = true) {
|
|
12
|
-
super(agentIdentifier, aggregator,
|
|
13
|
-
this.importAggregator()
|
|
13
|
+
super(agentIdentifier, aggregator, auto)
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated This feature has been replaced by Generic Events. Use/Import `GenericEvents` instead. This wrapper will be removed in a future release
|
|
19
|
+
*/
|
|
20
|
+
export const PageAction = Instrument
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { globalScope, isBrowserScope, originTime } from '../../../common/constants/runtime'
|
|
2
2
|
import { addPT, addPN } from '../../../common/timing/nav-timing'
|
|
3
3
|
import { stringify } from '../../../common/util/stringify'
|
|
4
|
-
import { getInfo,
|
|
4
|
+
import { getInfo, isValid } from '../../../common/config/info'
|
|
5
|
+
import { getRuntime } from '../../../common/config/runtime'
|
|
5
6
|
import { Harvest } from '../../../common/harvest/harvest'
|
|
6
7
|
import * as CONSTANTS from '../constants'
|
|
7
8
|
import { getActivatedFeaturesFlags } from './initialized-features'
|
|
@@ -11,12 +12,9 @@ import { AggregateBase } from '../../utils/aggregate-base'
|
|
|
11
12
|
import { firstContentfulPaint } from '../../../common/vitals/first-contentful-paint'
|
|
12
13
|
import { firstPaint } from '../../../common/vitals/first-paint'
|
|
13
14
|
import { timeToFirstByte } from '../../../common/vitals/time-to-first-byte'
|
|
14
|
-
import { drain } from '../../../common/drain/drain'
|
|
15
|
-
import { FEATURE_NAMES } from '../../../loaders/features/features'
|
|
16
|
-
import { handle } from '../../../common/event-emitter/handle'
|
|
17
|
-
import { SUPPORTABILITY_METRIC_CHANNEL } from '../../metrics/constants'
|
|
18
15
|
import { now } from '../../../common/timing/now'
|
|
19
16
|
import { TimeKeeper } from '../../../common/timing/time-keeper'
|
|
17
|
+
import { applyFnToProps } from '../../../common/util/traverse'
|
|
20
18
|
|
|
21
19
|
export class Aggregate extends AggregateBase {
|
|
22
20
|
static featureName = CONSTANTS.FEATURE_NAME
|
|
@@ -28,7 +26,7 @@ export class Aggregate extends AggregateBase {
|
|
|
28
26
|
this.firstByteToDomContent = 0 // our "dom processing" duration
|
|
29
27
|
this.timeKeeper = new TimeKeeper(this.agentIdentifier)
|
|
30
28
|
|
|
31
|
-
if (!
|
|
29
|
+
if (!isValid(agentIdentifier)) {
|
|
32
30
|
this.ee.abort()
|
|
33
31
|
return warn(43)
|
|
34
32
|
}
|
|
@@ -84,7 +82,7 @@ export class Aggregate extends AggregateBase {
|
|
|
84
82
|
|
|
85
83
|
let body
|
|
86
84
|
if (typeof info.jsAttributes === 'object' && Object.keys(info.jsAttributes).length > 0) {
|
|
87
|
-
body = { ja: info.jsAttributes }
|
|
85
|
+
body = applyFnToProps({ ja: info.jsAttributes }, this.obfuscator.obfuscateString.bind(this.obfuscator), 'string')
|
|
88
86
|
}
|
|
89
87
|
|
|
90
88
|
if (globalScope.performance) {
|
|
@@ -108,7 +106,9 @@ export class Aggregate extends AggregateBase {
|
|
|
108
106
|
queryParameters.fcp = firstContentfulPaint.current.value
|
|
109
107
|
|
|
110
108
|
if (this.timeKeeper?.ready) {
|
|
111
|
-
queryParameters.timestamp = this.timeKeeper.
|
|
109
|
+
queryParameters.timestamp = Math.floor(this.timeKeeper.correctAbsoluteTimestamp(
|
|
110
|
+
this.timeKeeper.convertRelativeTimestamp(now())
|
|
111
|
+
))
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
const rumStartTime = now()
|
|
@@ -130,22 +130,7 @@ export class Aggregate extends AggregateBase {
|
|
|
130
130
|
if (!this.timeKeeper.ready) throw new Error('TimeKeeper not ready')
|
|
131
131
|
|
|
132
132
|
agentRuntime.timeKeeper = this.timeKeeper
|
|
133
|
-
|
|
134
|
-
// Check if the time diff is such that we need to capture a supportability metric
|
|
135
|
-
if (this.timeKeeper.localTimeDiff >= 12 * 60 * 60 * 1000) {
|
|
136
|
-
handle(SUPPORTABILITY_METRIC_CHANNEL, ['PVE/NRTime/Calculation/DiffExceed12Hrs'], undefined, FEATURE_NAMES.metrics, this.ee)
|
|
137
|
-
} else if (this.timeKeeper.localTimeDiff >= 6 * 60 * 60 * 1000) {
|
|
138
|
-
handle(SUPPORTABILITY_METRIC_CHANNEL, ['PVE/NRTime/Calculation/DiffExceed6Hrs'], undefined, FEATURE_NAMES.metrics, this.ee)
|
|
139
|
-
} else if (this.timeKeeper.localTimeDiff >= 60 * 60 * 1000) {
|
|
140
|
-
handle(SUPPORTABILITY_METRIC_CHANNEL, ['PVE/NRTime/Calculation/DiffExceed1Hrs'], undefined, FEATURE_NAMES.metrics, this.ee)
|
|
141
|
-
}
|
|
142
133
|
} catch (error) {
|
|
143
|
-
if (error?.message?.indexOf('invalid format') > 0) {
|
|
144
|
-
handle(SUPPORTABILITY_METRIC_CHANNEL, ['PVE/NRTime/Calculation/InvalidFormat'], undefined, FEATURE_NAMES.metrics, this.ee)
|
|
145
|
-
} else {
|
|
146
|
-
handle(SUPPORTABILITY_METRIC_CHANNEL, ['PVE/NRTime/Calculation/Failed'], undefined, FEATURE_NAMES.metrics, this.ee)
|
|
147
|
-
}
|
|
148
|
-
drain(this.agentIdentifier, FEATURE_NAMES.metrics, true)
|
|
149
134
|
this.ee.abort()
|
|
150
135
|
warn(17, error)
|
|
151
136
|
return
|
|
@@ -18,7 +18,7 @@ export function getActivatedFeaturesFlags (agentId) {
|
|
|
18
18
|
flagArr.push('xhr'); break
|
|
19
19
|
case FEATURE_NAMES.jserrors:
|
|
20
20
|
flagArr.push('err'); break
|
|
21
|
-
case FEATURE_NAMES.
|
|
21
|
+
case FEATURE_NAMES.genericEvents:
|
|
22
22
|
flagArr.push('ins'); break
|
|
23
23
|
case FEATURE_NAMES.sessionTrace:
|
|
24
24
|
flagArr.push('stn'); break
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { nullable, numeric, getAddStringContext, addCustomAttributes } from '../../../common/serialize/bel-serializer'
|
|
7
|
-
import { mapOwn } from '../../../common/util/map-own'
|
|
8
7
|
import { HarvestScheduler } from '../../../common/harvest/harvest-scheduler'
|
|
9
8
|
import { registerHandler } from '../../../common/event-emitter/register-handler'
|
|
10
9
|
import { handle } from '../../../common/event-emitter/handle'
|
|
11
|
-
import { getInfo
|
|
10
|
+
import { getInfo } from '../../../common/config/info'
|
|
11
|
+
import { getConfigurationValue } from '../../../common/config/init'
|
|
12
12
|
import { FEATURE_NAME } from '../constants'
|
|
13
13
|
import { FEATURE_NAMES } from '../../../loaders/features/features'
|
|
14
14
|
import { AggregateBase } from '../../utils/aggregate-base'
|
|
@@ -22,6 +22,7 @@ import { timeToFirstByte } from '../../../common/vitals/time-to-first-byte'
|
|
|
22
22
|
import { longTask } from '../../../common/vitals/long-task'
|
|
23
23
|
import { subscribeToVisibilityChange } from '../../../common/window/page-visibility'
|
|
24
24
|
import { VITAL_NAMES } from '../../../common/vitals/constants'
|
|
25
|
+
import { EventBuffer } from '../../utils/event-buffer'
|
|
25
26
|
|
|
26
27
|
export class Aggregate extends AggregateBase {
|
|
27
28
|
static featureName = FEATURE_NAME
|
|
@@ -33,8 +34,7 @@ export class Aggregate extends AggregateBase {
|
|
|
33
34
|
constructor (agentIdentifier, aggregator) {
|
|
34
35
|
super(agentIdentifier, aggregator, FEATURE_NAME)
|
|
35
36
|
|
|
36
|
-
this.timings =
|
|
37
|
-
this.timingsSent = []
|
|
37
|
+
this.timings = new EventBuffer()
|
|
38
38
|
this.curSessEndRecorded = false
|
|
39
39
|
|
|
40
40
|
if (getConfigurationValue(this.agentIdentifier, 'page_view_timing.long_task') === true) longTask.subscribe(this.#handleVitalMetric)
|
|
@@ -116,7 +116,7 @@ export class Aggregate extends AggregateBase {
|
|
|
116
116
|
attrs.cls = cumulativeLayoutShift.current.value
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
this.timings.
|
|
119
|
+
this.timings.add({
|
|
120
120
|
name,
|
|
121
121
|
value,
|
|
122
122
|
attrs
|
|
@@ -126,10 +126,8 @@ export class Aggregate extends AggregateBase {
|
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
onHarvestFinished (result) {
|
|
129
|
-
if (result.retry && this.
|
|
130
|
-
|
|
131
|
-
this.timingsSent = []
|
|
132
|
-
}
|
|
129
|
+
if (result.retry && this.timings.held.hasData) this.timings.unhold()
|
|
130
|
+
else this.timings.held.clear()
|
|
133
131
|
}
|
|
134
132
|
|
|
135
133
|
appendGlobalCustomAttributes (timing) {
|
|
@@ -138,7 +136,7 @@ export class Aggregate extends AggregateBase {
|
|
|
138
136
|
|
|
139
137
|
var reservedAttributes = ['size', 'eid', 'cls', 'type', 'fid', 'elTag', 'elUrl', 'net-type',
|
|
140
138
|
'net-etype', 'net-rtt', 'net-dlink']
|
|
141
|
-
|
|
139
|
+
Object.entries(customAttributes || {}).forEach(([key, val]) => {
|
|
142
140
|
if (reservedAttributes.indexOf(key) < 0) {
|
|
143
141
|
timingAttributes[key] = val
|
|
144
142
|
}
|
|
@@ -147,16 +145,15 @@ export class Aggregate extends AggregateBase {
|
|
|
147
145
|
|
|
148
146
|
// serialize and return current timing data, clear and save current data for retry
|
|
149
147
|
prepareHarvest (options) {
|
|
150
|
-
if (this.timings.
|
|
148
|
+
if (!this.timings.hasData) return
|
|
151
149
|
|
|
152
|
-
var payload = this.getPayload(this.timings)
|
|
153
|
-
if (options.retry)
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
150
|
+
var payload = this.getPayload(this.timings.buffer)
|
|
151
|
+
if (options.retry) this.timings.hold()
|
|
152
|
+
else this.timings.clear()
|
|
153
|
+
|
|
154
|
+
return {
|
|
155
|
+
body: { e: payload }
|
|
157
156
|
}
|
|
158
|
-
this.timings = []
|
|
159
|
-
return { body: { e: payload } }
|
|
160
157
|
}
|
|
161
158
|
|
|
162
159
|
// serialize array of timing data
|
|
@@ -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
|
|
|
33
32
|
export class Aggregate extends AggregateBase {
|
|
34
33
|
static featureName = FEATURE_NAME
|
|
@@ -328,8 +327,13 @@ export class Aggregate extends AggregateBase {
|
|
|
328
327
|
|
|
329
328
|
const firstEventTimestamp = this.getCorrectedTimestamp(events[0]) // from rrweb node
|
|
330
329
|
const lastEventTimestamp = this.getCorrectedTimestamp(events[events.length - 1]) // from rrweb node
|
|
331
|
-
|
|
332
|
-
const
|
|
330
|
+
// from rrweb node || from when the harvest cycle started
|
|
331
|
+
const firstTimestamp = firstEventTimestamp || Math.floor(this.timeKeeper.correctAbsoluteTimestamp(
|
|
332
|
+
this.timeKeeper.correctAbsoluteTimestamp(recorderEvents.cycleTimestamp)
|
|
333
|
+
))
|
|
334
|
+
const lastTimestamp = lastEventTimestamp || Math.floor(this.timeKeeper.correctAbsoluteTimestamp(
|
|
335
|
+
this.timeKeeper.convertRelativeTimestamp(relativeNow)
|
|
336
|
+
))
|
|
333
337
|
|
|
334
338
|
const agentMetadata = agentRuntime.appMetadata?.agents?.[0] || {}
|
|
335
339
|
|
|
@@ -363,7 +367,7 @@ export class Aggregate extends AggregateBase {
|
|
|
363
367
|
'rrweb.version': RRWEB_VERSION,
|
|
364
368
|
'payload.type': recorderEvents.type,
|
|
365
369
|
// customer-defined data should go last so that if it exceeds the query param padding limit it will be truncated instead of important attrs
|
|
366
|
-
...(endUserId && { 'enduser.id': endUserId })
|
|
370
|
+
...(endUserId && { 'enduser.id': this.obfuscator.obfuscateString(endUserId) })
|
|
367
371
|
// The Query Param is being arbitrarily limited in length here. It is also applied when estimating the size of the payload in getPayloadSize()
|
|
368
372
|
}, QUERY_PARAM_PADDING).substring(1) // remove the leading '&'
|
|
369
373
|
},
|
|
@@ -19,10 +19,6 @@ export const RRWEB_EVENT_TYPES = {
|
|
|
19
19
|
Meta: 4,
|
|
20
20
|
Custom: 5
|
|
21
21
|
}
|
|
22
|
-
/** Vortex caps payload sizes at 1MB */
|
|
23
|
-
export const MAX_PAYLOAD_SIZE = 1000000
|
|
24
|
-
/** Unloading caps around 64kb */
|
|
25
|
-
export const IDEAL_PAYLOAD_SIZE = 64000
|
|
26
22
|
/** Interval between forcing new full snapshots -- 15 seconds in error mode (x2), 5 minutes in full mode */
|
|
27
23
|
export const CHECKOUT_MS = { [MODE.ERROR]: 15000, [MODE.FULL]: 300000, [MODE.OFF]: 0 }
|
|
28
24
|
export const ABORT_REASONS = {
|
|
@@ -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'
|
|
@@ -106,3 +103,5 @@ export class Instrument extends InstrumentBase {
|
|
|
106
103
|
}
|
|
107
104
|
}
|
|
108
105
|
}
|
|
106
|
+
|
|
107
|
+
export const SessionReplay = Instrument
|