@newrelic/browser-agent 1.263.0 → 1.265.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/README.md +2 -2
- package/dist/cjs/cdn/experimental.js +3 -7
- package/dist/cjs/cdn/pro.js +2 -2
- package/dist/cjs/cdn/spa.js +2 -2
- package/dist/cjs/common/aggregate/aggregator.js +2 -3
- package/dist/cjs/common/config/{state/configurable.js → configurable.js} +1 -1
- package/dist/cjs/common/config/{state/info.js → info.js} +1 -1
- package/dist/cjs/common/config/{state/init.js → init.js} +11 -8
- package/dist/cjs/common/config/{state/loader-config.js → loader-config.js} +1 -1
- package/dist/cjs/common/config/{state/runtime.js → runtime.js} +16 -5
- package/dist/cjs/common/constants/agent-constants.js +8 -0
- package/dist/cjs/common/constants/env.cdn.js +1 -1
- package/dist/cjs/common/constants/env.npm.js +1 -1
- package/dist/cjs/common/constants/runtime.js +1 -3
- package/dist/cjs/common/context/shared-context.js +1 -2
- package/dist/cjs/common/dispatch/global-event.js +1 -2
- package/dist/cjs/common/drain/drain.js +12 -18
- package/dist/cjs/common/event-emitter/contextual-ee.js +3 -4
- package/dist/cjs/common/event-listener/event-listener-opts.js +2 -6
- package/dist/cjs/common/harvest/harvest-scheduler.js +1 -2
- package/dist/cjs/common/harvest/harvest.js +30 -57
- package/dist/cjs/common/serialize/bel-serializer.js +6 -11
- package/dist/cjs/common/session/session-entity.js +10 -13
- package/dist/cjs/common/timing/nav-timing.js +1 -3
- package/dist/cjs/common/timing/time-keeper.js +16 -6
- package/dist/cjs/common/url/encode.js +3 -7
- package/dist/cjs/common/util/console.js +2 -0
- package/dist/cjs/common/util/invoke.js +6 -16
- package/dist/cjs/common/util/obfuscate.js +97 -53
- package/dist/cjs/common/util/submit-data.js +17 -21
- package/dist/cjs/common/util/text.js +9 -0
- package/dist/cjs/common/util/traverse.js +1 -3
- package/dist/cjs/common/vitals/cumulative-layout-shift.js +5 -6
- package/dist/cjs/common/vitals/first-contentful-paint.js +4 -5
- package/dist/cjs/common/vitals/first-input-delay.js +4 -5
- package/dist/cjs/common/vitals/interaction-to-next-paint.js +5 -6
- package/dist/cjs/common/vitals/largest-contentful-paint.js +4 -5
- package/dist/cjs/common/vitals/time-to-first-byte.js +4 -5
- package/dist/cjs/common/vitals/vital-metric.js +5 -7
- package/dist/cjs/common/window/nreum.js +2 -1
- package/dist/cjs/common/window/page-visibility.js +1 -4
- package/dist/cjs/common/wrap/wrap-events.js +1 -4
- package/dist/cjs/common/wrap/wrap-promise.js +1 -4
- package/dist/cjs/common/wrap/wrap-websocket.js +74 -0
- package/dist/cjs/features/ajax/aggregate/chunk.js +4 -3
- package/dist/cjs/features/ajax/aggregate/gql.js +4 -5
- package/dist/cjs/features/ajax/aggregate/index.js +19 -22
- package/dist/cjs/features/ajax/constants.js +2 -3
- package/dist/cjs/features/ajax/instrument/distributed-tracing.js +9 -8
- package/dist/cjs/features/ajax/instrument/index.js +14 -12
- package/dist/cjs/features/generic_events/aggregate/index.js +128 -0
- package/dist/cjs/features/generic_events/constants.js +10 -0
- package/dist/cjs/features/generic_events/index.js +12 -0
- package/dist/cjs/features/generic_events/instrument/index.js +27 -0
- package/dist/cjs/features/jserrors/aggregate/index.js +25 -44
- package/dist/cjs/features/jserrors/instrument/index.js +4 -4
- package/dist/cjs/features/logging/aggregate/index.js +33 -36
- package/dist/cjs/features/logging/constants.js +2 -3
- package/dist/cjs/features/logging/instrument/index.js +5 -6
- package/dist/cjs/features/logging/shared/log.js +1 -3
- package/dist/cjs/features/logging/shared/utils.js +2 -4
- package/dist/cjs/features/metrics/aggregate/index.js +34 -17
- package/dist/cjs/features/metrics/aggregate/websocket-detection.js +34 -0
- package/dist/cjs/features/metrics/constants.js +4 -2
- package/dist/cjs/features/metrics/instrument/index.js +12 -4
- package/dist/cjs/features/page_action/instrument/index.js +14 -10
- package/dist/cjs/features/page_view_event/aggregate/index.js +19 -39
- package/dist/cjs/features/page_view_event/aggregate/initialized-features.js +1 -1
- package/dist/cjs/features/page_view_event/instrument/index.js +4 -4
- package/dist/cjs/features/page_view_timing/aggregate/index.js +23 -39
- package/dist/cjs/features/page_view_timing/instrument/index.js +4 -4
- package/dist/cjs/features/session_replay/aggregate/index.js +35 -42
- package/dist/cjs/features/session_replay/constants.js +1 -5
- package/dist/cjs/features/session_replay/instrument/index.js +5 -9
- package/dist/cjs/features/session_replay/shared/recorder-events.js +25 -20
- package/dist/cjs/features/session_replay/shared/recorder.js +17 -13
- package/dist/cjs/features/session_replay/shared/stylesheet-evaluator.js +2 -2
- package/dist/cjs/features/session_replay/shared/utils.js +5 -4
- package/dist/cjs/features/session_trace/aggregate/index.js +25 -42
- package/dist/cjs/features/session_trace/aggregate/trace/storage.js +5 -3
- package/dist/cjs/features/session_trace/instrument/index.js +8 -7
- package/dist/cjs/features/soft_navigations/aggregate/ajax-node.js +1 -1
- package/dist/cjs/features/soft_navigations/aggregate/index.js +22 -30
- package/dist/cjs/features/soft_navigations/aggregate/initial-page-load-interaction.js +2 -2
- package/dist/cjs/features/soft_navigations/aggregate/interaction.js +4 -5
- package/dist/cjs/features/soft_navigations/instrument/index.js +14 -13
- package/dist/cjs/features/spa/aggregate/index.js +17 -28
- package/dist/cjs/features/spa/aggregate/interaction.js +7 -6
- package/dist/cjs/features/spa/aggregate/serializer.js +4 -5
- package/dist/cjs/features/spa/constants.js +2 -2
- package/dist/cjs/features/spa/instrument/index.js +20 -19
- package/dist/cjs/features/utils/agent-session.js +6 -4
- package/dist/cjs/features/utils/aggregate-base.js +17 -10
- package/dist/cjs/features/utils/event-buffer.js +132 -0
- package/dist/cjs/features/utils/feature-gates.js +2 -2
- package/dist/cjs/features/utils/instrument-base.js +7 -8
- package/dist/cjs/features/utils/lazy-feature-loader.js +12 -12
- package/dist/cjs/features/utils/nr1-debugger.js +1 -3
- package/dist/cjs/index.js +21 -0
- package/dist/cjs/loaders/agent-base.js +4 -12
- package/dist/cjs/loaders/agent.js +7 -2
- package/dist/cjs/loaders/api/api.js +23 -35
- package/dist/cjs/loaders/api/apiAsync.js +10 -13
- package/dist/cjs/loaders/browser-agent.js +4 -3
- package/dist/cjs/loaders/configure/configure.js +16 -15
- package/dist/cjs/loaders/features/enabled-features.js +2 -2
- package/dist/cjs/loaders/features/features.js +8 -4
- package/dist/cjs/loaders/micro-agent.js +16 -15
- package/dist/esm/cdn/experimental.js +2 -5
- package/dist/esm/cdn/pro.js +2 -2
- package/dist/esm/cdn/spa.js +2 -2
- package/dist/esm/common/aggregate/aggregator.js +2 -3
- package/dist/esm/common/config/{state/configurable.js → configurable.js} +1 -1
- package/dist/esm/common/config/{state/info.js → info.js} +1 -1
- package/dist/esm/common/config/{state/init.js → init.js} +11 -8
- package/dist/esm/common/config/{state/loader-config.js → loader-config.js} +1 -1
- package/dist/esm/common/config/{state/runtime.js → runtime.js} +17 -5
- package/dist/esm/common/constants/agent-constants.js +2 -0
- package/dist/esm/common/constants/env.cdn.js +1 -1
- package/dist/esm/common/constants/env.npm.js +1 -1
- package/dist/esm/common/constants/runtime.js +0 -2
- package/dist/esm/common/context/shared-context.js +1 -2
- package/dist/esm/common/dispatch/global-event.js +1 -2
- package/dist/esm/common/drain/drain.js +12 -18
- package/dist/esm/common/event-emitter/contextual-ee.js +2 -3
- package/dist/esm/common/event-listener/event-listener-opts.js +2 -6
- package/dist/esm/common/harvest/harvest-scheduler.js +1 -2
- package/dist/esm/common/harvest/harvest.js +24 -51
- package/dist/esm/common/serialize/bel-serializer.js +6 -11
- package/dist/esm/common/session/session-entity.js +10 -13
- package/dist/esm/common/timing/nav-timing.js +1 -3
- package/dist/esm/common/timing/time-keeper.js +15 -5
- package/dist/esm/common/url/encode.js +3 -7
- package/dist/esm/common/util/console.js +2 -0
- package/dist/esm/common/util/invoke.js +6 -16
- package/dist/esm/common/util/obfuscate.js +96 -49
- package/dist/esm/common/util/submit-data.js +17 -21
- package/dist/esm/common/util/text.js +3 -0
- package/dist/esm/common/util/traverse.js +1 -3
- package/dist/esm/common/vitals/cumulative-layout-shift.js +5 -6
- package/dist/esm/common/vitals/first-contentful-paint.js +4 -5
- package/dist/esm/common/vitals/first-input-delay.js +4 -5
- package/dist/esm/common/vitals/interaction-to-next-paint.js +5 -6
- package/dist/esm/common/vitals/largest-contentful-paint.js +4 -5
- package/dist/esm/common/vitals/time-to-first-byte.js +4 -5
- package/dist/esm/common/vitals/vital-metric.js +5 -7
- package/dist/esm/common/window/nreum.js +2 -1
- package/dist/esm/common/window/page-visibility.js +1 -4
- package/dist/esm/common/wrap/wrap-events.js +1 -4
- package/dist/esm/common/wrap/wrap-promise.js +1 -4
- package/dist/esm/common/wrap/wrap-websocket.js +67 -0
- package/dist/esm/features/ajax/aggregate/chunk.js +3 -2
- package/dist/esm/features/ajax/aggregate/gql.js +4 -5
- package/dist/esm/features/ajax/aggregate/index.js +16 -19
- package/dist/esm/features/ajax/constants.js +1 -2
- package/dist/esm/features/ajax/instrument/distributed-tracing.js +2 -1
- package/dist/esm/features/ajax/instrument/index.js +10 -8
- package/dist/esm/features/generic_events/aggregate/index.js +120 -0
- package/dist/esm/features/generic_events/constants.js +4 -0
- package/dist/esm/features/generic_events/index.js +1 -0
- package/dist/esm/features/generic_events/instrument/index.js +20 -0
- package/dist/esm/features/jserrors/aggregate/index.js +20 -39
- package/dist/esm/features/jserrors/instrument/index.js +3 -3
- package/dist/esm/features/logging/aggregate/index.js +31 -34
- package/dist/esm/features/logging/constants.js +1 -2
- package/dist/esm/features/logging/instrument/index.js +4 -5
- package/dist/esm/features/logging/shared/log.js +1 -3
- package/dist/esm/features/logging/shared/utils.js +2 -4
- package/dist/esm/features/metrics/aggregate/index.js +28 -11
- package/dist/esm/features/metrics/aggregate/websocket-detection.js +29 -0
- package/dist/esm/features/metrics/constants.js +3 -1
- package/dist/esm/features/metrics/instrument/index.js +12 -4
- package/dist/esm/features/page_action/instrument/index.js +14 -9
- package/dist/esm/features/page_view_event/aggregate/index.js +17 -37
- package/dist/esm/features/page_view_event/aggregate/initialized-features.js +1 -1
- package/dist/esm/features/page_view_event/instrument/index.js +3 -3
- package/dist/esm/features/page_view_timing/aggregate/index.js +20 -36
- package/dist/esm/features/page_view_timing/instrument/index.js +3 -3
- package/dist/esm/features/session_replay/aggregate/index.js +25 -32
- package/dist/esm/features/session_replay/constants.js +0 -4
- package/dist/esm/features/session_replay/index.js +1 -7
- package/dist/esm/features/session_replay/instrument/index.js +5 -8
- package/dist/esm/features/session_replay/shared/recorder-events.js +25 -20
- package/dist/esm/features/session_replay/shared/recorder.js +14 -10
- package/dist/esm/features/session_replay/shared/stylesheet-evaluator.js +2 -2
- package/dist/esm/features/session_replay/shared/utils.js +3 -2
- package/dist/esm/features/session_trace/aggregate/index.js +20 -37
- package/dist/esm/features/session_trace/aggregate/trace/storage.js +5 -3
- package/dist/esm/features/session_trace/instrument/index.js +5 -4
- package/dist/esm/features/soft_navigations/aggregate/ajax-node.js +1 -1
- package/dist/esm/features/soft_navigations/aggregate/index.js +21 -29
- package/dist/esm/features/soft_navigations/aggregate/initial-page-load-interaction.js +1 -1
- package/dist/esm/features/soft_navigations/aggregate/interaction.js +2 -3
- package/dist/esm/features/soft_navigations/instrument/index.js +11 -10
- package/dist/esm/features/spa/aggregate/index.js +11 -22
- package/dist/esm/features/spa/aggregate/interaction.js +6 -5
- package/dist/esm/features/spa/aggregate/serializer.js +2 -3
- package/dist/esm/features/spa/constants.js +2 -2
- package/dist/esm/features/spa/instrument/index.js +12 -11
- package/dist/esm/features/utils/agent-session.js +3 -1
- package/dist/esm/features/utils/aggregate-base.js +16 -9
- package/dist/esm/features/utils/event-buffer.js +126 -0
- package/dist/esm/features/utils/feature-gates.js +1 -1
- package/dist/esm/features/utils/instrument-base.js +6 -7
- package/dist/esm/features/utils/lazy-feature-loader.js +12 -12
- package/dist/esm/features/utils/nr1-debugger.js +1 -3
- package/dist/esm/index.js +3 -0
- package/dist/esm/loaders/agent-base.js +4 -12
- package/dist/esm/loaders/agent.js +7 -2
- package/dist/esm/loaders/api/api.js +18 -30
- package/dist/esm/loaders/api/apiAsync.js +3 -6
- package/dist/esm/loaders/browser-agent.js +3 -2
- package/dist/esm/loaders/configure/configure.js +9 -8
- package/dist/esm/loaders/features/enabled-features.js +1 -1
- package/dist/esm/loaders/features/features.js +8 -4
- package/dist/esm/loaders/micro-agent.js +11 -10
- package/dist/types/common/aggregate/aggregator.d.ts.map +1 -1
- package/dist/types/common/config/configurable.d.ts.map +1 -0
- package/dist/types/common/config/info.d.ts.map +1 -0
- package/dist/types/common/config/init.d.ts.map +1 -0
- package/dist/types/common/config/loader-config.d.ts.map +1 -0
- package/dist/types/common/config/runtime.d.ts.map +1 -0
- package/dist/types/common/constants/agent-constants.d.ts +3 -0
- package/dist/types/common/constants/agent-constants.d.ts.map +1 -0
- package/dist/types/common/constants/runtime.d.ts +0 -1
- package/dist/types/common/constants/runtime.d.ts.map +1 -1
- package/dist/types/common/harvest/harvest.d.ts +1 -7
- package/dist/types/common/harvest/harvest.d.ts.map +1 -1
- package/dist/types/common/serialize/bel-serializer.d.ts.map +1 -1
- package/dist/types/common/timing/time-keeper.d.ts +9 -2
- package/dist/types/common/timing/time-keeper.d.ts.map +1 -1
- package/dist/types/common/url/encode.d.ts.map +1 -1
- package/dist/types/common/util/console.d.ts.map +1 -1
- package/dist/types/common/util/obfuscate.d.ts +78 -6
- package/dist/types/common/util/obfuscate.d.ts.map +1 -1
- package/dist/types/common/util/submit-data.d.ts.map +1 -1
- package/dist/types/common/util/text.d.ts +2 -0
- package/dist/types/common/util/text.d.ts.map +1 -0
- package/dist/types/common/window/nreum.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-websocket.d.ts +4 -0
- package/dist/types/common/wrap/wrap-websocket.d.ts.map +1 -0
- package/dist/types/features/ajax/aggregate/chunk.d.ts.map +1 -1
- package/dist/types/features/ajax/aggregate/index.d.ts +2 -3
- package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/ajax/constants.d.ts +0 -1
- package/dist/types/features/ajax/constants.d.ts.map +1 -1
- package/dist/types/features/ajax/instrument/distributed-tracing.d.ts.map +1 -1
- package/dist/types/features/ajax/instrument/index.d.ts +1 -0
- package/dist/types/features/ajax/instrument/index.d.ts.map +1 -1
- package/dist/types/features/{page_action → generic_events}/aggregate/index.d.ts +10 -10
- package/dist/types/features/generic_events/aggregate/index.d.ts.map +1 -0
- package/dist/types/features/generic_events/constants.d.ts +4 -0
- package/dist/types/features/generic_events/constants.d.ts.map +1 -0
- package/dist/types/features/generic_events/index.d.ts +2 -0
- package/dist/types/features/generic_events/index.d.ts.map +1 -0
- package/dist/types/features/generic_events/instrument/index.d.ts +7 -0
- package/dist/types/features/generic_events/instrument/index.d.ts.map +1 -0
- package/dist/types/features/jserrors/aggregate/index.d.ts +2 -2
- package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/instrument/index.d.ts +1 -0
- package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -1
- package/dist/types/features/logging/aggregate/index.d.ts +4 -7
- package/dist/types/features/logging/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/logging/constants.d.ts +0 -1
- package/dist/types/features/logging/constants.d.ts.map +1 -1
- package/dist/types/features/logging/instrument/index.d.ts +1 -0
- package/dist/types/features/logging/instrument/index.d.ts.map +1 -1
- package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/metrics/aggregate/websocket-detection.d.ts +12 -0
- package/dist/types/features/metrics/aggregate/websocket-detection.d.ts.map +1 -0
- package/dist/types/features/metrics/constants.d.ts +1 -0
- package/dist/types/features/metrics/constants.d.ts.map +1 -1
- package/dist/types/features/metrics/instrument/index.d.ts +1 -0
- package/dist/types/features/metrics/instrument/index.d.ts.map +1 -1
- package/dist/types/features/page_action/instrument/index.d.ts +9 -4
- package/dist/types/features/page_action/instrument/index.d.ts.map +1 -1
- package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/page_view_event/instrument/index.d.ts +1 -0
- package/dist/types/features/page_view_event/instrument/index.d.ts.map +1 -1
- package/dist/types/features/page_view_timing/aggregate/index.d.ts +2 -2
- package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/page_view_timing/instrument/index.d.ts +1 -0
- package/dist/types/features/page_view_timing/instrument/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/constants.d.ts +0 -4
- package/dist/types/features/session_replay/constants.d.ts.map +1 -1
- package/dist/types/features/session_replay/instrument/index.d.ts +1 -0
- package/dist/types/features/session_replay/instrument/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/shared/recorder-events.d.ts +6 -6
- package/dist/types/features/session_replay/shared/recorder-events.d.ts.map +1 -1
- package/dist/types/features/session_replay/shared/recorder.d.ts +2 -2
- package/dist/types/features/session_replay/shared/recorder.d.ts.map +1 -1
- package/dist/types/features/session_replay/shared/utils.d.ts.map +1 -1
- package/dist/types/features/session_trace/aggregate/index.d.ts +2 -2
- package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_trace/aggregate/trace/storage.d.ts +1 -1
- package/dist/types/features/session_trace/aggregate/trace/storage.d.ts.map +1 -1
- package/dist/types/features/session_trace/instrument/index.d.ts +1 -0
- package/dist/types/features/session_trace/instrument/index.d.ts.map +1 -1
- package/dist/types/features/soft_navigations/aggregate/index.d.ts +3 -3
- package/dist/types/features/soft_navigations/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/soft_navigations/instrument/index.d.ts +1 -0
- package/dist/types/features/soft_navigations/instrument/index.d.ts.map +1 -1
- package/dist/types/features/spa/aggregate/index.d.ts +2 -2
- package/dist/types/features/spa/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/spa/aggregate/interaction.d.ts.map +1 -1
- package/dist/types/features/spa/aggregate/serializer.d.ts.map +1 -1
- package/dist/types/features/spa/constants.d.ts.map +1 -1
- package/dist/types/features/spa/instrument/index.d.ts +1 -0
- package/dist/types/features/spa/instrument/index.d.ts.map +1 -1
- package/dist/types/features/utils/agent-session.d.ts.map +1 -1
- package/dist/types/features/utils/aggregate-base.d.ts +1 -0
- package/dist/types/features/utils/aggregate-base.d.ts.map +1 -1
- package/dist/types/features/utils/event-buffer.d.ts +72 -0
- package/dist/types/features/utils/event-buffer.d.ts.map +1 -0
- package/dist/types/features/utils/instrument-base.d.ts +1 -0
- package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -0
- package/dist/types/loaders/agent-base.d.ts +1 -2
- package/dist/types/loaders/agent-base.d.ts.map +1 -1
- package/dist/types/loaders/agent.d.ts.map +1 -1
- package/dist/types/loaders/api/api.d.ts.map +1 -1
- package/dist/types/loaders/browser-agent.d.ts.map +1 -1
- package/dist/types/loaders/configure/configure.d.ts.map +1 -1
- package/dist/types/loaders/features/features.d.ts +1 -0
- package/dist/types/loaders/features/features.d.ts.map +1 -1
- package/dist/types/loaders/micro-agent.d.ts.map +1 -1
- package/package.json +67 -52
- package/src/cdn/experimental.js +2 -4
- package/src/cdn/pro.js +2 -2
- package/src/cdn/spa.js +2 -2
- package/src/common/aggregate/aggregator.js +2 -3
- package/src/common/config/__mocks__/info.js +3 -0
- package/src/common/config/__mocks__/init.js +3 -0
- package/src/common/config/__mocks__/loader-config.js +2 -0
- package/src/common/config/__mocks__/runtime.js +2 -0
- package/src/common/config/{state/configurable.js → configurable.js} +1 -1
- package/src/common/config/{state/info.js → info.js} +1 -1
- package/src/common/config/{state/init.js → init.js} +7 -6
- package/src/common/config/{state/loader-config.js → loader-config.js} +1 -1
- package/src/common/config/{state/runtime.js → runtime.js} +19 -5
- package/src/common/constants/agent-constants.js +2 -0
- package/src/common/constants/runtime.js +0 -2
- package/src/common/drain/drain.js +8 -6
- package/src/common/event-emitter/contextual-ee.js +1 -1
- package/src/common/harvest/harvest.js +10 -24
- package/src/common/serialize/bel-serializer.js +6 -9
- package/src/common/session/session-entity.js +4 -4
- package/src/common/timing/__mocks__/time-keeper.js +6 -2
- package/src/common/timing/time-keeper.js +15 -5
- package/src/common/url/encode.js +2 -3
- package/src/common/util/__mocks__/console.js +1 -0
- package/src/common/util/__mocks__/obfuscate.js +5 -8
- package/src/common/util/console.js +2 -0
- package/src/common/util/obfuscate.js +94 -50
- package/src/common/util/submit-data.js +0 -1
- package/src/common/util/text.js +6 -0
- package/src/common/window/__mocks__/nreum.js +1 -1
- package/src/common/window/nreum.js +2 -1
- package/src/common/wrap/wrap-websocket.js +73 -0
- package/src/features/ajax/aggregate/chunk.js +3 -2
- package/src/features/ajax/aggregate/index.js +20 -19
- package/src/features/ajax/constants.js +0 -2
- package/src/features/ajax/instrument/distributed-tracing.js +2 -1
- package/src/features/ajax/instrument/index.js +9 -5
- package/src/features/generic_events/aggregate/index.js +139 -0
- package/src/features/generic_events/constants.js +5 -0
- package/src/features/generic_events/index.js +1 -0
- package/src/features/generic_events/instrument/index.js +24 -0
- package/src/features/jserrors/aggregate/index.js +18 -9
- package/src/features/jserrors/instrument/index.js +2 -0
- package/src/features/logging/aggregate/index.js +39 -31
- package/src/features/logging/constants.js +0 -2
- package/src/features/logging/instrument/index.js +2 -0
- package/src/features/logging/shared/utils.js +1 -1
- package/src/features/metrics/aggregate/index.js +24 -9
- package/src/features/metrics/aggregate/websocket-detection.js +31 -0
- package/src/features/metrics/constants.js +3 -0
- package/src/features/metrics/instrument/index.js +13 -1
- package/src/features/page_action/instrument/index.js +11 -6
- package/src/features/page_view_event/aggregate/index.js +8 -23
- package/src/features/page_view_event/aggregate/initialized-features.js +1 -1
- package/src/features/page_view_event/instrument/index.js +2 -0
- package/src/features/page_view_timing/aggregate/index.js +15 -18
- package/src/features/page_view_timing/instrument/index.js +2 -0
- package/src/features/session_replay/aggregate/index.js +13 -9
- package/src/features/session_replay/constants.js +0 -4
- package/src/features/session_replay/index.js +1 -7
- package/src/features/session_replay/instrument/index.js +3 -4
- package/src/features/session_replay/shared/recorder-events.js +27 -20
- package/src/features/session_replay/shared/recorder.js +13 -6
- package/src/features/session_replay/shared/stylesheet-evaluator.js +2 -2
- package/src/features/session_replay/shared/utils.js +3 -2
- package/src/features/session_trace/aggregate/index.js +16 -7
- package/src/features/session_trace/aggregate/trace/storage.js +6 -1
- package/src/features/session_trace/instrument/index.js +4 -1
- package/src/features/soft_navigations/aggregate/ajax-node.js +1 -1
- package/src/features/soft_navigations/aggregate/index.js +13 -15
- package/src/features/soft_navigations/aggregate/initial-page-load-interaction.js +1 -1
- package/src/features/soft_navigations/aggregate/interaction.js +1 -1
- package/src/features/soft_navigations/instrument/index.js +9 -5
- package/src/features/spa/aggregate/index.js +12 -20
- package/src/features/spa/aggregate/interaction.js +6 -5
- package/src/features/spa/aggregate/serializer.js +2 -3
- package/src/features/spa/constants.js +2 -2
- package/src/features/spa/instrument/index.js +9 -3
- package/src/features/utils/agent-session.js +3 -1
- package/src/features/utils/aggregate-base.js +13 -3
- package/src/features/utils/event-buffer.js +126 -0
- package/src/features/utils/feature-gates.js +1 -1
- package/src/features/utils/instrument-base.js +2 -1
- package/src/features/utils/lazy-feature-loader.js +2 -2
- package/src/index.js +3 -0
- package/src/loaders/agent-base.js +2 -6
- package/src/loaders/agent.js +7 -2
- package/src/loaders/api/api.js +3 -2
- package/src/loaders/api/apiAsync.js +2 -2
- package/src/loaders/browser-agent.js +5 -3
- package/src/loaders/configure/configure.js +9 -2
- package/src/loaders/features/enabled-features.js +1 -1
- package/src/loaders/features/features.js +8 -4
- package/src/loaders/micro-agent.js +5 -2
- package/dist/cjs/cdn/polyfills/lite.js +0 -16
- package/dist/cjs/cdn/polyfills/pro.js +0 -21
- package/dist/cjs/cdn/polyfills/spa.js +0 -22
- package/dist/cjs/cdn/polyfills.js +0 -24
- package/dist/cjs/common/config/config.js +0 -76
- package/dist/cjs/common/config/state/originals.js +0 -8
- package/dist/cjs/common/util/map-own.js +0 -31
- package/dist/cjs/common/wrap/index.js +0 -61
- package/dist/cjs/features/page_action/aggregate/index.js +0 -121
- package/dist/esm/cdn/polyfills/lite.js +0 -14
- package/dist/esm/cdn/polyfills/pro.js +0 -19
- package/dist/esm/cdn/polyfills/spa.js +0 -20
- package/dist/esm/cdn/polyfills.js +0 -27
- package/dist/esm/common/config/config.js +0 -11
- package/dist/esm/common/config/state/originals.js +0 -2
- package/dist/esm/common/util/map-own.js +0 -24
- package/dist/esm/common/wrap/index.js +0 -13
- package/dist/esm/features/page_action/aggregate/index.js +0 -114
- package/dist/types/cdn/polyfills/lite.d.ts +0 -2
- package/dist/types/cdn/polyfills/lite.d.ts.map +0 -1
- package/dist/types/cdn/polyfills/pro.d.ts +0 -2
- package/dist/types/cdn/polyfills/pro.d.ts.map +0 -1
- package/dist/types/cdn/polyfills/spa.d.ts +0 -2
- package/dist/types/cdn/polyfills/spa.d.ts.map +0 -1
- package/dist/types/cdn/polyfills.d.ts +0 -2
- package/dist/types/cdn/polyfills.d.ts.map +0 -1
- package/dist/types/common/config/config.d.ts +0 -13
- package/dist/types/common/config/config.d.ts.map +0 -1
- package/dist/types/common/config/state/configurable.d.ts.map +0 -1
- package/dist/types/common/config/state/info.d.ts.map +0 -1
- package/dist/types/common/config/state/init.d.ts.map +0 -1
- package/dist/types/common/config/state/loader-config.d.ts.map +0 -1
- package/dist/types/common/config/state/originals.d.ts +0 -2
- package/dist/types/common/config/state/originals.d.ts.map +0 -1
- package/dist/types/common/config/state/runtime.d.ts.map +0 -1
- package/dist/types/common/util/map-own.d.ts +0 -3
- package/dist/types/common/util/map-own.d.ts.map +0 -1
- package/dist/types/common/wrap/index.d.ts +0 -10
- package/dist/types/common/wrap/index.d.ts.map +0 -1
- package/dist/types/features/page_action/aggregate/index.d.ts.map +0 -1
- package/src/cdn/polyfills/lite.js +0 -20
- package/src/cdn/polyfills/pro.js +0 -30
- package/src/cdn/polyfills/spa.js +0 -32
- package/src/cdn/polyfills.js +0 -27
- package/src/common/config/__mocks__/config.js +0 -11
- package/src/common/config/config.js +0 -12
- package/src/common/config/state/originals.js +0 -3
- package/src/common/util/map-own.js +0 -22
- package/src/common/wrap/index.js +0 -16
- package/src/features/page_action/aggregate/index.js +0 -114
- /package/dist/types/common/config/{state/configurable.d.ts → configurable.d.ts} +0 -0
- /package/dist/types/common/config/{state/info.d.ts → info.d.ts} +0 -0
- /package/dist/types/common/config/{state/init.d.ts → init.d.ts} +0 -0
- /package/dist/types/common/config/{state/loader-config.d.ts → loader-config.d.ts} +0 -0
- /package/dist/types/common/config/{state/runtime.d.ts → runtime.d.ts} +0 -0
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { SharedContext } from '../context/shared-context'
|
|
7
|
-
import { mapOwn } from '../util/map-own'
|
|
8
7
|
|
|
9
8
|
export class Aggregator extends SharedContext {
|
|
10
9
|
constructor (parent) {
|
|
@@ -34,7 +33,7 @@ export class Aggregator extends SharedContext {
|
|
|
34
33
|
oldMetrics.count += metrics.count
|
|
35
34
|
|
|
36
35
|
// iterate through each new metric and merge
|
|
37
|
-
|
|
36
|
+
Object.keys(metrics || {}).forEach((key) => {
|
|
38
37
|
// count is a special case handled above
|
|
39
38
|
if (key === 'count') return
|
|
40
39
|
|
|
@@ -94,7 +93,7 @@ export class Aggregator extends SharedContext {
|
|
|
94
93
|
function aggregateMetrics (newMetrics, oldMetrics) {
|
|
95
94
|
if (!oldMetrics) oldMetrics = { count: 0 }
|
|
96
95
|
oldMetrics.count += 1
|
|
97
|
-
|
|
96
|
+
Object.entries(newMetrics || {}).forEach(([key, value]) => {
|
|
98
97
|
oldMetrics[key] = updateMetric(value, oldMetrics[key])
|
|
99
98
|
})
|
|
100
99
|
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
|
|
|
8
8
|
const nrMask = '[data-nr-mask]'
|
|
@@ -41,12 +41,13 @@ const model = () => {
|
|
|
41
41
|
allowed_origins: undefined
|
|
42
42
|
},
|
|
43
43
|
feature_flags: [],
|
|
44
|
+
generic_events: { enabled: true, harvestTimeSeconds: 30, autoStart: true },
|
|
44
45
|
harvest: { tooManyRequestsDelay: 60 },
|
|
45
46
|
jserrors: { enabled: true, harvestTimeSeconds: 10, autoStart: true },
|
|
46
47
|
logging: { enabled: true, harvestTimeSeconds: 10, autoStart: true, level: LOG_LEVELS.INFO },
|
|
47
48
|
metrics: { enabled: true, autoStart: true },
|
|
48
49
|
obfuscate: undefined,
|
|
49
|
-
page_action: { enabled: true
|
|
50
|
+
page_action: { enabled: true },
|
|
50
51
|
page_view_event: { enabled: true, autoStart: true },
|
|
51
52
|
page_view_timing: { enabled: true, harvestTimeSeconds: 30, long_task: false, autoStart: true },
|
|
52
53
|
privacy: { cookies_enabled: true }, // *cli - per discussion, default should be 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'
|
|
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
|
|
|
6
12
|
const readonly = {
|
|
7
13
|
buildEnv: BUILD_ENV,
|
|
@@ -24,8 +30,8 @@ const model = {
|
|
|
24
30
|
appMetadata: {},
|
|
25
31
|
session: undefined,
|
|
26
32
|
denyList: undefined,
|
|
27
|
-
|
|
28
|
-
|
|
33
|
+
timeKeeper: undefined,
|
|
34
|
+
obfuscator: undefined
|
|
29
35
|
}
|
|
30
36
|
|
|
31
37
|
const _cache = {}
|
|
@@ -42,6 +48,14 @@ export function setRuntime (id, obj) {
|
|
|
42
48
|
...getModeledObject(obj, model),
|
|
43
49
|
...readonly
|
|
44
50
|
}
|
|
51
|
+
|
|
52
|
+
if (!Object.hasOwnProperty.call(_cache[id], 'harvestCount')) {
|
|
53
|
+
// Harvest count needs to be added as a getter so the variable is updated each time it is accessed
|
|
54
|
+
Object.defineProperty(_cache[id], 'harvestCount', {
|
|
55
|
+
get: () => ++harvestCount
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
|
|
45
59
|
const agentInst = getNREUMInitializedAgent(id)
|
|
46
60
|
if (agentInst) agentInst.runtime = _cache[id]
|
|
47
61
|
}
|
|
@@ -72,8 +72,6 @@ export const ffVersion = (() => {
|
|
|
72
72
|
return 0
|
|
73
73
|
})()
|
|
74
74
|
|
|
75
|
-
export const isIE = Boolean(isBrowserScope && window.document.documentMode) // deprecated property that only works in IE
|
|
76
|
-
|
|
77
75
|
export const supportsSendBeacon = !!globalScope.navigator?.sendBeacon
|
|
78
76
|
|
|
79
77
|
/**
|
|
@@ -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
|
|
|
11
11
|
const registry = {}
|
|
12
12
|
|
|
@@ -102,10 +102,12 @@ function drainGroup (agentIdentifier, group, activateGroup = true) {
|
|
|
102
102
|
emitEvent(bufferedEventsInGroup[i], groupHandlers)
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
// registration
|
|
108
|
-
|
|
105
|
+
Object.entries(groupHandlers).forEach(([eventType, handlerRegistrationList]) => {
|
|
106
|
+
Object.values(handlerRegistrationList || {}).forEach((registration) => {
|
|
107
|
+
// registration *should* be an array of: [targetEE, eventHandler]
|
|
108
|
+
// certain browser polyfills of .values and .entries pass the prototype methods into the callback,
|
|
109
|
+
// which breaks this assumption and throws errors. So we make sure here that we only call .on() if its an actual NR EE
|
|
110
|
+
if (registration[0]?.on && registration[0]?.context() instanceof EventContext) registration[0].on(eventType, registration[1])
|
|
109
111
|
})
|
|
110
112
|
})
|
|
111
113
|
}
|
|
@@ -125,7 +127,7 @@ function drainGroup (agentIdentifier, group, activateGroup = true) {
|
|
|
125
127
|
*/
|
|
126
128
|
function emitEvent (evt, groupHandlers) {
|
|
127
129
|
var type = evt[1]
|
|
128
|
-
|
|
130
|
+
Object.values(groupHandlers[type] || {}).forEach((registration) => {
|
|
129
131
|
var sourceEE = evt[0]
|
|
130
132
|
var ee = registration[0]
|
|
131
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
|
|
|
@@ -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'
|
|
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
|
|
|
@@ -32,7 +32,7 @@ export class Harvest extends SharedContext {
|
|
|
32
32
|
super(parent) // gets any allowed properties from the parent and stores them in `sharedContext`
|
|
33
33
|
|
|
34
34
|
this.tooManyRequestsDelay = getConfigurationValue(this.sharedContext.agentIdentifier, 'harvest.tooManyRequestsDelay') || 60
|
|
35
|
-
this.obfuscator =
|
|
35
|
+
this.obfuscator = getRuntime(this.sharedContext.agentIdentifier).obfuscator
|
|
36
36
|
|
|
37
37
|
this._events = {}
|
|
38
38
|
}
|
|
@@ -50,7 +50,7 @@ export class Harvest extends SharedContext {
|
|
|
50
50
|
isFinalHarvest: spec.opts?.unload === true
|
|
51
51
|
}
|
|
52
52
|
const payload = this.createPayload(spec.endpoint, options)
|
|
53
|
-
const caller = this.
|
|
53
|
+
const caller = this._send.bind(this)
|
|
54
54
|
return caller({ ...spec, payload, submitMethod })
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -59,21 +59,11 @@ export class Harvest extends SharedContext {
|
|
|
59
59
|
* @param {NetworkSendSpec} spec Specification for sending data
|
|
60
60
|
*/
|
|
61
61
|
send (spec = {}) {
|
|
62
|
-
const caller = this.
|
|
62
|
+
const caller = this._send.bind(this)
|
|
63
63
|
|
|
64
64
|
return caller(spec)
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
/**
|
|
68
|
-
* Apply obfuscation rules to the payload and then initial the harvest network call.
|
|
69
|
-
* @param {NetworkSendSpec} spec Specification for sending data
|
|
70
|
-
*/
|
|
71
|
-
obfuscateAndSend (spec = {}) {
|
|
72
|
-
const { payload = {} } = spec
|
|
73
|
-
applyFnToProps(payload, (...args) => this.obfuscator.obfuscateString(...args), 'string', ['e'])
|
|
74
|
-
return this._send({ ...spec, payload })
|
|
75
|
-
}
|
|
76
|
-
|
|
77
67
|
/**
|
|
78
68
|
* Initiate a harvest call. Typically used by `sendX` and `send` methods or called directly
|
|
79
69
|
* for raw network calls.
|
|
@@ -137,8 +127,8 @@ export class Harvest extends SharedContext {
|
|
|
137
127
|
/* Since workers don't support sendBeacon right now, they can only use XHR method.
|
|
138
128
|
Because they still do permit synch XHR, the idea is that at final harvest time (worker is closing),
|
|
139
129
|
we just make a BLOCKING request--trivial impact--with the remaining data as a temp fill-in for sendBeacon.
|
|
140
|
-
Following the removal of img-element method
|
|
141
|
-
let result = submitMethod({ url: fullUrl, body, sync: opts.unload && (isWorkerScope
|
|
130
|
+
Following the removal of img-element method. */
|
|
131
|
+
let result = submitMethod({ url: fullUrl, body, sync: opts.unload && (isWorkerScope), headers })
|
|
142
132
|
|
|
143
133
|
if (!opts.unload && cbFinished && submitMethod === submitData.xhr) {
|
|
144
134
|
const harvestScope = this
|
|
@@ -160,9 +150,6 @@ export class Harvest extends SharedContext {
|
|
|
160
150
|
}, eventListenerOpts(false))
|
|
161
151
|
}
|
|
162
152
|
|
|
163
|
-
const runtime = getRuntime(this.sharedContext.agentIdentifier)
|
|
164
|
-
runtime.harvestCount++
|
|
165
|
-
|
|
166
153
|
return result
|
|
167
154
|
}
|
|
168
155
|
|
|
@@ -171,8 +158,7 @@ export class Harvest extends SharedContext {
|
|
|
171
158
|
const runtime = getRuntime(this.sharedContext.agentIdentifier)
|
|
172
159
|
const info = getInfo(this.sharedContext.agentIdentifier)
|
|
173
160
|
|
|
174
|
-
const
|
|
175
|
-
const ref = this.obfuscator.shouldObfuscate() ? this.obfuscator.obfuscateString(location) : location
|
|
161
|
+
const ref = this.obfuscator.obfuscateString(cleanURL(getLocation()))
|
|
176
162
|
const hr = runtime?.session?.state.sessionReplayMode === 1 && endpoint !== 'jserrors'
|
|
177
163
|
|
|
178
164
|
const qps = [
|
|
@@ -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
|
|
|
10
9
|
var hasOwnProp = Object.prototype.hasOwnProperty
|
|
11
10
|
var MAX_ATTRIBUTES = 64
|
|
@@ -24,17 +23,15 @@ export function numeric (n, noDefault) {
|
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
export function getAddStringContext (agentIdentifier) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
let stringTableIdx = 0
|
|
27
|
+
const stringTable = Object.prototype.hasOwnProperty.call(Object, 'create') ? Object.create(null) : {}
|
|
28
|
+
const obfuscator = getRuntime(agentIdentifier).obfuscator
|
|
30
29
|
|
|
31
30
|
return addString
|
|
32
31
|
|
|
33
32
|
function addString (str) {
|
|
34
33
|
if (typeof str === 'undefined' || str === '') return ''
|
|
35
|
-
|
|
36
|
-
str = String(str)
|
|
37
|
-
if (obfuscator.shouldObfuscate()) str = obfuscator.obfuscateString(str)
|
|
34
|
+
str = obfuscator.obfuscateString(String(str))
|
|
38
35
|
if (hasOwnProp.call(stringTable, str)) {
|
|
39
36
|
return numeric(stringTable[str], true)
|
|
40
37
|
} else {
|
|
@@ -47,7 +44,7 @@ export function getAddStringContext (agentIdentifier) {
|
|
|
47
44
|
export function addCustomAttributes (attrs, addString) {
|
|
48
45
|
var attrParts = []
|
|
49
46
|
|
|
50
|
-
|
|
47
|
+
Object.entries(attrs || {}).forEach(([key, val]) => {
|
|
51
48
|
if (attrParts.length >= MAX_ATTRIBUTES) return
|
|
52
49
|
var type = 5
|
|
53
50
|
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'
|
|
@@ -57,7 +57,7 @@ export class SessionEntity {
|
|
|
57
57
|
* if the event was spawned on the current page or an adjacent page, and the behavior tied
|
|
58
58
|
* to storage events is critical to apply only to cross-tab behavior
|
|
59
59
|
* */
|
|
60
|
-
if (isBrowserScope
|
|
60
|
+
if (isBrowserScope) {
|
|
61
61
|
windowAddEventListener('storage', (event) => {
|
|
62
62
|
if (event.key === this.lookupKey) {
|
|
63
63
|
const obj = typeof event.newValue === 'string' ? JSON.parse(event.newValue) : event.newValue
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
export const TimeKeeper = jest.fn(function () {
|
|
2
|
-
|
|
1
|
+
export const TimeKeeper = jest.fn(function () {
|
|
2
|
+
this.ready = true
|
|
3
|
+
this.convertRelativeTimestamp = jest.fn()
|
|
4
|
+
this.convertAbsoluteTimestamp = jest.fn()
|
|
5
|
+
this.correctAbsoluteTimestamp = jest.fn()
|
|
6
|
+
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { originTime } from '../constants/runtime'
|
|
2
|
-
import { getRuntime } from '../config/
|
|
2
|
+
import { getRuntime } from '../config/runtime'
|
|
3
3
|
|
|
4
4
|
const rfc2616Regex = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), ([0-3][0-9]) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ([0-9]{4}) ([01][0-9]|2[0-3])(:[0-5][0-9]){2} GMT$/
|
|
5
5
|
|
|
@@ -87,21 +87,31 @@ export class TimeKeeper {
|
|
|
87
87
|
|
|
88
88
|
/**
|
|
89
89
|
* Converts a page origin relative time to an absolute timestamp
|
|
90
|
-
*
|
|
90
|
+
* using the user's local clock.
|
|
91
91
|
* @param relativeTime {number} The relative time of the event in milliseconds
|
|
92
92
|
* @returns {number} Corrected unix/epoch timestamp
|
|
93
93
|
*/
|
|
94
94
|
convertRelativeTimestamp (relativeTime) {
|
|
95
|
-
return
|
|
95
|
+
return originTime + relativeTime
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
|
-
*
|
|
99
|
+
* Converts an absolute timestamp to a relative timestamp using the
|
|
100
|
+
* user's local clock.
|
|
101
|
+
* @param timestamp
|
|
102
|
+
* @returns {number}
|
|
103
|
+
*/
|
|
104
|
+
convertAbsoluteTimestamp (timestamp) {
|
|
105
|
+
return timestamp - originTime
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Corrects an absolute timestamp to NR server time.
|
|
100
110
|
* @param timestamp {number} The unix/epoch timestamp of the event with milliseconds
|
|
101
111
|
* @return {number} Corrected unix/epoch timestamp
|
|
102
112
|
*/
|
|
103
113
|
correctAbsoluteTimestamp (timestamp) {
|
|
104
|
-
return
|
|
114
|
+
return timestamp - this.#localTimeDiff
|
|
105
115
|
}
|
|
106
116
|
|
|
107
117
|
/** Process the session entity and use the info to set the main time calculations if present */
|
package/src/common/url/encode.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
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
7
|
|
|
9
8
|
// Characters that are safe in a qs, but get encoded.
|
|
@@ -16,7 +15,7 @@ var charMap = {
|
|
|
16
15
|
'%3B': ';'
|
|
17
16
|
}
|
|
18
17
|
|
|
19
|
-
var charList =
|
|
18
|
+
var charList = Object.keys(charMap)
|
|
20
19
|
var safeEncoded = new RegExp(charList.join('|'), 'g')
|
|
21
20
|
|
|
22
21
|
function real (c) {
|
|
@@ -43,7 +42,7 @@ export function obj (payload, maxBytes) {
|
|
|
43
42
|
var total = 0
|
|
44
43
|
var result = ''
|
|
45
44
|
|
|
46
|
-
|
|
45
|
+
Object.entries(payload || {}).forEach(([feature, dataArray]) => {
|
|
47
46
|
var intermediate = []
|
|
48
47
|
var next
|
|
49
48
|
var i
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const warn = jest.fn()
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
export const Obfuscator = jest.fn(function () {
|
|
2
|
-
this.
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
this.shouldObfuscate = jest.fn(() => false)
|
|
7
|
-
this.obfuscateString = jest.fn((input) => input)
|
|
2
|
+
this.ruleValidationCache = []
|
|
3
|
+
this.obfuscateString = jest.fn(input => input)
|
|
8
4
|
})
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
|
|
6
|
+
Obfuscator.prototype.validateObfuscationRule = jest.fn(rule => true)
|
|
7
|
+
Obfuscator.prototype.getRuleValidationCache = jest.fn(agentIdentifier => [])
|
|
@@ -1,67 +1,111 @@
|
|
|
1
|
-
import { getConfigurationValue } from '../config/
|
|
2
|
-
import { SharedContext } from '../context/shared-context'
|
|
1
|
+
import { getConfigurationValue } from '../config/init'
|
|
3
2
|
import { isFileProtocol } from '../url/protocol'
|
|
4
3
|
import { warn } from './console'
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return getRules(this.sharedContext.agentIdentifier).length > 0
|
|
13
|
-
}
|
|
5
|
+
/**
|
|
6
|
+
* Represents an obfuscation rule that can be applied to harvested payloads
|
|
7
|
+
* @typedef {object} ObfuscationRule
|
|
8
|
+
* @property {string|RegExp} regex The regular expression to match against in the payload
|
|
9
|
+
* @property {string} [replacement] The string to replace the matched regex with
|
|
10
|
+
*/
|
|
14
11
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Represents an obfuscation rule validation state
|
|
14
|
+
* @typedef {object} ObfuscationRuleValidation
|
|
15
|
+
* @property {ObfuscationRule} rule The original rule validated
|
|
16
|
+
* @property {boolean} isValid Whether the rule is valid
|
|
17
|
+
* @property {object} errors Validation errors
|
|
18
|
+
* @property {boolean} errors.regexMissingDetected Whether the regex is missing
|
|
19
|
+
* @property {boolean} errors.invalidRegexDetected Whether the regex is invalid
|
|
20
|
+
* @property {boolean} errors.invalidReplacementDetected Whether the replacement is invalid
|
|
21
|
+
*/
|
|
19
22
|
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
export class Obfuscator {
|
|
24
|
+
/**
|
|
25
|
+
* @type {ObfuscationRuleValidation[]}
|
|
26
|
+
*/
|
|
27
|
+
#ruleValidationCache
|
|
22
28
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
var replacement = rules[i].replacement || '*'
|
|
27
|
-
obfuscated = obfuscated.replace(regex, replacement)
|
|
28
|
-
}
|
|
29
|
-
return obfuscated
|
|
29
|
+
constructor (agentIdentifier) {
|
|
30
|
+
this.#ruleValidationCache = Obfuscator.getRuleValidationCache(agentIdentifier)
|
|
31
|
+
Obfuscator.logObfuscationRuleErrors(this.#ruleValidationCache)
|
|
30
32
|
}
|
|
31
|
-
}
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var configRules = getConfigurationValue(agentIdentifier, 'obfuscate') || []
|
|
37
|
-
|
|
38
|
-
rules = rules.concat(configRules)
|
|
34
|
+
get ruleValidationCache () {
|
|
35
|
+
return this.#ruleValidationCache
|
|
36
|
+
}
|
|
39
37
|
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Applies all valid obfuscation rules to the provided input string
|
|
40
|
+
* @param {string} input String to obfuscate
|
|
41
|
+
* @returns {string}
|
|
42
|
+
*/
|
|
43
|
+
obfuscateString (input) {
|
|
44
|
+
// if input is not of type string or is an empty string, short-circuit
|
|
45
|
+
if (typeof input !== 'string' || input.trim().length === 0) return input
|
|
42
46
|
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
return this.#ruleValidationCache
|
|
48
|
+
.filter(ruleValidation => ruleValidation.isValid)
|
|
49
|
+
.reduce((input, ruleValidation) => {
|
|
50
|
+
const { rule } = ruleValidation
|
|
51
|
+
return input.replace(rule.regex, rule.replacement || '*')
|
|
52
|
+
}, input)
|
|
53
|
+
}
|
|
45
54
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Returns an array of obfuscation rules to be applied to harvested payloads
|
|
57
|
+
* @param {string} agentIdentifier The agent identifier to get rules for
|
|
58
|
+
* @returns {ObfuscationRuleValidation[]} The array of rules or validation states
|
|
59
|
+
*/
|
|
60
|
+
static getRuleValidationCache (agentIdentifier) {
|
|
61
|
+
/**
|
|
62
|
+
* @type {ObfuscationRule[]}
|
|
63
|
+
*/
|
|
64
|
+
let rules = getConfigurationValue(agentIdentifier, 'obfuscate') || []
|
|
65
|
+
if (isFileProtocol()) {
|
|
66
|
+
rules.push({
|
|
67
|
+
regex: /^file:\/\/(.*)/,
|
|
68
|
+
replacement: atob('ZmlsZTovL09CRlVTQ0FURUQ=')
|
|
69
|
+
})
|
|
57
70
|
}
|
|
58
71
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
72
|
+
return rules.map(rule => Obfuscator.validateObfuscationRule(rule))
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Validates an obfuscation rule and provides errors if any are found.
|
|
77
|
+
* @param {ObfuscationRule} rule The rule to validate
|
|
78
|
+
* @returns {ObfuscationRuleValidation} The validation state of the rule
|
|
79
|
+
*/
|
|
80
|
+
static validateObfuscationRule (rule) {
|
|
81
|
+
const regexMissingDetected = Boolean(rule.regex === undefined)
|
|
82
|
+
const invalidRegexDetected = Boolean(rule.regex !== undefined && typeof rule.regex !== 'string' && !(rule.regex instanceof RegExp))
|
|
83
|
+
const invalidReplacementDetected = Boolean(rule.replacement && typeof rule.replacement !== 'string')
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
rule,
|
|
87
|
+
isValid: !regexMissingDetected && !invalidRegexDetected && !invalidReplacementDetected,
|
|
88
|
+
errors: {
|
|
89
|
+
regexMissingDetected,
|
|
90
|
+
invalidRegexDetected,
|
|
91
|
+
invalidReplacementDetected
|
|
92
|
+
}
|
|
63
93
|
}
|
|
64
94
|
}
|
|
65
95
|
|
|
66
|
-
|
|
96
|
+
/**
|
|
97
|
+
* Logs any obfuscation rule errors to the console. This is called when an obfuscator
|
|
98
|
+
* instance is created.
|
|
99
|
+
* @param {ObfuscationRuleValidation[]} ruleValidationCache The cache of rule validation states
|
|
100
|
+
*/
|
|
101
|
+
static logObfuscationRuleErrors (ruleValidationCache) {
|
|
102
|
+
for (const ruleValidation of ruleValidationCache) {
|
|
103
|
+
const { rule, isValid, errors } = ruleValidation
|
|
104
|
+
if (isValid) continue
|
|
105
|
+
|
|
106
|
+
if (errors.regexMissingDetected) warn(12, rule)
|
|
107
|
+
else if (errors.invalidRegexDetected) warn(13, rule)
|
|
108
|
+
if (errors.invalidReplacementDetected) warn(14, rule)
|
|
109
|
+
}
|
|
110
|
+
}
|
|
67
111
|
}
|
|
@@ -20,7 +20,6 @@ export function getSubmitMethod ({ isFinalHarvest = false } = {}) {
|
|
|
20
20
|
return isFinalHarvest && isBrowserScope && supportsSendBeacon
|
|
21
21
|
// Use sendBeacon for final harvest
|
|
22
22
|
? beacon
|
|
23
|
-
// Only IE does not support sendBeacon for final harvest
|
|
24
23
|
// If not final harvest, or not browserScope, always use xhr post
|
|
25
24
|
: xhr
|
|
26
25
|
}
|