@newrelic/browser-agent 1.267.0 → 1.269.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 +28 -0
- package/README.md +2 -1
- package/dist/cjs/common/config/init.js +3 -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/dom/iframe.js +10 -0
- package/dist/cjs/common/dom/selector-path.js +48 -0
- package/dist/cjs/common/event-listener/event-listener-opts.js +4 -26
- package/dist/cjs/common/timing/time-keeper.js +9 -0
- package/dist/cjs/common/util/stringify.js +1 -1
- package/dist/cjs/features/generic_events/aggregate/index.js +80 -9
- package/dist/cjs/features/generic_events/aggregate/user-actions/aggregated-user-action.js +39 -0
- package/dist/cjs/features/generic_events/aggregate/user-actions/user-actions-aggregator.js +77 -0
- package/dist/cjs/features/generic_events/constants.js +6 -2
- package/dist/cjs/features/generic_events/instrument/index.js +12 -1
- package/dist/cjs/features/jserrors/aggregate/index.js +23 -3
- package/dist/cjs/features/jserrors/aggregate/internal-errors.js +42 -0
- package/dist/cjs/features/logging/aggregate/index.js +10 -2
- package/dist/cjs/features/metrics/aggregate/index.js +2 -1
- package/dist/cjs/features/page_view_event/aggregate/index.js +1 -1
- package/dist/cjs/features/session_replay/aggregate/index.js +5 -3
- package/dist/cjs/features/session_trace/aggregate/index.js +11 -9
- package/dist/cjs/features/spa/instrument/index.js +4 -0
- package/dist/cjs/loaders/agent-base.js +1 -0
- package/dist/cjs/loaders/micro-agent.js +1 -1
- package/dist/esm/common/config/init.js +3 -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/dom/iframe.js +4 -0
- package/dist/esm/common/dom/selector-path.js +41 -0
- package/dist/esm/common/event-listener/event-listener-opts.js +4 -27
- package/dist/esm/common/timing/time-keeper.js +9 -0
- package/dist/esm/common/util/stringify.js +1 -1
- package/dist/esm/features/generic_events/aggregate/index.js +82 -11
- package/dist/esm/features/generic_events/aggregate/user-actions/aggregated-user-action.js +32 -0
- package/dist/esm/features/generic_events/aggregate/user-actions/user-actions-aggregator.js +70 -0
- package/dist/esm/features/generic_events/constants.js +5 -1
- package/dist/esm/features/generic_events/instrument/index.js +14 -3
- package/dist/esm/features/jserrors/aggregate/index.js +23 -3
- package/dist/esm/features/jserrors/aggregate/internal-errors.js +36 -0
- package/dist/esm/features/logging/aggregate/index.js +10 -2
- package/dist/esm/features/metrics/aggregate/index.js +2 -1
- package/dist/esm/features/page_view_event/aggregate/index.js +1 -1
- package/dist/esm/features/session_replay/aggregate/index.js +5 -3
- package/dist/esm/features/session_trace/aggregate/index.js +11 -9
- package/dist/esm/features/spa/instrument/index.js +4 -0
- package/dist/esm/loaders/agent-base.js +1 -0
- package/dist/esm/loaders/micro-agent.js +1 -1
- package/dist/types/common/config/init.d.ts.map +1 -1
- package/dist/types/common/dom/iframe.d.ts +2 -0
- package/dist/types/common/dom/iframe.d.ts.map +1 -0
- package/dist/types/common/dom/selector-path.d.ts +2 -0
- package/dist/types/common/dom/selector-path.d.ts.map +1 -0
- package/dist/types/common/event-listener/event-listener-opts.d.ts +2 -2
- package/dist/types/common/event-listener/event-listener-opts.d.ts.map +1 -1
- package/dist/types/common/timing/time-keeper.d.ts +6 -0
- package/dist/types/common/timing/time-keeper.d.ts.map +1 -1
- package/dist/types/features/generic_events/aggregate/index.d.ts +16 -1
- package/dist/types/features/generic_events/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/generic_events/aggregate/user-actions/aggregated-user-action.d.ts +22 -0
- package/dist/types/features/generic_events/aggregate/user-actions/aggregated-user-action.d.ts.map +1 -0
- package/dist/types/features/generic_events/aggregate/user-actions/user-actions-aggregator.d.ts +12 -0
- package/dist/types/features/generic_events/aggregate/user-actions/user-actions-aggregator.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 -1
- package/dist/types/features/generic_events/instrument/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/aggregate/index.d.ts +10 -1
- package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/aggregate/internal-errors.d.ts +7 -0
- package/dist/types/features/jserrors/aggregate/internal-errors.d.ts.map +1 -0
- package/dist/types/features/logging/aggregate/index.d.ts +3 -0
- package/dist/types/features/logging/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/metrics/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/session_replay/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/spa/instrument/index.d.ts +3 -0
- package/dist/types/features/spa/instrument/index.d.ts.map +1 -1
- package/dist/types/loaders/agent-base.d.ts +1 -0
- package/dist/types/loaders/agent-base.d.ts.map +1 -1
- package/dist/types/loaders/micro-agent.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/common/config/init.js +1 -0
- package/src/common/dom/iframe.js +4 -0
- package/src/common/dom/selector-path.js +45 -0
- package/src/common/event-listener/event-listener-opts.js +5 -30
- package/src/common/timing/__mocks__/time-keeper.js +1 -0
- package/src/common/timing/time-keeper.js +9 -0
- package/src/common/util/stringify.js +1 -1
- package/src/features/generic_events/aggregate/index.js +74 -14
- package/src/features/generic_events/aggregate/user-actions/aggregated-user-action.js +33 -0
- package/src/features/generic_events/aggregate/user-actions/user-actions-aggregator.js +73 -0
- package/src/features/generic_events/constants.js +6 -0
- package/src/features/generic_events/instrument/index.js +19 -3
- package/src/features/jserrors/aggregate/index.js +21 -7
- package/src/features/jserrors/aggregate/internal-errors.js +33 -0
- package/src/features/logging/aggregate/index.js +9 -4
- package/src/features/metrics/aggregate/index.js +2 -1
- package/src/features/page_view_event/aggregate/index.js +1 -3
- package/src/features/session_replay/aggregate/index.js +5 -7
- package/src/features/session_trace/aggregate/index.js +12 -16
- package/src/features/spa/instrument/index.js +3 -0
- package/src/loaders/agent-base.js +1 -0
- package/src/loaders/micro-agent.js +2 -1
|
@@ -11,6 +11,7 @@ import { deregisterDrain } from '../../../common/drain/drain'
|
|
|
11
11
|
import { globalScope } from '../../../common/constants/runtime'
|
|
12
12
|
import { MODE, SESSION_EVENTS } from '../../../common/session/constants'
|
|
13
13
|
import { applyFnToProps } from '../../../common/util/traverse'
|
|
14
|
+
import { cleanURL } from '../../../common/url/clean-url'
|
|
14
15
|
|
|
15
16
|
const ERROR_MODE_SECONDS_WINDOW = 30 * 1000 // sliding window of nodes to track when simply monitoring (but not harvesting) in error mode
|
|
16
17
|
/** Reserved room for query param attrs */
|
|
@@ -63,6 +64,12 @@ export class Aggregate extends AggregateBase {
|
|
|
63
64
|
// if another page's session entity has expired, or another page has transitioned to off and this one hasn't... we can just abort straight away here
|
|
64
65
|
if (this.sessionId !== sessionState.value || (eventType === 'cross-tab' && this.scheduler?.started && sessionState.sessionTraceMode === MODE.OFF)) this.abort(2)
|
|
65
66
|
})
|
|
67
|
+
|
|
68
|
+
if (typeof PerformanceNavigationTiming !== 'undefined') {
|
|
69
|
+
this.traceStorage.storeTiming(globalScope.performance?.getEntriesByType?.('navigation')[0])
|
|
70
|
+
} else {
|
|
71
|
+
this.traceStorage.storeTiming(globalScope.performance?.timing, true)
|
|
72
|
+
}
|
|
66
73
|
}
|
|
67
74
|
|
|
68
75
|
/** ST/SR sampling flow in BCS - https://drive.google.com/file/d/19hwt2oft-8Hh4RrjpLqEXfpP_9wYBLcq/view?usp=sharing */
|
|
@@ -92,12 +99,6 @@ export class Aggregate extends AggregateBase {
|
|
|
92
99
|
registerHandler('trace-jserror', (...args) => this.traceStorage.storeErrorAgg(...args), this.featureName, this.ee)
|
|
93
100
|
registerHandler('pvtAdded', (...args) => this.traceStorage.processPVT(...args), this.featureName, this.ee)
|
|
94
101
|
|
|
95
|
-
if (typeof PerformanceNavigationTiming !== 'undefined') {
|
|
96
|
-
this.traceStorage.storeTiming(globalScope.performance?.getEntriesByType?.('navigation')[0])
|
|
97
|
-
} else {
|
|
98
|
-
this.traceStorage.storeTiming(globalScope.performance?.timing, true)
|
|
99
|
-
}
|
|
100
|
-
|
|
101
102
|
/** Only start actually harvesting if running in full mode at init time */
|
|
102
103
|
if (this.mode === MODE.FULL) this.startHarvesting()
|
|
103
104
|
else {
|
|
@@ -154,21 +155,15 @@ export class Aggregate extends AggregateBase {
|
|
|
154
155
|
type: 'BrowserSessionChunk',
|
|
155
156
|
app_id: this.agentInfo.applicationID,
|
|
156
157
|
protocol_version: '0',
|
|
157
|
-
timestamp: Math.floor(this.timeKeeper.
|
|
158
|
-
this.timeKeeper.convertRelativeTimestamp(earliestTimeStamp)
|
|
159
|
-
)),
|
|
158
|
+
timestamp: Math.floor(this.timeKeeper.correctRelativeTimestamp(earliestTimeStamp)),
|
|
160
159
|
attributes: encodeObj({
|
|
161
160
|
...(agentMetadata.entityGuid && { entityGuid: agentMetadata.entityGuid }),
|
|
162
161
|
harvestId: `${this.agentRuntime.session?.state.value}_${this.agentRuntime.ptid}_${this.agentRuntime.harvestCount}`,
|
|
163
162
|
// this section of attributes must be controllable and stay below the query param padding limit -- see QUERY_PARAM_PADDING
|
|
164
163
|
// if not, data could be lost to truncation at time of sending, potentially breaking parsing / API behavior in NR1
|
|
165
164
|
// trace payload metadata
|
|
166
|
-
'trace.firstTimestamp': Math.floor(this.timeKeeper.
|
|
167
|
-
|
|
168
|
-
)),
|
|
169
|
-
'trace.lastTimestamp': Math.floor(this.timeKeeper.correctAbsoluteTimestamp(
|
|
170
|
-
this.timeKeeper.convertRelativeTimestamp(latestTimeStamp)
|
|
171
|
-
)),
|
|
165
|
+
'trace.firstTimestamp': Math.floor(this.timeKeeper.correctRelativeTimestamp(earliestTimeStamp)),
|
|
166
|
+
'trace.lastTimestamp': Math.floor(this.timeKeeper.correctRelativeTimestamp(latestTimeStamp)),
|
|
172
167
|
'trace.nodes': stns.length,
|
|
173
168
|
'trace.originTimestamp': this.timeKeeper.correctedOriginTime,
|
|
174
169
|
// other payload metadata
|
|
@@ -178,7 +173,8 @@ export class Aggregate extends AggregateBase {
|
|
|
178
173
|
ptid: `${this.ptid}`,
|
|
179
174
|
session: `${this.sessionId}`,
|
|
180
175
|
// customer-defined data should go last so that if it exceeds the query param padding limit it will be truncated instead of important attrs
|
|
181
|
-
...(endUserId && { 'enduser.id': this.obfuscator.obfuscateString(endUserId) })
|
|
176
|
+
...(endUserId && { 'enduser.id': this.obfuscator.obfuscateString(endUserId) }),
|
|
177
|
+
currentUrl: this.obfuscator.obfuscateString(cleanURL('' + location))
|
|
182
178
|
// The Query Param is being arbitrarily limited in length here. It is also applied when estimating the size of the payload in getPayloadSize()
|
|
183
179
|
}, QUERY_PARAM_PADDING).substring(1) // remove the leading '&'
|
|
184
180
|
},
|
|
@@ -20,6 +20,9 @@ const {
|
|
|
20
20
|
FEATURE_NAME, START, END, BODY, CB_END, JS_TIME, FETCH, FN_START, CB_START, FN_END
|
|
21
21
|
} = CONSTANTS
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated This feature has been deprecated, in favor of `soft_navigations`, which is in limited preview. Consider using/importing `SoftNavigations` instead. To gain access to the limited preview, please see https://docs.newrelic.com/docs/browser/single-page-app-monitoring/get-started/browser-spa-v2/ for more information. This feature will be removed in a future release.
|
|
25
|
+
*/
|
|
23
26
|
export class Instrument extends InstrumentBase {
|
|
24
27
|
static featureName = FEATURE_NAME
|
|
25
28
|
constructor (agentIdentifier, aggregator, auto = true) {
|
|
@@ -173,6 +173,7 @@ export class AgentBase {
|
|
|
173
173
|
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/interaction/}
|
|
174
174
|
* @returns {InteractionInstance} An API object that is bound to a specific BrowserInteraction event. Each time this method is called for the same BrowserInteraction, a new object is created, but it still references the same interaction.
|
|
175
175
|
* - Note: Does not apply to MicroAgent
|
|
176
|
+
* - Deprecation Notice: interaction.createTracer is deprecated. See https://docs.newrelic.com/eol/2024/04/eol-04-24-24-createtracer/ for more information.
|
|
176
177
|
*/
|
|
177
178
|
interaction () {
|
|
178
179
|
return this.#callMethod('interaction')
|