@newrelic/browser-agent 1.262.0 → 1.264.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 +21 -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 +3 -3
- package/dist/cjs/common/config/state/configurable.js +4 -4
- package/dist/cjs/common/config/state/init.js +11 -6
- 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 +2 -2
- package/dist/cjs/common/drain/drain.js +5 -5
- package/dist/cjs/common/harvest/harvest.js +3 -3
- package/dist/cjs/common/serialize/bel-serializer.js +2 -2
- package/dist/cjs/common/session/session-entity.js +3 -3
- package/dist/cjs/common/timing/time-keeper.js +13 -2
- package/dist/cjs/common/url/encode.js +3 -5
- package/dist/cjs/common/util/console.js +3 -4
- package/dist/cjs/common/util/obfuscate.js +3 -3
- package/dist/cjs/common/util/submit-data.js +0 -1
- package/dist/cjs/common/vitals/vital-metric.js +1 -1
- package/dist/cjs/common/wrap/wrap-logger.js +1 -2
- package/dist/cjs/common/wrap/wrap-xhr.js +1 -1
- package/dist/cjs/features/ajax/aggregate/index.js +1 -1
- package/dist/cjs/features/ajax/instrument/index.js +1 -1
- package/dist/cjs/features/generic_events/aggregate/index.js +137 -0
- package/dist/cjs/features/generic_events/constants.js +8 -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 +13 -12
- package/dist/cjs/features/jserrors/instrument/index.js +1 -1
- package/dist/cjs/features/logging/aggregate/index.js +6 -6
- package/dist/cjs/features/logging/constants.js +2 -5
- package/dist/cjs/features/logging/instrument/index.js +1 -1
- package/dist/cjs/features/metrics/aggregate/index.js +17 -1
- package/dist/cjs/features/metrics/instrument/index.js +1 -1
- package/dist/cjs/features/page_action/instrument/index.js +6 -6
- package/dist/cjs/features/page_view_event/aggregate/index.js +21 -5
- package/dist/cjs/features/page_view_event/aggregate/initialized-features.js +1 -1
- package/dist/cjs/features/page_view_event/instrument/index.js +1 -1
- package/dist/cjs/features/page_view_timing/aggregate/index.js +3 -3
- package/dist/cjs/features/page_view_timing/instrument/index.js +1 -1
- package/dist/cjs/features/session_replay/aggregate/index.js +3 -3
- package/dist/cjs/features/session_replay/instrument/index.js +1 -1
- package/dist/cjs/features/session_replay/shared/recorder.js +1 -1
- package/dist/cjs/features/session_replay/shared/stylesheet-evaluator.js +1 -1
- package/dist/cjs/features/session_trace/aggregate/index.js +1 -1
- package/dist/cjs/features/session_trace/aggregate/trace/storage.js +2 -2
- package/dist/cjs/features/session_trace/instrument/index.js +1 -1
- package/dist/cjs/features/soft_navigations/aggregate/bel-node.js +1 -1
- package/dist/cjs/features/soft_navigations/aggregate/index.js +1 -1
- package/dist/cjs/features/soft_navigations/aggregate/interaction.js +5 -5
- package/dist/cjs/features/soft_navigations/instrument/index.js +1 -1
- package/dist/cjs/features/spa/aggregate/index.js +3 -4
- package/dist/cjs/features/spa/aggregate/interaction.js +2 -2
- package/dist/cjs/features/spa/aggregate/serializer.js +1 -2
- package/dist/cjs/features/spa/instrument/index.js +1 -1
- package/dist/cjs/features/utils/aggregate-base.js +6 -3
- package/dist/cjs/features/utils/instrument-base.js +2 -2
- package/dist/cjs/features/utils/lazy-feature-loader.js +2 -2
- package/dist/cjs/index.js +21 -0
- package/dist/cjs/loaders/agent-base.js +1 -5
- package/dist/cjs/loaders/agent.js +3 -4
- package/dist/cjs/loaders/api/api.js +10 -8
- package/dist/cjs/loaders/api/apiAsync.js +1 -1
- package/dist/cjs/loaders/browser-agent.js +4 -3
- package/dist/cjs/loaders/configure/configure.js +4 -3
- package/dist/cjs/loaders/features/features.js +8 -4
- package/dist/cjs/loaders/micro-agent.js +6 -6
- 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 +3 -3
- package/dist/esm/common/config/state/configurable.js +4 -4
- package/dist/esm/common/config/state/init.js +11 -6
- 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 +2 -2
- package/dist/esm/common/drain/drain.js +5 -5
- package/dist/esm/common/harvest/harvest.js +4 -4
- package/dist/esm/common/serialize/bel-serializer.js +2 -2
- package/dist/esm/common/session/session-entity.js +4 -4
- package/dist/esm/common/timing/time-keeper.js +12 -2
- package/dist/esm/common/url/encode.js +3 -5
- package/dist/esm/common/util/console.js +3 -4
- package/dist/esm/common/util/obfuscate.js +3 -3
- package/dist/esm/common/util/submit-data.js +0 -1
- package/dist/esm/common/vitals/vital-metric.js +1 -1
- package/dist/esm/common/wrap/wrap-logger.js +1 -2
- package/dist/esm/common/wrap/wrap-xhr.js +1 -1
- package/dist/esm/features/ajax/aggregate/index.js +1 -1
- package/dist/esm/features/ajax/instrument/index.js +1 -1
- package/dist/esm/features/generic_events/aggregate/index.js +129 -0
- package/dist/esm/features/generic_events/constants.js +2 -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 +13 -12
- package/dist/esm/features/jserrors/instrument/index.js +1 -1
- package/dist/esm/features/logging/aggregate/index.js +7 -7
- package/dist/esm/features/logging/constants.js +1 -4
- package/dist/esm/features/logging/instrument/index.js +1 -1
- package/dist/esm/features/metrics/aggregate/index.js +17 -1
- package/dist/esm/features/metrics/instrument/index.js +1 -1
- package/dist/esm/features/page_action/instrument/index.js +7 -6
- package/dist/esm/features/page_view_event/aggregate/index.js +22 -6
- package/dist/esm/features/page_view_event/aggregate/initialized-features.js +1 -1
- package/dist/esm/features/page_view_event/instrument/index.js +1 -1
- package/dist/esm/features/page_view_timing/aggregate/index.js +3 -3
- package/dist/esm/features/page_view_timing/instrument/index.js +1 -1
- package/dist/esm/features/session_replay/aggregate/index.js +3 -3
- package/dist/esm/features/session_replay/instrument/index.js +1 -1
- package/dist/esm/features/session_replay/shared/recorder.js +1 -1
- package/dist/esm/features/session_replay/shared/stylesheet-evaluator.js +1 -1
- package/dist/esm/features/session_trace/aggregate/index.js +1 -1
- package/dist/esm/features/session_trace/aggregate/trace/storage.js +2 -2
- package/dist/esm/features/session_trace/instrument/index.js +1 -1
- package/dist/esm/features/soft_navigations/aggregate/bel-node.js +1 -1
- package/dist/esm/features/soft_navigations/aggregate/index.js +1 -1
- package/dist/esm/features/soft_navigations/aggregate/interaction.js +5 -5
- package/dist/esm/features/soft_navigations/instrument/index.js +1 -1
- package/dist/esm/features/spa/aggregate/index.js +3 -4
- package/dist/esm/features/spa/aggregate/interaction.js +2 -2
- package/dist/esm/features/spa/aggregate/serializer.js +1 -2
- package/dist/esm/features/spa/instrument/index.js +1 -1
- package/dist/esm/features/utils/aggregate-base.js +7 -4
- package/dist/esm/features/utils/instrument-base.js +2 -2
- package/dist/esm/features/utils/lazy-feature-loader.js +2 -2
- package/dist/esm/index.js +3 -0
- package/dist/esm/loaders/agent-base.js +1 -5
- package/dist/esm/loaders/agent.js +3 -4
- package/dist/esm/loaders/api/api.js +10 -8
- package/dist/esm/loaders/api/apiAsync.js +1 -1
- package/dist/esm/loaders/browser-agent.js +3 -2
- package/dist/esm/loaders/configure/configure.js +4 -3
- package/dist/esm/loaders/features/features.js +8 -4
- package/dist/esm/loaders/micro-agent.js +6 -6
- package/dist/types/common/aggregate/aggregator.d.ts.map +1 -1
- package/dist/types/common/config/state/init.d.ts.map +1 -1
- 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/drain/drain.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 +2 -1
- 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 +1 -1
- package/dist/types/common/util/console.d.ts.map +1 -1
- package/dist/types/common/util/submit-data.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-logger.d.ts.map +1 -1
- package/dist/types/features/{page_action → generic_events}/aggregate/index.d.ts +7 -5
- package/dist/types/features/generic_events/aggregate/index.d.ts.map +1 -0
- package/dist/types/features/generic_events/constants.d.ts +2 -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 +6 -0
- package/dist/types/features/generic_events/instrument/index.d.ts.map +1 -0
- package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/logging/constants.d.ts +0 -3
- package/dist/types/features/logging/constants.d.ts.map +1 -1
- package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/page_action/instrument/index.d.ts +5 -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_timing/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/shared/recorder.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/spa/aggregate/serializer.d.ts.map +1 -1
- package/dist/types/features/utils/aggregate-base.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -0
- package/dist/types/loaders/agent-base.d.ts +0 -1
- 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/package.json +25 -6
- 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/state/configurable.js +4 -4
- package/src/common/config/state/init.js +6 -4
- package/src/common/constants/runtime.js +0 -2
- package/src/common/context/shared-context.js +2 -2
- package/src/common/drain/drain.js +4 -5
- package/src/common/harvest/harvest.js +4 -4
- package/src/common/serialize/bel-serializer.js +1 -2
- package/src/common/session/session-entity.js +4 -4
- package/src/common/timing/time-keeper.js +14 -2
- package/src/common/url/encode.js +2 -3
- package/src/common/util/console.js +3 -4
- package/src/common/util/obfuscate.js +3 -3
- package/src/common/util/submit-data.js +0 -1
- package/src/common/wrap/wrap-logger.js +1 -2
- package/src/common/wrap/wrap-xhr.js +1 -1
- package/src/features/generic_events/aggregate/index.js +133 -0
- package/src/features/generic_events/constants.js +3 -0
- package/src/features/generic_events/index.js +1 -0
- package/src/features/generic_events/instrument/index.js +22 -0
- package/src/features/jserrors/aggregate/index.js +4 -5
- package/src/features/logging/aggregate/index.js +6 -6
- package/src/features/logging/constants.js +0 -4
- package/src/features/metrics/aggregate/index.js +12 -0
- package/src/features/page_action/instrument/index.js +6 -6
- package/src/features/page_view_event/aggregate/index.js +22 -5
- package/src/features/page_view_event/aggregate/initialized-features.js +1 -1
- package/src/features/page_view_timing/aggregate/index.js +1 -2
- package/src/features/session_replay/aggregate/index.js +1 -1
- package/src/features/session_replay/shared/recorder.js +1 -1
- package/src/features/spa/aggregate/index.js +2 -3
- package/src/features/spa/aggregate/interaction.js +1 -2
- package/src/features/spa/aggregate/serializer.js +1 -2
- package/src/features/utils/aggregate-base.js +7 -4
- package/src/features/utils/instrument-base.js +2 -2
- package/src/features/utils/lazy-feature-loader.js +2 -2
- package/src/index.js +3 -0
- package/src/loaders/agent-base.js +1 -5
- package/src/loaders/agent.js +3 -4
- package/src/loaders/api/api.js +10 -8
- package/src/loaders/api/apiAsync.js +1 -1
- package/src/loaders/browser-agent.js +5 -3
- package/src/loaders/configure/configure.js +5 -1
- package/src/loaders/features/features.js +8 -4
- package/src/loaders/micro-agent.js +6 -6
- 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/util/map-own.js +0 -31
- 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/util/map-own.js +0 -24
- 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/util/map-own.d.ts +0 -3
- package/dist/types/common/util/map-own.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/util/map-own.js +0 -22
- package/src/features/page_action/aggregate/index.js +0 -114
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { stringify } from '../../../common/util/stringify'
|
|
6
|
+
import { HarvestScheduler } from '../../../common/harvest/harvest-scheduler'
|
|
7
|
+
import { cleanURL } from '../../../common/url/clean-url'
|
|
8
|
+
import { getConfigurationValue, getInfo, getRuntime } from '../../../common/config/config'
|
|
9
|
+
import { FEATURE_NAME } from '../constants'
|
|
10
|
+
import { isBrowserScope } from '../../../common/constants/runtime'
|
|
11
|
+
import { AggregateBase } from '../../utils/aggregate-base'
|
|
12
|
+
import { warn } from '../../../common/util/console'
|
|
13
|
+
import { now } from '../../../common/timing/now'
|
|
14
|
+
import { registerHandler } from '../../../common/event-emitter/register-handler'
|
|
15
|
+
import { deregisterDrain } from '../../../common/drain/drain'
|
|
16
|
+
import { SUPPORTABILITY_METRIC_CHANNEL } from '../../metrics/constants'
|
|
17
|
+
|
|
18
|
+
export class Aggregate extends AggregateBase {
|
|
19
|
+
#agentRuntime
|
|
20
|
+
static featureName = FEATURE_NAME
|
|
21
|
+
constructor (agentIdentifier, aggregator) {
|
|
22
|
+
super(agentIdentifier, aggregator, FEATURE_NAME)
|
|
23
|
+
|
|
24
|
+
this.eventsPerHarvest = 1000
|
|
25
|
+
this.harvestTimeSeconds = getConfigurationValue(this.agentIdentifier, 'generic_events.harvestTimeSeconds')
|
|
26
|
+
|
|
27
|
+
this.referrerUrl = (isBrowserScope && document.referrer) ? cleanURL(document.referrer) : undefined
|
|
28
|
+
this.currentEvents = []
|
|
29
|
+
|
|
30
|
+
this.events = []
|
|
31
|
+
this.overflow = []
|
|
32
|
+
|
|
33
|
+
this.#agentRuntime = getRuntime(this.agentIdentifier)
|
|
34
|
+
|
|
35
|
+
this.waitForFlags(['ins']).then(([ins]) => {
|
|
36
|
+
if (!ins) {
|
|
37
|
+
this.blocked = true
|
|
38
|
+
deregisterDrain(this.agentIdentifier, this.featureName)
|
|
39
|
+
return
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (getConfigurationValue(this.agentIdentifier, 'page_action.enabled')) {
|
|
43
|
+
registerHandler('api-addPageAction', (timestamp, name, attributes) => {
|
|
44
|
+
this.addEvent({
|
|
45
|
+
...attributes,
|
|
46
|
+
eventType: 'PageAction',
|
|
47
|
+
timestamp: this.#agentRuntime.timeKeeper.convertRelativeTimestamp(timestamp),
|
|
48
|
+
timeSinceLoad: timestamp / 1000,
|
|
49
|
+
actionName: name,
|
|
50
|
+
referrerUrl: this.referrerUrl,
|
|
51
|
+
currentUrl: cleanURL('' + location),
|
|
52
|
+
...(isBrowserScope && {
|
|
53
|
+
browserWidth: window.document.documentElement?.clientWidth,
|
|
54
|
+
browserHeight: window.document.documentElement?.clientHeight
|
|
55
|
+
})
|
|
56
|
+
})
|
|
57
|
+
}, this.featureName, this.ee)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
this.harvestScheduler = new HarvestScheduler('ins', { onFinished: (...args) => this.onHarvestFinished(...args) }, this)
|
|
61
|
+
this.harvestScheduler.harvest.on('ins', (...args) => this.onHarvestStarted(...args))
|
|
62
|
+
this.harvestScheduler.startTimer(this.harvestTimeSeconds, 0)
|
|
63
|
+
|
|
64
|
+
this.drain()
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
onHarvestStarted (options) {
|
|
69
|
+
const { userAttributes, atts } = getInfo(this.agentIdentifier)
|
|
70
|
+
const harvestEvents = this.overflow.length ? this.overflow.splice(0, Infinity) : this.events.splice(0, Infinity)
|
|
71
|
+
var payload = ({
|
|
72
|
+
qs: {
|
|
73
|
+
ua: userAttributes,
|
|
74
|
+
at: atts
|
|
75
|
+
},
|
|
76
|
+
body: {
|
|
77
|
+
ins: harvestEvents
|
|
78
|
+
}
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
if (options.retry) {
|
|
82
|
+
this.currentEvents = harvestEvents
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return payload
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
onHarvestFinished (result) {
|
|
89
|
+
if (result && result.sent && result.retry && this.currentEvents.length) {
|
|
90
|
+
this.events = this.currentEvents.concat(this.events)
|
|
91
|
+
this.currentEvents = []
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// WARNING: Insights times are in seconds. EXCEPT timestamp, which is in ms.
|
|
96
|
+
addEvent (obj = {}) {
|
|
97
|
+
if (!obj || !Object.keys(obj).length) return
|
|
98
|
+
if (!obj.eventType) {
|
|
99
|
+
warn(44)
|
|
100
|
+
return
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
for (let key in obj) {
|
|
104
|
+
let val = obj[key]
|
|
105
|
+
obj[key] = (val && typeof val === 'object' ? stringify(val) : val)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const defaultEventAttributes = {
|
|
109
|
+
/** should be overridden by the event-specific attributes, but just in case -- set it to now() */
|
|
110
|
+
timestamp: this.#agentRuntime.timeKeeper.convertRelativeTimestamp(now()),
|
|
111
|
+
/** all generic events require a pageUrl */
|
|
112
|
+
pageUrl: cleanURL(getRuntime(this.agentIdentifier).origin)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const eventAttributes = {
|
|
116
|
+
/** Agent-level custom attributes */
|
|
117
|
+
...(getInfo(this.agentIdentifier).jsAttributes || {}),
|
|
118
|
+
/** Fallbacks for required properties in-case the event did not supply them, should take precedence over agent-level custom attrs */
|
|
119
|
+
...defaultEventAttributes,
|
|
120
|
+
/** Event-specific attributes take precedence over agent-level custom attributes and fallbacks */
|
|
121
|
+
...obj
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
this.events.push(eventAttributes)
|
|
125
|
+
|
|
126
|
+
// check if we've reached the harvest limit...
|
|
127
|
+
if (this.events.length >= this.eventsPerHarvest) {
|
|
128
|
+
this.ee.emit(SUPPORTABILITY_METRIC_CHANNEL, ['GenericEvents/Harvest/Max/Seen'])
|
|
129
|
+
this.overflow = [...this.overflow, ...this.events.splice(0, Infinity)]
|
|
130
|
+
this.harvestScheduler.runHarvest()
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Instrument as GenericEvents } from './instrument/index'
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
2
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { getConfigurationValue } from '../../../common/config/config'
|
|
6
|
+
import { deregisterDrain } from '../../../common/drain/drain'
|
|
7
|
+
import { InstrumentBase } from '../../utils/instrument-base'
|
|
8
|
+
import { FEATURE_NAME } from '../constants'
|
|
9
|
+
|
|
10
|
+
export class Instrument extends InstrumentBase {
|
|
11
|
+
static featureName = FEATURE_NAME
|
|
12
|
+
constructor (agentIdentifier, aggregator, auto = true) {
|
|
13
|
+
super(agentIdentifier, aggregator, FEATURE_NAME, auto)
|
|
14
|
+
const genericEventSourceConfigs = [
|
|
15
|
+
getConfigurationValue(this.agentIdentifier, 'page_action.enabled')
|
|
16
|
+
// other future generic event source configs to go here, like M&Ms, PageResouce, etc.
|
|
17
|
+
]
|
|
18
|
+
/** If any of the sources are active, import the aggregator. otherwise deregister */
|
|
19
|
+
if (genericEventSourceConfigs.some(x => x)) this.importAggregator()
|
|
20
|
+
else deregisterDrain(this.agentIdentifier, this.featureName)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -12,7 +12,6 @@ import { registerHandler as register } from '../../../common/event-emitter/regis
|
|
|
12
12
|
import { HarvestScheduler } from '../../../common/harvest/harvest-scheduler'
|
|
13
13
|
import { stringify } from '../../../common/util/stringify'
|
|
14
14
|
import { handle } from '../../../common/event-emitter/handle'
|
|
15
|
-
import { mapOwn } from '../../../common/util/map-own'
|
|
16
15
|
import { getInfo, getConfigurationValue, getRuntime } from '../../../common/config/config'
|
|
17
16
|
import { globalScope } from '../../../common/constants/runtime'
|
|
18
17
|
|
|
@@ -91,7 +90,7 @@ export class Aggregate extends AggregateBase {
|
|
|
91
90
|
|
|
92
91
|
onHarvestFinished (result) {
|
|
93
92
|
if (result.retry && this.currentBody) {
|
|
94
|
-
|
|
93
|
+
Object.entries(this.currentBody || {}).forEach(([key, value]) => {
|
|
95
94
|
for (var i = 0; i < value.length; i++) {
|
|
96
95
|
var bucket = value[i]
|
|
97
96
|
var name = this.getBucketName(key, bucket.params, bucket.custom)
|
|
@@ -264,8 +263,8 @@ export class Aggregate extends AggregateBase {
|
|
|
264
263
|
var allCustomAttrs = {}
|
|
265
264
|
const localCustomAttrs = item[4]
|
|
266
265
|
|
|
267
|
-
|
|
268
|
-
|
|
266
|
+
Object.entries(interaction.root.attrs.custom || {}).forEach(setCustom) // tack on custom attrs from the interaction
|
|
267
|
+
Object.entries(localCustomAttrs || {}).forEach(setCustom)
|
|
269
268
|
|
|
270
269
|
var params = item[2]
|
|
271
270
|
if (wasSaved) {
|
|
@@ -281,7 +280,7 @@ export class Aggregate extends AggregateBase {
|
|
|
281
280
|
|
|
282
281
|
this.aggregator.store(item[0], aggregateHash, params, item[3], allCustomAttrs)
|
|
283
282
|
|
|
284
|
-
function setCustom (key, val) {
|
|
283
|
+
function setCustom ([key, val]) {
|
|
285
284
|
allCustomAttrs[key] = (val && typeof val === 'object' ? stringify(val) : val)
|
|
286
285
|
}
|
|
287
286
|
})
|
|
@@ -6,7 +6,7 @@ import { warn } from '../../../common/util/console'
|
|
|
6
6
|
import { stringify } from '../../../common/util/stringify'
|
|
7
7
|
import { SUPPORTABILITY_METRIC_CHANNEL } from '../../metrics/constants'
|
|
8
8
|
import { AggregateBase } from '../../utils/aggregate-base'
|
|
9
|
-
import { FEATURE_NAME, LOGGING_EVENT_EMITTER_CHANNEL,
|
|
9
|
+
import { FEATURE_NAME, LOGGING_EVENT_EMITTER_CHANNEL, LOG_LEVELS, MAX_PAYLOAD_SIZE } from '../constants'
|
|
10
10
|
import { Log } from '../shared/log'
|
|
11
11
|
import { isValidLogLevel } from '../shared/utils'
|
|
12
12
|
|
|
@@ -49,7 +49,7 @@ export class Aggregate extends AggregateBase {
|
|
|
49
49
|
|
|
50
50
|
if (!attributes || typeof attributes !== 'object') attributes = {}
|
|
51
51
|
if (typeof level === 'string') level = level.toUpperCase()
|
|
52
|
-
if (!isValidLogLevel(level)) return warn(
|
|
52
|
+
if (!isValidLogLevel(level)) return warn(30, level)
|
|
53
53
|
|
|
54
54
|
try {
|
|
55
55
|
if (typeof message !== 'string') {
|
|
@@ -63,13 +63,13 @@ export class Aggregate extends AggregateBase {
|
|
|
63
63
|
else message = String(message)
|
|
64
64
|
}
|
|
65
65
|
} catch (err) {
|
|
66
|
-
warn(
|
|
66
|
+
warn(16, message)
|
|
67
67
|
return
|
|
68
68
|
}
|
|
69
|
-
if (typeof message !== 'string' || !message) return warn(
|
|
69
|
+
if (typeof message !== 'string' || !message) return warn(32)
|
|
70
70
|
if (message.length > MAX_PAYLOAD_SIZE) {
|
|
71
71
|
handle(SUPPORTABILITY_METRIC_CHANNEL, ['Logging/Harvest/Failed/Seen', message.length])
|
|
72
|
-
return warn(
|
|
72
|
+
return warn(31, message.slice(0, 25) + '...')
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
const log = new Log(
|
|
@@ -81,7 +81,7 @@ export class Aggregate extends AggregateBase {
|
|
|
81
81
|
const logBytes = log.message.length + stringify(log.attributes).length + log.level.length + 10 // timestamp == 10 chars
|
|
82
82
|
if (logBytes > MAX_PAYLOAD_SIZE) {
|
|
83
83
|
handle(SUPPORTABILITY_METRIC_CHANNEL, ['Logging/Harvest/Failed/Seen', logBytes])
|
|
84
|
-
return warn(
|
|
84
|
+
return warn(31, log.message.slice(0, 25) + '...')
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
if (this.estimatedBytes + logBytes >= MAX_PAYLOAD_SIZE) {
|
|
@@ -13,7 +13,3 @@ export const LOGGING_EVENT_EMITTER_CHANNEL = 'log'
|
|
|
13
13
|
export const FEATURE_NAME = FEATURE_NAMES.logging
|
|
14
14
|
|
|
15
15
|
export const MAX_PAYLOAD_SIZE = 1000000
|
|
16
|
-
|
|
17
|
-
export const LOGGING_FAILURE_MESSAGE = 'failed to wrap logger: '
|
|
18
|
-
export const LOGGING_LEVEL_FAILURE_MESSAGE = 'invalid log level: '
|
|
19
|
-
export const LOGGING_IGNORED = 'ignored log: '
|
|
@@ -96,6 +96,18 @@ export class Aggregate extends AggregateBase {
|
|
|
96
96
|
// Check if proxy for either chunks or beacon is being used
|
|
97
97
|
if (proxy.assets) this.storeSupportabilityMetrics('Config/AssetsUrl/Changed')
|
|
98
98
|
if (proxy.beacon) this.storeSupportabilityMetrics('Config/BeaconUrl/Changed')
|
|
99
|
+
|
|
100
|
+
if (isBrowserScope && window.MutationObserver) {
|
|
101
|
+
this.storeSupportabilityMetrics('Generic/VideoElement/Added', window.document.querySelectorAll('video').length)
|
|
102
|
+
const mo = new MutationObserver(records => {
|
|
103
|
+
records.forEach(record => {
|
|
104
|
+
record.addedNodes.forEach(addedNode => {
|
|
105
|
+
if (addedNode instanceof HTMLVideoElement) { this.storeSupportabilityMetrics('Generic/VideoElement/Added', 1) }
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
})
|
|
109
|
+
mo.observe(window.document.body, { childList: true, subtree: true })
|
|
110
|
+
}
|
|
99
111
|
}
|
|
100
112
|
|
|
101
113
|
eachSessionChecks () {
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import { FEATURE_NAME } from '../constants'
|
|
6
|
+
import { GenericEvents } from '../../generic_events'
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated This feature has been replaced by Generic Events. Use/Import `GenericEvents` instead. This wrapper will be removed in a future release
|
|
10
|
+
*/
|
|
11
|
+
export class Instrument extends GenericEvents {
|
|
11
12
|
constructor (agentIdentifier, aggregator, auto = true) {
|
|
12
|
-
super(agentIdentifier, aggregator,
|
|
13
|
-
this.importAggregator()
|
|
13
|
+
super(agentIdentifier, aggregator, auto)
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { globalScope, isBrowserScope, originTime } from '../../../common/constants/runtime'
|
|
2
2
|
import { addPT, addPN } from '../../../common/timing/nav-timing'
|
|
3
3
|
import { stringify } from '../../../common/util/stringify'
|
|
4
|
-
import { getInfo, getRuntime } from '../../../common/config/config'
|
|
4
|
+
import { getInfo, getRuntime, isConfigured } from '../../../common/config/config'
|
|
5
5
|
import { Harvest } from '../../../common/harvest/harvest'
|
|
6
6
|
import * as CONSTANTS from '../constants'
|
|
7
7
|
import { getActivatedFeaturesFlags } from './initialized-features'
|
|
@@ -28,6 +28,11 @@ export class Aggregate extends AggregateBase {
|
|
|
28
28
|
this.firstByteToDomContent = 0 // our "dom processing" duration
|
|
29
29
|
this.timeKeeper = new TimeKeeper(this.agentIdentifier)
|
|
30
30
|
|
|
31
|
+
if (!isConfigured(agentIdentifier)) {
|
|
32
|
+
this.ee.abort()
|
|
33
|
+
return warn(43)
|
|
34
|
+
}
|
|
35
|
+
|
|
31
36
|
if (isBrowserScope) {
|
|
32
37
|
timeToFirstByte.subscribe(({ value, attrs }) => {
|
|
33
38
|
const navEntry = attrs.navigationEntry
|
|
@@ -48,7 +53,6 @@ export class Aggregate extends AggregateBase {
|
|
|
48
53
|
const agentRuntime = getRuntime(this.agentIdentifier)
|
|
49
54
|
const harvester = new Harvest(this)
|
|
50
55
|
|
|
51
|
-
if (!info.beacon) return
|
|
52
56
|
if (info.queueTime) this.aggregator.store('measures', 'qt', { value: info.queueTime })
|
|
53
57
|
if (info.applicationTime) this.aggregator.store('measures', 'ap', { value: info.applicationTime })
|
|
54
58
|
|
|
@@ -126,11 +130,24 @@ export class Aggregate extends AggregateBase {
|
|
|
126
130
|
if (!this.timeKeeper.ready) throw new Error('TimeKeeper not ready')
|
|
127
131
|
|
|
128
132
|
agentRuntime.timeKeeper = this.timeKeeper
|
|
133
|
+
|
|
134
|
+
// Check if the time diff is such that we need to capture a supportability metric
|
|
135
|
+
if (this.timeKeeper.localTimeDiff >= 12 * 60 * 60 * 1000) {
|
|
136
|
+
handle(SUPPORTABILITY_METRIC_CHANNEL, ['PVE/NRTime/Calculation/DiffExceed12Hrs'], undefined, FEATURE_NAMES.metrics, this.ee)
|
|
137
|
+
} else if (this.timeKeeper.localTimeDiff >= 6 * 60 * 60 * 1000) {
|
|
138
|
+
handle(SUPPORTABILITY_METRIC_CHANNEL, ['PVE/NRTime/Calculation/DiffExceed6Hrs'], undefined, FEATURE_NAMES.metrics, this.ee)
|
|
139
|
+
} else if (this.timeKeeper.localTimeDiff >= 60 * 60 * 1000) {
|
|
140
|
+
handle(SUPPORTABILITY_METRIC_CHANNEL, ['PVE/NRTime/Calculation/DiffExceed1Hrs'], undefined, FEATURE_NAMES.metrics, this.ee)
|
|
141
|
+
}
|
|
129
142
|
} catch (error) {
|
|
130
|
-
|
|
143
|
+
if (error?.message?.indexOf('invalid format') > 0) {
|
|
144
|
+
handle(SUPPORTABILITY_METRIC_CHANNEL, ['PVE/NRTime/Calculation/InvalidFormat'], undefined, FEATURE_NAMES.metrics, this.ee)
|
|
145
|
+
} else {
|
|
146
|
+
handle(SUPPORTABILITY_METRIC_CHANNEL, ['PVE/NRTime/Calculation/Failed'], undefined, FEATURE_NAMES.metrics, this.ee)
|
|
147
|
+
}
|
|
131
148
|
drain(this.agentIdentifier, FEATURE_NAMES.metrics, true)
|
|
132
149
|
this.ee.abort()
|
|
133
|
-
warn(
|
|
150
|
+
warn(17, error)
|
|
134
151
|
return
|
|
135
152
|
}
|
|
136
153
|
|
|
@@ -141,7 +158,7 @@ export class Aggregate extends AggregateBase {
|
|
|
141
158
|
this.drain()
|
|
142
159
|
} catch (err) {
|
|
143
160
|
this.ee.abort()
|
|
144
|
-
warn(
|
|
161
|
+
warn(18, err)
|
|
145
162
|
}
|
|
146
163
|
}
|
|
147
164
|
})
|
|
@@ -18,7 +18,7 @@ export function getActivatedFeaturesFlags (agentId) {
|
|
|
18
18
|
flagArr.push('xhr'); break
|
|
19
19
|
case FEATURE_NAMES.jserrors:
|
|
20
20
|
flagArr.push('err'); break
|
|
21
|
-
case FEATURE_NAMES.
|
|
21
|
+
case FEATURE_NAMES.genericEvents:
|
|
22
22
|
flagArr.push('ins'); break
|
|
23
23
|
case FEATURE_NAMES.sessionTrace:
|
|
24
24
|
flagArr.push('stn'); break
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { nullable, numeric, getAddStringContext, addCustomAttributes } from '../../../common/serialize/bel-serializer'
|
|
7
|
-
import { mapOwn } from '../../../common/util/map-own'
|
|
8
7
|
import { HarvestScheduler } from '../../../common/harvest/harvest-scheduler'
|
|
9
8
|
import { registerHandler } from '../../../common/event-emitter/register-handler'
|
|
10
9
|
import { handle } from '../../../common/event-emitter/handle'
|
|
@@ -138,7 +137,7 @@ export class Aggregate extends AggregateBase {
|
|
|
138
137
|
|
|
139
138
|
var reservedAttributes = ['size', 'eid', 'cls', 'type', 'fid', 'elTag', 'elUrl', 'net-type',
|
|
140
139
|
'net-etype', 'net-rtt', 'net-dlink']
|
|
141
|
-
|
|
140
|
+
Object.entries(customAttributes || {}).forEach(([key, val]) => {
|
|
142
141
|
if (reservedAttributes.indexOf(key) < 0) {
|
|
143
142
|
timingAttributes[key] = val
|
|
144
143
|
}
|
|
@@ -394,7 +394,7 @@ export class Aggregate extends AggregateBase {
|
|
|
394
394
|
|
|
395
395
|
/** Abort the feature, once aborted it will not resume */
|
|
396
396
|
abort (reason = {}, data) {
|
|
397
|
-
warn(
|
|
397
|
+
warn(33, reason.message)
|
|
398
398
|
handle(SUPPORTABILITY_METRIC_CHANNEL, [`SessionReplay/Abort/${reason.sm}`, data], undefined, FEATURE_NAMES.metrics, this.ee)
|
|
399
399
|
this.blocked = true
|
|
400
400
|
this.mode = MODE.OFF
|
|
@@ -35,7 +35,7 @@ export class Recorder {
|
|
|
35
35
|
/** Config to inform to inline stylesheet contents (true default) */
|
|
36
36
|
this.shouldInlineStylesheets = getConfigurationValue(this.parent.agentIdentifier, 'session_replay.inline_stylesheet')
|
|
37
37
|
/** A flag that can be set to false by failing conversions to stop the fetching process */
|
|
38
|
-
this.shouldFix = this.shouldInlineStylesheets
|
|
38
|
+
this.shouldFix = this.shouldInlineStylesheets && getConfigurationValue(this.parent.agentIdentifier, 'session_replay.fix_stylesheets')
|
|
39
39
|
/** The method to stop recording. This defaults to a noop, but is overwritten once the recording library is imported and initialized */
|
|
40
40
|
this.stopRecording = () => { /* no-op until set by rrweb initializer */ }
|
|
41
41
|
}
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
import { registerHandler as register } from '../../../common/event-emitter/register-handler'
|
|
7
7
|
import { parseUrl } from '../../../common/url/parse-url'
|
|
8
8
|
import { shouldCollectEvent } from '../../../common/deny-list/deny-list'
|
|
9
|
-
import { mapOwn } from '../../../common/util/map-own'
|
|
10
9
|
import { navTimingValues as navTiming } from '../../../common/timing/nav-timing'
|
|
11
10
|
import { generateUuid } from '../../../common/ids/unique-id'
|
|
12
11
|
import { Interaction } from './interaction'
|
|
@@ -668,7 +667,7 @@ export class Aggregate extends AggregateBase {
|
|
|
668
667
|
|
|
669
668
|
// make sure that newrelic[INTERACTION]() works in end handler
|
|
670
669
|
state.currentNode = root
|
|
671
|
-
|
|
670
|
+
Object.values(interaction.handlers || {}).forEach(function (cb) {
|
|
672
671
|
cb(attrs.store)
|
|
673
672
|
})
|
|
674
673
|
setCurrentNode(null)
|
|
@@ -757,7 +756,7 @@ export class Aggregate extends AggregateBase {
|
|
|
757
756
|
handle(SUPPORTABILITY_METRIC_CHANNEL, [`Spa/Interaction/${smCategory}/Duration/Ms`, Math.max((interaction.root?.end || 0) - (interaction.root?.start || 0), 0)], undefined, FEATURE_NAMES.metrics, baseEE)
|
|
758
757
|
|
|
759
758
|
scheduler?.scheduleHarvest(0)
|
|
760
|
-
if (!scheduler) warn(
|
|
759
|
+
if (!scheduler) warn(19)
|
|
761
760
|
}
|
|
762
761
|
|
|
763
762
|
function isEnabled () {
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { getInfo, getRuntime, originals } from '../../../common/config/config'
|
|
7
|
-
import { mapOwn } from '../../../common/util/map-own'
|
|
8
7
|
import { ee } from '../../../common/event-emitter/contextual-ee'
|
|
9
8
|
import { InteractionNode } from './interaction-node'
|
|
10
9
|
|
|
@@ -101,7 +100,7 @@ InteractionPrototype.finish = function finishInteraction () {
|
|
|
101
100
|
this.onFinished(this)
|
|
102
101
|
}
|
|
103
102
|
|
|
104
|
-
|
|
103
|
+
Object.entries(getInfo(interaction.agentIdentifier).jsAttributes || {}).forEach(([attr, value]) => {
|
|
105
104
|
if (!(attr in customAttrs)) customAttrs[attr] = value
|
|
106
105
|
})
|
|
107
106
|
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
import { cleanURL } from '../../../common/url/clean-url'
|
|
6
|
-
import { mapOwn } from '../../../common/util/map-own'
|
|
7
6
|
import { nullable, numeric, getAddStringContext, addCustomAttributes } from '../../../common/serialize/bel-serializer'
|
|
8
7
|
import { SharedContext } from '../../../common/context/shared-context'
|
|
9
8
|
import { getInfo } from '../../../common/config/config'
|
|
@@ -181,7 +180,7 @@ export class Serializer extends SharedContext {
|
|
|
181
180
|
// get all navTiming values except navigationStart
|
|
182
181
|
// (since its the same as interaction.start)
|
|
183
182
|
// and limit to just the first 20 values we know about
|
|
184
|
-
|
|
183
|
+
Object.values(navTiming.slice(1, 21) || {}).forEach((v) => {
|
|
185
184
|
if (v !== undefined) {
|
|
186
185
|
navTimingNode += seperator + numeric(v - prev)
|
|
187
186
|
seperator = ','
|
|
@@ -2,7 +2,7 @@ import { FeatureBase } from './feature-base'
|
|
|
2
2
|
import { getInfo, isConfigured, getRuntime } from '../../common/config/config'
|
|
3
3
|
import { configure } from '../../loaders/configure/configure'
|
|
4
4
|
import { gosCDN } from '../../common/window/nreum'
|
|
5
|
-
import { drain } from '../../common/drain/drain'
|
|
5
|
+
import { deregisterDrain, drain } from '../../common/drain/drain'
|
|
6
6
|
import { activatedFeatures } from '../../common/util/feature-flags'
|
|
7
7
|
|
|
8
8
|
export class AggregateBase extends FeatureBase {
|
|
@@ -34,6 +34,8 @@ export class AggregateBase extends FeatureBase {
|
|
|
34
34
|
})
|
|
35
35
|
return flagsPromise.catch(err => {
|
|
36
36
|
this.ee.emit('internal-error', [err])
|
|
37
|
+
this.blocked = true
|
|
38
|
+
deregisterDrain(this.agentIdentifier, this.featureName)
|
|
37
39
|
})
|
|
38
40
|
}
|
|
39
41
|
|
|
@@ -49,7 +51,8 @@ export class AggregateBase extends FeatureBase {
|
|
|
49
51
|
checkConfiguration () {
|
|
50
52
|
// NOTE: This check has to happen at aggregator load time
|
|
51
53
|
if (!isConfigured(this.agentIdentifier)) {
|
|
52
|
-
|
|
54
|
+
const cdn = gosCDN()
|
|
55
|
+
let jsAttributes = { ...cdn.info?.jsAttributes }
|
|
53
56
|
try {
|
|
54
57
|
jsAttributes = {
|
|
55
58
|
...jsAttributes,
|
|
@@ -59,9 +62,9 @@ export class AggregateBase extends FeatureBase {
|
|
|
59
62
|
// do nothing
|
|
60
63
|
}
|
|
61
64
|
configure({ agentIdentifier: this.agentIdentifier }, {
|
|
62
|
-
...
|
|
65
|
+
...cdn,
|
|
63
66
|
info: {
|
|
64
|
-
...
|
|
67
|
+
...cdn.info,
|
|
65
68
|
jsAttributes
|
|
66
69
|
},
|
|
67
70
|
runtime: getRuntime(this.agentIdentifier)
|
|
@@ -85,7 +85,7 @@ export class InstrumentBase extends FeatureBase {
|
|
|
85
85
|
session = setupAgentSession(this.agentIdentifier)
|
|
86
86
|
}
|
|
87
87
|
} catch (e) {
|
|
88
|
-
warn(
|
|
88
|
+
warn(20, e)
|
|
89
89
|
this.ee.emit('internal-error', [e])
|
|
90
90
|
if (this.featureName === FEATURE_NAMES.sessionReplay) this.abortHandler?.() // SR should stop recording if session DNE
|
|
91
91
|
}
|
|
@@ -105,7 +105,7 @@ export class InstrumentBase extends FeatureBase {
|
|
|
105
105
|
this.featAggregate = new Aggregate(this.agentIdentifier, this.aggregator, argsObjFromInstrument)
|
|
106
106
|
loadedSuccessfully(true)
|
|
107
107
|
} catch (e) {
|
|
108
|
-
warn(
|
|
108
|
+
warn(34, e)
|
|
109
109
|
this.abortHandler?.() // undo any important alterations made to the page
|
|
110
110
|
// not supported yet but nice to do: "abort" this agent's EE for this feature specifically
|
|
111
111
|
drain(this.agentIdentifier, this.featureName, true)
|
|
@@ -18,12 +18,12 @@ export function lazyFeatureLoader (featureName, featurePart) {
|
|
|
18
18
|
return import(/* webpackChunkName: "ajax-aggregate" */ '../ajax/aggregate')
|
|
19
19
|
case FEATURE_NAMES.jserrors:
|
|
20
20
|
return import(/* webpackChunkName: "jserrors-aggregate" */ '../jserrors/aggregate')
|
|
21
|
+
case FEATURE_NAMES.genericEvents:
|
|
22
|
+
return import(/* webpackChunkName: "generic_events-aggregate" */ '../generic_events/aggregate')
|
|
21
23
|
case FEATURE_NAMES.logging:
|
|
22
24
|
return import(/* webpackChunkName: "logging-aggregate" */ '../logging/aggregate')
|
|
23
25
|
case FEATURE_NAMES.metrics:
|
|
24
26
|
return import(/* webpackChunkName: "metrics-aggregate" */ '../metrics/aggregate')
|
|
25
|
-
case FEATURE_NAMES.pageAction:
|
|
26
|
-
return import(/* webpackChunkName: "page_action-aggregate" */ '../page_action/aggregate')
|
|
27
27
|
case FEATURE_NAMES.pageViewEvent:
|
|
28
28
|
return import(/* webpackChunkName: "page_view_event-aggregate" */ '../page_view_event/aggregate')
|
|
29
29
|
case FEATURE_NAMES.pageViewTiming:
|
package/src/index.js
CHANGED
|
@@ -4,9 +4,12 @@ export { MicroAgent } from './loaders/micro-agent'
|
|
|
4
4
|
|
|
5
5
|
export { Ajax } from './features/ajax'
|
|
6
6
|
export { JSErrors } from './features/jserrors'
|
|
7
|
+
export { GenericEvents } from './features/generic_events'
|
|
8
|
+
export { Logging } from './features/logging'
|
|
7
9
|
export { Metrics } from './features/metrics'
|
|
8
10
|
export { PageAction } from './features/page_action'
|
|
9
11
|
export { PageViewEvent } from './features/page_view_event'
|
|
10
12
|
export { PageViewTiming } from './features/page_view_timing'
|
|
11
13
|
export { SessionTrace } from './features/session_trace'
|
|
14
|
+
export { SessionReplay } from './features/session_replay'
|
|
12
15
|
export { Spa } from './features/spa'
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import { warn } from '../common/util/console'
|
|
4
4
|
import { SR_EVENT_EMITTER_TYPES } from '../features/session_replay/constants'
|
|
5
5
|
import { generateRandomHexString } from '../common/ids/unique-id'
|
|
6
|
-
import { ee } from '../common/event-emitter/contextual-ee'
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* @typedef {import('./api/interaction-types').InteractionInstance} InteractionInstance
|
|
@@ -14,9 +13,6 @@ export class AgentBase {
|
|
|
14
13
|
|
|
15
14
|
constructor (agentIdentifier = generateRandomHexString(16)) {
|
|
16
15
|
this.agentIdentifier = agentIdentifier
|
|
17
|
-
|
|
18
|
-
// Assign the observation context to the event emitter, so it knows how to create observation contexts
|
|
19
|
-
this.ee = ee.get(agentIdentifier)
|
|
20
16
|
}
|
|
21
17
|
|
|
22
18
|
/**
|
|
@@ -25,7 +21,7 @@ export class AgentBase {
|
|
|
25
21
|
* @param {...any} args
|
|
26
22
|
*/
|
|
27
23
|
#callMethod (methodName, ...args) {
|
|
28
|
-
if (typeof this.api?.[methodName] !== 'function') warn(
|
|
24
|
+
if (typeof this.api?.[methodName] !== 'function') warn(35, methodName)
|
|
29
25
|
else return this.api[methodName](...args)
|
|
30
26
|
}
|
|
31
27
|
|
package/src/loaders/agent.js
CHANGED
|
@@ -13,7 +13,6 @@ import { Instrument as PageViewEvent } from '../features/page_view_event/instrum
|
|
|
13
13
|
import { Aggregator } from '../common/aggregate/aggregator'
|
|
14
14
|
import { gosNREUM, setNREUMInitializedAgent } from '../common/window/nreum'
|
|
15
15
|
import { warn } from '../common/util/console'
|
|
16
|
-
import { stringify } from '../common/util/stringify'
|
|
17
16
|
import { globalScope } from '../common/constants/runtime'
|
|
18
17
|
|
|
19
18
|
/**
|
|
@@ -31,7 +30,7 @@ export class Agent extends AgentBase {
|
|
|
31
30
|
if (!globalScope) {
|
|
32
31
|
// We could not determine the runtime environment. Short-circuite the agent here
|
|
33
32
|
// to avoid possible exceptions later that may cause issues with customer's application.
|
|
34
|
-
warn(
|
|
33
|
+
warn(21)
|
|
35
34
|
return
|
|
36
35
|
}
|
|
37
36
|
|
|
@@ -74,12 +73,12 @@ export class Agent extends AgentBase {
|
|
|
74
73
|
|
|
75
74
|
const dependencies = getFeatureDependencyNames(InstrumentCtor.featureName)
|
|
76
75
|
const hasAllDeps = dependencies.every(featName => featName in this.features) // any other feature(s) this depends on should've been initialized on prior iterations by priority order
|
|
77
|
-
if (!hasAllDeps) warn(
|
|
76
|
+
if (!hasAllDeps) warn(36, InstrumentCtor.featureName)
|
|
78
77
|
|
|
79
78
|
this.features[InstrumentCtor.featureName] = new InstrumentCtor(this.agentIdentifier, this.sharedAggregator)
|
|
80
79
|
})
|
|
81
80
|
} catch (err) {
|
|
82
|
-
warn(
|
|
81
|
+
warn(22, err)
|
|
83
82
|
for (const featName in this.features) { // this.features hold only features that have been instantiated
|
|
84
83
|
this.features[featName].abortHandler?.()
|
|
85
84
|
}
|