@newrelic/browser-agent 1.264.0 → 1.265.1
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 +31 -0
- package/dist/cjs/common/aggregate/aggregator.js +1 -2
- package/dist/cjs/common/config/{state/configurable.js → configurable.js} +1 -1
- package/dist/cjs/common/config/{state/info.js → info.js} +1 -1
- package/dist/cjs/common/config/{state/init.js → init.js} +5 -5
- package/dist/cjs/common/config/{state/loader-config.js → loader-config.js} +1 -1
- package/dist/cjs/common/config/{state/runtime.js → runtime.js} +16 -5
- package/dist/cjs/common/constants/agent-constants.js +8 -0
- package/dist/cjs/common/constants/env.cdn.js +1 -1
- package/dist/cjs/common/constants/env.npm.js +1 -1
- package/dist/cjs/common/context/shared-context.js +1 -2
- package/dist/cjs/common/dispatch/global-event.js +1 -2
- package/dist/cjs/common/drain/drain.js +10 -16
- package/dist/cjs/common/event-emitter/contextual-ee.js +3 -4
- package/dist/cjs/common/event-listener/event-listener-opts.js +2 -6
- package/dist/cjs/common/harvest/harvest-scheduler.js +1 -2
- package/dist/cjs/common/harvest/harvest.js +29 -56
- package/dist/cjs/common/serialize/bel-serializer.js +6 -11
- package/dist/cjs/common/session/session-entity.js +9 -12
- package/dist/cjs/common/timing/nav-timing.js +1 -3
- package/dist/cjs/common/timing/time-keeper.js +16 -6
- package/dist/cjs/common/url/encode.js +2 -4
- package/dist/cjs/common/util/console.js +2 -0
- package/dist/cjs/common/util/invoke.js +6 -16
- package/dist/cjs/common/util/obfuscate.js +97 -53
- package/dist/cjs/common/util/submit-data.js +17 -20
- package/dist/cjs/common/util/text.js +9 -0
- package/dist/cjs/common/util/traverse.js +1 -3
- package/dist/cjs/common/vitals/cumulative-layout-shift.js +5 -6
- package/dist/cjs/common/vitals/first-contentful-paint.js +4 -5
- package/dist/cjs/common/vitals/first-input-delay.js +4 -5
- package/dist/cjs/common/vitals/interaction-to-next-paint.js +5 -6
- package/dist/cjs/common/vitals/largest-contentful-paint.js +4 -5
- package/dist/cjs/common/vitals/time-to-first-byte.js +4 -5
- package/dist/cjs/common/vitals/vital-metric.js +6 -8
- package/dist/cjs/common/window/nreum.js +2 -1
- package/dist/cjs/common/window/page-visibility.js +1 -4
- package/dist/cjs/common/wrap/wrap-events.js +1 -4
- package/dist/cjs/common/wrap/wrap-promise.js +1 -4
- package/dist/cjs/common/wrap/wrap-websocket.js +74 -0
- package/dist/cjs/features/ajax/aggregate/chunk.js +4 -3
- package/dist/cjs/features/ajax/aggregate/gql.js +4 -5
- package/dist/cjs/features/ajax/aggregate/index.js +20 -23
- package/dist/cjs/features/ajax/constants.js +2 -3
- package/dist/cjs/features/ajax/instrument/distributed-tracing.js +9 -8
- package/dist/cjs/features/ajax/instrument/index.js +15 -13
- package/dist/cjs/features/generic_events/aggregate/index.js +49 -58
- package/dist/cjs/features/generic_events/constants.js +4 -2
- package/dist/cjs/features/generic_events/instrument/index.js +7 -7
- package/dist/cjs/features/jserrors/aggregate/index.js +24 -44
- package/dist/cjs/features/jserrors/instrument/index.js +5 -5
- package/dist/cjs/features/logging/aggregate/index.js +34 -37
- package/dist/cjs/features/logging/constants.js +2 -3
- package/dist/cjs/features/logging/instrument/index.js +6 -7
- package/dist/cjs/features/logging/shared/log.js +1 -3
- package/dist/cjs/features/logging/shared/utils.js +2 -4
- package/dist/cjs/features/metrics/aggregate/index.js +37 -18
- package/dist/cjs/features/metrics/aggregate/websocket-detection.js +34 -0
- package/dist/cjs/features/metrics/constants.js +5 -1
- package/dist/cjs/features/metrics/instrument/index.js +16 -5
- package/dist/cjs/features/page_action/instrument/index.js +8 -4
- package/dist/cjs/features/page_view_event/aggregate/index.js +20 -40
- package/dist/cjs/features/page_view_event/instrument/index.js +5 -5
- package/dist/cjs/features/page_view_timing/aggregate/index.js +24 -40
- package/dist/cjs/features/page_view_timing/instrument/index.js +5 -5
- package/dist/cjs/features/session_replay/aggregate/index.js +37 -44
- package/dist/cjs/features/session_replay/constants.js +1 -5
- package/dist/cjs/features/session_replay/instrument/index.js +6 -10
- package/dist/cjs/features/session_replay/shared/recorder-events.js +25 -20
- package/dist/cjs/features/session_replay/shared/recorder.js +17 -13
- package/dist/cjs/features/session_replay/shared/stylesheet-evaluator.js +3 -3
- package/dist/cjs/features/session_replay/shared/utils.js +5 -4
- package/dist/cjs/features/session_trace/aggregate/index.js +26 -43
- package/dist/cjs/features/session_trace/aggregate/trace/storage.js +7 -5
- package/dist/cjs/features/session_trace/instrument/index.js +9 -8
- package/dist/cjs/features/soft_navigations/aggregate/ajax-node.js +1 -1
- package/dist/cjs/features/soft_navigations/aggregate/bel-node.js +1 -1
- package/dist/cjs/features/soft_navigations/aggregate/index.js +23 -31
- package/dist/cjs/features/soft_navigations/aggregate/initial-page-load-interaction.js +2 -2
- package/dist/cjs/features/soft_navigations/aggregate/interaction.js +9 -10
- package/dist/cjs/features/soft_navigations/instrument/index.js +15 -14
- package/dist/cjs/features/spa/aggregate/index.js +17 -27
- package/dist/cjs/features/spa/aggregate/interaction.js +7 -6
- package/dist/cjs/features/spa/aggregate/serializer.js +3 -3
- package/dist/cjs/features/spa/constants.js +2 -2
- package/dist/cjs/features/spa/instrument/index.js +21 -20
- package/dist/cjs/features/utils/agent-session.js +6 -4
- package/dist/cjs/features/utils/aggregate-base.js +15 -10
- package/dist/cjs/features/utils/event-buffer.js +132 -0
- package/dist/cjs/features/utils/feature-gates.js +2 -2
- package/dist/cjs/features/utils/instrument-base.js +7 -8
- package/dist/cjs/features/utils/lazy-feature-loader.js +11 -11
- package/dist/cjs/features/utils/nr1-debugger.js +1 -3
- package/dist/cjs/loaders/agent-base.js +4 -8
- package/dist/cjs/loaders/agent.js +7 -2
- package/dist/cjs/loaders/api/api.js +22 -34
- package/dist/cjs/loaders/api/apiAsync.js +9 -12
- package/dist/cjs/loaders/configure/configure.js +12 -12
- package/dist/cjs/loaders/features/enabled-features.js +2 -2
- package/dist/cjs/loaders/micro-agent.js +15 -14
- package/dist/esm/common/aggregate/aggregator.js +1 -2
- package/dist/esm/common/config/{state/configurable.js → configurable.js} +1 -1
- package/dist/esm/common/config/{state/info.js → info.js} +1 -1
- package/dist/esm/common/config/{state/init.js → init.js} +5 -5
- package/dist/esm/common/config/{state/loader-config.js → loader-config.js} +1 -1
- package/dist/esm/common/config/{state/runtime.js → runtime.js} +17 -5
- package/dist/esm/common/constants/agent-constants.js +2 -0
- package/dist/esm/common/constants/env.cdn.js +1 -1
- package/dist/esm/common/constants/env.npm.js +1 -1
- package/dist/esm/common/context/shared-context.js +1 -2
- package/dist/esm/common/dispatch/global-event.js +1 -2
- package/dist/esm/common/drain/drain.js +10 -16
- package/dist/esm/common/event-emitter/contextual-ee.js +2 -3
- package/dist/esm/common/event-listener/event-listener-opts.js +2 -6
- package/dist/esm/common/harvest/harvest-scheduler.js +1 -2
- package/dist/esm/common/harvest/harvest.js +21 -48
- package/dist/esm/common/serialize/bel-serializer.js +6 -11
- package/dist/esm/common/session/session-entity.js +8 -11
- package/dist/esm/common/timing/nav-timing.js +1 -3
- package/dist/esm/common/timing/time-keeper.js +15 -5
- package/dist/esm/common/url/encode.js +2 -4
- package/dist/esm/common/util/console.js +2 -0
- package/dist/esm/common/util/invoke.js +6 -16
- package/dist/esm/common/util/obfuscate.js +96 -49
- package/dist/esm/common/util/submit-data.js +17 -20
- package/dist/esm/common/util/text.js +3 -0
- package/dist/esm/common/util/traverse.js +1 -3
- package/dist/esm/common/vitals/cumulative-layout-shift.js +5 -6
- package/dist/esm/common/vitals/first-contentful-paint.js +4 -5
- package/dist/esm/common/vitals/first-input-delay.js +4 -5
- package/dist/esm/common/vitals/interaction-to-next-paint.js +5 -6
- package/dist/esm/common/vitals/largest-contentful-paint.js +4 -5
- package/dist/esm/common/vitals/time-to-first-byte.js +4 -5
- package/dist/esm/common/vitals/vital-metric.js +6 -8
- package/dist/esm/common/window/nreum.js +2 -1
- package/dist/esm/common/window/page-visibility.js +1 -4
- package/dist/esm/common/wrap/wrap-events.js +1 -4
- package/dist/esm/common/wrap/wrap-promise.js +1 -4
- package/dist/esm/common/wrap/wrap-websocket.js +67 -0
- package/dist/esm/features/ajax/aggregate/chunk.js +3 -2
- package/dist/esm/features/ajax/aggregate/gql.js +4 -5
- package/dist/esm/features/ajax/aggregate/index.js +17 -20
- package/dist/esm/features/ajax/constants.js +1 -2
- package/dist/esm/features/ajax/instrument/distributed-tracing.js +2 -1
- package/dist/esm/features/ajax/instrument/index.js +11 -9
- package/dist/esm/features/generic_events/aggregate/index.js +41 -50
- package/dist/esm/features/generic_events/constants.js +3 -1
- package/dist/esm/features/generic_events/instrument/index.js +5 -5
- package/dist/esm/features/jserrors/aggregate/index.js +19 -39
- package/dist/esm/features/jserrors/instrument/index.js +4 -4
- package/dist/esm/features/logging/aggregate/index.js +32 -35
- package/dist/esm/features/logging/constants.js +1 -2
- package/dist/esm/features/logging/instrument/index.js +5 -6
- package/dist/esm/features/logging/shared/log.js +1 -3
- package/dist/esm/features/logging/shared/utils.js +2 -4
- package/dist/esm/features/metrics/aggregate/index.js +31 -12
- package/dist/esm/features/metrics/aggregate/websocket-detection.js +29 -0
- package/dist/esm/features/metrics/constants.js +4 -1
- package/dist/esm/features/metrics/instrument/index.js +15 -5
- package/dist/esm/features/page_action/instrument/index.js +7 -3
- package/dist/esm/features/page_view_event/aggregate/index.js +18 -38
- package/dist/esm/features/page_view_event/instrument/index.js +4 -4
- package/dist/esm/features/page_view_timing/aggregate/index.js +21 -37
- package/dist/esm/features/page_view_timing/instrument/index.js +4 -4
- package/dist/esm/features/session_replay/aggregate/index.js +27 -34
- package/dist/esm/features/session_replay/constants.js +0 -4
- package/dist/esm/features/session_replay/index.js +1 -7
- package/dist/esm/features/session_replay/instrument/index.js +6 -9
- package/dist/esm/features/session_replay/shared/recorder-events.js +25 -20
- package/dist/esm/features/session_replay/shared/recorder.js +14 -10
- package/dist/esm/features/session_replay/shared/stylesheet-evaluator.js +3 -3
- package/dist/esm/features/session_replay/shared/utils.js +3 -2
- package/dist/esm/features/session_trace/aggregate/index.js +21 -38
- package/dist/esm/features/session_trace/aggregate/trace/storage.js +7 -5
- package/dist/esm/features/session_trace/instrument/index.js +6 -5
- package/dist/esm/features/soft_navigations/aggregate/ajax-node.js +1 -1
- package/dist/esm/features/soft_navigations/aggregate/bel-node.js +1 -1
- package/dist/esm/features/soft_navigations/aggregate/index.js +22 -30
- package/dist/esm/features/soft_navigations/aggregate/initial-page-load-interaction.js +1 -1
- package/dist/esm/features/soft_navigations/aggregate/interaction.js +7 -8
- package/dist/esm/features/soft_navigations/instrument/index.js +12 -11
- package/dist/esm/features/spa/aggregate/index.js +11 -21
- package/dist/esm/features/spa/aggregate/interaction.js +6 -5
- package/dist/esm/features/spa/aggregate/serializer.js +1 -1
- package/dist/esm/features/spa/constants.js +2 -2
- package/dist/esm/features/spa/instrument/index.js +13 -12
- package/dist/esm/features/utils/agent-session.js +3 -1
- package/dist/esm/features/utils/aggregate-base.js +13 -8
- package/dist/esm/features/utils/event-buffer.js +126 -0
- package/dist/esm/features/utils/feature-gates.js +1 -1
- package/dist/esm/features/utils/instrument-base.js +6 -7
- package/dist/esm/features/utils/lazy-feature-loader.js +11 -11
- package/dist/esm/features/utils/nr1-debugger.js +1 -3
- package/dist/esm/loaders/agent-base.js +4 -8
- package/dist/esm/loaders/agent.js +7 -2
- package/dist/esm/loaders/api/api.js +17 -29
- package/dist/esm/loaders/api/apiAsync.js +2 -5
- package/dist/esm/loaders/configure/configure.js +5 -5
- package/dist/esm/loaders/features/enabled-features.js +1 -1
- package/dist/esm/loaders/micro-agent.js +10 -9
- package/dist/types/common/config/configurable.d.ts.map +1 -0
- package/dist/types/common/config/info.d.ts.map +1 -0
- package/dist/types/common/config/init.d.ts.map +1 -0
- package/dist/types/common/config/loader-config.d.ts.map +1 -0
- package/dist/types/common/config/runtime.d.ts.map +1 -0
- package/dist/types/common/constants/agent-constants.d.ts +3 -0
- package/dist/types/common/constants/agent-constants.d.ts.map +1 -0
- package/dist/types/common/drain/drain.d.ts.map +1 -1
- package/dist/types/common/harvest/harvest.d.ts +1 -7
- package/dist/types/common/harvest/harvest.d.ts.map +1 -1
- package/dist/types/common/serialize/bel-serializer.d.ts.map +1 -1
- package/dist/types/common/timing/time-keeper.d.ts +9 -2
- package/dist/types/common/timing/time-keeper.d.ts.map +1 -1
- package/dist/types/common/util/console.d.ts.map +1 -1
- package/dist/types/common/util/obfuscate.d.ts +78 -6
- package/dist/types/common/util/obfuscate.d.ts.map +1 -1
- package/dist/types/common/util/text.d.ts +2 -0
- package/dist/types/common/util/text.d.ts.map +1 -0
- package/dist/types/common/window/nreum.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-websocket.d.ts +4 -0
- package/dist/types/common/wrap/wrap-websocket.d.ts.map +1 -0
- package/dist/types/features/ajax/aggregate/chunk.d.ts.map +1 -1
- package/dist/types/features/ajax/aggregate/index.d.ts +2 -3
- package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/ajax/constants.d.ts +0 -1
- package/dist/types/features/ajax/constants.d.ts.map +1 -1
- package/dist/types/features/ajax/instrument/distributed-tracing.d.ts.map +1 -1
- package/dist/types/features/ajax/instrument/index.d.ts +1 -0
- package/dist/types/features/ajax/instrument/index.d.ts.map +1 -1
- package/dist/types/features/generic_events/aggregate/index.d.ts +6 -8
- package/dist/types/features/generic_events/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/generic_events/constants.d.ts +2 -0
- package/dist/types/features/generic_events/constants.d.ts.map +1 -1
- package/dist/types/features/generic_events/instrument/index.d.ts +1 -0
- package/dist/types/features/generic_events/instrument/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/aggregate/index.d.ts +2 -2
- package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/instrument/index.d.ts +1 -0
- package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -1
- package/dist/types/features/logging/aggregate/index.d.ts +4 -7
- package/dist/types/features/logging/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/logging/constants.d.ts +0 -1
- package/dist/types/features/logging/constants.d.ts.map +1 -1
- package/dist/types/features/logging/instrument/index.d.ts +1 -0
- package/dist/types/features/logging/instrument/index.d.ts.map +1 -1
- package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/metrics/aggregate/websocket-detection.d.ts +12 -0
- package/dist/types/features/metrics/aggregate/websocket-detection.d.ts.map +1 -0
- package/dist/types/features/metrics/constants.d.ts.map +1 -1
- package/dist/types/features/metrics/instrument/index.d.ts +1 -0
- package/dist/types/features/metrics/instrument/index.d.ts.map +1 -1
- package/dist/types/features/page_action/instrument/index.d.ts +4 -0
- package/dist/types/features/page_action/instrument/index.d.ts.map +1 -1
- package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/page_view_event/instrument/index.d.ts +1 -0
- package/dist/types/features/page_view_event/instrument/index.d.ts.map +1 -1
- package/dist/types/features/page_view_timing/aggregate/index.d.ts +2 -2
- package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/page_view_timing/instrument/index.d.ts +1 -0
- package/dist/types/features/page_view_timing/instrument/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/constants.d.ts +0 -4
- package/dist/types/features/session_replay/constants.d.ts.map +1 -1
- package/dist/types/features/session_replay/instrument/index.d.ts +1 -0
- package/dist/types/features/session_replay/instrument/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/shared/recorder-events.d.ts +6 -6
- package/dist/types/features/session_replay/shared/recorder-events.d.ts.map +1 -1
- package/dist/types/features/session_replay/shared/recorder.d.ts +2 -2
- package/dist/types/features/session_replay/shared/recorder.d.ts.map +1 -1
- package/dist/types/features/session_replay/shared/utils.d.ts.map +1 -1
- package/dist/types/features/session_trace/aggregate/index.d.ts +2 -2
- package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_trace/aggregate/trace/storage.d.ts +1 -1
- package/dist/types/features/session_trace/aggregate/trace/storage.d.ts.map +1 -1
- package/dist/types/features/session_trace/instrument/index.d.ts +1 -0
- package/dist/types/features/session_trace/instrument/index.d.ts.map +1 -1
- package/dist/types/features/soft_navigations/aggregate/index.d.ts +3 -3
- package/dist/types/features/soft_navigations/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/soft_navigations/instrument/index.d.ts +1 -0
- package/dist/types/features/soft_navigations/instrument/index.d.ts.map +1 -1
- package/dist/types/features/spa/aggregate/index.d.ts +2 -2
- package/dist/types/features/spa/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/spa/aggregate/interaction.d.ts.map +1 -1
- package/dist/types/features/spa/constants.d.ts.map +1 -1
- package/dist/types/features/spa/instrument/index.d.ts +1 -0
- package/dist/types/features/spa/instrument/index.d.ts.map +1 -1
- package/dist/types/features/utils/agent-session.d.ts.map +1 -1
- package/dist/types/features/utils/aggregate-base.d.ts +1 -0
- package/dist/types/features/utils/aggregate-base.d.ts.map +1 -1
- package/dist/types/features/utils/event-buffer.d.ts +72 -0
- package/dist/types/features/utils/event-buffer.d.ts.map +1 -0
- package/dist/types/features/utils/instrument-base.d.ts +1 -0
- package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
- package/dist/types/loaders/agent-base.d.ts +1 -1
- package/dist/types/loaders/agent.d.ts.map +1 -1
- package/dist/types/loaders/api/api.d.ts.map +1 -1
- package/dist/types/loaders/configure/configure.d.ts.map +1 -1
- package/dist/types/loaders/micro-agent.d.ts.map +1 -1
- package/package.json +55 -59
- package/src/common/config/__mocks__/info.js +3 -0
- package/src/common/config/__mocks__/init.js +3 -0
- package/src/common/config/__mocks__/loader-config.js +2 -0
- package/src/common/config/__mocks__/runtime.js +2 -0
- package/src/common/config/{state/configurable.js → configurable.js} +1 -1
- package/src/common/config/{state/info.js → info.js} +1 -1
- package/src/common/config/{state/init.js → init.js} +5 -5
- package/src/common/config/{state/loader-config.js → loader-config.js} +1 -1
- package/src/common/config/{state/runtime.js → runtime.js} +19 -5
- package/src/common/constants/agent-constants.js +2 -0
- package/src/common/drain/drain.js +5 -2
- package/src/common/event-emitter/contextual-ee.js +1 -1
- package/src/common/harvest/harvest.js +7 -21
- package/src/common/serialize/bel-serializer.js +5 -7
- package/src/common/session/session-entity.js +2 -2
- package/src/common/timing/__mocks__/time-keeper.js +6 -2
- package/src/common/timing/time-keeper.js +15 -5
- package/src/common/util/__mocks__/console.js +1 -0
- package/src/common/util/__mocks__/obfuscate.js +5 -8
- package/src/common/util/console.js +2 -0
- package/src/common/util/obfuscate.js +94 -50
- package/src/common/util/text.js +6 -0
- package/src/common/window/__mocks__/nreum.js +1 -1
- package/src/common/window/nreum.js +2 -1
- package/src/common/wrap/wrap-websocket.js +73 -0
- package/src/features/ajax/aggregate/chunk.js +3 -2
- package/src/features/ajax/aggregate/index.js +20 -19
- package/src/features/ajax/constants.js +0 -2
- package/src/features/ajax/instrument/distributed-tracing.js +2 -1
- package/src/features/ajax/instrument/index.js +9 -5
- package/src/features/generic_events/aggregate/index.js +43 -37
- package/src/features/generic_events/constants.js +2 -0
- package/src/features/generic_events/instrument/index.js +3 -1
- package/src/features/jserrors/aggregate/index.js +14 -4
- package/src/features/jserrors/instrument/index.js +2 -0
- package/src/features/logging/aggregate/index.js +39 -31
- package/src/features/logging/constants.js +0 -2
- package/src/features/logging/instrument/index.js +2 -0
- package/src/features/logging/shared/utils.js +1 -1
- package/src/features/metrics/aggregate/index.js +24 -9
- package/src/features/metrics/aggregate/websocket-detection.js +31 -0
- package/src/features/metrics/constants.js +3 -0
- package/src/features/metrics/instrument/index.js +13 -1
- package/src/features/page_action/instrument/index.js +5 -0
- package/src/features/page_view_event/aggregate/index.js +8 -23
- package/src/features/page_view_event/instrument/index.js +2 -0
- package/src/features/page_view_timing/aggregate/index.js +14 -16
- package/src/features/page_view_timing/instrument/index.js +2 -0
- package/src/features/session_replay/aggregate/index.js +13 -9
- package/src/features/session_replay/constants.js +0 -4
- package/src/features/session_replay/index.js +1 -7
- package/src/features/session_replay/instrument/index.js +3 -4
- package/src/features/session_replay/shared/recorder-events.js +27 -20
- package/src/features/session_replay/shared/recorder.js +13 -6
- package/src/features/session_replay/shared/stylesheet-evaluator.js +2 -2
- package/src/features/session_replay/shared/utils.js +3 -2
- package/src/features/session_trace/aggregate/index.js +16 -7
- package/src/features/session_trace/aggregate/trace/storage.js +6 -1
- package/src/features/session_trace/instrument/index.js +4 -1
- package/src/features/soft_navigations/aggregate/ajax-node.js +1 -1
- package/src/features/soft_navigations/aggregate/index.js +13 -15
- package/src/features/soft_navigations/aggregate/initial-page-load-interaction.js +1 -1
- package/src/features/soft_navigations/aggregate/interaction.js +1 -1
- package/src/features/soft_navigations/instrument/index.js +9 -5
- package/src/features/spa/aggregate/index.js +11 -18
- package/src/features/spa/aggregate/interaction.js +5 -3
- package/src/features/spa/aggregate/serializer.js +1 -1
- package/src/features/spa/constants.js +2 -2
- package/src/features/spa/instrument/index.js +9 -3
- package/src/features/utils/agent-session.js +3 -1
- package/src/features/utils/aggregate-base.js +10 -2
- package/src/features/utils/event-buffer.js +126 -0
- package/src/features/utils/feature-gates.js +1 -1
- package/src/features/utils/instrument-base.js +2 -1
- package/src/loaders/agent-base.js +2 -2
- package/src/loaders/agent.js +7 -2
- package/src/loaders/api/api.js +2 -1
- package/src/loaders/api/apiAsync.js +1 -1
- package/src/loaders/configure/configure.js +4 -1
- package/src/loaders/features/enabled-features.js +1 -1
- package/src/loaders/micro-agent.js +4 -1
- package/dist/cjs/common/config/config.js +0 -76
- package/dist/cjs/common/config/state/originals.js +0 -8
- package/dist/cjs/common/wrap/index.js +0 -61
- package/dist/esm/common/config/config.js +0 -11
- package/dist/esm/common/config/state/originals.js +0 -2
- package/dist/esm/common/wrap/index.js +0 -13
- package/dist/types/common/config/config.d.ts +0 -13
- package/dist/types/common/config/config.d.ts.map +0 -1
- package/dist/types/common/config/state/configurable.d.ts.map +0 -1
- package/dist/types/common/config/state/info.d.ts.map +0 -1
- package/dist/types/common/config/state/init.d.ts.map +0 -1
- package/dist/types/common/config/state/loader-config.d.ts.map +0 -1
- package/dist/types/common/config/state/originals.d.ts +0 -2
- package/dist/types/common/config/state/originals.d.ts.map +0 -1
- package/dist/types/common/config/state/runtime.d.ts.map +0 -1
- package/dist/types/common/wrap/index.d.ts +0 -10
- package/dist/types/common/wrap/index.d.ts.map +0 -1
- package/src/common/config/__mocks__/config.js +0 -11
- package/src/common/config/config.js +0 -12
- package/src/common/config/state/originals.js +0 -3
- package/src/common/wrap/index.js +0 -16
- /package/dist/types/common/config/{state/configurable.d.ts → configurable.d.ts} +0 -0
- /package/dist/types/common/config/{state/info.d.ts → info.d.ts} +0 -0
- /package/dist/types/common/config/{state/init.d.ts → init.d.ts} +0 -0
- /package/dist/types/common/config/{state/loader-config.d.ts → loader-config.d.ts} +0 -0
- /package/dist/types/common/config/{state/runtime.d.ts → runtime.d.ts} +0 -0
|
@@ -5,11 +5,10 @@ import { initiallyHidden, isBrowserScope } from '../constants/runtime';
|
|
|
5
5
|
import { cleanURL } from '../url/clean-url';
|
|
6
6
|
export const largestContentfulPaint = new VitalMetric(VITAL_NAMES.LARGEST_CONTENTFUL_PAINT);
|
|
7
7
|
if (isBrowserScope) {
|
|
8
|
-
onLCP(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} = _ref;
|
|
8
|
+
onLCP(({
|
|
9
|
+
value,
|
|
10
|
+
attribution
|
|
11
|
+
}) => {
|
|
13
12
|
/* Largest Contentful Paint - As of WV v3, it still imperfectly tries to detect document vis state asap and isn't supposed to report if page starts hidden. */
|
|
14
13
|
if (initiallyHidden || largestContentfulPaint.isValid) return;
|
|
15
14
|
let attrs;
|
|
@@ -12,11 +12,10 @@ export const timeToFirstByte = new VitalMetric(VITAL_NAMES.TIME_TO_FIRST_BYTE);
|
|
|
12
12
|
* - cross-origin iframes specifically in firefox and safari
|
|
13
13
|
*/
|
|
14
14
|
if (isBrowserScope && typeof PerformanceNavigationTiming !== 'undefined' && !isiOS && window === window.parent) {
|
|
15
|
-
onTTFB(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} = _ref;
|
|
15
|
+
onTTFB(({
|
|
16
|
+
value,
|
|
17
|
+
attribution
|
|
18
|
+
}) => {
|
|
20
19
|
if (timeToFirstByte.isValid) return;
|
|
21
20
|
timeToFirstByte.update({
|
|
22
21
|
value,
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
export class VitalMetric {
|
|
2
|
-
#subscribers =
|
|
2
|
+
#subscribers = new Set();
|
|
3
3
|
history = [];
|
|
4
4
|
constructor(name, roundingMethod) {
|
|
5
5
|
this.name = name;
|
|
6
6
|
this.attrs = {};
|
|
7
7
|
this.roundingMethod = typeof roundingMethod === 'function' ? roundingMethod : Math.floor;
|
|
8
8
|
}
|
|
9
|
-
update(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} = _ref;
|
|
9
|
+
update({
|
|
10
|
+
value,
|
|
11
|
+
attrs = {}
|
|
12
|
+
}) {
|
|
14
13
|
if (value === undefined || value === null || value < 0) return;
|
|
15
14
|
const state = {
|
|
16
15
|
value: this.roundingMethod(value),
|
|
@@ -36,8 +35,7 @@ export class VitalMetric {
|
|
|
36
35
|
get isValid() {
|
|
37
36
|
return this.current.value >= 0;
|
|
38
37
|
}
|
|
39
|
-
subscribe(callback) {
|
|
40
|
-
let buffered = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
38
|
+
subscribe(callback, buffered = true) {
|
|
41
39
|
if (typeof callback !== 'function') return;
|
|
42
40
|
this.#subscribers.add(callback);
|
|
43
41
|
// emit full history on subscription ("buffered" behavior)
|
|
@@ -50,7 +50,8 @@ export function gosNREUMOriginals() {
|
|
|
50
50
|
PR: globalScope.Promise,
|
|
51
51
|
MO: globalScope.MutationObserver,
|
|
52
52
|
// this'll be undefined if not in a web window
|
|
53
|
-
FETCH: globalScope.fetch
|
|
53
|
+
FETCH: globalScope.fetch,
|
|
54
|
+
WS: globalScope.WebSocket
|
|
54
55
|
};
|
|
55
56
|
}
|
|
56
57
|
return nr;
|
|
@@ -10,10 +10,7 @@ import { documentAddEventListener } from '../event-listener/event-listener-opts'
|
|
|
10
10
|
* @param {boolean} [toHiddenOnly=false] - only execute the 'cb' when the vis is changing to the hidden state; no arg is passed to 'cb' if used
|
|
11
11
|
* @returns void
|
|
12
12
|
*/
|
|
13
|
-
export function subscribeToVisibilityChange(cb) {
|
|
14
|
-
let toHiddenOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
15
|
-
let capture = arguments.length > 2 ? arguments[2] : undefined;
|
|
16
|
-
let abortSignal = arguments.length > 3 ? arguments[3] : undefined;
|
|
13
|
+
export function subscribeToVisibilityChange(cb, toHiddenOnly = false, capture, abortSignal) {
|
|
17
14
|
documentAddEventListener('visibilitychange', handleVisibilityChange, capture, abortSignal);
|
|
18
15
|
function handleVisibilityChange() {
|
|
19
16
|
if (toHiddenOnly) {
|
|
@@ -75,14 +75,11 @@ export function wrapEvents(sharedEE) {
|
|
|
75
75
|
* @param {Function} cb - the function to run on the ancestral object once found, accepts an object as a arg
|
|
76
76
|
* @param {Array} rest - [optional] any additional arguments to pass to the cb
|
|
77
77
|
*/
|
|
78
|
-
function findEventListenerProtoAndCb(object, cb) {
|
|
78
|
+
function findEventListenerProtoAndCb(object, cb, ...rest) {
|
|
79
79
|
let step = object;
|
|
80
80
|
while (typeof step === 'object' && !Object.prototype.hasOwnProperty.call(step, ADD_EVENT_LISTENER)) {
|
|
81
81
|
step = Object.getPrototypeOf(step);
|
|
82
82
|
}
|
|
83
|
-
for (var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
84
|
-
rest[_key - 2] = arguments[_key];
|
|
85
|
-
}
|
|
86
83
|
if (step) cb(step, ...rest);
|
|
87
84
|
}
|
|
88
85
|
|
|
@@ -104,13 +104,10 @@ export function wrapPromise(sharedEE) {
|
|
|
104
104
|
|
|
105
105
|
// Note that this wrapping affects the same originals.PR (prototype) object.
|
|
106
106
|
const prevPromiseOrigThen = prevPromiseObj.prototype.then;
|
|
107
|
-
prevPromiseObj.prototype.then = function wrappedThen() {
|
|
107
|
+
prevPromiseObj.prototype.then = function wrappedThen(...args) {
|
|
108
108
|
var originalThis = this;
|
|
109
109
|
var ctx = getContext(originalThis);
|
|
110
110
|
ctx.promise = originalThis;
|
|
111
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
112
|
-
args[_key] = arguments[_key];
|
|
113
|
-
}
|
|
114
111
|
args[0] = promiseWrapper(args[0], 'cb-', ctx, null, false);
|
|
115
112
|
args[1] = promiseWrapper(args[1], 'cb-', ctx, null, false);
|
|
116
113
|
const origFnCallWithThis = prevPromiseOrigThen.apply(this, args);
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { globalScope } from '../constants/runtime';
|
|
2
|
+
import { now } from '../timing/now';
|
|
3
|
+
import { checkState } from '../window/load';
|
|
4
|
+
import { generateRandomHexString } from '../ids/unique-id';
|
|
5
|
+
import { gosNREUMOriginals } from '../window/nreum';
|
|
6
|
+
export const WEBSOCKET_TAG = 'websocket-';
|
|
7
|
+
export const ADD_EVENT_LISTENER_TAG = 'addEventListener';
|
|
8
|
+
const wrapped = {};
|
|
9
|
+
export function wrapWebSocket(sharedEE) {
|
|
10
|
+
if (wrapped[sharedEE.debugId]++) return sharedEE;
|
|
11
|
+
const originals = gosNREUMOriginals().o;
|
|
12
|
+
if (!originals.WS) return sharedEE;
|
|
13
|
+
function reporter(socketId) {
|
|
14
|
+
const createdAt = now();
|
|
15
|
+
return function (message, ...data) {
|
|
16
|
+
const timestamp = data[0]?.timeStamp || now();
|
|
17
|
+
const isLoaded = checkState();
|
|
18
|
+
sharedEE.emit(WEBSOCKET_TAG + message, [timestamp, timestamp - createdAt, isLoaded, socketId, ...data]);
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
Object.defineProperty(WrappedWebSocket, 'name', {
|
|
22
|
+
value: 'WebSocket'
|
|
23
|
+
});
|
|
24
|
+
function WrappedWebSocket() {
|
|
25
|
+
const ws = new originals.WS(...arguments);
|
|
26
|
+
const socketId = generateRandomHexString(6);
|
|
27
|
+
const report = reporter(socketId);
|
|
28
|
+
report('new');
|
|
29
|
+
const events = ['message', 'error', 'open', 'close'];
|
|
30
|
+
/** add event listeners */
|
|
31
|
+
events.forEach(evt => {
|
|
32
|
+
ws.addEventListener(evt, function (e) {
|
|
33
|
+
report(ADD_EVENT_LISTENER_TAG, {
|
|
34
|
+
eventType: evt,
|
|
35
|
+
event: e
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
/** could also observe the on-events for runtime processing, but not implemented yet */
|
|
41
|
+
|
|
42
|
+
/** observe the static method send, but noteably not close, as that is currently observed with the event listener */;
|
|
43
|
+
['send'].forEach(wrapStaticProperty);
|
|
44
|
+
function wrapStaticProperty(prop) {
|
|
45
|
+
const originalProp = ws[prop];
|
|
46
|
+
if (originalProp) {
|
|
47
|
+
Object.defineProperty(proxiedProp, 'name', {
|
|
48
|
+
value: prop
|
|
49
|
+
});
|
|
50
|
+
function proxiedProp() {
|
|
51
|
+
report(prop, ...arguments);
|
|
52
|
+
try {
|
|
53
|
+
return originalProp.apply(this, arguments);
|
|
54
|
+
} catch (err) {
|
|
55
|
+
report(prop + '-err', ...arguments);
|
|
56
|
+
// rethrow error so we don't effect execution by observing.
|
|
57
|
+
throw err;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
ws[prop] = proxiedProp;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return ws;
|
|
64
|
+
}
|
|
65
|
+
globalScope.WebSocket = WrappedWebSocket;
|
|
66
|
+
return sharedEE;
|
|
67
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { nullable, numeric, getAddStringContext, addCustomAttributes } from '../../../common/serialize/bel-serializer';
|
|
2
|
-
import { getInfo } from '../../../common/config/
|
|
2
|
+
import { getInfo } from '../../../common/config/info';
|
|
3
|
+
import { MAX_PAYLOAD_SIZE } from '../../../common/constants/agent-constants';
|
|
3
4
|
export default class Chunk {
|
|
4
5
|
constructor(events, aggregateInstance) {
|
|
5
6
|
this.addString = getAddStringContext(aggregateInstance.agentIdentifier); // pass agentIdentifier here
|
|
@@ -38,6 +39,6 @@ export default class Chunk {
|
|
|
38
39
|
if (i + 1 < events.length) insert += ';';
|
|
39
40
|
this.payload += insert;
|
|
40
41
|
}
|
|
41
|
-
this.tooBig = this.payload.length * 2 >
|
|
42
|
+
this.tooBig = this.payload.length * 2 > MAX_PAYLOAD_SIZE;
|
|
42
43
|
}
|
|
43
44
|
}
|
|
@@ -14,11 +14,10 @@ import { isPureObject } from '../../../common/util/type-check';
|
|
|
14
14
|
* @param {string} query Ajax request query param string
|
|
15
15
|
* @returns {GQLMetadata | undefined}
|
|
16
16
|
*/
|
|
17
|
-
export function parseGQL(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
17
|
+
export function parseGQL({
|
|
18
|
+
body,
|
|
19
|
+
query
|
|
20
|
+
} = {}) {
|
|
22
21
|
if (!body && !query) return;
|
|
23
22
|
try {
|
|
24
23
|
const gqlBody = parseBatchGQL(parseGQLContents(body));
|
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
import { registerHandler } from '../../../common/event-emitter/register-handler';
|
|
6
6
|
import { stringify } from '../../../common/util/stringify';
|
|
7
7
|
import { handle } from '../../../common/event-emitter/handle';
|
|
8
|
-
import {
|
|
8
|
+
import { getInfo } from '../../../common/config/info';
|
|
9
|
+
import { getConfiguration } from '../../../common/config/init';
|
|
10
|
+
import { getRuntime } from '../../../common/config/runtime';
|
|
9
11
|
import { HarvestScheduler } from '../../../common/harvest/harvest-scheduler';
|
|
10
12
|
import { setDenyList, shouldCollectEvent } from '../../../common/deny-list/deny-list';
|
|
11
13
|
import { FEATURE_NAME } from '../constants';
|
|
@@ -15,8 +17,9 @@ import { AggregateBase } from '../../utils/aggregate-base';
|
|
|
15
17
|
import { parseGQL } from './gql';
|
|
16
18
|
import { getNREUMInitializedAgent } from '../../../common/window/nreum';
|
|
17
19
|
import Chunk from './chunk';
|
|
20
|
+
import { EventBuffer } from '../../utils/event-buffer';
|
|
18
21
|
export class Aggregate extends AggregateBase {
|
|
19
|
-
static featureName =
|
|
22
|
+
static featureName = FEATURE_NAME;
|
|
20
23
|
#agentInfo;
|
|
21
24
|
#agentRuntime;
|
|
22
25
|
#agentInit;
|
|
@@ -26,25 +29,23 @@ export class Aggregate extends AggregateBase {
|
|
|
26
29
|
this.#agentRuntime = getRuntime(agentIdentifier);
|
|
27
30
|
this.#agentInit = getConfiguration(agentIdentifier);
|
|
28
31
|
const harvestTimeSeconds = this.#agentInit.ajax.harvestTimeSeconds || 10;
|
|
29
|
-
this.MAX_PAYLOAD_SIZE = this.#agentInit.ajax.maxPayloadSize || 1000000;
|
|
30
32
|
setDenyList(this.#agentRuntime.denyList);
|
|
31
|
-
this.ajaxEvents =
|
|
33
|
+
this.ajaxEvents = new EventBuffer();
|
|
32
34
|
this.spaAjaxEvents = {};
|
|
33
|
-
this.sentAjaxEvents = [];
|
|
34
35
|
const classThis = this;
|
|
35
36
|
|
|
36
37
|
// --- v Used by old spa feature
|
|
37
38
|
this.ee.on('interactionDone', (interaction, wasSaved) => {
|
|
38
|
-
if (!this.spaAjaxEvents[interaction.id]) return;
|
|
39
|
+
if (!this.spaAjaxEvents[interaction.id]?.hasData) return;
|
|
39
40
|
if (!wasSaved) {
|
|
40
41
|
// if the ixn was saved, then its ajax reqs are part of the payload whereas if it was discarded, it should still be harvested in the ajax feature itself
|
|
41
|
-
this.spaAjaxEvents[interaction.id]
|
|
42
|
+
this.ajaxEvents.merge(this.spaAjaxEvents[interaction.id]);
|
|
42
43
|
}
|
|
43
44
|
delete this.spaAjaxEvents[interaction.id];
|
|
44
45
|
});
|
|
45
46
|
// --- ^
|
|
46
47
|
// --- v Used by new soft nav
|
|
47
|
-
registerHandler('returnAjax', event => this.ajaxEvents.
|
|
48
|
+
registerHandler('returnAjax', event => this.ajaxEvents.add(event), this.featureName, this.ee);
|
|
48
49
|
// --- ^
|
|
49
50
|
registerHandler('xhr', function () {
|
|
50
51
|
// the EE-drain system not only switches "this" but also passes a new EventContext with info. Should consider platform refactor to another system which passes a mutable context around separately and predictably to avoid problems like this.
|
|
@@ -104,7 +105,7 @@ export class Aggregate extends AggregateBase {
|
|
|
104
105
|
if (ctx.dt) {
|
|
105
106
|
event.spanId = ctx.dt.spanId;
|
|
106
107
|
event.traceId = ctx.dt.traceId;
|
|
107
|
-
event.spanTimestamp = this.#agentRuntime.timeKeeper.correctAbsoluteTimestamp(ctx.dt.timestamp);
|
|
108
|
+
event.spanTimestamp = Math.floor(this.#agentRuntime.timeKeeper.correctAbsoluteTimestamp(ctx.dt.timestamp));
|
|
108
109
|
}
|
|
109
110
|
|
|
110
111
|
// parsed from the AJAX body, looking for operationName param & parsing query for operationType
|
|
@@ -120,31 +121,27 @@ export class Aggregate extends AggregateBase {
|
|
|
120
121
|
} else if (ctx.spaNode) {
|
|
121
122
|
// For old spa (when running), if the ajax happened inside an interaction, hold it until the interaction finishes
|
|
122
123
|
const interactionId = ctx.spaNode.interaction.id;
|
|
123
|
-
this.spaAjaxEvents[interactionId]
|
|
124
|
-
this.spaAjaxEvents[interactionId].
|
|
124
|
+
this.spaAjaxEvents[interactionId] ??= new EventBuffer();
|
|
125
|
+
this.spaAjaxEvents[interactionId].add(event);
|
|
125
126
|
} else {
|
|
126
|
-
this.ajaxEvents.
|
|
127
|
+
this.ajaxEvents.add(event);
|
|
127
128
|
}
|
|
128
129
|
}
|
|
129
130
|
prepareHarvest(options) {
|
|
130
131
|
options = options || {};
|
|
131
|
-
if (this.ajaxEvents.length === 0) return null;
|
|
132
|
-
const payload = this.#getPayload(this.ajaxEvents);
|
|
132
|
+
if (this.ajaxEvents.buffer.length === 0) return null;
|
|
133
|
+
const payload = this.#getPayload(this.ajaxEvents.buffer);
|
|
133
134
|
const payloadObjs = [];
|
|
134
135
|
for (let i = 0; i < payload.length; i++) payloadObjs.push({
|
|
135
136
|
body: {
|
|
136
137
|
e: payload[i]
|
|
137
138
|
}
|
|
138
139
|
});
|
|
139
|
-
if (options.retry) this.
|
|
140
|
-
this.ajaxEvents = [];
|
|
140
|
+
if (options.retry) this.ajaxEvents.hold();else this.ajaxEvents.clear();
|
|
141
141
|
return payloadObjs;
|
|
142
142
|
}
|
|
143
143
|
onEventsHarvestFinished(result) {
|
|
144
|
-
if (result.retry && this.
|
|
145
|
-
this.ajaxEvents.unshift(...this.sentAjaxEvents);
|
|
146
|
-
this.sentAjaxEvents = [];
|
|
147
|
-
}
|
|
144
|
+
if (result.retry && this.ajaxEvents.held.hasData) this.ajaxEvents.unhold();else this.ajaxEvents.held.clear();
|
|
148
145
|
}
|
|
149
146
|
#getPayload(events, numberOfChunks) {
|
|
150
147
|
numberOfChunks = numberOfChunks || 1;
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
|
-
import { getConfiguration, getConfigurationValue
|
|
5
|
+
import { getConfiguration, getConfigurationValue } from '../../../common/config/init';
|
|
6
|
+
import { getLoaderConfig } from '../../../common/config/loader-config';
|
|
6
7
|
import { generateSpanId, generateTraceId } from '../../../common/ids/unique-id';
|
|
7
8
|
import { parseUrl } from '../../../common/url/parse-url';
|
|
8
9
|
import { globalScope } from '../../../common/constants/runtime';
|
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { gosNREUMOriginals } from '../../../common/window/nreum';
|
|
6
|
+
import { getLoaderConfig } from '../../../common/config/loader-config';
|
|
6
7
|
import { handle } from '../../../common/event-emitter/handle';
|
|
7
8
|
import { id } from '../../../common/ids/id';
|
|
8
9
|
import { ffVersion, globalScope, isBrowserScope } from '../../../common/constants/runtime';
|
|
9
10
|
import { dataSize } from '../../../common/util/data-size';
|
|
10
11
|
import { eventListenerOpts } from '../../../common/event-listener/event-listener-opts';
|
|
11
|
-
import {
|
|
12
|
+
import { wrapXhr } from '../../../common/wrap/wrap-xhr';
|
|
13
|
+
import { wrapFetch } from '../../../common/wrap/wrap-fetch';
|
|
12
14
|
import { parseUrl } from '../../../common/url/parse-url';
|
|
13
15
|
import { DT } from './distributed-tracing';
|
|
14
16
|
import { responseSizeFromXhr } from './response-size';
|
|
@@ -20,12 +22,11 @@ import { now } from '../../../common/timing/now';
|
|
|
20
22
|
import { hasUndefinedHostname } from '../../../common/deny-list/deny-list';
|
|
21
23
|
var handlers = ['load', 'error', 'abort', 'timeout'];
|
|
22
24
|
var handlersLen = handlers.length;
|
|
23
|
-
var origRequest =
|
|
24
|
-
var origXHR =
|
|
25
|
+
var origRequest = gosNREUMOriginals().o.REQ;
|
|
26
|
+
var origXHR = gosNREUMOriginals().o.XHR;
|
|
25
27
|
export class Instrument extends InstrumentBase {
|
|
26
|
-
static featureName =
|
|
27
|
-
constructor(agentIdentifier, aggregator) {
|
|
28
|
-
let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
28
|
+
static featureName = FEATURE_NAME;
|
|
29
|
+
constructor(agentIdentifier, aggregator, auto = true) {
|
|
29
30
|
super(agentIdentifier, aggregator, FEATURE_NAME, auto);
|
|
30
31
|
this.dt = new DT(agentIdentifier);
|
|
31
32
|
this.handler = (type, args, ctx, group) => handle(type, args, ctx, group, this.ee);
|
|
@@ -339,7 +340,7 @@ function subscribeToEvents(agentIdentifier, ee, handler, dt) {
|
|
|
339
340
|
if (hasUndefinedHostname(params)) return; // don't bother with XHR of url with no hostname
|
|
340
341
|
|
|
341
342
|
metrics.duration = now() - this.startTime;
|
|
342
|
-
if (!this.
|
|
343
|
+
if (!this.loadCazptureCalled && xhr.readyState === 4) {
|
|
343
344
|
captureXhrData(this, xhr);
|
|
344
345
|
} else if (params.status == null) {
|
|
345
346
|
params.status = 0;
|
|
@@ -373,4 +374,5 @@ function addUrl(ctx, url) {
|
|
|
373
374
|
params.pathname = parsed.pathname;
|
|
374
375
|
ctx.parsedOrigin = parsed;
|
|
375
376
|
ctx.sameOrigin = parsed.sameOrigin;
|
|
376
|
-
}
|
|
377
|
+
}
|
|
378
|
+
export const Ajax = Instrument;
|
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
import { stringify } from '../../../common/util/stringify';
|
|
6
6
|
import { HarvestScheduler } from '../../../common/harvest/harvest-scheduler';
|
|
7
7
|
import { cleanURL } from '../../../common/url/clean-url';
|
|
8
|
-
import {
|
|
8
|
+
import { getInfo } from '../../../common/config/info';
|
|
9
|
+
import { getConfigurationValue } from '../../../common/config/init';
|
|
10
|
+
import { getRuntime } from '../../../common/config/runtime';
|
|
9
11
|
import { FEATURE_NAME } from '../constants';
|
|
10
12
|
import { isBrowserScope } from '../../../common/constants/runtime';
|
|
11
13
|
import { AggregateBase } from '../../utils/aggregate-base';
|
|
@@ -14,22 +16,20 @@ import { now } from '../../../common/timing/now';
|
|
|
14
16
|
import { registerHandler } from '../../../common/event-emitter/register-handler';
|
|
15
17
|
import { deregisterDrain } from '../../../common/drain/drain';
|
|
16
18
|
import { SUPPORTABILITY_METRIC_CHANNEL } from '../../metrics/constants';
|
|
19
|
+
import { EventBuffer } from '../../utils/event-buffer';
|
|
20
|
+
import { applyFnToProps } from '../../../common/util/traverse';
|
|
21
|
+
import { IDEAL_PAYLOAD_SIZE } from '../../../common/constants/agent-constants';
|
|
17
22
|
export class Aggregate extends AggregateBase {
|
|
18
23
|
#agentRuntime;
|
|
19
|
-
static featureName =
|
|
24
|
+
static featureName = FEATURE_NAME;
|
|
20
25
|
constructor(agentIdentifier, aggregator) {
|
|
21
|
-
var _this;
|
|
22
26
|
super(agentIdentifier, aggregator, FEATURE_NAME);
|
|
23
|
-
_this = this;
|
|
24
27
|
this.eventsPerHarvest = 1000;
|
|
25
28
|
this.harvestTimeSeconds = getConfigurationValue(this.agentIdentifier, 'generic_events.harvestTimeSeconds');
|
|
26
29
|
this.referrerUrl = isBrowserScope && document.referrer ? cleanURL(document.referrer) : undefined;
|
|
27
|
-
this.
|
|
28
|
-
this.events = [];
|
|
29
|
-
this.overflow = [];
|
|
30
|
+
this.events = new EventBuffer();
|
|
30
31
|
this.#agentRuntime = getRuntime(this.agentIdentifier);
|
|
31
|
-
this.waitForFlags(['ins']).then(
|
|
32
|
-
let [ins] = _ref;
|
|
32
|
+
this.waitForFlags(['ins']).then(([ins]) => {
|
|
33
33
|
if (!ins) {
|
|
34
34
|
this.blocked = true;
|
|
35
35
|
deregisterDrain(this.agentIdentifier, this.featureName);
|
|
@@ -40,7 +40,7 @@ export class Aggregate extends AggregateBase {
|
|
|
40
40
|
this.addEvent({
|
|
41
41
|
...attributes,
|
|
42
42
|
eventType: 'PageAction',
|
|
43
|
-
timestamp: this.#agentRuntime.timeKeeper.convertRelativeTimestamp(timestamp),
|
|
43
|
+
timestamp: Math.floor(this.#agentRuntime.timeKeeper.correctAbsoluteTimestamp(this.#agentRuntime.timeKeeper.convertRelativeTimestamp(timestamp))),
|
|
44
44
|
timeSinceLoad: timestamp / 1000,
|
|
45
45
|
actionName: name,
|
|
46
46
|
referrerUrl: this.referrerUrl,
|
|
@@ -53,47 +53,16 @@ export class Aggregate extends AggregateBase {
|
|
|
53
53
|
}, this.featureName, this.ee);
|
|
54
54
|
}
|
|
55
55
|
this.harvestScheduler = new HarvestScheduler('ins', {
|
|
56
|
-
onFinished:
|
|
57
|
-
return _this.onHarvestFinished(...arguments);
|
|
58
|
-
}
|
|
56
|
+
onFinished: (...args) => this.onHarvestFinished(...args)
|
|
59
57
|
}, this);
|
|
60
|
-
this.harvestScheduler.harvest.on('ins',
|
|
61
|
-
return _this.onHarvestStarted(...arguments);
|
|
62
|
-
});
|
|
58
|
+
this.harvestScheduler.harvest.on('ins', (...args) => this.onHarvestStarted(...args));
|
|
63
59
|
this.harvestScheduler.startTimer(this.harvestTimeSeconds, 0);
|
|
64
60
|
this.drain();
|
|
65
61
|
});
|
|
66
62
|
}
|
|
67
|
-
onHarvestStarted(options) {
|
|
68
|
-
const {
|
|
69
|
-
userAttributes,
|
|
70
|
-
atts
|
|
71
|
-
} = getInfo(this.agentIdentifier);
|
|
72
|
-
const harvestEvents = this.overflow.length ? this.overflow.splice(0, Infinity) : this.events.splice(0, Infinity);
|
|
73
|
-
var payload = {
|
|
74
|
-
qs: {
|
|
75
|
-
ua: userAttributes,
|
|
76
|
-
at: atts
|
|
77
|
-
},
|
|
78
|
-
body: {
|
|
79
|
-
ins: harvestEvents
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
if (options.retry) {
|
|
83
|
-
this.currentEvents = harvestEvents;
|
|
84
|
-
}
|
|
85
|
-
return payload;
|
|
86
|
-
}
|
|
87
|
-
onHarvestFinished(result) {
|
|
88
|
-
if (result && result.sent && result.retry && this.currentEvents.length) {
|
|
89
|
-
this.events = this.currentEvents.concat(this.events);
|
|
90
|
-
this.currentEvents = [];
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
63
|
|
|
94
64
|
// WARNING: Insights times are in seconds. EXCEPT timestamp, which is in ms.
|
|
95
|
-
addEvent() {
|
|
96
|
-
let obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
65
|
+
addEvent(obj = {}) {
|
|
97
66
|
if (!obj || !Object.keys(obj).length) return;
|
|
98
67
|
if (!obj.eventType) {
|
|
99
68
|
warn(44);
|
|
@@ -105,7 +74,7 @@ export class Aggregate extends AggregateBase {
|
|
|
105
74
|
}
|
|
106
75
|
const defaultEventAttributes = {
|
|
107
76
|
/** should be overridden by the event-specific attributes, but just in case -- set it to now() */
|
|
108
|
-
timestamp: this.#agentRuntime.timeKeeper.convertRelativeTimestamp(now()),
|
|
77
|
+
timestamp: Math.floor(this.#agentRuntime.timeKeeper.correctAbsoluteTimestamp(this.#agentRuntime.timeKeeper.convertRelativeTimestamp(now()))),
|
|
109
78
|
/** all generic events require a pageUrl */
|
|
110
79
|
pageUrl: cleanURL(getRuntime(this.agentIdentifier).origin)
|
|
111
80
|
};
|
|
@@ -117,12 +86,34 @@ export class Aggregate extends AggregateBase {
|
|
|
117
86
|
/** Event-specific attributes take precedence over agent-level custom attributes and fallbacks */
|
|
118
87
|
...obj
|
|
119
88
|
};
|
|
120
|
-
this.events.
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
89
|
+
this.events.add(eventAttributes);
|
|
90
|
+
this.checkEventLimits();
|
|
91
|
+
}
|
|
92
|
+
onHarvestStarted(options) {
|
|
93
|
+
const {
|
|
94
|
+
userAttributes,
|
|
95
|
+
atts
|
|
96
|
+
} = getInfo(this.agentIdentifier);
|
|
97
|
+
if (!this.events.hasData) return;
|
|
98
|
+
var payload = {
|
|
99
|
+
qs: {
|
|
100
|
+
ua: userAttributes,
|
|
101
|
+
at: atts
|
|
102
|
+
},
|
|
103
|
+
body: applyFnToProps({
|
|
104
|
+
ins: this.events.buffer
|
|
105
|
+
}, this.obfuscator.obfuscateString.bind(this.obfuscator), 'string')
|
|
106
|
+
};
|
|
107
|
+
if (options.retry) this.events.hold();
|
|
108
|
+
return payload;
|
|
109
|
+
}
|
|
110
|
+
onHarvestFinished(result) {
|
|
111
|
+
if (result && result?.sent && result?.retry && this.events.held.hasData) this.events.unhold();else this.events.held.clear();
|
|
112
|
+
}
|
|
113
|
+
checkEventLimits() {
|
|
114
|
+
// check if we've reached any harvest limits...
|
|
115
|
+
if (this.events.bytes > IDEAL_PAYLOAD_SIZE) {
|
|
124
116
|
this.ee.emit(SUPPORTABILITY_METRIC_CHANNEL, ['GenericEvents/Harvest/Max/Seen']);
|
|
125
|
-
this.overflow = [...this.overflow, ...this.events.splice(0, Infinity)];
|
|
126
117
|
this.harvestScheduler.runHarvest();
|
|
127
118
|
}
|
|
128
119
|
}
|
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
* SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { getConfigurationValue } from '../../../common/config/
|
|
5
|
+
import { getConfigurationValue } from '../../../common/config/init';
|
|
6
6
|
import { deregisterDrain } from '../../../common/drain/drain';
|
|
7
7
|
import { InstrumentBase } from '../../utils/instrument-base';
|
|
8
8
|
import { FEATURE_NAME } from '../constants';
|
|
9
9
|
export class Instrument extends InstrumentBase {
|
|
10
|
-
static featureName =
|
|
11
|
-
constructor(agentIdentifier, aggregator) {
|
|
12
|
-
let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
10
|
+
static featureName = FEATURE_NAME;
|
|
11
|
+
constructor(agentIdentifier, aggregator, auto = true) {
|
|
13
12
|
super(agentIdentifier, aggregator, FEATURE_NAME, auto);
|
|
14
13
|
const genericEventSourceConfigs = [getConfigurationValue(this.agentIdentifier, 'page_action.enabled')
|
|
15
14
|
// other future generic event source configs to go here, like M&Ms, PageResouce, etc.
|
|
@@ -17,4 +16,5 @@ export class Instrument extends InstrumentBase {
|
|
|
17
16
|
/** If any of the sources are active, import the aggregator. otherwise deregister */
|
|
18
17
|
if (genericEventSourceConfigs.some(x => x)) this.importAggregator();else deregisterDrain(this.agentIdentifier, this.featureName);
|
|
19
18
|
}
|
|
20
|
-
}
|
|
19
|
+
}
|
|
20
|
+
export const GenericEvents = Instrument;
|