@newrelic/browser-agent 1.237.1 → 1.239.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/dist/cjs/common/config/state/init.js +21 -13
- package/dist/cjs/common/config/state/runtime.js +0 -4
- 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 +3 -3
- package/dist/cjs/common/constants/shared-channel.js +3 -1
- package/dist/cjs/common/deny-list/deny-list.js +3 -9
- package/dist/cjs/common/drain/drain.js +1 -1
- package/dist/cjs/common/event-emitter/contextual-ee.js +24 -32
- package/dist/cjs/common/event-emitter/event-context.js +12 -0
- package/dist/cjs/common/harvest/harvest-scheduler.js +2 -4
- package/dist/cjs/common/harvest/harvest.js +4 -7
- package/dist/cjs/common/ids/bundle-id.js +19 -0
- package/dist/cjs/common/serialize/bel-serializer.js +1 -1
- package/dist/cjs/common/session/session-entity.js +16 -12
- package/dist/cjs/common/storage/first-party-cookies.js +5 -4
- package/dist/cjs/common/storage/local-storage.js +3 -2
- package/dist/cjs/common/timer/interaction-timer.js +14 -6
- package/dist/cjs/common/timing/nav-timing.js +1 -1
- package/dist/cjs/common/unload/eol.js +4 -30
- package/dist/cjs/common/util/feature-flags.js +14 -15
- package/dist/cjs/common/util/invoke.js +3 -1
- package/dist/cjs/common/util/obfuscate.js +3 -5
- package/dist/cjs/common/util/traverse.js +1 -0
- package/dist/cjs/common/window/page-visibility.js +1 -2
- package/dist/cjs/common/wrap/wrap-events.js +3 -2
- package/dist/cjs/common/wrap/wrap-fetch.js +1 -3
- package/dist/cjs/common/wrap/wrap-function.js +15 -46
- package/dist/cjs/common/wrap/wrap-jsonp.js +1 -1
- package/dist/cjs/common/wrap/wrap-mutation.js +1 -2
- package/dist/cjs/common/wrap/wrap-promise.js +2 -3
- package/dist/cjs/common/wrap/wrap-xhr.js +23 -27
- package/dist/cjs/features/ajax/aggregate/index.js +5 -7
- package/dist/cjs/features/ajax/instrument/distributed-tracing.js +8 -12
- package/dist/cjs/features/ajax/instrument/index.js +66 -24
- package/dist/cjs/features/jserrors/aggregate/canonical-function-name.js +0 -1
- package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.js +4 -4
- package/dist/cjs/features/jserrors/aggregate/index.js +4 -5
- package/dist/cjs/features/metrics/aggregate/framework-detection.js +103 -7
- package/dist/cjs/features/metrics/aggregate/index.js +20 -37
- package/dist/cjs/features/metrics/instrument/index.js +0 -2
- package/dist/cjs/features/page_action/aggregate/index.js +17 -19
- package/dist/cjs/features/page_view_event/aggregate/index.js +1 -2
- package/dist/cjs/features/page_view_event/instrument/index.js +4 -2
- package/dist/cjs/features/page_view_timing/aggregate/index.js +6 -7
- package/dist/cjs/features/session_replay/aggregate/index.js +5 -3
- package/dist/cjs/features/session_trace/aggregate/index.js +22 -16
- package/dist/cjs/features/spa/aggregate/index.js +14 -20
- package/dist/cjs/features/spa/aggregate/interaction.js +0 -2
- package/dist/cjs/features/spa/aggregate/serializer.js +1 -1
- package/dist/cjs/features/utils/aggregate-base.js +4 -0
- package/dist/cjs/features/utils/handler-cache.js +3 -1
- package/dist/cjs/features/utils/instrument-base.js +24 -6
- package/dist/cjs/loaders/agent-base.js +23 -0
- package/dist/cjs/loaders/agent.js +7 -7
- package/dist/cjs/loaders/api/api.js +34 -4
- package/dist/cjs/loaders/api/apiAsync.js +19 -20
- package/dist/cjs/loaders/api/interaction-types.js +11 -4
- package/dist/cjs/loaders/configure/configure.js +3 -0
- package/dist/cjs/loaders/micro-agent.js +20 -3
- package/dist/esm/common/config/state/init.js +21 -13
- package/dist/esm/common/config/state/runtime.js +0 -4
- 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 +1 -1
- package/dist/esm/common/constants/shared-channel.js +3 -1
- package/dist/esm/common/deny-list/deny-list.js +3 -9
- package/dist/esm/common/drain/drain.js +1 -1
- package/dist/esm/common/event-emitter/contextual-ee.js +22 -29
- package/dist/esm/common/event-emitter/event-context.js +5 -0
- package/dist/esm/common/harvest/harvest-scheduler.js +2 -4
- package/dist/esm/common/harvest/harvest.js +4 -7
- package/dist/esm/common/ids/bundle-id.js +13 -0
- package/dist/esm/common/serialize/bel-serializer.js +1 -1
- package/dist/esm/common/session/session-entity.js +16 -12
- package/dist/esm/common/storage/first-party-cookies.js +5 -4
- package/dist/esm/common/storage/local-storage.js +3 -2
- package/dist/esm/common/timer/interaction-timer.js +14 -6
- package/dist/esm/common/timing/nav-timing.js +1 -1
- package/dist/esm/common/unload/eol.js +5 -31
- package/dist/esm/common/util/feature-flags.js +14 -15
- package/dist/esm/common/util/invoke.js +3 -1
- package/dist/esm/common/util/obfuscate.js +3 -5
- package/dist/esm/common/util/traverse.js +1 -0
- package/dist/esm/common/window/page-visibility.js +1 -2
- package/dist/esm/common/wrap/wrap-events.js +4 -3
- package/dist/esm/common/wrap/wrap-fetch.js +2 -4
- package/dist/esm/common/wrap/wrap-function.js +15 -44
- package/dist/esm/common/wrap/wrap-jsonp.js +1 -1
- package/dist/esm/common/wrap/wrap-mutation.js +2 -3
- package/dist/esm/common/wrap/wrap-promise.js +3 -4
- package/dist/esm/common/wrap/wrap-xhr.js +23 -27
- package/dist/esm/features/ajax/aggregate/index.js +5 -7
- package/dist/esm/features/ajax/instrument/distributed-tracing.js +8 -12
- package/dist/esm/features/ajax/instrument/index.js +67 -25
- package/dist/esm/features/jserrors/aggregate/canonical-function-name.js +0 -1
- package/dist/esm/features/jserrors/aggregate/compute-stack-trace.js +4 -4
- package/dist/esm/features/jserrors/aggregate/index.js +4 -5
- package/dist/esm/features/metrics/aggregate/framework-detection.js +103 -7
- package/dist/esm/features/metrics/aggregate/index.js +22 -39
- package/dist/esm/features/metrics/instrument/index.js +1 -3
- package/dist/esm/features/page_action/aggregate/index.js +17 -19
- package/dist/esm/features/page_view_event/aggregate/index.js +1 -2
- package/dist/esm/features/page_view_event/instrument/index.js +4 -2
- package/dist/esm/features/page_view_timing/aggregate/index.js +7 -8
- package/dist/esm/features/session_replay/aggregate/index.js +4 -2
- package/dist/esm/features/session_trace/aggregate/index.js +22 -16
- package/dist/esm/features/spa/aggregate/index.js +14 -20
- package/dist/esm/features/spa/aggregate/interaction.js +0 -2
- package/dist/esm/features/spa/aggregate/serializer.js +1 -1
- package/dist/esm/features/utils/aggregate-base.js +4 -0
- package/dist/esm/features/utils/handler-cache.js +3 -1
- package/dist/esm/features/utils/instrument-base.js +24 -6
- package/dist/esm/loaders/agent-base.js +23 -0
- package/dist/esm/loaders/agent.js +7 -7
- package/dist/esm/loaders/api/api.js +34 -4
- package/dist/esm/loaders/api/apiAsync.js +19 -20
- package/dist/esm/loaders/api/interaction-types.js +11 -4
- package/dist/esm/loaders/configure/configure.js +3 -0
- package/dist/esm/loaders/features/enabled-features.js +1 -1
- package/dist/esm/loaders/micro-agent.js +21 -4
- package/dist/types/common/config/state/init.d.ts.map +1 -1
- package/dist/types/common/config/state/runtime.d.ts.map +1 -1
- package/dist/types/common/constants/runtime.d.ts +1 -1
- package/dist/types/common/constants/runtime.d.ts.map +1 -1
- package/dist/types/common/event-emitter/contextual-ee.d.ts +22 -2
- package/dist/types/common/event-emitter/contextual-ee.d.ts.map +1 -1
- package/dist/types/common/event-emitter/event-context.d.ts +5 -0
- package/dist/types/common/event-emitter/event-context.d.ts.map +1 -0
- package/dist/types/common/event-emitter/register-handler.d.ts +1 -1
- package/dist/types/common/harvest/harvest-scheduler.d.ts.map +1 -1
- package/dist/types/common/harvest/harvest.d.ts.map +1 -1
- package/dist/types/common/ids/bundle-id.d.ts +5 -0
- package/dist/types/common/ids/bundle-id.d.ts.map +1 -0
- package/dist/types/common/session/session-entity.d.ts +12 -15
- package/dist/types/common/session/session-entity.d.ts.map +1 -1
- package/dist/types/common/storage/first-party-cookies.d.ts +1 -1
- package/dist/types/common/storage/first-party-cookies.d.ts.map +1 -1
- package/dist/types/common/storage/local-storage.d.ts.map +1 -1
- package/dist/types/common/timer/interaction-timer.d.ts +3 -0
- package/dist/types/common/timer/interaction-timer.d.ts.map +1 -1
- package/dist/types/common/unload/eol.d.ts +1 -2
- package/dist/types/common/unload/eol.d.ts.map +1 -1
- package/dist/types/common/util/feature-flags.d.ts.map +1 -1
- package/dist/types/common/util/obfuscate.d.ts.map +1 -1
- package/dist/types/common/util/traverse.d.ts.map +1 -1
- package/dist/types/common/window/nreum.d.ts +2 -2
- package/dist/types/common/window/page-visibility.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-events.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-fetch.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-function.d.ts +1 -19
- package/dist/types/common/wrap/wrap-function.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-mutation.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-promise.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-xhr.d.ts.map +1 -1
- package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/ajax/instrument/distributed-tracing.d.ts +1 -1
- package/dist/types/features/ajax/instrument/distributed-tracing.d.ts.map +1 -1
- package/dist/types/features/ajax/instrument/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/aggregate/canonical-function-name.d.ts.map +1 -1
- package/dist/types/features/jserrors/aggregate/index.d.ts +1 -1
- package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/metrics/aggregate/framework-detection.d.ts.map +1 -1
- package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/metrics/instrument/index.d.ts.map +1 -1
- package/dist/types/features/page_action/aggregate/index.d.ts +2 -2
- package/dist/types/features/page_action/aggregate/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_timing/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_trace/aggregate/index.d.ts +5 -0
- package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
- 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/utils/aggregate-base.d.ts +1 -0
- package/dist/types/features/utils/aggregate-base.d.ts.map +1 -1
- package/dist/types/features/utils/handler-cache.d.ts.map +1 -1
- package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
- package/dist/types/loaders/agent-base.d.ts +15 -0
- package/dist/types/loaders/agent-base.d.ts.map +1 -1
- package/dist/types/loaders/agent.d.ts +1 -1
- package/dist/types/loaders/agent.d.ts.map +1 -1
- package/dist/types/loaders/api/api.d.ts +7 -0
- package/dist/types/loaders/api/api.d.ts.map +1 -1
- package/dist/types/loaders/api/apiAsync.d.ts.map +1 -1
- package/dist/types/loaders/api/interaction-types.d.ts +18 -7
- package/dist/types/loaders/api/interaction-types.d.ts.map +1 -1
- package/dist/types/loaders/configure/configure.d.ts +2 -0
- package/dist/types/loaders/configure/configure.d.ts.map +1 -1
- package/dist/types/loaders/features/features.d.ts +9 -9
- package/dist/types/loaders/micro-agent.d.ts +7 -1
- package/dist/types/loaders/micro-agent.d.ts.map +1 -1
- package/package.json +62 -38
- package/src/common/aggregate/aggregator.test.js +107 -0
- package/src/common/config/state/configurable.test.js +73 -0
- package/src/common/config/state/info.test.js +31 -0
- package/src/common/config/state/init.js +13 -12
- package/src/common/config/state/init.test.js +28 -0
- package/src/common/config/state/loader-config.test.js +21 -0
- package/src/common/config/state/runtime.js +0 -2
- package/src/common/config/state/runtime.test.js +21 -0
- package/src/common/constants/__mocks__/runtime.js +1 -1
- package/src/common/constants/runtime.js +1 -1
- package/src/common/constants/runtime.test.js +2 -2
- package/src/common/constants/shared-channel.js +1 -1
- package/src/common/deny-list/deny-list.js +3 -11
- package/src/common/deny-list/deny-list.test.js +103 -30
- package/src/common/drain/drain.js +1 -1
- package/src/common/drain/drain.test.js +74 -0
- package/src/common/event-emitter/{contextual-ee.test.js → contextual-ee.component-test.js} +15 -32
- package/src/common/event-emitter/contextual-ee.js +26 -37
- package/src/common/event-emitter/event-context.js +5 -0
- package/src/common/harvest/harvest-scheduler.js +2 -5
- package/src/common/harvest/harvest-scheduler.test.js +2 -6
- package/src/common/harvest/harvest.js +4 -7
- package/src/common/harvest/harvest.test.js +1 -3
- package/src/common/ids/__mocks__/bundle-id.js +2 -0
- package/src/common/ids/__mocks__/unique-id.js +17 -0
- package/src/common/ids/bundle-id.js +13 -0
- package/src/common/ids/id.test.js +6 -6
- package/src/common/serialize/bel-serializer.js +1 -1
- package/src/common/session/session-entity.component-test.js +3 -2
- package/src/common/session/session-entity.js +11 -9
- package/src/common/storage/first-party-cookies.js +5 -4
- package/src/common/storage/local-storage.js +3 -2
- package/src/common/timer/interaction-timer.component-test.js +52 -7
- package/src/common/timer/interaction-timer.js +15 -6
- package/src/common/timer/timer.test.js +0 -1
- package/src/common/timing/nav-timing.js +1 -1
- package/src/common/unload/eol.js +5 -31
- package/src/common/url/__mocks__/parse-url.js +15 -0
- package/src/common/url/{encode.component-test.js → encode.test.js} +1 -0
- package/src/common/util/__mocks__/get-or-set.js +5 -0
- package/src/common/util/__mocks__/invoke.js +1 -0
- package/src/common/util/data-size.test.js +0 -1
- package/src/common/util/feature-flags.js +15 -17
- package/src/common/util/feature-flags.test.js +4 -8
- package/src/common/util/invoke.js +1 -1
- package/src/common/util/obfuscate.js +3 -5
- package/src/common/util/submit-data.test.js +1 -1
- package/src/common/util/traverse.js +1 -0
- package/src/common/window/__mocks__/nreum.js +12 -0
- package/src/common/window/page-visibility.js +1 -2
- package/src/common/wrap/wrap-events.js +4 -3
- package/src/common/wrap/wrap-fetch.js +2 -4
- package/src/common/wrap/wrap-function.js +16 -44
- package/src/common/wrap/wrap-jsonp.js +1 -1
- package/src/common/wrap/wrap-mutation.js +2 -3
- package/src/common/wrap/{wrap-promise.test.js → wrap-promise.component-test.js} +2 -32
- package/src/common/wrap/wrap-promise.js +3 -4
- package/src/common/wrap/wrap-xhr.js +24 -28
- package/src/features/ajax/aggregate/index.js +5 -7
- package/src/features/ajax/instrument/distributed-tracing.js +8 -12
- package/src/features/ajax/instrument/distributed-tracing.test.js +375 -0
- package/src/features/ajax/instrument/index.js +62 -27
- package/src/features/jserrors/aggregate/canonical-function-name.js +0 -2
- package/src/features/jserrors/aggregate/compute-stack-trace.js +4 -4
- package/src/features/jserrors/aggregate/compute-stack-trace.test.js +1 -1
- package/src/features/jserrors/aggregate/index.js +4 -5
- package/src/features/metrics/aggregate/framework-detection.js +129 -8
- package/src/features/metrics/aggregate/framework-detection.test.js +213 -82
- package/src/features/metrics/aggregate/index.js +22 -45
- package/src/features/metrics/instrument/index.js +1 -3
- package/src/features/page_action/aggregate/index.js +12 -13
- package/src/features/page_view_event/aggregate/index.js +1 -2
- package/src/features/page_view_event/instrument/index.js +2 -2
- package/src/features/page_view_timing/aggregate/index.js +7 -8
- package/src/features/session_replay/aggregate/index.component-test.js +3 -15
- package/src/features/session_replay/aggregate/index.js +4 -2
- package/src/features/session_trace/aggregate/index.js +22 -16
- package/src/features/spa/aggregate/index.js +14 -20
- package/src/features/spa/aggregate/interaction.js +0 -2
- package/src/features/spa/aggregate/serializer.js +1 -1
- package/src/features/utils/aggregate-base.js +5 -0
- package/src/features/utils/aggregate-base.test.js +2 -1
- package/src/features/utils/handler-cache.js +3 -2
- package/src/features/utils/instrument-base.js +25 -6
- package/src/features/utils/instrument-base.test.js +2 -2
- package/src/loaders/agent-base.js +23 -0
- package/src/loaders/agent.js +7 -7
- package/src/loaders/api/api.component-test.js +45 -0
- package/src/loaders/api/api.js +34 -4
- package/src/loaders/api/api.test.js +85 -0
- package/src/loaders/api/apiAsync.js +19 -20
- package/src/loaders/api/apiAsync.test.js +17 -0
- package/src/loaders/api/interaction-types.js +11 -4
- package/src/loaders/configure/configure.js +3 -0
- package/src/loaders/features/enabled-features.js +1 -1
- package/src/loaders/micro-agent.js +22 -4
- package/dist/cjs/features/metrics/aggregate/endpoint-map.js +0 -14
- package/dist/cjs/features/metrics/aggregate/polyfill-detection.es5.js +0 -14
- package/dist/cjs/features/metrics/aggregate/polyfill-detection.js +0 -53
- package/dist/esm/features/metrics/aggregate/endpoint-map.js +0 -7
- package/dist/esm/features/metrics/aggregate/polyfill-detection.es5.js +0 -8
- package/dist/esm/features/metrics/aggregate/polyfill-detection.js +0 -47
- package/dist/types/features/metrics/aggregate/endpoint-map.d.ts +0 -8
- package/dist/types/features/metrics/aggregate/endpoint-map.d.ts.map +0 -1
- package/dist/types/features/metrics/aggregate/polyfill-detection.d.ts +0 -6
- package/dist/types/features/metrics/aggregate/polyfill-detection.d.ts.map +0 -1
- package/dist/types/features/metrics/aggregate/polyfill-detection.es5.d.ts +0 -7
- package/dist/types/features/metrics/aggregate/polyfill-detection.es5.d.ts.map +0 -1
- package/src/features/metrics/aggregate/endpoint-map.js +0 -7
- package/src/features/metrics/aggregate/polyfill-detection.es5.js +0 -8
- package/src/features/metrics/aggregate/polyfill-detection.es5.test.js +0 -16
- package/src/features/metrics/aggregate/polyfill-detection.js +0 -48
- package/src/features/metrics/aggregate/polyfill-detection.test.js +0 -163
- /package/src/common/url/{protocol.component-test.js → protocol.test.js} +0 -0
|
@@ -17,8 +17,6 @@ const model = () => {
|
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
19
|
return {
|
|
20
|
-
allow_bfcache: true,
|
|
21
|
-
// *cli - temporary feature flag for BFCache work
|
|
22
20
|
privacy: {
|
|
23
21
|
cookies_enabled: true
|
|
24
22
|
},
|
|
@@ -27,7 +25,8 @@ const model = () => {
|
|
|
27
25
|
deny_list: undefined,
|
|
28
26
|
block_internal: true,
|
|
29
27
|
enabled: true,
|
|
30
|
-
harvestTimeSeconds: 10
|
|
28
|
+
harvestTimeSeconds: 10,
|
|
29
|
+
autoStart: true
|
|
31
30
|
},
|
|
32
31
|
distributed_tracing: {
|
|
33
32
|
enabled: undefined,
|
|
@@ -46,32 +45,39 @@ const model = () => {
|
|
|
46
45
|
obfuscate: undefined,
|
|
47
46
|
jserrors: {
|
|
48
47
|
enabled: true,
|
|
49
|
-
harvestTimeSeconds: 10
|
|
48
|
+
harvestTimeSeconds: 10,
|
|
49
|
+
autoStart: true
|
|
50
50
|
},
|
|
51
51
|
metrics: {
|
|
52
|
-
enabled: true
|
|
52
|
+
enabled: true,
|
|
53
|
+
autoStart: true
|
|
53
54
|
},
|
|
54
55
|
page_action: {
|
|
55
56
|
enabled: true,
|
|
56
|
-
harvestTimeSeconds: 30
|
|
57
|
+
harvestTimeSeconds: 30,
|
|
58
|
+
autoStart: true
|
|
57
59
|
},
|
|
58
60
|
page_view_event: {
|
|
59
|
-
enabled: true
|
|
61
|
+
enabled: true,
|
|
62
|
+
autoStart: true
|
|
60
63
|
},
|
|
61
64
|
page_view_timing: {
|
|
62
65
|
enabled: true,
|
|
63
66
|
harvestTimeSeconds: 30,
|
|
64
|
-
long_task: false
|
|
67
|
+
long_task: false,
|
|
68
|
+
autoStart: true
|
|
65
69
|
},
|
|
66
70
|
session_trace: {
|
|
67
71
|
enabled: true,
|
|
68
|
-
harvestTimeSeconds: 10
|
|
72
|
+
harvestTimeSeconds: 10,
|
|
73
|
+
autoStart: true
|
|
69
74
|
},
|
|
70
75
|
harvest: {
|
|
71
76
|
tooManyRequestsDelay: 60
|
|
72
77
|
},
|
|
73
78
|
session_replay: {
|
|
74
79
|
// feature settings
|
|
80
|
+
autoStart: true,
|
|
75
81
|
enabled: false,
|
|
76
82
|
harvestTimeSeconds: 60,
|
|
77
83
|
sampleRate: 0.1,
|
|
@@ -110,23 +116,25 @@ const model = () => {
|
|
|
110
116
|
},
|
|
111
117
|
spa: {
|
|
112
118
|
enabled: true,
|
|
113
|
-
harvestTimeSeconds: 10
|
|
119
|
+
harvestTimeSeconds: 10,
|
|
120
|
+
autoStart: true
|
|
114
121
|
}
|
|
115
122
|
};
|
|
116
123
|
};
|
|
117
124
|
const _cache = {};
|
|
125
|
+
const missingAgentIdError = 'All configuration objects require an agent identifier!';
|
|
118
126
|
function getConfiguration(id) {
|
|
119
|
-
if (!id) throw new Error(
|
|
127
|
+
if (!id) throw new Error(missingAgentIdError);
|
|
120
128
|
if (!_cache[id]) throw new Error("Configuration for ".concat(id, " was never set"));
|
|
121
129
|
return _cache[id];
|
|
122
130
|
}
|
|
123
131
|
function setConfiguration(id, obj) {
|
|
124
|
-
if (!id) throw new Error(
|
|
132
|
+
if (!id) throw new Error(missingAgentIdError);
|
|
125
133
|
_cache[id] = (0, _configurable.getModeledObject)(obj, model());
|
|
126
134
|
(0, _nreum.gosNREUMInitializedAgents)(id, _cache[id], 'config');
|
|
127
135
|
}
|
|
128
136
|
function getConfigurationValue(id, path) {
|
|
129
|
-
if (!id) throw new Error(
|
|
137
|
+
if (!id) throw new Error(missingAgentIdError);
|
|
130
138
|
var val = getConfiguration(id);
|
|
131
139
|
if (val) {
|
|
132
140
|
var parts = path.split('.');
|
|
@@ -11,10 +11,6 @@ var _runtime = require("../../constants/runtime");
|
|
|
11
11
|
var _env = require("../../constants/env.npm");
|
|
12
12
|
const model = {
|
|
13
13
|
buildEnv: _env.BUILD_ENV,
|
|
14
|
-
bytesSent: {},
|
|
15
|
-
// Used for SM to capture body bytes sent per endpoint
|
|
16
|
-
queryBytesSent: {},
|
|
17
|
-
// Used for SM to capture query parameter bytes sent per endpoint
|
|
18
14
|
customTransaction: undefined,
|
|
19
15
|
disabled: false,
|
|
20
16
|
distMethod: _env.DIST_METHOD,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.supportsSendBeacon = exports.isiOS = exports.isWorkerScope = exports.isIE = exports.isBrowserScope = exports.initialLocation = exports.
|
|
6
|
+
exports.supportsSendBeacon = exports.isiOS = exports.isWorkerScope = exports.isIE = exports.isBrowserScope = exports.initialLocation = exports.iOSBelow16 = exports.globalScope = exports.ffVersion = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* @file Contains constants about the environment the agent is running
|
|
9
9
|
* within. These values are derived at the time the agent is first loaded.
|
|
@@ -36,8 +36,8 @@ const isiOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
|
|
|
36
36
|
* This was fixed in v16+.
|
|
37
37
|
*/
|
|
38
38
|
exports.isiOS = isiOS;
|
|
39
|
-
const
|
|
40
|
-
exports.
|
|
39
|
+
const iOSBelow16 = isiOS && typeof SharedWorker === 'undefined';
|
|
40
|
+
exports.iOSBelow16 = iOSBelow16;
|
|
41
41
|
const ffVersion = (() => {
|
|
42
42
|
const match = navigator.userAgent.match(/Firefox[/\s](\d+\.\d+)/);
|
|
43
43
|
if (Array.isArray(match) && match.length >= 2) {
|
|
@@ -11,7 +11,9 @@ exports.sharedChannel = void 0;
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
let onReplayReady;
|
|
14
|
-
const sessionReplayInitialized = new Promise(resolve =>
|
|
14
|
+
const sessionReplayInitialized = new Promise(resolve => {
|
|
15
|
+
onReplayReady = resolve;
|
|
16
|
+
});
|
|
15
17
|
const sharedChannel = Object.freeze({
|
|
16
18
|
onReplayReady,
|
|
17
19
|
sessionReplayInitialized
|
|
@@ -64,7 +64,7 @@ function setDenyList(denyListConfig) {
|
|
|
64
64
|
host = url;
|
|
65
65
|
pathname = '';
|
|
66
66
|
}
|
|
67
|
-
let [hostname
|
|
67
|
+
let [hostname] = host.split(':');
|
|
68
68
|
denyList.push({
|
|
69
69
|
hostname,
|
|
70
70
|
pathname
|
|
@@ -81,10 +81,7 @@ function domainMatchesPattern(pattern, domain) {
|
|
|
81
81
|
if (pattern.length > domain.length) {
|
|
82
82
|
return false;
|
|
83
83
|
}
|
|
84
|
-
|
|
85
|
-
return true;
|
|
86
|
-
}
|
|
87
|
-
return false;
|
|
84
|
+
return domain.indexOf(pattern) === domain.length - pattern.length;
|
|
88
85
|
}
|
|
89
86
|
|
|
90
87
|
/**
|
|
@@ -105,8 +102,5 @@ function comparePath(pattern, path) {
|
|
|
105
102
|
if (pattern === '') {
|
|
106
103
|
return true;
|
|
107
104
|
}
|
|
108
|
-
|
|
109
|
-
return true;
|
|
110
|
-
}
|
|
111
|
-
return false;
|
|
105
|
+
return pattern === path;
|
|
112
106
|
}
|
|
@@ -55,7 +55,6 @@ function drain() {
|
|
|
55
55
|
let agentIdentifier = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
56
56
|
let featureName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'feature';
|
|
57
57
|
curateRegistry(agentIdentifier);
|
|
58
|
-
|
|
59
58
|
// If the feature for the specified agent is not in the registry, that means the instrument file was bypassed.
|
|
60
59
|
// This could happen in tests, or loaders that directly import the aggregator. In these cases it is safe to
|
|
61
60
|
// drain the feature group immediately rather than waiting to drain all at once.
|
|
@@ -74,6 +73,7 @@ function drain() {
|
|
|
74
73
|
items.sort((a, b) => a[1].priority - b[1].priority);
|
|
75
74
|
items.forEach(_ref2 => {
|
|
76
75
|
let [group] = _ref2;
|
|
76
|
+
registry[agentIdentifier].delete(group);
|
|
77
77
|
drainGroup(group);
|
|
78
78
|
});
|
|
79
79
|
}
|
|
@@ -3,30 +3,29 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.ee = void 0;
|
|
7
|
-
exports.getOrSetContext = getOrSetContext;
|
|
6
|
+
exports.ee = exports.contextId = void 0;
|
|
8
7
|
var _nreum = require("../window/nreum");
|
|
9
8
|
var _getOrSet = require("../util/get-or-set");
|
|
10
|
-
var _mapOwn = require("../util/map-own");
|
|
11
9
|
var _config = require("../config/config");
|
|
10
|
+
var _eventContext = require("./event-context");
|
|
11
|
+
var _bundleId = require("../ids/bundle-id");
|
|
12
12
|
/*
|
|
13
13
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
14
14
|
* SPDX-License-Identifier: Apache-2.0
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
// create a unique id to store event context data for the current agent bundle
|
|
18
|
+
const contextId = "nr@context:".concat(_bundleId.bundleId);
|
|
19
19
|
// create global emitter instance that can be shared among bundles
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
exports.contextId = contextId;
|
|
21
|
+
const globalInstance = ee(undefined, 'globalEE');
|
|
22
|
+
|
|
23
|
+
// Only override the exposed event emitter if one has not already been exposed
|
|
22
24
|
exports.ee = globalInstance;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
} else {
|
|
26
|
-
exports.ee = globalInstance = ee(undefined, 'globalEE');
|
|
25
|
+
const nr = (0, _nreum.gosNREUM)();
|
|
26
|
+
if (!nr.ee) {
|
|
27
27
|
nr.ee = globalInstance;
|
|
28
28
|
}
|
|
29
|
-
function EventContext() {}
|
|
30
29
|
function ee(old, debugId) {
|
|
31
30
|
var handlers = {};
|
|
32
31
|
var bufferGroupMap = {};
|
|
@@ -45,27 +44,27 @@ function ee(old, debugId) {
|
|
|
45
44
|
}
|
|
46
45
|
var emitter = {
|
|
47
46
|
on: addEventListener,
|
|
48
|
-
addEventListener
|
|
49
|
-
removeEventListener
|
|
50
|
-
emit
|
|
47
|
+
addEventListener,
|
|
48
|
+
removeEventListener,
|
|
49
|
+
emit,
|
|
51
50
|
get: getOrCreate,
|
|
52
|
-
listeners
|
|
53
|
-
context
|
|
51
|
+
listeners,
|
|
52
|
+
context,
|
|
54
53
|
buffer: bufferEventsByGroup,
|
|
55
54
|
abort,
|
|
56
55
|
aborted: false,
|
|
57
|
-
isBuffering
|
|
56
|
+
isBuffering,
|
|
58
57
|
debugId,
|
|
59
58
|
backlog: isolatedBacklog ? {} : old && typeof old.backlog === 'object' ? old.backlog : {}
|
|
60
59
|
};
|
|
61
60
|
return emitter;
|
|
62
61
|
function context(contextOrStore) {
|
|
63
|
-
if (contextOrStore && contextOrStore instanceof EventContext) {
|
|
62
|
+
if (contextOrStore && contextOrStore instanceof _eventContext.EventContext) {
|
|
64
63
|
return contextOrStore;
|
|
65
64
|
} else if (contextOrStore) {
|
|
66
|
-
return (0, _getOrSet.getOrSet)(contextOrStore,
|
|
65
|
+
return (0, _getOrSet.getOrSet)(contextOrStore, contextId, () => new _eventContext.EventContext(contextId));
|
|
67
66
|
} else {
|
|
68
|
-
return
|
|
67
|
+
return new _eventContext.EventContext(contextId);
|
|
69
68
|
}
|
|
70
69
|
}
|
|
71
70
|
function emit(type, args, contextOrStore, force, bubble) {
|
|
@@ -112,12 +111,13 @@ function ee(old, debugId) {
|
|
|
112
111
|
return emitters[name] = emitters[name] || ee(emitter, name);
|
|
113
112
|
}
|
|
114
113
|
function bufferEventsByGroup(types, group) {
|
|
115
|
-
|
|
114
|
+
const eventBuffer = getBuffer();
|
|
115
|
+
group = group || 'feature';
|
|
116
116
|
|
|
117
117
|
// do not buffer events if agent has been aborted
|
|
118
118
|
if (emitter.aborted) return;
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
Object.entries(types || {}).forEach(_ref => {
|
|
120
|
+
let [_, type] = _ref;
|
|
121
121
|
bufferGroupMap[type] = group;
|
|
122
122
|
if (!(group in eventBuffer)) {
|
|
123
123
|
eventBuffer[group] = [];
|
|
@@ -135,14 +135,6 @@ function ee(old, debugId) {
|
|
|
135
135
|
return emitter.backlog;
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
|
-
|
|
139
|
-
// get context object from store object, or create if does not exist
|
|
140
|
-
function getOrSetContext(obj) {
|
|
141
|
-
return (0, _getOrSet.getOrSet)(obj, ctxId, getNewContext);
|
|
142
|
-
}
|
|
143
|
-
function getNewContext() {
|
|
144
|
-
return new EventContext();
|
|
145
|
-
}
|
|
146
138
|
function abort() {
|
|
147
139
|
globalInstance.aborted = true;
|
|
148
140
|
globalInstance.backlog = {};
|
|
@@ -8,7 +8,6 @@ var submitData = _interopRequireWildcard(require("../util/submit-data"));
|
|
|
8
8
|
var _sharedContext = require("../context/shared-context");
|
|
9
9
|
var _harvest = require("./harvest");
|
|
10
10
|
var _eol = require("../unload/eol");
|
|
11
|
-
var _config = require("../config/config");
|
|
12
11
|
var _sessionEntity = require("../session/session-entity");
|
|
13
12
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
13
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -43,7 +42,7 @@ class HarvestScheduler extends _sharedContext.SharedContext {
|
|
|
43
42
|
this.harvest = new _harvest.Harvest(this.sharedContext);
|
|
44
43
|
|
|
45
44
|
// unload if EOL mechanism fires
|
|
46
|
-
(0, _eol.subscribeToEOL)(this.unload.bind(this)
|
|
45
|
+
(0, _eol.subscribeToEOL)(this.unload.bind(this));
|
|
47
46
|
|
|
48
47
|
/* Flush all buffered data if session resets and give up retries. This should be synchronous to ensure that the correct `session` value is sent.
|
|
49
48
|
Since session-reset generates a new session ID and the ID is grabbed at send-time, any delays or retries would cause the payload to be sent under
|
|
@@ -110,7 +109,7 @@ class HarvestScheduler extends _sharedContext.SharedContext {
|
|
|
110
109
|
if (!submitMethod) return false;
|
|
111
110
|
const retry = !opts?.unload && submitMethod === submitData.xhr;
|
|
112
111
|
payload = this.opts.getPayload({
|
|
113
|
-
retry
|
|
112
|
+
retry
|
|
114
113
|
});
|
|
115
114
|
if (!payload) {
|
|
116
115
|
if (this.started) {
|
|
@@ -146,7 +145,6 @@ class HarvestScheduler extends _sharedContext.SharedContext {
|
|
|
146
145
|
if (this.started) {
|
|
147
146
|
this.scheduleHarvest();
|
|
148
147
|
}
|
|
149
|
-
return;
|
|
150
148
|
}
|
|
151
149
|
onHarvestFinished(opts, result) {
|
|
152
150
|
if (this.opts.onFinished) {
|
|
@@ -56,7 +56,8 @@ class Harvest extends _sharedContext.SharedContext {
|
|
|
56
56
|
isFinalHarvest: spec.opts?.unload
|
|
57
57
|
});
|
|
58
58
|
const options = {
|
|
59
|
-
retry: !spec.opts?.unload && submitMethod === submitData.xhr
|
|
59
|
+
retry: !spec.opts?.unload && submitMethod === submitData.xhr,
|
|
60
|
+
isFinalHarvest: spec.opts?.unload === true
|
|
60
61
|
};
|
|
61
62
|
const payload = this.createPayload(spec.endpoint, options);
|
|
62
63
|
const caller = this.obfuscator.shouldObfuscate() ? this.obfuscateAndSend.bind(this) : this._send.bind(this);
|
|
@@ -130,7 +131,8 @@ class Harvest extends _sharedContext.SharedContext {
|
|
|
130
131
|
}
|
|
131
132
|
return false;
|
|
132
133
|
}
|
|
133
|
-
|
|
134
|
+
const endpointURLPart = endpoint !== 'rum' ? "/".concat(endpoint) : '';
|
|
135
|
+
let url = "".concat(this.getScheme(), "://").concat(info.errorBeacon).concat(endpointURLPart, "/1/").concat(info.licenseKey);
|
|
134
136
|
if (customUrl) url = customUrl;
|
|
135
137
|
if (raw) url = "".concat(this.getScheme(), "://").concat(info.errorBeacon, "/").concat(endpoint);
|
|
136
138
|
const baseParams = !raw && includeBaseParams ? this.baseQueryString() : '';
|
|
@@ -158,11 +160,6 @@ class Harvest extends _sharedContext.SharedContext {
|
|
|
158
160
|
// If body is null, undefined, or an empty object or array, send an empty string instead
|
|
159
161
|
body = '';
|
|
160
162
|
}
|
|
161
|
-
|
|
162
|
-
// Get bytes harvested per endpoint as a supportability metric. See metrics aggregator (on unload).
|
|
163
|
-
agentRuntime.bytesSent[endpoint] = (agentRuntime.bytesSent[endpoint] || 0) + body?.length || 0;
|
|
164
|
-
// Get query bytes harvested per endpoint as a supportability metric. See metrics aggregator (on unload).
|
|
165
|
-
agentRuntime.queryBytesSent[endpoint] = (agentRuntime.queryBytesSent[endpoint] || 0) + fullUrl.split('?').slice(-1)[0]?.length || 0;
|
|
166
163
|
const headers = [];
|
|
167
164
|
headers.push({
|
|
168
165
|
key: 'content-type',
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.bundleId = void 0;
|
|
7
|
+
var _uniqueId = require("./unique-id");
|
|
8
|
+
/**
|
|
9
|
+
* @file Contains a unique identifier for the running agent bundle
|
|
10
|
+
* when loaded.
|
|
11
|
+
* @copyright 2023 New Relic Corporation. All rights reserved.
|
|
12
|
+
* @license Apache-2.0
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Provides a unique id for the current agent bundle
|
|
17
|
+
*/
|
|
18
|
+
const bundleId = (0, _uniqueId.generateUuid)();
|
|
19
|
+
exports.bundleId = bundleId;
|
|
@@ -34,7 +34,7 @@ function getAddStringContext(agentIdentifier) {
|
|
|
34
34
|
function addString(str) {
|
|
35
35
|
if (typeof str === 'undefined' || str === '') return '';
|
|
36
36
|
var obfuscator = new _obfuscate.Obfuscator({
|
|
37
|
-
agentIdentifier
|
|
37
|
+
agentIdentifier
|
|
38
38
|
});
|
|
39
39
|
str = String(str);
|
|
40
40
|
if (obfuscator.shouldObfuscate()) str = obfuscator.obfuscateString(str);
|
|
@@ -48,33 +48,37 @@ class SessionEntity {
|
|
|
48
48
|
* expiresMs and inactiveMs are used to "expire" the session, but can be overridden in the constructor. Pass 0 to disable expiration timers.
|
|
49
49
|
*/
|
|
50
50
|
constructor(opts) {
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
setup(_ref) {
|
|
54
|
-
let {
|
|
51
|
+
const {
|
|
55
52
|
agentIdentifier,
|
|
56
53
|
key,
|
|
57
|
-
storage
|
|
58
|
-
|
|
59
|
-
expiresMs = _constants.DEFAULT_EXPIRES_MS,
|
|
60
|
-
inactiveMs = _constants.DEFAULT_INACTIVE_MS
|
|
61
|
-
} = _ref;
|
|
54
|
+
storage
|
|
55
|
+
} = opts;
|
|
62
56
|
if (!agentIdentifier || !key || !storage) {
|
|
63
57
|
throw new Error("Missing required field(s):".concat(!agentIdentifier ? ' agentID' : '').concat(!key ? ' key' : '').concat(!storage ? ' storage' : ''));
|
|
64
58
|
}
|
|
65
59
|
this.agentIdentifier = agentIdentifier;
|
|
66
60
|
this.storage = storage;
|
|
67
61
|
this.state = {};
|
|
68
|
-
this.sync(model);
|
|
69
62
|
|
|
70
63
|
// key is intended to act as the k=v pair
|
|
71
64
|
this.key = key;
|
|
65
|
+
this.ee = _contextualEe.ee.get(agentIdentifier);
|
|
66
|
+
(0, _wrap.wrapEvents)(this.ee);
|
|
67
|
+
this.setup(opts);
|
|
68
|
+
}
|
|
69
|
+
setup(_ref) {
|
|
70
|
+
let {
|
|
71
|
+
value = (0, _uniqueId.generateRandomHexString)(16),
|
|
72
|
+
expiresMs = _constants.DEFAULT_EXPIRES_MS,
|
|
73
|
+
inactiveMs = _constants.DEFAULT_INACTIVE_MS
|
|
74
|
+
} = _ref;
|
|
75
|
+
this.state = {};
|
|
76
|
+
this.sync(model);
|
|
77
|
+
|
|
72
78
|
// value is intended to act as the primary value of the k=v pair
|
|
73
79
|
this.state.value = value;
|
|
74
80
|
this.expiresMs = expiresMs;
|
|
75
81
|
this.inactiveMs = inactiveMs;
|
|
76
|
-
this.ee = _contextualEe.ee.get(agentIdentifier);
|
|
77
|
-
(0, _wrap.wrapEvents)(this.ee);
|
|
78
82
|
|
|
79
83
|
// the first time the session entity class is instantiated, we check the storage API for an existing
|
|
80
84
|
// object. If it exists, the values inside the object are used to inform the timers that run locally.
|
|
@@ -13,22 +13,23 @@ class FirstPartyCookies {
|
|
|
13
13
|
var match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
|
|
14
14
|
if (match) return match[2];
|
|
15
15
|
} catch (err) {
|
|
16
|
+
// Error is ignored
|
|
16
17
|
return '';
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
20
|
set(key, value) {
|
|
20
21
|
try {
|
|
21
|
-
const cookie = "".concat(key, "=").concat(value, "; Domain=").concat(domain, "; Path=/");
|
|
22
|
+
const cookie = "".concat(key, "=").concat(value, "; Domain=").concat(this.domain, "; Path=/");
|
|
22
23
|
document.cookie = cookie;
|
|
23
24
|
} catch (err) {
|
|
24
|
-
|
|
25
|
+
// Error is ignored
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
remove(key) {
|
|
28
29
|
try {
|
|
29
|
-
|
|
30
|
+
document.cookie = "".concat(key, "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; Domain=").concat(this.domain, "; Path=/");
|
|
30
31
|
} catch (err) {
|
|
31
|
-
|
|
32
|
+
// Error is ignored
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
}
|
|
@@ -11,6 +11,7 @@ class LocalStorage {
|
|
|
11
11
|
// Cast it back to undefined if it doesnt exist
|
|
12
12
|
return localStorage.getItem(key) || undefined;
|
|
13
13
|
} catch (err) {
|
|
14
|
+
// Error is ignored
|
|
14
15
|
return '';
|
|
15
16
|
}
|
|
16
17
|
}
|
|
@@ -19,14 +20,14 @@ class LocalStorage {
|
|
|
19
20
|
if (value === undefined || value === null) return this.remove(key);
|
|
20
21
|
return localStorage.setItem(key, value);
|
|
21
22
|
} catch (err) {
|
|
22
|
-
|
|
23
|
+
// Error is ignored
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
remove(key) {
|
|
26
27
|
try {
|
|
27
28
|
localStorage.removeItem(key);
|
|
28
29
|
} catch (err) {
|
|
29
|
-
|
|
30
|
+
// Error is ignored
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
33
|
}
|
|
@@ -27,14 +27,16 @@ class InteractionTimer extends _timer.Timer {
|
|
|
27
27
|
}
|
|
28
28
|
if (_runtime.isBrowserScope && opts.ee) {
|
|
29
29
|
if (opts.ee) {
|
|
30
|
+
this.ee = opts.ee;
|
|
30
31
|
const debouncedRefresh = (0, _invoke.debounce)(this.refresh.bind(this), 500, {
|
|
31
32
|
leading: true
|
|
32
33
|
});
|
|
33
|
-
|
|
34
|
+
this.refreshHandler = evts => {
|
|
34
35
|
if (opts.refreshEvents.includes(evts?.[0]?.type)) {
|
|
35
36
|
debouncedRefresh();
|
|
36
37
|
}
|
|
37
|
-
}
|
|
38
|
+
};
|
|
39
|
+
opts.ee.on('fn-end', this.refreshHandler);
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
// watch for the vis state changing. If the page is hidden, the local inactivity timer should be paused
|
|
@@ -48,22 +50,28 @@ class InteractionTimer extends _timer.Timer {
|
|
|
48
50
|
(0, _pageVisibility.subscribeToVisibilityChange)(state => {
|
|
49
51
|
if (state === 'hidden') this.pause();
|
|
50
52
|
// vis change --> visible is treated like a new interaction with the page
|
|
51
|
-
else
|
|
52
|
-
this.refresh();
|
|
53
|
-
this.onResume(); // emit resume event after state updated
|
|
54
|
-
}
|
|
53
|
+
else this.resume();
|
|
55
54
|
}, false, false, this.abortController?.signal);
|
|
56
55
|
}
|
|
57
56
|
}
|
|
58
57
|
abort() {
|
|
59
58
|
this.clear();
|
|
60
59
|
this.abortController?.abort();
|
|
60
|
+
if (this.refreshHandler) {
|
|
61
|
+
this.ee.removeEventListener('fn-end', this.refreshHandler);
|
|
62
|
+
this.refreshHandler = this.ee = null;
|
|
63
|
+
}
|
|
61
64
|
}
|
|
62
65
|
pause() {
|
|
63
66
|
this.onPause();
|
|
64
67
|
clearTimeout(this.timer);
|
|
65
68
|
this.remainingMs = this.initialMs - (Date.now() - this.startTimestamp);
|
|
66
69
|
}
|
|
70
|
+
resume() {
|
|
71
|
+
this.refresh();
|
|
72
|
+
this.onResume(); // emit resume event after state updated
|
|
73
|
+
}
|
|
74
|
+
|
|
67
75
|
refresh(cb, ms) {
|
|
68
76
|
this.clear();
|
|
69
77
|
this.timer = this.create(cb, ms);
|
|
@@ -35,7 +35,7 @@ var DOM_CONTENT_LOAD_EVENT = 'domContentLoadedEvent';
|
|
|
35
35
|
var navTimingValues = [];
|
|
36
36
|
exports.navTimingValues = navTimingValues;
|
|
37
37
|
function getPntType(type) {
|
|
38
|
-
if (typeof type
|
|
38
|
+
if (typeof type === 'number') return type;
|
|
39
39
|
const types = {
|
|
40
40
|
navigate: undefined,
|
|
41
41
|
reload: 1,
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.subscribeToEOL = subscribeToEOL;
|
|
7
7
|
var _eventListenerOpts = require("../event-listener/event-listener-opts");
|
|
8
|
-
var _invoke = require("../util/invoke");
|
|
9
8
|
var _runtime = require("../constants/runtime");
|
|
10
9
|
var _pageVisibility = require("../window/page-visibility");
|
|
11
10
|
/*
|
|
@@ -30,37 +29,12 @@ if (_runtime.isWorkerScope) {
|
|
|
30
29
|
* Subscribes a provided callback to the time/event when the agent should treat it as end-of-life.
|
|
31
30
|
* This is used, for example, to submit a final harvest and send all remaining data on best-effort.
|
|
32
31
|
* @param {function} cb - func to run before or during the last reliable event or time of an env's life span
|
|
33
|
-
* @param {boolean} allowBFCache - (temp) feature flag to gate new v1222 BFC support
|
|
34
32
|
*/
|
|
35
|
-
function subscribeToEOL(cb
|
|
33
|
+
function subscribeToEOL(cb) {
|
|
36
34
|
if (_runtime.isBrowserScope) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
// --this ought to be removed once support for version below 14.5 phases out
|
|
41
|
-
} else {
|
|
42
|
-
var oneCall = (0, _invoke.single)(cb);
|
|
43
|
-
|
|
44
|
-
// Firefox has a bug wherein a slow-loading resource loaded from the 'pagehide'
|
|
45
|
-
// or 'unload' event will delay the 'load' event firing on the next page load.
|
|
46
|
-
// In Firefox versions that support sendBeacon, this doesn't matter, because
|
|
47
|
-
// we'll use it instead of an image load for our final harvest.
|
|
48
|
-
//
|
|
49
|
-
// Some Safari versions never fire the 'unload' event for pages that are being
|
|
50
|
-
// put into the WebKit page cache, so we *need* to use the pagehide event for
|
|
51
|
-
// the final submission from Safari.
|
|
52
|
-
//
|
|
53
|
-
// Generally speaking, we will try to submit our final harvest from either
|
|
54
|
-
// pagehide or unload, whichever comes first, but in Firefox, we need to avoid
|
|
55
|
-
// attempting to submit from pagehide to ensure that we don't slow down loading
|
|
56
|
-
// of the next page.
|
|
57
|
-
if (!_runtime.ffVersion || navigator.sendBeacon) {
|
|
58
|
-
(0, _eventListenerOpts.windowAddEventListener)('pagehide', oneCall);
|
|
59
|
-
} else {
|
|
60
|
-
(0, _eventListenerOpts.windowAddEventListener)('beforeunload', oneCall);
|
|
61
|
-
}
|
|
62
|
-
(0, _eventListenerOpts.windowAddEventListener)('unload', oneCall);
|
|
63
|
-
}
|
|
35
|
+
(0, _pageVisibility.subscribeToVisibilityChange)(cb, true); // when user switches tab or hides window, esp. mobile scenario
|
|
36
|
+
(0, _eventListenerOpts.windowAddEventListener)('pagehide', cb); // when user navigates away, and because safari iOS v14.4- doesn't fully support vis change
|
|
37
|
+
// --this ought to be removed once support for version below 14.5 phases out
|
|
64
38
|
} else if (_runtime.isWorkerScope) {
|
|
65
39
|
_runtime.globalScope.cleanupTasks.push(cb); // close() should run these tasks before quitting thread
|
|
66
40
|
}
|