@newrelic/browser-agent 1.263.0 → 1.265.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/README.md +2 -2
- package/dist/cjs/cdn/experimental.js +3 -7
- package/dist/cjs/cdn/pro.js +2 -2
- package/dist/cjs/cdn/spa.js +2 -2
- package/dist/cjs/common/aggregate/aggregator.js +2 -3
- package/dist/cjs/common/config/{state/configurable.js → configurable.js} +1 -1
- package/dist/cjs/common/config/{state/info.js → info.js} +1 -1
- package/dist/cjs/common/config/{state/init.js → init.js} +11 -8
- package/dist/cjs/common/config/{state/loader-config.js → loader-config.js} +1 -1
- package/dist/cjs/common/config/{state/runtime.js → runtime.js} +16 -5
- package/dist/cjs/common/constants/agent-constants.js +8 -0
- package/dist/cjs/common/constants/env.cdn.js +1 -1
- package/dist/cjs/common/constants/env.npm.js +1 -1
- package/dist/cjs/common/constants/runtime.js +1 -3
- package/dist/cjs/common/context/shared-context.js +1 -2
- package/dist/cjs/common/dispatch/global-event.js +1 -2
- package/dist/cjs/common/drain/drain.js +12 -18
- package/dist/cjs/common/event-emitter/contextual-ee.js +3 -4
- package/dist/cjs/common/event-listener/event-listener-opts.js +2 -6
- package/dist/cjs/common/harvest/harvest-scheduler.js +1 -2
- package/dist/cjs/common/harvest/harvest.js +30 -57
- package/dist/cjs/common/serialize/bel-serializer.js +6 -11
- package/dist/cjs/common/session/session-entity.js +10 -13
- package/dist/cjs/common/timing/nav-timing.js +1 -3
- package/dist/cjs/common/timing/time-keeper.js +16 -6
- package/dist/cjs/common/url/encode.js +3 -7
- package/dist/cjs/common/util/console.js +2 -0
- package/dist/cjs/common/util/invoke.js +6 -16
- package/dist/cjs/common/util/obfuscate.js +97 -53
- package/dist/cjs/common/util/submit-data.js +17 -21
- package/dist/cjs/common/util/text.js +9 -0
- package/dist/cjs/common/util/traverse.js +1 -3
- package/dist/cjs/common/vitals/cumulative-layout-shift.js +5 -6
- package/dist/cjs/common/vitals/first-contentful-paint.js +4 -5
- package/dist/cjs/common/vitals/first-input-delay.js +4 -5
- package/dist/cjs/common/vitals/interaction-to-next-paint.js +5 -6
- package/dist/cjs/common/vitals/largest-contentful-paint.js +4 -5
- package/dist/cjs/common/vitals/time-to-first-byte.js +4 -5
- package/dist/cjs/common/vitals/vital-metric.js +5 -7
- package/dist/cjs/common/window/nreum.js +2 -1
- package/dist/cjs/common/window/page-visibility.js +1 -4
- package/dist/cjs/common/wrap/wrap-events.js +1 -4
- package/dist/cjs/common/wrap/wrap-promise.js +1 -4
- package/dist/cjs/common/wrap/wrap-websocket.js +74 -0
- package/dist/cjs/features/ajax/aggregate/chunk.js +4 -3
- package/dist/cjs/features/ajax/aggregate/gql.js +4 -5
- package/dist/cjs/features/ajax/aggregate/index.js +19 -22
- package/dist/cjs/features/ajax/constants.js +2 -3
- package/dist/cjs/features/ajax/instrument/distributed-tracing.js +9 -8
- package/dist/cjs/features/ajax/instrument/index.js +14 -12
- package/dist/cjs/features/generic_events/aggregate/index.js +128 -0
- package/dist/cjs/features/generic_events/constants.js +10 -0
- package/dist/cjs/features/generic_events/index.js +12 -0
- package/dist/cjs/features/generic_events/instrument/index.js +27 -0
- package/dist/cjs/features/jserrors/aggregate/index.js +25 -44
- package/dist/cjs/features/jserrors/instrument/index.js +4 -4
- package/dist/cjs/features/logging/aggregate/index.js +33 -36
- package/dist/cjs/features/logging/constants.js +2 -3
- package/dist/cjs/features/logging/instrument/index.js +5 -6
- package/dist/cjs/features/logging/shared/log.js +1 -3
- package/dist/cjs/features/logging/shared/utils.js +2 -4
- package/dist/cjs/features/metrics/aggregate/index.js +34 -17
- package/dist/cjs/features/metrics/aggregate/websocket-detection.js +34 -0
- package/dist/cjs/features/metrics/constants.js +4 -2
- package/dist/cjs/features/metrics/instrument/index.js +12 -4
- package/dist/cjs/features/page_action/instrument/index.js +14 -10
- package/dist/cjs/features/page_view_event/aggregate/index.js +19 -39
- package/dist/cjs/features/page_view_event/aggregate/initialized-features.js +1 -1
- package/dist/cjs/features/page_view_event/instrument/index.js +4 -4
- package/dist/cjs/features/page_view_timing/aggregate/index.js +23 -39
- package/dist/cjs/features/page_view_timing/instrument/index.js +4 -4
- package/dist/cjs/features/session_replay/aggregate/index.js +35 -42
- package/dist/cjs/features/session_replay/constants.js +1 -5
- package/dist/cjs/features/session_replay/instrument/index.js +5 -9
- package/dist/cjs/features/session_replay/shared/recorder-events.js +25 -20
- package/dist/cjs/features/session_replay/shared/recorder.js +17 -13
- package/dist/cjs/features/session_replay/shared/stylesheet-evaluator.js +2 -2
- package/dist/cjs/features/session_replay/shared/utils.js +5 -4
- package/dist/cjs/features/session_trace/aggregate/index.js +25 -42
- package/dist/cjs/features/session_trace/aggregate/trace/storage.js +5 -3
- package/dist/cjs/features/session_trace/instrument/index.js +8 -7
- package/dist/cjs/features/soft_navigations/aggregate/ajax-node.js +1 -1
- package/dist/cjs/features/soft_navigations/aggregate/index.js +22 -30
- package/dist/cjs/features/soft_navigations/aggregate/initial-page-load-interaction.js +2 -2
- package/dist/cjs/features/soft_navigations/aggregate/interaction.js +4 -5
- package/dist/cjs/features/soft_navigations/instrument/index.js +14 -13
- package/dist/cjs/features/spa/aggregate/index.js +17 -28
- package/dist/cjs/features/spa/aggregate/interaction.js +7 -6
- package/dist/cjs/features/spa/aggregate/serializer.js +4 -5
- package/dist/cjs/features/spa/constants.js +2 -2
- package/dist/cjs/features/spa/instrument/index.js +20 -19
- package/dist/cjs/features/utils/agent-session.js +6 -4
- package/dist/cjs/features/utils/aggregate-base.js +17 -10
- package/dist/cjs/features/utils/event-buffer.js +132 -0
- package/dist/cjs/features/utils/feature-gates.js +2 -2
- package/dist/cjs/features/utils/instrument-base.js +7 -8
- package/dist/cjs/features/utils/lazy-feature-loader.js +12 -12
- package/dist/cjs/features/utils/nr1-debugger.js +1 -3
- package/dist/cjs/index.js +21 -0
- package/dist/cjs/loaders/agent-base.js +4 -12
- package/dist/cjs/loaders/agent.js +7 -2
- package/dist/cjs/loaders/api/api.js +23 -35
- package/dist/cjs/loaders/api/apiAsync.js +10 -13
- package/dist/cjs/loaders/browser-agent.js +4 -3
- package/dist/cjs/loaders/configure/configure.js +16 -15
- package/dist/cjs/loaders/features/enabled-features.js +2 -2
- package/dist/cjs/loaders/features/features.js +8 -4
- package/dist/cjs/loaders/micro-agent.js +16 -15
- package/dist/esm/cdn/experimental.js +2 -5
- package/dist/esm/cdn/pro.js +2 -2
- package/dist/esm/cdn/spa.js +2 -2
- package/dist/esm/common/aggregate/aggregator.js +2 -3
- package/dist/esm/common/config/{state/configurable.js → configurable.js} +1 -1
- package/dist/esm/common/config/{state/info.js → info.js} +1 -1
- package/dist/esm/common/config/{state/init.js → init.js} +11 -8
- package/dist/esm/common/config/{state/loader-config.js → loader-config.js} +1 -1
- package/dist/esm/common/config/{state/runtime.js → runtime.js} +17 -5
- package/dist/esm/common/constants/agent-constants.js +2 -0
- package/dist/esm/common/constants/env.cdn.js +1 -1
- package/dist/esm/common/constants/env.npm.js +1 -1
- package/dist/esm/common/constants/runtime.js +0 -2
- package/dist/esm/common/context/shared-context.js +1 -2
- package/dist/esm/common/dispatch/global-event.js +1 -2
- package/dist/esm/common/drain/drain.js +12 -18
- package/dist/esm/common/event-emitter/contextual-ee.js +2 -3
- package/dist/esm/common/event-listener/event-listener-opts.js +2 -6
- package/dist/esm/common/harvest/harvest-scheduler.js +1 -2
- package/dist/esm/common/harvest/harvest.js +24 -51
- package/dist/esm/common/serialize/bel-serializer.js +6 -11
- package/dist/esm/common/session/session-entity.js +10 -13
- package/dist/esm/common/timing/nav-timing.js +1 -3
- package/dist/esm/common/timing/time-keeper.js +15 -5
- package/dist/esm/common/url/encode.js +3 -7
- package/dist/esm/common/util/console.js +2 -0
- package/dist/esm/common/util/invoke.js +6 -16
- package/dist/esm/common/util/obfuscate.js +96 -49
- package/dist/esm/common/util/submit-data.js +17 -21
- package/dist/esm/common/util/text.js +3 -0
- package/dist/esm/common/util/traverse.js +1 -3
- package/dist/esm/common/vitals/cumulative-layout-shift.js +5 -6
- package/dist/esm/common/vitals/first-contentful-paint.js +4 -5
- package/dist/esm/common/vitals/first-input-delay.js +4 -5
- package/dist/esm/common/vitals/interaction-to-next-paint.js +5 -6
- package/dist/esm/common/vitals/largest-contentful-paint.js +4 -5
- package/dist/esm/common/vitals/time-to-first-byte.js +4 -5
- package/dist/esm/common/vitals/vital-metric.js +5 -7
- package/dist/esm/common/window/nreum.js +2 -1
- package/dist/esm/common/window/page-visibility.js +1 -4
- package/dist/esm/common/wrap/wrap-events.js +1 -4
- package/dist/esm/common/wrap/wrap-promise.js +1 -4
- package/dist/esm/common/wrap/wrap-websocket.js +67 -0
- package/dist/esm/features/ajax/aggregate/chunk.js +3 -2
- package/dist/esm/features/ajax/aggregate/gql.js +4 -5
- package/dist/esm/features/ajax/aggregate/index.js +16 -19
- package/dist/esm/features/ajax/constants.js +1 -2
- package/dist/esm/features/ajax/instrument/distributed-tracing.js +2 -1
- package/dist/esm/features/ajax/instrument/index.js +10 -8
- package/dist/esm/features/generic_events/aggregate/index.js +120 -0
- package/dist/esm/features/generic_events/constants.js +4 -0
- package/dist/esm/features/generic_events/index.js +1 -0
- package/dist/esm/features/generic_events/instrument/index.js +20 -0
- package/dist/esm/features/jserrors/aggregate/index.js +20 -39
- package/dist/esm/features/jserrors/instrument/index.js +3 -3
- package/dist/esm/features/logging/aggregate/index.js +31 -34
- package/dist/esm/features/logging/constants.js +1 -2
- package/dist/esm/features/logging/instrument/index.js +4 -5
- package/dist/esm/features/logging/shared/log.js +1 -3
- package/dist/esm/features/logging/shared/utils.js +2 -4
- package/dist/esm/features/metrics/aggregate/index.js +28 -11
- package/dist/esm/features/metrics/aggregate/websocket-detection.js +29 -0
- package/dist/esm/features/metrics/constants.js +3 -1
- package/dist/esm/features/metrics/instrument/index.js +12 -4
- package/dist/esm/features/page_action/instrument/index.js +14 -9
- package/dist/esm/features/page_view_event/aggregate/index.js +17 -37
- package/dist/esm/features/page_view_event/aggregate/initialized-features.js +1 -1
- package/dist/esm/features/page_view_event/instrument/index.js +3 -3
- package/dist/esm/features/page_view_timing/aggregate/index.js +20 -36
- package/dist/esm/features/page_view_timing/instrument/index.js +3 -3
- package/dist/esm/features/session_replay/aggregate/index.js +25 -32
- package/dist/esm/features/session_replay/constants.js +0 -4
- package/dist/esm/features/session_replay/index.js +1 -7
- package/dist/esm/features/session_replay/instrument/index.js +5 -8
- package/dist/esm/features/session_replay/shared/recorder-events.js +25 -20
- package/dist/esm/features/session_replay/shared/recorder.js +14 -10
- package/dist/esm/features/session_replay/shared/stylesheet-evaluator.js +2 -2
- package/dist/esm/features/session_replay/shared/utils.js +3 -2
- package/dist/esm/features/session_trace/aggregate/index.js +20 -37
- package/dist/esm/features/session_trace/aggregate/trace/storage.js +5 -3
- package/dist/esm/features/session_trace/instrument/index.js +5 -4
- package/dist/esm/features/soft_navigations/aggregate/ajax-node.js +1 -1
- package/dist/esm/features/soft_navigations/aggregate/index.js +21 -29
- package/dist/esm/features/soft_navigations/aggregate/initial-page-load-interaction.js +1 -1
- package/dist/esm/features/soft_navigations/aggregate/interaction.js +2 -3
- package/dist/esm/features/soft_navigations/instrument/index.js +11 -10
- package/dist/esm/features/spa/aggregate/index.js +11 -22
- package/dist/esm/features/spa/aggregate/interaction.js +6 -5
- package/dist/esm/features/spa/aggregate/serializer.js +2 -3
- package/dist/esm/features/spa/constants.js +2 -2
- package/dist/esm/features/spa/instrument/index.js +12 -11
- package/dist/esm/features/utils/agent-session.js +3 -1
- package/dist/esm/features/utils/aggregate-base.js +16 -9
- package/dist/esm/features/utils/event-buffer.js +126 -0
- package/dist/esm/features/utils/feature-gates.js +1 -1
- package/dist/esm/features/utils/instrument-base.js +6 -7
- package/dist/esm/features/utils/lazy-feature-loader.js +12 -12
- package/dist/esm/features/utils/nr1-debugger.js +1 -3
- package/dist/esm/index.js +3 -0
- package/dist/esm/loaders/agent-base.js +4 -12
- package/dist/esm/loaders/agent.js +7 -2
- package/dist/esm/loaders/api/api.js +18 -30
- package/dist/esm/loaders/api/apiAsync.js +3 -6
- package/dist/esm/loaders/browser-agent.js +3 -2
- package/dist/esm/loaders/configure/configure.js +9 -8
- package/dist/esm/loaders/features/enabled-features.js +1 -1
- package/dist/esm/loaders/features/features.js +8 -4
- package/dist/esm/loaders/micro-agent.js +11 -10
- package/dist/types/common/aggregate/aggregator.d.ts.map +1 -1
- package/dist/types/common/config/configurable.d.ts.map +1 -0
- package/dist/types/common/config/info.d.ts.map +1 -0
- package/dist/types/common/config/init.d.ts.map +1 -0
- package/dist/types/common/config/loader-config.d.ts.map +1 -0
- package/dist/types/common/config/runtime.d.ts.map +1 -0
- package/dist/types/common/constants/agent-constants.d.ts +3 -0
- package/dist/types/common/constants/agent-constants.d.ts.map +1 -0
- package/dist/types/common/constants/runtime.d.ts +0 -1
- package/dist/types/common/constants/runtime.d.ts.map +1 -1
- package/dist/types/common/harvest/harvest.d.ts +1 -7
- package/dist/types/common/harvest/harvest.d.ts.map +1 -1
- package/dist/types/common/serialize/bel-serializer.d.ts.map +1 -1
- package/dist/types/common/timing/time-keeper.d.ts +9 -2
- package/dist/types/common/timing/time-keeper.d.ts.map +1 -1
- package/dist/types/common/url/encode.d.ts.map +1 -1
- package/dist/types/common/util/console.d.ts.map +1 -1
- package/dist/types/common/util/obfuscate.d.ts +78 -6
- package/dist/types/common/util/obfuscate.d.ts.map +1 -1
- package/dist/types/common/util/submit-data.d.ts.map +1 -1
- package/dist/types/common/util/text.d.ts +2 -0
- package/dist/types/common/util/text.d.ts.map +1 -0
- package/dist/types/common/window/nreum.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-websocket.d.ts +4 -0
- package/dist/types/common/wrap/wrap-websocket.d.ts.map +1 -0
- package/dist/types/features/ajax/aggregate/chunk.d.ts.map +1 -1
- package/dist/types/features/ajax/aggregate/index.d.ts +2 -3
- package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/ajax/constants.d.ts +0 -1
- package/dist/types/features/ajax/constants.d.ts.map +1 -1
- package/dist/types/features/ajax/instrument/distributed-tracing.d.ts.map +1 -1
- package/dist/types/features/ajax/instrument/index.d.ts +1 -0
- package/dist/types/features/ajax/instrument/index.d.ts.map +1 -1
- package/dist/types/features/{page_action → generic_events}/aggregate/index.d.ts +10 -10
- package/dist/types/features/generic_events/aggregate/index.d.ts.map +1 -0
- package/dist/types/features/generic_events/constants.d.ts +4 -0
- package/dist/types/features/generic_events/constants.d.ts.map +1 -0
- package/dist/types/features/generic_events/index.d.ts +2 -0
- package/dist/types/features/generic_events/index.d.ts.map +1 -0
- package/dist/types/features/generic_events/instrument/index.d.ts +7 -0
- package/dist/types/features/generic_events/instrument/index.d.ts.map +1 -0
- package/dist/types/features/jserrors/aggregate/index.d.ts +2 -2
- package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/instrument/index.d.ts +1 -0
- package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -1
- package/dist/types/features/logging/aggregate/index.d.ts +4 -7
- package/dist/types/features/logging/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/logging/constants.d.ts +0 -1
- package/dist/types/features/logging/constants.d.ts.map +1 -1
- package/dist/types/features/logging/instrument/index.d.ts +1 -0
- package/dist/types/features/logging/instrument/index.d.ts.map +1 -1
- package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/metrics/aggregate/websocket-detection.d.ts +12 -0
- package/dist/types/features/metrics/aggregate/websocket-detection.d.ts.map +1 -0
- package/dist/types/features/metrics/constants.d.ts +1 -0
- package/dist/types/features/metrics/constants.d.ts.map +1 -1
- package/dist/types/features/metrics/instrument/index.d.ts +1 -0
- package/dist/types/features/metrics/instrument/index.d.ts.map +1 -1
- package/dist/types/features/page_action/instrument/index.d.ts +9 -4
- package/dist/types/features/page_action/instrument/index.d.ts.map +1 -1
- package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/page_view_event/instrument/index.d.ts +1 -0
- package/dist/types/features/page_view_event/instrument/index.d.ts.map +1 -1
- package/dist/types/features/page_view_timing/aggregate/index.d.ts +2 -2
- package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/page_view_timing/instrument/index.d.ts +1 -0
- package/dist/types/features/page_view_timing/instrument/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/constants.d.ts +0 -4
- package/dist/types/features/session_replay/constants.d.ts.map +1 -1
- package/dist/types/features/session_replay/instrument/index.d.ts +1 -0
- package/dist/types/features/session_replay/instrument/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/shared/recorder-events.d.ts +6 -6
- package/dist/types/features/session_replay/shared/recorder-events.d.ts.map +1 -1
- package/dist/types/features/session_replay/shared/recorder.d.ts +2 -2
- package/dist/types/features/session_replay/shared/recorder.d.ts.map +1 -1
- package/dist/types/features/session_replay/shared/utils.d.ts.map +1 -1
- package/dist/types/features/session_trace/aggregate/index.d.ts +2 -2
- package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_trace/aggregate/trace/storage.d.ts +1 -1
- package/dist/types/features/session_trace/aggregate/trace/storage.d.ts.map +1 -1
- package/dist/types/features/session_trace/instrument/index.d.ts +1 -0
- package/dist/types/features/session_trace/instrument/index.d.ts.map +1 -1
- package/dist/types/features/soft_navigations/aggregate/index.d.ts +3 -3
- package/dist/types/features/soft_navigations/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/soft_navigations/instrument/index.d.ts +1 -0
- package/dist/types/features/soft_navigations/instrument/index.d.ts.map +1 -1
- package/dist/types/features/spa/aggregate/index.d.ts +2 -2
- package/dist/types/features/spa/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/spa/aggregate/interaction.d.ts.map +1 -1
- package/dist/types/features/spa/aggregate/serializer.d.ts.map +1 -1
- package/dist/types/features/spa/constants.d.ts.map +1 -1
- package/dist/types/features/spa/instrument/index.d.ts +1 -0
- package/dist/types/features/spa/instrument/index.d.ts.map +1 -1
- package/dist/types/features/utils/agent-session.d.ts.map +1 -1
- package/dist/types/features/utils/aggregate-base.d.ts +1 -0
- package/dist/types/features/utils/aggregate-base.d.ts.map +1 -1
- package/dist/types/features/utils/event-buffer.d.ts +72 -0
- package/dist/types/features/utils/event-buffer.d.ts.map +1 -0
- package/dist/types/features/utils/instrument-base.d.ts +1 -0
- package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -0
- package/dist/types/loaders/agent-base.d.ts +1 -2
- package/dist/types/loaders/agent-base.d.ts.map +1 -1
- package/dist/types/loaders/agent.d.ts.map +1 -1
- package/dist/types/loaders/api/api.d.ts.map +1 -1
- package/dist/types/loaders/browser-agent.d.ts.map +1 -1
- package/dist/types/loaders/configure/configure.d.ts.map +1 -1
- package/dist/types/loaders/features/features.d.ts +1 -0
- package/dist/types/loaders/features/features.d.ts.map +1 -1
- package/dist/types/loaders/micro-agent.d.ts.map +1 -1
- package/package.json +67 -52
- package/src/cdn/experimental.js +2 -4
- package/src/cdn/pro.js +2 -2
- package/src/cdn/spa.js +2 -2
- package/src/common/aggregate/aggregator.js +2 -3
- package/src/common/config/__mocks__/info.js +3 -0
- package/src/common/config/__mocks__/init.js +3 -0
- package/src/common/config/__mocks__/loader-config.js +2 -0
- package/src/common/config/__mocks__/runtime.js +2 -0
- package/src/common/config/{state/configurable.js → configurable.js} +1 -1
- package/src/common/config/{state/info.js → info.js} +1 -1
- package/src/common/config/{state/init.js → init.js} +7 -6
- package/src/common/config/{state/loader-config.js → loader-config.js} +1 -1
- package/src/common/config/{state/runtime.js → runtime.js} +19 -5
- package/src/common/constants/agent-constants.js +2 -0
- package/src/common/constants/runtime.js +0 -2
- package/src/common/drain/drain.js +8 -6
- package/src/common/event-emitter/contextual-ee.js +1 -1
- package/src/common/harvest/harvest.js +10 -24
- package/src/common/serialize/bel-serializer.js +6 -9
- package/src/common/session/session-entity.js +4 -4
- package/src/common/timing/__mocks__/time-keeper.js +6 -2
- package/src/common/timing/time-keeper.js +15 -5
- package/src/common/url/encode.js +2 -3
- package/src/common/util/__mocks__/console.js +1 -0
- package/src/common/util/__mocks__/obfuscate.js +5 -8
- package/src/common/util/console.js +2 -0
- package/src/common/util/obfuscate.js +94 -50
- package/src/common/util/submit-data.js +0 -1
- package/src/common/util/text.js +6 -0
- package/src/common/window/__mocks__/nreum.js +1 -1
- package/src/common/window/nreum.js +2 -1
- package/src/common/wrap/wrap-websocket.js +73 -0
- package/src/features/ajax/aggregate/chunk.js +3 -2
- package/src/features/ajax/aggregate/index.js +20 -19
- package/src/features/ajax/constants.js +0 -2
- package/src/features/ajax/instrument/distributed-tracing.js +2 -1
- package/src/features/ajax/instrument/index.js +9 -5
- package/src/features/generic_events/aggregate/index.js +139 -0
- package/src/features/generic_events/constants.js +5 -0
- package/src/features/generic_events/index.js +1 -0
- package/src/features/generic_events/instrument/index.js +24 -0
- package/src/features/jserrors/aggregate/index.js +18 -9
- package/src/features/jserrors/instrument/index.js +2 -0
- package/src/features/logging/aggregate/index.js +39 -31
- package/src/features/logging/constants.js +0 -2
- package/src/features/logging/instrument/index.js +2 -0
- package/src/features/logging/shared/utils.js +1 -1
- package/src/features/metrics/aggregate/index.js +24 -9
- package/src/features/metrics/aggregate/websocket-detection.js +31 -0
- package/src/features/metrics/constants.js +3 -0
- package/src/features/metrics/instrument/index.js +13 -1
- package/src/features/page_action/instrument/index.js +11 -6
- package/src/features/page_view_event/aggregate/index.js +8 -23
- package/src/features/page_view_event/aggregate/initialized-features.js +1 -1
- package/src/features/page_view_event/instrument/index.js +2 -0
- package/src/features/page_view_timing/aggregate/index.js +15 -18
- package/src/features/page_view_timing/instrument/index.js +2 -0
- package/src/features/session_replay/aggregate/index.js +13 -9
- package/src/features/session_replay/constants.js +0 -4
- package/src/features/session_replay/index.js +1 -7
- package/src/features/session_replay/instrument/index.js +3 -4
- package/src/features/session_replay/shared/recorder-events.js +27 -20
- package/src/features/session_replay/shared/recorder.js +13 -6
- package/src/features/session_replay/shared/stylesheet-evaluator.js +2 -2
- package/src/features/session_replay/shared/utils.js +3 -2
- package/src/features/session_trace/aggregate/index.js +16 -7
- package/src/features/session_trace/aggregate/trace/storage.js +6 -1
- package/src/features/session_trace/instrument/index.js +4 -1
- package/src/features/soft_navigations/aggregate/ajax-node.js +1 -1
- package/src/features/soft_navigations/aggregate/index.js +13 -15
- package/src/features/soft_navigations/aggregate/initial-page-load-interaction.js +1 -1
- package/src/features/soft_navigations/aggregate/interaction.js +1 -1
- package/src/features/soft_navigations/instrument/index.js +9 -5
- package/src/features/spa/aggregate/index.js +12 -20
- package/src/features/spa/aggregate/interaction.js +6 -5
- package/src/features/spa/aggregate/serializer.js +2 -3
- package/src/features/spa/constants.js +2 -2
- package/src/features/spa/instrument/index.js +9 -3
- package/src/features/utils/agent-session.js +3 -1
- package/src/features/utils/aggregate-base.js +13 -3
- package/src/features/utils/event-buffer.js +126 -0
- package/src/features/utils/feature-gates.js +1 -1
- package/src/features/utils/instrument-base.js +2 -1
- package/src/features/utils/lazy-feature-loader.js +2 -2
- package/src/index.js +3 -0
- package/src/loaders/agent-base.js +2 -6
- package/src/loaders/agent.js +7 -2
- package/src/loaders/api/api.js +3 -2
- package/src/loaders/api/apiAsync.js +2 -2
- package/src/loaders/browser-agent.js +5 -3
- package/src/loaders/configure/configure.js +9 -2
- package/src/loaders/features/enabled-features.js +1 -1
- package/src/loaders/features/features.js +8 -4
- package/src/loaders/micro-agent.js +5 -2
- package/dist/cjs/cdn/polyfills/lite.js +0 -16
- package/dist/cjs/cdn/polyfills/pro.js +0 -21
- package/dist/cjs/cdn/polyfills/spa.js +0 -22
- package/dist/cjs/cdn/polyfills.js +0 -24
- package/dist/cjs/common/config/config.js +0 -76
- package/dist/cjs/common/config/state/originals.js +0 -8
- package/dist/cjs/common/util/map-own.js +0 -31
- package/dist/cjs/common/wrap/index.js +0 -61
- package/dist/cjs/features/page_action/aggregate/index.js +0 -121
- package/dist/esm/cdn/polyfills/lite.js +0 -14
- package/dist/esm/cdn/polyfills/pro.js +0 -19
- package/dist/esm/cdn/polyfills/spa.js +0 -20
- package/dist/esm/cdn/polyfills.js +0 -27
- package/dist/esm/common/config/config.js +0 -11
- package/dist/esm/common/config/state/originals.js +0 -2
- package/dist/esm/common/util/map-own.js +0 -24
- package/dist/esm/common/wrap/index.js +0 -13
- package/dist/esm/features/page_action/aggregate/index.js +0 -114
- package/dist/types/cdn/polyfills/lite.d.ts +0 -2
- package/dist/types/cdn/polyfills/lite.d.ts.map +0 -1
- package/dist/types/cdn/polyfills/pro.d.ts +0 -2
- package/dist/types/cdn/polyfills/pro.d.ts.map +0 -1
- package/dist/types/cdn/polyfills/spa.d.ts +0 -2
- package/dist/types/cdn/polyfills/spa.d.ts.map +0 -1
- package/dist/types/cdn/polyfills.d.ts +0 -2
- package/dist/types/cdn/polyfills.d.ts.map +0 -1
- package/dist/types/common/config/config.d.ts +0 -13
- package/dist/types/common/config/config.d.ts.map +0 -1
- package/dist/types/common/config/state/configurable.d.ts.map +0 -1
- package/dist/types/common/config/state/info.d.ts.map +0 -1
- package/dist/types/common/config/state/init.d.ts.map +0 -1
- package/dist/types/common/config/state/loader-config.d.ts.map +0 -1
- package/dist/types/common/config/state/originals.d.ts +0 -2
- package/dist/types/common/config/state/originals.d.ts.map +0 -1
- package/dist/types/common/config/state/runtime.d.ts.map +0 -1
- package/dist/types/common/util/map-own.d.ts +0 -3
- package/dist/types/common/util/map-own.d.ts.map +0 -1
- package/dist/types/common/wrap/index.d.ts +0 -10
- package/dist/types/common/wrap/index.d.ts.map +0 -1
- package/dist/types/features/page_action/aggregate/index.d.ts.map +0 -1
- package/src/cdn/polyfills/lite.js +0 -20
- package/src/cdn/polyfills/pro.js +0 -30
- package/src/cdn/polyfills/spa.js +0 -32
- package/src/cdn/polyfills.js +0 -27
- package/src/common/config/__mocks__/config.js +0 -11
- package/src/common/config/config.js +0 -12
- package/src/common/config/state/originals.js +0 -3
- package/src/common/util/map-own.js +0 -22
- package/src/common/wrap/index.js +0 -16
- package/src/features/page_action/aggregate/index.js +0 -114
- /package/dist/types/common/config/{state/configurable.d.ts → configurable.d.ts} +0 -0
- /package/dist/types/common/config/{state/info.d.ts → info.d.ts} +0 -0
- /package/dist/types/common/config/{state/init.d.ts → init.d.ts} +0 -0
- /package/dist/types/common/config/{state/loader-config.d.ts → loader-config.d.ts} +0 -0
- /package/dist/types/common/config/{state/runtime.d.ts → runtime.d.ts} +0 -0
|
@@ -16,13 +16,10 @@ import { Instrument as InstrumentErrors } from '../features/jserrors/instrument'
|
|
|
16
16
|
import { Instrument as InstrumentXhr } from '../features/ajax/instrument';
|
|
17
17
|
import { Instrument as InstrumentSessionTrace } from '../features/session_trace/instrument';
|
|
18
18
|
import { Instrument as InstrumentSessionReplay } from '../features/session_replay/instrument';
|
|
19
|
-
|
|
19
|
+
import { Instrument as InstrumentGenericEvents } from '../features/generic_events/instrument';
|
|
20
20
|
import { Instrument as InstrumentSoftNav } from '../features/soft_navigations/instrument';
|
|
21
|
-
import { Instrument as InstrumentPageAction } from '../features/page_action/instrument';
|
|
22
21
|
import { Instrument as InstrumentLogs } from '../features/logging/instrument';
|
|
23
22
|
new Agent({
|
|
24
|
-
features: [InstrumentXhr, InstrumentPageViewEvent, InstrumentPageViewTiming, InstrumentSessionTrace, InstrumentSessionReplay, InstrumentMetrics,
|
|
25
|
-
// InstrumentSpa,
|
|
26
|
-
InstrumentSoftNav],
|
|
23
|
+
features: [InstrumentXhr, InstrumentPageViewEvent, InstrumentPageViewTiming, InstrumentSessionTrace, InstrumentSessionReplay, InstrumentMetrics, InstrumentErrors, InstrumentGenericEvents, InstrumentLogs, InstrumentSoftNav],
|
|
27
24
|
loaderType: 'experimental'
|
|
28
25
|
});
|
package/dist/esm/cdn/pro.js
CHANGED
|
@@ -11,9 +11,9 @@ import { Instrument as InstrumentErrors } from '../features/jserrors/instrument'
|
|
|
11
11
|
import { Instrument as InstrumentXhr } from '../features/ajax/instrument';
|
|
12
12
|
import { Instrument as InstrumentSessionTrace } from '../features/session_trace/instrument';
|
|
13
13
|
import { Instrument as InstrumentSessionReplay } from '../features/session_replay/instrument';
|
|
14
|
-
import { Instrument as
|
|
14
|
+
import { Instrument as InstrumentGenericEvents } from '../features/generic_events/instrument';
|
|
15
15
|
import { Instrument as InstrumentLogs } from '../features/logging/instrument';
|
|
16
16
|
new Agent({
|
|
17
|
-
features: [InstrumentPageViewEvent, InstrumentPageViewTiming, InstrumentSessionTrace, InstrumentSessionReplay, InstrumentXhr, InstrumentMetrics,
|
|
17
|
+
features: [InstrumentPageViewEvent, InstrumentPageViewTiming, InstrumentSessionTrace, InstrumentSessionReplay, InstrumentXhr, InstrumentMetrics, InstrumentErrors, InstrumentGenericEvents, InstrumentLogs],
|
|
18
18
|
loaderType: 'pro'
|
|
19
19
|
});
|
package/dist/esm/cdn/spa.js
CHANGED
|
@@ -12,10 +12,10 @@ import { Instrument as InstrumentSessionTrace } from '../features/session_trace/
|
|
|
12
12
|
import { Instrument as InstrumentSessionReplay } from '../features/session_replay/instrument';
|
|
13
13
|
import { Instrument as InstrumentSoftNav } from '../features/soft_navigations/instrument';
|
|
14
14
|
import { Instrument as InstrumentSpa } from '../features/spa/instrument';
|
|
15
|
-
import { Instrument as
|
|
15
|
+
import { Instrument as InstrumentGenericEvents } from '../features/generic_events/instrument';
|
|
16
16
|
import { Instrument as InstrumentLogs } from '../features/logging/instrument';
|
|
17
17
|
new Agent({
|
|
18
|
-
features: [InstrumentXhr, InstrumentPageViewEvent, InstrumentPageViewTiming, InstrumentSessionTrace, InstrumentSessionReplay, InstrumentMetrics,
|
|
18
|
+
features: [InstrumentXhr, InstrumentPageViewEvent, InstrumentPageViewTiming, InstrumentSessionTrace, InstrumentSessionReplay, InstrumentMetrics, InstrumentErrors, InstrumentGenericEvents, InstrumentLogs, InstrumentSoftNav, InstrumentSpa // either the softnav or the old spa will be used (not both), but we still need to pack both to avoid dynamic import for instrument files
|
|
19
19
|
],
|
|
20
20
|
loaderType: 'spa'
|
|
21
21
|
});
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { SharedContext } from '../context/shared-context';
|
|
7
|
-
import { mapOwn } from '../util/map-own';
|
|
8
7
|
export class Aggregator extends SharedContext {
|
|
9
8
|
constructor(parent) {
|
|
10
9
|
super(parent);
|
|
@@ -30,7 +29,7 @@ export class Aggregator extends SharedContext {
|
|
|
30
29
|
oldMetrics.count += metrics.count;
|
|
31
30
|
|
|
32
31
|
// iterate through each new metric and merge
|
|
33
|
-
|
|
32
|
+
Object.keys(metrics || {}).forEach(key => {
|
|
34
33
|
// count is a special case handled above
|
|
35
34
|
if (key === 'count') return;
|
|
36
35
|
var oldMetric = oldMetrics[key];
|
|
@@ -89,7 +88,7 @@ function aggregateMetrics(newMetrics, oldMetrics) {
|
|
|
89
88
|
count: 0
|
|
90
89
|
};
|
|
91
90
|
oldMetrics.count += 1;
|
|
92
|
-
|
|
91
|
+
Object.entries(newMetrics || {}).forEach(([key, value]) => {
|
|
93
92
|
oldMetrics[key] = updateMetric(value, oldMetrics[key]);
|
|
94
93
|
});
|
|
95
94
|
return oldMetrics;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { LOG_LEVELS } from '
|
|
2
|
-
import { isValidSelector } from '
|
|
3
|
-
import { DEFAULT_EXPIRES_MS, DEFAULT_INACTIVE_MS } from '
|
|
4
|
-
import { warn } from '
|
|
5
|
-
import { getNREUMInitializedAgent } from '
|
|
1
|
+
import { LOG_LEVELS } from '../../features/logging/constants';
|
|
2
|
+
import { isValidSelector } from '../dom/query-selector';
|
|
3
|
+
import { DEFAULT_EXPIRES_MS, DEFAULT_INACTIVE_MS } from '../session/constants';
|
|
4
|
+
import { warn } from '../util/console';
|
|
5
|
+
import { getNREUMInitializedAgent } from '../window/nreum';
|
|
6
6
|
import { getModeledObject } from './configurable';
|
|
7
7
|
const nrMask = '[data-nr-mask]';
|
|
8
8
|
const model = () => {
|
|
@@ -45,6 +45,11 @@ const model = () => {
|
|
|
45
45
|
allowed_origins: undefined
|
|
46
46
|
},
|
|
47
47
|
feature_flags: [],
|
|
48
|
+
generic_events: {
|
|
49
|
+
enabled: true,
|
|
50
|
+
harvestTimeSeconds: 30,
|
|
51
|
+
autoStart: true
|
|
52
|
+
},
|
|
48
53
|
harvest: {
|
|
49
54
|
tooManyRequestsDelay: 60
|
|
50
55
|
},
|
|
@@ -65,9 +70,7 @@ const model = () => {
|
|
|
65
70
|
},
|
|
66
71
|
obfuscate: undefined,
|
|
67
72
|
page_action: {
|
|
68
|
-
enabled: true
|
|
69
|
-
harvestTimeSeconds: 30,
|
|
70
|
-
autoStart: true
|
|
73
|
+
enabled: true
|
|
71
74
|
},
|
|
72
75
|
page_view_event: {
|
|
73
76
|
enabled: true,
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { getModeledObject } from './configurable';
|
|
2
|
-
import { getNREUMInitializedAgent } from '
|
|
3
|
-
import { globalScope, originTime } from '
|
|
4
|
-
import { BUILD_ENV, DIST_METHOD, VERSION } from "
|
|
2
|
+
import { getNREUMInitializedAgent } from '../window/nreum';
|
|
3
|
+
import { globalScope, originTime } from '../constants/runtime';
|
|
4
|
+
import { BUILD_ENV, DIST_METHOD, VERSION } from "../constants/env.npm";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Module level count of harvests. This property will auto-increment each time it is accessed.
|
|
8
|
+
* @type {number}
|
|
9
|
+
*/
|
|
10
|
+
let harvestCount = 0;
|
|
5
11
|
const readonly = {
|
|
6
12
|
buildEnv: BUILD_ENV,
|
|
7
13
|
distMethod: DIST_METHOD,
|
|
@@ -22,8 +28,8 @@ const model = {
|
|
|
22
28
|
appMetadata: {},
|
|
23
29
|
session: undefined,
|
|
24
30
|
denyList: undefined,
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
timeKeeper: undefined,
|
|
32
|
+
obfuscator: undefined
|
|
27
33
|
};
|
|
28
34
|
const _cache = {};
|
|
29
35
|
export function getRuntime(id) {
|
|
@@ -37,6 +43,12 @@ export function setRuntime(id, obj) {
|
|
|
37
43
|
...getModeledObject(obj, model),
|
|
38
44
|
...readonly
|
|
39
45
|
};
|
|
46
|
+
if (!Object.hasOwnProperty.call(_cache[id], 'harvestCount')) {
|
|
47
|
+
// Harvest count needs to be added as a getter so the variable is updated each time it is accessed
|
|
48
|
+
Object.defineProperty(_cache[id], 'harvestCount', {
|
|
49
|
+
get: () => ++harvestCount
|
|
50
|
+
});
|
|
51
|
+
}
|
|
40
52
|
const agentInst = getNREUMInitializedAgent(id);
|
|
41
53
|
if (agentInst) agentInst.runtime = _cache[id];
|
|
42
54
|
}
|
|
@@ -37,8 +37,6 @@ export const ffVersion = (() => {
|
|
|
37
37
|
}
|
|
38
38
|
return 0;
|
|
39
39
|
})();
|
|
40
|
-
export const isIE = Boolean(isBrowserScope && window.document.documentMode); // deprecated property that only works in IE
|
|
41
|
-
|
|
42
40
|
export const supportsSendBeacon = !!globalScope.navigator?.sendBeacon;
|
|
43
41
|
|
|
44
42
|
/**
|
|
@@ -9,8 +9,7 @@ export class SharedContext {
|
|
|
9
9
|
if (typeof context !== 'object') return warn(8);
|
|
10
10
|
this.sharedContext = {};
|
|
11
11
|
Object.assign(this.sharedContext, model);
|
|
12
|
-
Object.entries(context).forEach(
|
|
13
|
-
let [key, value] = _ref;
|
|
12
|
+
Object.entries(context).forEach(([key, value]) => {
|
|
14
13
|
if (Object.keys(model).includes(key)) this.sharedContext[key] = value;
|
|
15
14
|
});
|
|
16
15
|
} catch (err) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { globalScope } from '../constants/runtime';
|
|
2
2
|
const GLOBAL_EVENT_NAMESPACE = 'newrelic';
|
|
3
|
-
export function dispatchGlobalEvent() {
|
|
4
|
-
let detail = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
3
|
+
export function dispatchGlobalEvent(detail = {}) {
|
|
5
4
|
try {
|
|
6
5
|
globalScope.dispatchEvent(new CustomEvent(GLOBAL_EVENT_NAMESPACE, {
|
|
7
6
|
detail
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { ee } from '../event-emitter/contextual-ee';
|
|
7
|
-
import { mapOwn } from '../util/map-own';
|
|
8
7
|
import { registerHandler as defaultRegister } from '../event-emitter/register-handler';
|
|
9
8
|
import { featurePriority } from '../../loaders/features/features';
|
|
9
|
+
import { EventContext } from '../event-emitter/event-context';
|
|
10
10
|
const registry = {};
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -57,10 +57,7 @@ function curateRegistry(agentIdentifier) {
|
|
|
57
57
|
* @param {string} featureName - A named group into which the feature's buffered events are bucketed.
|
|
58
58
|
* @param {boolean} force - Whether to force the drain to occur immediately, bypassing the registry and staging logic.
|
|
59
59
|
*/
|
|
60
|
-
export function drain() {
|
|
61
|
-
let agentIdentifier = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
62
|
-
let featureName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'feature';
|
|
63
|
-
let force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
60
|
+
export function drain(agentIdentifier = '', featureName = 'feature', force = false) {
|
|
64
61
|
curateRegistry(agentIdentifier);
|
|
65
62
|
// If the feature for the specified agent is not in the registry, that means the instrument file was bypassed.
|
|
66
63
|
// This could happen in tests, or loaders that directly import the aggregator. In these cases it is safe to
|
|
@@ -77,13 +74,9 @@ function checkCanDrainAll(agentIdentifier) {
|
|
|
77
74
|
// Only when the event-groups for all features are ready to drain (staged) do we execute the drain. This has the effect
|
|
78
75
|
// that the last feature to call drain triggers drain for all features.
|
|
79
76
|
const items = Array.from(registry[agentIdentifier]);
|
|
80
|
-
if (items.every(
|
|
81
|
-
let [key, values] = _ref;
|
|
82
|
-
return values.staged;
|
|
83
|
-
})) {
|
|
77
|
+
if (items.every(([key, values]) => values.staged)) {
|
|
84
78
|
items.sort((a, b) => a[1].priority - b[1].priority);
|
|
85
|
-
items.forEach(
|
|
86
|
-
let [group] = _ref2;
|
|
79
|
+
items.forEach(([group]) => {
|
|
87
80
|
registry[agentIdentifier].delete(group);
|
|
88
81
|
drainGroup(agentIdentifier, group);
|
|
89
82
|
});
|
|
@@ -95,8 +88,7 @@ function checkCanDrainAll(agentIdentifier) {
|
|
|
95
88
|
* the subscribed handlers for the group.
|
|
96
89
|
* @param {*} group - The name of a particular feature's event "bucket".
|
|
97
90
|
*/
|
|
98
|
-
function drainGroup(agentIdentifier, group) {
|
|
99
|
-
let activateGroup = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
91
|
+
function drainGroup(agentIdentifier, group, activateGroup = true) {
|
|
100
92
|
const baseEE = agentIdentifier ? ee.get(agentIdentifier) : ee;
|
|
101
93
|
const handlers = defaultRegister.handlers; // other storage in registerHandler
|
|
102
94
|
if (baseEE.aborted || !baseEE.backlog || !handlers) return;
|
|
@@ -111,10 +103,12 @@ function drainGroup(agentIdentifier, group) {
|
|
|
111
103
|
// eslint-disable-line no-unmodified-loop-condition
|
|
112
104
|
emitEvent(bufferedEventsInGroup[i], groupHandlers);
|
|
113
105
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
// registration
|
|
117
|
-
|
|
106
|
+
Object.entries(groupHandlers).forEach(([eventType, handlerRegistrationList]) => {
|
|
107
|
+
Object.values(handlerRegistrationList || {}).forEach(registration => {
|
|
108
|
+
// registration *should* be an array of: [targetEE, eventHandler]
|
|
109
|
+
// certain browser polyfills of .values and .entries pass the prototype methods into the callback,
|
|
110
|
+
// which breaks this assumption and throws errors. So we make sure here that we only call .on() if its an actual NR EE
|
|
111
|
+
if (registration[0]?.on && registration[0]?.context() instanceof EventContext) registration[0].on(eventType, registration[1]);
|
|
118
112
|
});
|
|
119
113
|
});
|
|
120
114
|
}
|
|
@@ -133,7 +127,7 @@ function drainGroup(agentIdentifier, group) {
|
|
|
133
127
|
*/
|
|
134
128
|
function emitEvent(evt, groupHandlers) {
|
|
135
129
|
var type = evt[1];
|
|
136
|
-
|
|
130
|
+
Object.values(groupHandlers[type] || {}).forEach(registration => {
|
|
137
131
|
var sourceEE = evt[0];
|
|
138
132
|
var ee = registration[0];
|
|
139
133
|
if (ee === sourceEE) {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { gosNREUM } from '../window/nreum';
|
|
7
7
|
import { getOrSet } from '../util/get-or-set';
|
|
8
|
-
import { getRuntime } from '../config/
|
|
8
|
+
import { getRuntime } from '../config/runtime';
|
|
9
9
|
import { EventContext } from './event-context';
|
|
10
10
|
import { bundleId } from '../ids/bundle-id';
|
|
11
11
|
|
|
@@ -125,8 +125,7 @@ function ee(old, debugId) {
|
|
|
125
125
|
|
|
126
126
|
// do not buffer events if agent has been aborted
|
|
127
127
|
if (emitter.aborted) return;
|
|
128
|
-
Object.entries(types || {}).forEach(
|
|
129
|
-
let [_, type] = _ref;
|
|
128
|
+
Object.entries(types || {}).forEach(([_, type]) => {
|
|
130
129
|
bufferGroupMap[type] = group;
|
|
131
130
|
if (!(group in eventBuffer)) {
|
|
132
131
|
eventBuffer[group] = [];
|
|
@@ -30,14 +30,10 @@ export function eventListenerOpts(useCapture, abortSignal) {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
/** Do not use this within the worker context. */
|
|
33
|
-
export function windowAddEventListener(event, listener) {
|
|
34
|
-
let capture = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
35
|
-
let abortSignal = arguments.length > 3 ? arguments[3] : undefined;
|
|
33
|
+
export function windowAddEventListener(event, listener, capture = false, abortSignal) {
|
|
36
34
|
window.addEventListener(event, listener, eventListenerOpts(capture, abortSignal));
|
|
37
35
|
}
|
|
38
36
|
/** Do not use this within the worker context. */
|
|
39
|
-
export function documentAddEventListener(event, listener) {
|
|
40
|
-
let capture = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
41
|
-
let abortSignal = arguments.length > 3 ? arguments[3] : undefined;
|
|
37
|
+
export function documentAddEventListener(event, listener, capture = false, abortSignal) {
|
|
42
38
|
document.addEventListener(event, listener, eventListenerOpts(capture, abortSignal));
|
|
43
39
|
}
|
|
@@ -62,8 +62,7 @@ export class HarvestScheduler extends SharedContext {
|
|
|
62
62
|
this.started = true;
|
|
63
63
|
this.scheduleHarvest(initialDelay != null ? initialDelay : this.interval);
|
|
64
64
|
}
|
|
65
|
-
stopTimer() {
|
|
66
|
-
let permanently = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
65
|
+
stopTimer(permanently = false) {
|
|
67
66
|
this.aborted = permanently; // stopping permanently is same as aborting, but this function also cleans up the setTimeout loop
|
|
68
67
|
this.started = false;
|
|
69
68
|
if (this.timeoutHandle) {
|
|
@@ -7,14 +7,14 @@ import { obj as encodeObj, param as encodeParam } from '../url/encode';
|
|
|
7
7
|
import { stringify } from '../util/stringify';
|
|
8
8
|
import * as submitData from '../util/submit-data';
|
|
9
9
|
import { getLocation } from '../url/location';
|
|
10
|
-
import { getInfo
|
|
10
|
+
import { getInfo } from '../config/info';
|
|
11
|
+
import { getConfigurationValue, getConfiguration } from '../config/init';
|
|
12
|
+
import { getRuntime } from '../config/runtime';
|
|
11
13
|
import { cleanURL } from '../url/clean-url';
|
|
12
14
|
import { eventListenerOpts } from '../event-listener/event-listener-opts';
|
|
13
|
-
import { Obfuscator } from '../util/obfuscate';
|
|
14
|
-
import { applyFnToProps } from '../util/traverse';
|
|
15
15
|
import { SharedContext } from '../context/shared-context';
|
|
16
16
|
import { VERSION } from "../constants/env.npm";
|
|
17
|
-
import { isWorkerScope
|
|
17
|
+
import { isWorkerScope } from '../constants/runtime';
|
|
18
18
|
import { warn } from '../util/console';
|
|
19
19
|
import { now } from '../timing/now';
|
|
20
20
|
const warnings = {};
|
|
@@ -31,7 +31,7 @@ export class Harvest extends SharedContext {
|
|
|
31
31
|
super(parent); // gets any allowed properties from the parent and stores them in `sharedContext`
|
|
32
32
|
|
|
33
33
|
this.tooManyRequestsDelay = getConfigurationValue(this.sharedContext.agentIdentifier, 'harvest.tooManyRequestsDelay') || 60;
|
|
34
|
-
this.obfuscator =
|
|
34
|
+
this.obfuscator = getRuntime(this.sharedContext.agentIdentifier).obfuscator;
|
|
35
35
|
this._events = {};
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -41,8 +41,7 @@ export class Harvest extends SharedContext {
|
|
|
41
41
|
* Note: Used by page_action
|
|
42
42
|
* @param {NetworkSendSpec} spec Specification for sending data
|
|
43
43
|
*/
|
|
44
|
-
sendX() {
|
|
45
|
-
let spec = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
44
|
+
sendX(spec = {}) {
|
|
46
45
|
const submitMethod = submitData.getSubmitMethod({
|
|
47
46
|
isFinalHarvest: spec.opts?.unload
|
|
48
47
|
});
|
|
@@ -51,7 +50,7 @@ export class Harvest extends SharedContext {
|
|
|
51
50
|
isFinalHarvest: spec.opts?.unload === true
|
|
52
51
|
};
|
|
53
52
|
const payload = this.createPayload(spec.endpoint, options);
|
|
54
|
-
const caller = this.
|
|
53
|
+
const caller = this._send.bind(this);
|
|
55
54
|
return caller({
|
|
56
55
|
...spec,
|
|
57
56
|
payload,
|
|
@@ -63,31 +62,11 @@ export class Harvest extends SharedContext {
|
|
|
63
62
|
* Initiate a harvest call.
|
|
64
63
|
* @param {NetworkSendSpec} spec Specification for sending data
|
|
65
64
|
*/
|
|
66
|
-
send() {
|
|
67
|
-
|
|
68
|
-
const caller = this.obfuscator.shouldObfuscate() ? this.obfuscateAndSend.bind(this) : this._send.bind(this);
|
|
65
|
+
send(spec = {}) {
|
|
66
|
+
const caller = this._send.bind(this);
|
|
69
67
|
return caller(spec);
|
|
70
68
|
}
|
|
71
69
|
|
|
72
|
-
/**
|
|
73
|
-
* Apply obfuscation rules to the payload and then initial the harvest network call.
|
|
74
|
-
* @param {NetworkSendSpec} spec Specification for sending data
|
|
75
|
-
*/
|
|
76
|
-
obfuscateAndSend() {
|
|
77
|
-
var _this = this;
|
|
78
|
-
let spec = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
79
|
-
const {
|
|
80
|
-
payload = {}
|
|
81
|
-
} = spec;
|
|
82
|
-
applyFnToProps(payload, function () {
|
|
83
|
-
return _this.obfuscator.obfuscateString(...arguments);
|
|
84
|
-
}, 'string', ['e']);
|
|
85
|
-
return this._send({
|
|
86
|
-
...spec,
|
|
87
|
-
payload
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
|
|
91
70
|
/**
|
|
92
71
|
* Initiate a harvest call. Typically used by `sendX` and `send` methods or called directly
|
|
93
72
|
* for raw network calls.
|
|
@@ -95,17 +74,16 @@ export class Harvest extends SharedContext {
|
|
|
95
74
|
* @returns {boolean} True if the network call succeeded. For final harvest calls, the return
|
|
96
75
|
* value should not be relied upon because network calls will be made asynchronously.
|
|
97
76
|
*/
|
|
98
|
-
_send(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
} = _ref;
|
|
77
|
+
_send({
|
|
78
|
+
endpoint,
|
|
79
|
+
payload = {},
|
|
80
|
+
opts = {},
|
|
81
|
+
submitMethod,
|
|
82
|
+
cbFinished,
|
|
83
|
+
customUrl,
|
|
84
|
+
raw,
|
|
85
|
+
includeBaseParams = true
|
|
86
|
+
}) {
|
|
109
87
|
const info = getInfo(this.sharedContext.agentIdentifier);
|
|
110
88
|
if (!info.errorBeacon) return false;
|
|
111
89
|
const agentRuntime = getRuntime(this.sharedContext.agentIdentifier);
|
|
@@ -163,11 +141,11 @@ export class Harvest extends SharedContext {
|
|
|
163
141
|
/* Since workers don't support sendBeacon right now, they can only use XHR method.
|
|
164
142
|
Because they still do permit synch XHR, the idea is that at final harvest time (worker is closing),
|
|
165
143
|
we just make a BLOCKING request--trivial impact--with the remaining data as a temp fill-in for sendBeacon.
|
|
166
|
-
Following the removal of img-element method
|
|
144
|
+
Following the removal of img-element method. */
|
|
167
145
|
let result = submitMethod({
|
|
168
146
|
url: fullUrl,
|
|
169
147
|
body,
|
|
170
|
-
sync: opts.unload &&
|
|
148
|
+
sync: opts.unload && isWorkerScope,
|
|
171
149
|
headers
|
|
172
150
|
});
|
|
173
151
|
if (!opts.unload && cbFinished && submitMethod === submitData.xhr) {
|
|
@@ -193,8 +171,6 @@ export class Harvest extends SharedContext {
|
|
|
193
171
|
cbFinished(cbResult);
|
|
194
172
|
}, eventListenerOpts(false));
|
|
195
173
|
}
|
|
196
|
-
const runtime = getRuntime(this.sharedContext.agentIdentifier);
|
|
197
|
-
runtime.harvestCount++;
|
|
198
174
|
return result;
|
|
199
175
|
}
|
|
200
176
|
|
|
@@ -202,8 +178,7 @@ export class Harvest extends SharedContext {
|
|
|
202
178
|
baseQueryString(qs, endpoint) {
|
|
203
179
|
const runtime = getRuntime(this.sharedContext.agentIdentifier);
|
|
204
180
|
const info = getInfo(this.sharedContext.agentIdentifier);
|
|
205
|
-
const
|
|
206
|
-
const ref = this.obfuscator.shouldObfuscate() ? this.obfuscator.obfuscateString(location) : location;
|
|
181
|
+
const ref = this.obfuscator.obfuscateString(cleanURL(getLocation()));
|
|
207
182
|
const hr = runtime?.session?.state.sessionReplayMode === 1 && endpoint !== 'jserrors';
|
|
208
183
|
const qps = ['a=' + info.applicationID, encodeParam('sa', info.sa ? '' + info.sa : ''), encodeParam('v', VERSION), transactionNameParam(info), encodeParam('ct', runtime.customTransaction), '&rst=' + now(), '&ck=0',
|
|
209
184
|
// ck param DEPRECATED - still expected by backend
|
|
@@ -254,13 +229,11 @@ export class Harvest extends SharedContext {
|
|
|
254
229
|
* @param {HarvestPayload} payload Payload to be sent to the endpoint.
|
|
255
230
|
* @returns {HarvestPayload} Cleaned payload payload to be sent to the endpoint.
|
|
256
231
|
*/
|
|
257
|
-
cleanPayload() {
|
|
258
|
-
let payload = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
232
|
+
cleanPayload(payload = {}) {
|
|
259
233
|
const clean = input => {
|
|
260
234
|
if (typeof Uint8Array !== 'undefined' && input instanceof Uint8Array || Array.isArray(input)) return input;
|
|
261
235
|
if (typeof input === 'string') return input.length > 0 ? input : null;
|
|
262
|
-
return Object.entries(input || {}).reduce((accumulator,
|
|
263
|
-
let [key, value] = _ref2;
|
|
236
|
+
return Object.entries(input || {}).reduce((accumulator, [key, value]) => {
|
|
264
237
|
if (typeof value === 'number' || typeof value === 'string' && value.length > 0 || typeof value === 'object' && Object.keys(value || {}).length > 0) {
|
|
265
238
|
accumulator[key] = value;
|
|
266
239
|
}
|
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { mapOwn } from '../util/map-own';
|
|
7
6
|
import { stringify } from '../util/stringify';
|
|
8
|
-
import {
|
|
7
|
+
import { getRuntime } from '../config/runtime';
|
|
9
8
|
var hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
9
|
var MAX_ATTRIBUTES = 64;
|
|
11
10
|
export function nullable(val, fn, comma) {
|
|
@@ -18,17 +17,13 @@ export function numeric(n, noDefault) {
|
|
|
18
17
|
return n === undefined || n === 0 ? '' : Math.floor(n).toString(36);
|
|
19
18
|
}
|
|
20
19
|
export function getAddStringContext(agentIdentifier) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
let stringTableIdx = 0;
|
|
21
|
+
const stringTable = Object.prototype.hasOwnProperty.call(Object, 'create') ? Object.create(null) : {};
|
|
22
|
+
const obfuscator = getRuntime(agentIdentifier).obfuscator;
|
|
24
23
|
return addString;
|
|
25
24
|
function addString(str) {
|
|
26
25
|
if (typeof str === 'undefined' || str === '') return '';
|
|
27
|
-
|
|
28
|
-
agentIdentifier
|
|
29
|
-
});
|
|
30
|
-
str = String(str);
|
|
31
|
-
if (obfuscator.shouldObfuscate()) str = obfuscator.obfuscateString(str);
|
|
26
|
+
str = obfuscator.obfuscateString(String(str));
|
|
32
27
|
if (hasOwnProp.call(stringTable, str)) {
|
|
33
28
|
return numeric(stringTable[str], true);
|
|
34
29
|
} else {
|
|
@@ -39,7 +34,7 @@ export function getAddStringContext(agentIdentifier) {
|
|
|
39
34
|
}
|
|
40
35
|
export function addCustomAttributes(attrs, addString) {
|
|
41
36
|
var attrParts = [];
|
|
42
|
-
|
|
37
|
+
Object.entries(attrs || {}).forEach(([key, val]) => {
|
|
43
38
|
if (attrParts.length >= MAX_ATTRIBUTES) return;
|
|
44
39
|
var type = 5;
|
|
45
40
|
var serializedValue;
|
|
@@ -3,11 +3,11 @@ import { warn } from '../util/console';
|
|
|
3
3
|
import { stringify } from '../util/stringify';
|
|
4
4
|
import { ee } from '../event-emitter/contextual-ee';
|
|
5
5
|
import { Timer } from '../timer/timer';
|
|
6
|
-
import { isBrowserScope
|
|
6
|
+
import { isBrowserScope } from '../constants/runtime';
|
|
7
7
|
import { DEFAULT_EXPIRES_MS, DEFAULT_INACTIVE_MS, MODE, PREFIX, SESSION_EVENTS, SESSION_EVENT_TYPES } from './constants';
|
|
8
8
|
import { InteractionTimer } from '../timer/interaction-timer';
|
|
9
|
-
import { wrapEvents } from '../wrap';
|
|
10
|
-
import { getModeledObject } from '../config/
|
|
9
|
+
import { wrapEvents } from '../wrap/wrap-events';
|
|
10
|
+
import { getModeledObject } from '../config/configurable';
|
|
11
11
|
import { handle } from '../event-emitter/handle';
|
|
12
12
|
import { SUPPORTABILITY_METRIC_CHANNEL } from '../../features/metrics/constants';
|
|
13
13
|
import { FEATURE_NAMES } from '../../loaders/features/features';
|
|
@@ -59,7 +59,7 @@ export class SessionEntity {
|
|
|
59
59
|
* if the event was spawned on the current page or an adjacent page, and the behavior tied
|
|
60
60
|
* to storage events is critical to apply only to cross-tab behavior
|
|
61
61
|
* */
|
|
62
|
-
if (isBrowserScope
|
|
62
|
+
if (isBrowserScope) {
|
|
63
63
|
windowAddEventListener('storage', event => {
|
|
64
64
|
if (event.key === this.lookupKey) {
|
|
65
65
|
const obj = typeof event.newValue === 'string' ? JSON.parse(event.newValue) : event.newValue;
|
|
@@ -69,12 +69,11 @@ export class SessionEntity {
|
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
setup(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
} = _ref;
|
|
72
|
+
setup({
|
|
73
|
+
value = generateRandomHexString(16),
|
|
74
|
+
expiresMs = DEFAULT_EXPIRES_MS,
|
|
75
|
+
inactiveMs = DEFAULT_INACTIVE_MS
|
|
76
|
+
}) {
|
|
78
77
|
/** Ensure that certain properties are preserved across a reset if already set */
|
|
79
78
|
const persistentAttributes = {
|
|
80
79
|
serverTimeDiff: this.state.serverTimeDiff || model.serverTimeDiff
|
|
@@ -282,9 +281,7 @@ export class SessionEntity {
|
|
|
282
281
|
if (type === 'inactive') tag = 'Session/Inactive/Seen';
|
|
283
282
|
if (tag) handle(SUPPORTABILITY_METRIC_CHANNEL, [tag, value], undefined, FEATURE_NAMES.metrics, this.ee);
|
|
284
283
|
}
|
|
285
|
-
getDuration() {
|
|
286
|
-
let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.state;
|
|
287
|
-
let useUpdatedAt = arguments.length > 1 ? arguments[1] : undefined;
|
|
284
|
+
getDuration(data = this.state, useUpdatedAt) {
|
|
288
285
|
const startingTimestamp = data.expiresAt - this.expiresMs;
|
|
289
286
|
const endingTimestamp = !useUpdatedAt ? data.updatedAt : Date.now();
|
|
290
287
|
return endingTimestamp - startingTimestamp;
|
|
@@ -35,9 +35,7 @@ function getPntType(type) {
|
|
|
35
35
|
};
|
|
36
36
|
return types[type];
|
|
37
37
|
}
|
|
38
|
-
export function addPT(offset, pt) {
|
|
39
|
-
let v = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
40
|
-
let isL1Api = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
38
|
+
export function addPT(offset, pt, v = {}, isL1Api = false) {
|
|
41
39
|
if (!pt) return;
|
|
42
40
|
v.of = offset;
|
|
43
41
|
handleValue(v.of, v, 'n', true);
|