@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
|
@@ -11,7 +11,9 @@ import { registerHandler as register } from '../../../common/event-emitter/regis
|
|
|
11
11
|
import { HarvestScheduler } from '../../../common/harvest/harvest-scheduler';
|
|
12
12
|
import { stringify } from '../../../common/util/stringify';
|
|
13
13
|
import { handle } from '../../../common/event-emitter/handle';
|
|
14
|
-
import { getInfo
|
|
14
|
+
import { getInfo } from '../../../common/config/info';
|
|
15
|
+
import { getConfigurationValue } from '../../../common/config/init';
|
|
16
|
+
import { getRuntime } from '../../../common/config/runtime';
|
|
15
17
|
import { globalScope } from '../../../common/constants/runtime';
|
|
16
18
|
import { FEATURE_NAME } from '../constants';
|
|
17
19
|
import { FEATURE_NAMES } from '../../../loaders/features/features';
|
|
@@ -19,17 +21,16 @@ import { AggregateBase } from '../../utils/aggregate-base';
|
|
|
19
21
|
import { getNREUMInitializedAgent } from '../../../common/window/nreum';
|
|
20
22
|
import { deregisterDrain } from '../../../common/drain/drain';
|
|
21
23
|
import { now } from '../../../common/timing/now';
|
|
24
|
+
import { applyFnToProps } from '../../../common/util/traverse';
|
|
22
25
|
|
|
23
26
|
/**
|
|
24
27
|
* @typedef {import('./compute-stack-trace.js').StackInfo} StackInfo
|
|
25
28
|
*/
|
|
26
29
|
|
|
27
30
|
export class Aggregate extends AggregateBase {
|
|
28
|
-
static featureName =
|
|
31
|
+
static featureName = FEATURE_NAME;
|
|
29
32
|
constructor(agentIdentifier, aggregator) {
|
|
30
|
-
var _this;
|
|
31
33
|
super(agentIdentifier, aggregator, FEATURE_NAME);
|
|
32
|
-
_this = this;
|
|
33
34
|
this.stackReported = {};
|
|
34
35
|
this.observedAt = {};
|
|
35
36
|
this.pageviewReported = {};
|
|
@@ -39,28 +40,19 @@ export class Aggregate extends AggregateBase {
|
|
|
39
40
|
|
|
40
41
|
// this will need to change to match whatever ee we use in the instrument
|
|
41
42
|
this.ee.on('interactionDone', (interaction, wasSaved) => this.onInteractionDone(interaction, wasSaved));
|
|
42
|
-
register('err',
|
|
43
|
-
|
|
44
|
-
}, this.featureName, this.ee);
|
|
45
|
-
register('ierr', function () {
|
|
46
|
-
return _this.storeError(...arguments);
|
|
47
|
-
}, this.featureName, this.ee);
|
|
43
|
+
register('err', (...args) => this.storeError(...args), this.featureName, this.ee);
|
|
44
|
+
register('ierr', (...args) => this.storeError(...args), this.featureName, this.ee);
|
|
48
45
|
register('softNavFlush', (interactionId, wasFinished, softNavAttrs) => this.onSoftNavNotification(interactionId, wasFinished, softNavAttrs), this.featureName, this.ee); // when an ixn is done or cancelled
|
|
49
46
|
|
|
50
47
|
const harvestTimeSeconds = getConfigurationValue(this.agentIdentifier, 'jserrors.harvestTimeSeconds') || 10;
|
|
51
48
|
|
|
52
49
|
// 0 == off, 1 == on
|
|
53
|
-
this.waitForFlags(['err']).then(
|
|
54
|
-
let [errFlag] = _ref;
|
|
50
|
+
this.waitForFlags(['err']).then(([errFlag]) => {
|
|
55
51
|
if (errFlag) {
|
|
56
52
|
const scheduler = new HarvestScheduler('jserrors', {
|
|
57
|
-
onFinished:
|
|
58
|
-
return _this.onHarvestFinished(...arguments);
|
|
59
|
-
}
|
|
53
|
+
onFinished: (...args) => this.onHarvestFinished(...args)
|
|
60
54
|
}, this);
|
|
61
|
-
scheduler.harvest.on('jserrors',
|
|
62
|
-
return _this.onHarvestStarted(...arguments);
|
|
63
|
-
});
|
|
55
|
+
scheduler.harvest.on('jserrors', (...args) => this.onHarvestStarted(...args));
|
|
64
56
|
scheduler.startTimer(harvestTimeSeconds);
|
|
65
57
|
this.drain();
|
|
66
58
|
} else {
|
|
@@ -71,7 +63,7 @@ export class Aggregate extends AggregateBase {
|
|
|
71
63
|
}
|
|
72
64
|
onHarvestStarted(options) {
|
|
73
65
|
// this gets rid of dependency in AJAX module
|
|
74
|
-
var body = this.aggregator.take(['err', 'ierr', 'xhr']);
|
|
66
|
+
var body = applyFnToProps(this.aggregator.take(['err', 'ierr', 'xhr']), this.obfuscator.obfuscateString.bind(this.obfuscator), 'string');
|
|
75
67
|
if (options.retry) {
|
|
76
68
|
this.currentBody = body;
|
|
77
69
|
}
|
|
@@ -94,8 +86,7 @@ export class Aggregate extends AggregateBase {
|
|
|
94
86
|
}
|
|
95
87
|
onHarvestFinished(result) {
|
|
96
88
|
if (result.retry && this.currentBody) {
|
|
97
|
-
Object.entries(this.currentBody || {}).forEach(
|
|
98
|
-
let [key, value] = _ref2;
|
|
89
|
+
Object.entries(this.currentBody || {}).forEach(([key, value]) => {
|
|
99
90
|
for (var i = 0; i < value.length; i++) {
|
|
100
91
|
var bucket = value[i];
|
|
101
92
|
var name = this.getBucketName(key, bucket.params, bucket.custom);
|
|
@@ -171,7 +162,7 @@ export class Aggregate extends AggregateBase {
|
|
|
171
162
|
if (!this.stackReported[bucketHash]) {
|
|
172
163
|
this.stackReported[bucketHash] = true;
|
|
173
164
|
params.stack_trace = truncateSize(stackInfo.stackString);
|
|
174
|
-
this.observedAt[bucketHash] = agentRuntime.timeKeeper.convertRelativeTimestamp(time);
|
|
165
|
+
this.observedAt[bucketHash] = Math.floor(agentRuntime.timeKeeper.correctAbsoluteTimestamp(agentRuntime.timeKeeper.convertRelativeTimestamp(time)));
|
|
175
166
|
} else {
|
|
176
167
|
params.browser_stack_hash = stringHashCode(stackInfo.stackString);
|
|
177
168
|
}
|
|
@@ -187,7 +178,7 @@ export class Aggregate extends AggregateBase {
|
|
|
187
178
|
this.pageviewReported[bucketHash] = true;
|
|
188
179
|
}
|
|
189
180
|
params.firstOccurrenceTimestamp = this.observedAt[bucketHash];
|
|
190
|
-
params.timestamp = agentRuntime.timeKeeper.convertRelativeTimestamp(time);
|
|
181
|
+
params.timestamp = Math.floor(agentRuntime.timeKeeper.correctAbsoluteTimestamp(agentRuntime.timeKeeper.convertRelativeTimestamp(time)));
|
|
191
182
|
var type = internal ? 'ierr' : 'err';
|
|
192
183
|
var newMetrics = {
|
|
193
184
|
time
|
|
@@ -220,30 +211,20 @@ export class Aggregate extends AggregateBase {
|
|
|
220
211
|
this.#storeJserrorForHarvest(jsErrorEvent, params.browserInteractionId !== undefined, params._softNavAttributes);
|
|
221
212
|
}
|
|
222
213
|
}
|
|
223
|
-
#storeJserrorForHarvest(errorInfoArr, softNavOccurredFinished) {
|
|
224
|
-
let softNavCustomAttrs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
214
|
+
#storeJserrorForHarvest(errorInfoArr, softNavOccurredFinished, softNavCustomAttrs = {}) {
|
|
225
215
|
let [type, bucketHash, params, newMetrics, localAttrs] = errorInfoArr;
|
|
226
216
|
const allCustomAttrs = {};
|
|
227
217
|
if (softNavOccurredFinished) {
|
|
228
|
-
Object.entries(softNavCustomAttrs).forEach(
|
|
229
|
-
let [k, v] = _ref3;
|
|
230
|
-
return setCustom(k, v);
|
|
231
|
-
}); // when an ixn finishes, it'll include stuff in jsAttributes + attrs specific to the ixn
|
|
218
|
+
Object.entries(softNavCustomAttrs).forEach(([k, v]) => setCustom(k, v)); // when an ixn finishes, it'll include stuff in jsAttributes + attrs specific to the ixn
|
|
232
219
|
bucketHash += params.browserInteractionId;
|
|
233
220
|
delete params._softNavAttributes; // cleanup temp properties from synchronous evaluation; this is harmless when async from soft nav (properties DNE)
|
|
234
221
|
delete params._softNavFinished;
|
|
235
222
|
} else {
|
|
236
223
|
// interaction was cancelled -> error should not be associated OR there was no interaction
|
|
237
|
-
Object.entries(getInfo(this.agentIdentifier).jsAttributes).forEach(
|
|
238
|
-
let [k, v] = _ref4;
|
|
239
|
-
return setCustom(k, v);
|
|
240
|
-
});
|
|
224
|
+
Object.entries(getInfo(this.agentIdentifier).jsAttributes).forEach(([k, v]) => setCustom(k, v));
|
|
241
225
|
delete params.browserInteractionId;
|
|
242
226
|
}
|
|
243
|
-
if (localAttrs) Object.entries(localAttrs).forEach(
|
|
244
|
-
let [k, v] = _ref5;
|
|
245
|
-
return setCustom(k, v);
|
|
246
|
-
}); // local custom attrs are applied in either case with the highest precedence
|
|
227
|
+
if (localAttrs) Object.entries(localAttrs).forEach(([k, v]) => setCustom(k, v)); // local custom attrs are applied in either case with the highest precedence
|
|
247
228
|
|
|
248
229
|
const jsAttributesHash = stringHashCode(stringify(allCustomAttrs));
|
|
249
230
|
const aggregateHash = bucketHash + ':' + jsAttributesHash;
|
|
@@ -272,8 +253,7 @@ export class Aggregate extends AggregateBase {
|
|
|
272
253
|
var jsAttributesHash = stringHashCode(stringify(allCustomAttrs));
|
|
273
254
|
var aggregateHash = hash + ':' + jsAttributesHash;
|
|
274
255
|
this.aggregator.store(item[0], aggregateHash, params, item[3], allCustomAttrs);
|
|
275
|
-
function setCustom(
|
|
276
|
-
let [key, val] = _ref6;
|
|
256
|
+
function setCustom([key, val]) {
|
|
277
257
|
allCustomAttrs[key] = val && typeof val === 'object' ? stringify(val) : val;
|
|
278
258
|
}
|
|
279
259
|
});
|
|
@@ -12,10 +12,9 @@ import { now } from '../../../common/timing/now';
|
|
|
12
12
|
import { SR_EVENT_EMITTER_TYPES } from '../../session_replay/constants';
|
|
13
13
|
import { castError, castErrorEvent, castPromiseRejectionEvent } from '../shared/cast-error';
|
|
14
14
|
export class Instrument extends InstrumentBase {
|
|
15
|
-
static featureName =
|
|
15
|
+
static featureName = FEATURE_NAME;
|
|
16
16
|
#replayRunning = false;
|
|
17
|
-
constructor(agentIdentifier, aggregator) {
|
|
18
|
-
let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
17
|
+
constructor(agentIdentifier, aggregator, auto = true) {
|
|
19
18
|
super(agentIdentifier, aggregator, FEATURE_NAME, auto);
|
|
20
19
|
try {
|
|
21
20
|
// this try-catch can be removed when IE11 is completely unsupported & gone
|
|
@@ -47,4 +46,5 @@ export class Instrument extends InstrumentBase {
|
|
|
47
46
|
this.removeOnAbort?.abort();
|
|
48
47
|
this.abortHandler = undefined; // weakly allow this abort op to run only once
|
|
49
48
|
}
|
|
50
|
-
}
|
|
49
|
+
}
|
|
50
|
+
export const JSErrors = Instrument;
|
|
@@ -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,22 +8,21 @@ 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
|
export class Aggregate extends AggregateBase {
|
|
13
|
-
static featureName =
|
|
18
|
+
static featureName = FEATURE_NAME;
|
|
14
19
|
#agentRuntime;
|
|
15
20
|
#agentInfo;
|
|
16
21
|
constructor(agentIdentifier, aggregator) {
|
|
17
22
|
super(agentIdentifier, aggregator, FEATURE_NAME);
|
|
18
23
|
|
|
19
24
|
/** held logs before sending */
|
|
20
|
-
this.bufferedLogs =
|
|
21
|
-
/** held logs during sending, for retries */
|
|
22
|
-
this.outgoingLogs = [];
|
|
23
|
-
/** the estimated bytes of log data waiting to be sent -- triggers a harvest if adding a new log will exceed limit */
|
|
24
|
-
this.estimatedBytes = 0;
|
|
25
|
+
this.bufferedLogs = new EventBuffer();
|
|
25
26
|
this.#agentRuntime = getRuntime(this.agentIdentifier);
|
|
26
27
|
this.#agentInfo = getInfo(this.agentIdentifier);
|
|
27
28
|
this.harvestTimeSeconds = getConfigurationValue(this.agentIdentifier, 'logging.harvestTimeSeconds');
|
|
@@ -32,16 +33,14 @@ export class Aggregate extends AggregateBase {
|
|
|
32
33
|
getPayload: this.prepareHarvest.bind(this),
|
|
33
34
|
raw: true
|
|
34
35
|
}, this);
|
|
35
|
-
/** harvest immediately once started to purge pre-load logs collected */
|
|
36
|
-
this.scheduler.startTimer(this.harvestTimeSeconds, 0);
|
|
37
36
|
/** emitted by instrument class (wrapped loggers) or the api methods directly */
|
|
38
37
|
registerHandler(LOGGING_EVENT_EMITTER_CHANNEL, this.handleLog.bind(this), this.featureName, this.ee);
|
|
39
38
|
this.drain();
|
|
39
|
+
/** harvest immediately once started to purge pre-load logs collected */
|
|
40
|
+
this.scheduler.startTimer(this.harvestTimeSeconds, 0);
|
|
40
41
|
});
|
|
41
42
|
}
|
|
42
|
-
handleLog(timestamp, message) {
|
|
43
|
-
let attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
44
|
-
let level = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : LOG_LEVELS.INFO;
|
|
43
|
+
handleLog(timestamp, message, attributes = {}, level = LOG_LEVELS.INFO) {
|
|
45
44
|
if (this.blocked) return;
|
|
46
45
|
if (!attributes || typeof attributes !== 'object') attributes = {};
|
|
47
46
|
if (typeof level === 'string') level = level.toUpperCase();
|
|
@@ -61,30 +60,26 @@ export class Aggregate extends AggregateBase {
|
|
|
61
60
|
return;
|
|
62
61
|
}
|
|
63
62
|
if (typeof message !== 'string' || !message) return warn(32);
|
|
64
|
-
|
|
65
|
-
handle(SUPPORTABILITY_METRIC_CHANNEL, ['Logging/Harvest/Failed/Seen', message.length]);
|
|
66
|
-
return warn(31, message.slice(0, 25) + '...');
|
|
67
|
-
}
|
|
68
|
-
const log = new Log(this.#agentRuntime.timeKeeper.convertRelativeTimestamp(timestamp), message, attributes, level);
|
|
63
|
+
const log = new Log(Math.floor(this.#agentRuntime.timeKeeper.correctAbsoluteTimestamp(this.#agentRuntime.timeKeeper.convertRelativeTimestamp(timestamp))), message, attributes, level);
|
|
69
64
|
const logBytes = log.message.length + stringify(log.attributes).length + log.level.length + 10; // timestamp == 10 chars
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
65
|
+
|
|
66
|
+
if (!this.bufferedLogs.canMerge(logBytes)) {
|
|
67
|
+
if (this.bufferedLogs.hasData) {
|
|
68
|
+
handle(SUPPORTABILITY_METRIC_CHANNEL, ['Logging/Harvest/Early/Seen', this.bufferedLogs.bytes + logBytes]);
|
|
69
|
+
this.scheduler.runHarvest({});
|
|
70
|
+
if (logBytes < MAX_PAYLOAD_SIZE) this.bufferedLogs.add(log);
|
|
71
|
+
} else {
|
|
72
|
+
handle(SUPPORTABILITY_METRIC_CHANNEL, ['Logging/Harvest/Failed/Seen', logBytes]);
|
|
73
|
+
warn(31, log.message.slice(0, 25) + '...');
|
|
74
|
+
}
|
|
75
|
+
return;
|
|
77
76
|
}
|
|
78
|
-
this.
|
|
79
|
-
this.bufferedLogs.push(log);
|
|
77
|
+
this.bufferedLogs.add(log);
|
|
80
78
|
}
|
|
81
|
-
prepareHarvest() {
|
|
82
|
-
if (this.blocked || !
|
|
83
|
-
/** populate outgoing array while also clearing main buffer */
|
|
84
|
-
this.outgoingLogs.push(...this.bufferedLogs.splice(0));
|
|
85
|
-
this.estimatedBytes = 0;
|
|
79
|
+
prepareHarvest(options = {}) {
|
|
80
|
+
if (this.blocked || !this.bufferedLogs.hasData) return;
|
|
86
81
|
/** see https://source.datanerd.us/agents/rum-specs/blob/main/browser/Log for logging spec */
|
|
87
|
-
|
|
82
|
+
const payload = {
|
|
88
83
|
qs: {
|
|
89
84
|
browser_monitoring_key: this.#agentInfo.licenseKey
|
|
90
85
|
},
|
|
@@ -110,11 +105,13 @@ export class Aggregate extends AggregateBase {
|
|
|
110
105
|
}
|
|
111
106
|
},
|
|
112
107
|
/** logs section contains individual unique log entries */
|
|
113
|
-
logs: this.
|
|
108
|
+
logs: applyFnToProps(this.bufferedLogs.buffer, this.obfuscator.obfuscateString.bind(this.obfuscator), 'string')
|
|
114
109
|
}]
|
|
115
110
|
};
|
|
111
|
+
if (options.retry) this.bufferedLogs.hold();else this.bufferedLogs.clear();
|
|
112
|
+
return payload;
|
|
116
113
|
}
|
|
117
114
|
onHarvestFinished(result) {
|
|
118
|
-
if (
|
|
115
|
+
if (result.retry) this.bufferedLogs.unhold();else this.bufferedLogs.held.clear();
|
|
119
116
|
}
|
|
120
117
|
}
|
|
@@ -2,14 +2,12 @@ import { InstrumentBase } from '../../utils/instrument-base';
|
|
|
2
2
|
import { FEATURE_NAME } from '../constants';
|
|
3
3
|
import { bufferLog } from '../shared/utils';
|
|
4
4
|
export class Instrument extends InstrumentBase {
|
|
5
|
-
static featureName =
|
|
6
|
-
constructor(agentIdentifier, aggregator) {
|
|
7
|
-
let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
5
|
+
static featureName = FEATURE_NAME;
|
|
6
|
+
constructor(agentIdentifier, aggregator, auto = true) {
|
|
8
7
|
super(agentIdentifier, aggregator, FEATURE_NAME, auto);
|
|
9
8
|
const instanceEE = this.ee;
|
|
10
9
|
/** emitted by wrap-logger function */
|
|
11
|
-
this.ee.on('wrap-logger-end', function handleLog(
|
|
12
|
-
let [message] = _ref;
|
|
10
|
+
this.ee.on('wrap-logger-end', function handleLog([message]) {
|
|
13
11
|
const {
|
|
14
12
|
level,
|
|
15
13
|
customAttributes
|
|
@@ -18,4 +16,5 @@ export class Instrument extends InstrumentBase {
|
|
|
18
16
|
});
|
|
19
17
|
this.importAggregator();
|
|
20
18
|
}
|
|
21
|
-
}
|
|
19
|
+
}
|
|
20
|
+
export const Logging = Instrument;
|
|
@@ -17,9 +17,7 @@ export class Log {
|
|
|
17
17
|
* @param {object} attributes - other log event attributes
|
|
18
18
|
* @param {enum} level - Log level
|
|
19
19
|
*/
|
|
20
|
-
constructor(timestamp, message) {
|
|
21
|
-
let attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
22
|
-
let level = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : LOG_LEVELS.INFO;
|
|
20
|
+
constructor(timestamp, message, attributes = {}, level = LOG_LEVELS.INFO) {
|
|
23
21
|
/** @type {long} */
|
|
24
22
|
this.timestamp = timestamp;
|
|
25
23
|
this.message = message;
|
|
@@ -10,9 +10,7 @@ import { LOGGING_EVENT_EMITTER_CHANNEL, LOG_LEVELS } from '../constants';
|
|
|
10
10
|
* @param {{[key: string]: *}} customAttributes - The log's custom attributes if any
|
|
11
11
|
* @param {enum} level - the log level enum
|
|
12
12
|
*/
|
|
13
|
-
export function bufferLog(ee, message) {
|
|
14
|
-
let customAttributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
15
|
-
let level = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : LOG_LEVELS.INFO;
|
|
13
|
+
export function bufferLog(ee, message, customAttributes = {}, level = LOG_LEVELS.INFO) {
|
|
16
14
|
handle(SUPPORTABILITY_METRIC_CHANNEL, ["API/logging/".concat(level.toLowerCase(), "/called")], undefined, FEATURE_NAMES.metrics, ee);
|
|
17
15
|
handle(LOGGING_EVENT_EMITTER_CHANNEL, [now(), message, customAttributes, level], undefined, FEATURE_NAMES.logging, ee);
|
|
18
16
|
}
|
|
@@ -24,5 +22,5 @@ export function bufferLog(ee, message) {
|
|
|
24
22
|
*/
|
|
25
23
|
export function isValidLogLevel(level) {
|
|
26
24
|
if (typeof level !== 'string') return false;
|
|
27
|
-
return Object.values(LOG_LEVELS).some(logLevel => logLevel === level);
|
|
25
|
+
return Object.values(LOG_LEVELS).some(logLevel => logLevel === level.toUpperCase().trim());
|
|
28
26
|
}
|
|
@@ -1,21 +1,23 @@
|
|
|
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'
|
|
15
|
+
|
|
13
16
|
export class Aggregate extends AggregateBase {
|
|
14
|
-
static featureName =
|
|
17
|
+
static featureName = FEATURE_NAME;
|
|
15
18
|
constructor(agentIdentifier, aggregator) {
|
|
16
19
|
super(agentIdentifier, aggregator, FEATURE_NAME);
|
|
17
|
-
this.waitForFlags(['err']).then(
|
|
18
|
-
let [errFlag] = _ref;
|
|
20
|
+
this.waitForFlags(['err']).then(([errFlag]) => {
|
|
19
21
|
if (errFlag) {
|
|
20
22
|
// *cli, Mar 23 - Per NR-94597, this feature should only harvest ONCE at the (potential) EoL time of the page.
|
|
21
23
|
const scheduler = new HarvestScheduler('jserrors', {
|
|
@@ -95,21 +97,32 @@ export class Aggregate extends AggregateBase {
|
|
|
95
97
|
}
|
|
96
98
|
|
|
97
99
|
// Capture SMs to assess customer engagement with the obfuscation config
|
|
98
|
-
const
|
|
99
|
-
if (
|
|
100
|
-
|
|
100
|
+
const ruleValidations = this.obfuscator.ruleValidationCache;
|
|
101
|
+
if (ruleValidations.length > 0) {
|
|
102
|
+
this.storeSupportabilityMetrics('Generic/Obfuscate/Detected');
|
|
103
|
+
if (ruleValidations.filter(ruleValidation => !ruleValidation.isValid).length > 0) this.storeSupportabilityMetrics('Generic/Obfuscate/Invalid');
|
|
104
|
+
}
|
|
101
105
|
|
|
102
106
|
// Check if proxy for either chunks or beacon is being used
|
|
103
107
|
if (proxy.assets) this.storeSupportabilityMetrics('Config/AssetsUrl/Changed');
|
|
104
108
|
if (proxy.beacon) this.storeSupportabilityMetrics('Config/BeaconUrl/Changed');
|
|
105
109
|
if (isBrowserScope && window.MutationObserver) {
|
|
106
|
-
|
|
110
|
+
if (window.self !== window.top) {
|
|
111
|
+
this.storeSupportabilityMetrics('Generic/Runtime/IFrame/Detected');
|
|
112
|
+
}
|
|
113
|
+
const preExistingVideos = window.document.querySelectorAll('video').length;
|
|
114
|
+
if (preExistingVideos) this.storeSupportabilityMetrics('Generic/VideoElement/Added', preExistingVideos);
|
|
115
|
+
const preExistingIframes = window.document.querySelectorAll('iframe').length;
|
|
116
|
+
if (preExistingIframes) this.storeSupportabilityMetrics('Generic/IFrame/Added', preExistingIframes);
|
|
107
117
|
const mo = new MutationObserver(records => {
|
|
108
118
|
records.forEach(record => {
|
|
109
119
|
record.addedNodes.forEach(addedNode => {
|
|
110
120
|
if (addedNode instanceof HTMLVideoElement) {
|
|
111
121
|
this.storeSupportabilityMetrics('Generic/VideoElement/Added', 1);
|
|
112
122
|
}
|
|
123
|
+
if (addedNode instanceof HTMLIFrameElement) {
|
|
124
|
+
this.storeSupportabilityMetrics('Generic/IFrame/Added', 1);
|
|
125
|
+
}
|
|
113
126
|
});
|
|
114
127
|
});
|
|
115
128
|
});
|
|
@@ -118,6 +131,12 @@ export class Aggregate extends AggregateBase {
|
|
|
118
131
|
subtree: true
|
|
119
132
|
});
|
|
120
133
|
}
|
|
134
|
+
|
|
135
|
+
// WATCHABLE_WEB_SOCKET_EVENTS.forEach(tag => {
|
|
136
|
+
// registerHandler('buffered-' + WEBSOCKET_TAG + tag, (...args) => {
|
|
137
|
+
// handleWebsocketEvents(this.storeSupportabilityMetrics.bind(this), tag, ...args)
|
|
138
|
+
// }, this.featureName, this.ee)
|
|
139
|
+
// })
|
|
121
140
|
}
|
|
122
141
|
eachSessionChecks() {
|
|
123
142
|
if (!isBrowserScope) return;
|
|
@@ -159,8 +178,8 @@ export class Aggregate extends AggregateBase {
|
|
|
159
178
|
if (typeof performance !== 'undefined') {
|
|
160
179
|
const markers = performance.getEntriesByType('mark');
|
|
161
180
|
const measures = performance.getEntriesByType('measure');
|
|
162
|
-
this.storeSupportabilityMetrics('Generic/Performance/Mark/Seen', markers.length);
|
|
163
|
-
this.storeSupportabilityMetrics('Generic/Performance/Measure/Seen', measures.length);
|
|
181
|
+
if (markers.length) this.storeSupportabilityMetrics('Generic/Performance/Mark/Seen', markers.length);
|
|
182
|
+
if (measures.length) this.storeSupportabilityMetrics('Generic/Performance/Measure/Seen', measures.length);
|
|
164
183
|
}
|
|
165
184
|
} catch (e) {
|
|
166
185
|
// do nothing
|
|
@@ -0,0 +1,29 @@
|
|
|
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';else metricTag += '-Dirty';
|
|
21
|
+
}
|
|
22
|
+
const bytes = metricTag === 'Message' && dataSize(data?.event?.data) || metricTag === 'Send' && dataSize(data);
|
|
23
|
+
reporter(buildSMTag(metricTag, 'Ms'), timestamp);
|
|
24
|
+
reporter(buildSMTag(metricTag, 'MsSinceClassInit'), timeSinceInit);
|
|
25
|
+
if (bytes) reporter(buildSMTag(metricTag, 'Bytes'), bytes);
|
|
26
|
+
}
|
|
27
|
+
function buildSMTag(tag, category) {
|
|
28
|
+
return 'WebSocket/' + tag + '/' + category;
|
|
29
|
+
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
// import { ADD_EVENT_LISTENER_TAG } from '../../common/wrap/wrap-websocket'
|
|
1
2
|
import { FEATURE_NAMES } from '../../loaders/features/features';
|
|
2
3
|
export const FEATURE_NAME = FEATURE_NAMES.metrics;
|
|
3
4
|
export const SUPPORTABILITY_METRIC = 'sm';
|
|
4
5
|
export const CUSTOM_METRIC = 'cm';
|
|
5
6
|
export const SUPPORTABILITY_METRIC_CHANNEL = 'storeSupportabilityMetrics';
|
|
6
|
-
export const CUSTOM_METRIC_CHANNEL = 'storeEventMetrics';
|
|
7
|
+
export const CUSTOM_METRIC_CHANNEL = 'storeEventMetrics';
|
|
8
|
+
|
|
9
|
+
// export const WATCHABLE_WEB_SOCKET_EVENTS = ['new', 'send', 'close', ADD_EVENT_LISTENER_TAG]
|
|
@@ -1,10 +1,20 @@
|
|
|
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
|
export class Instrument extends InstrumentBase {
|
|
4
|
-
static featureName =
|
|
5
|
-
constructor(agentIdentifier, aggregator) {
|
|
6
|
-
let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
6
|
+
static featureName = FEATURE_NAME;
|
|
7
|
+
constructor(agentIdentifier, aggregator, auto = true) {
|
|
7
8
|
super(agentIdentifier, aggregator, FEATURE_NAME, auto);
|
|
9
|
+
// wrapWebSocket(this.ee)
|
|
10
|
+
|
|
11
|
+
// WATCHABLE_WEB_SOCKET_EVENTS.forEach((suffix) => {
|
|
12
|
+
// this.ee.on(WEBSOCKET_TAG + suffix, (...args) => {
|
|
13
|
+
// handle('buffered-' + WEBSOCKET_TAG + suffix, [...args], undefined, this.featureName, this.ee)
|
|
14
|
+
// })
|
|
15
|
+
// })
|
|
16
|
+
|
|
8
17
|
this.importAggregator();
|
|
9
18
|
}
|
|
10
|
-
}
|
|
19
|
+
}
|
|
20
|
+
export const Metrics = Instrument;
|
|
@@ -9,8 +9,12 @@ import { GenericEvents } from '../../generic_events';
|
|
|
9
9
|
* @deprecated This feature has been replaced by Generic Events. Use/Import `GenericEvents` instead. This wrapper will be removed in a future release
|
|
10
10
|
*/
|
|
11
11
|
export class Instrument extends GenericEvents {
|
|
12
|
-
constructor(agentIdentifier, aggregator) {
|
|
13
|
-
let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
12
|
+
constructor(agentIdentifier, aggregator, auto = true) {
|
|
14
13
|
super(agentIdentifier, aggregator, auto);
|
|
15
14
|
}
|
|
16
|
-
}
|
|
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;
|