@newrelic/browser-agent 1.316.0 → 1.317.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 +15 -0
- package/dist/cjs/common/config/init-types.js +1 -0
- package/dist/cjs/common/config/init.js +6 -4
- package/dist/cjs/common/constants/env.cdn.js +2 -2
- package/dist/cjs/common/constants/env.npm.js +2 -2
- package/dist/cjs/common/constants/events.js +26 -0
- package/dist/cjs/common/harvest/harvester.js +12 -4
- package/dist/cjs/common/payloads/payloads.js +127 -0
- package/dist/cjs/common/serialize/bel-serializer.js +4 -3
- package/dist/cjs/common/util/data-size.js +2 -2
- package/dist/cjs/common/util/obfuscate.js +147 -3
- package/dist/cjs/common/wrap/wrap-websocket.js +2 -1
- package/dist/cjs/common/wrap/wrap-xhr.js +1 -1
- package/dist/cjs/features/ajax/aggregate/gql.js +40 -1
- package/dist/cjs/features/ajax/aggregate/index.js +51 -13
- package/dist/cjs/features/ajax/constants.js +6 -1
- package/dist/cjs/features/ajax/instrument/index.js +105 -17
- package/dist/cjs/features/generic_events/aggregate/index.js +15 -10
- package/dist/cjs/features/generic_events/constants.js +3 -2
- package/dist/cjs/features/jserrors/aggregate/format-stack-trace.js +2 -2
- package/dist/cjs/features/jserrors/aggregate/index.js +12 -3
- package/dist/cjs/features/logging/aggregate/index.js +7 -3
- package/dist/cjs/features/metrics/aggregate/index.js +5 -1
- package/dist/cjs/features/page_view_event/aggregate/index.js +7 -3
- package/dist/cjs/features/page_view_timing/aggregate/index.js +6 -1
- package/dist/cjs/features/session_replay/aggregate/index.js +7 -1
- package/dist/cjs/features/session_trace/aggregate/index.js +6 -2
- package/dist/cjs/features/soft_navigations/aggregate/ajax-node.js +36 -5
- package/dist/cjs/features/soft_navigations/aggregate/index.js +7 -1
- package/dist/cjs/features/soft_navigations/aggregate/initial-page-load-interaction.js +1 -1
- package/dist/cjs/features/soft_navigations/aggregate/interaction.js +6 -4
- package/dist/cjs/features/utils/aggregate-base.js +2 -3
- package/dist/esm/common/config/init-types.js +1 -0
- package/dist/esm/common/config/init.js +3 -1
- package/dist/esm/common/constants/env.cdn.js +2 -2
- package/dist/esm/common/constants/env.npm.js +2 -2
- package/dist/esm/common/constants/events.js +20 -0
- package/dist/esm/common/harvest/harvester.js +12 -4
- package/dist/esm/common/payloads/payloads.js +118 -0
- package/dist/esm/common/serialize/bel-serializer.js +4 -3
- package/dist/esm/common/util/data-size.js +2 -2
- package/dist/esm/common/util/obfuscate.js +147 -3
- package/dist/esm/common/wrap/wrap-websocket.js +2 -1
- package/dist/esm/common/wrap/wrap-xhr.js +1 -1
- package/dist/esm/features/ajax/aggregate/gql.js +39 -1
- package/dist/esm/features/ajax/aggregate/index.js +52 -14
- package/dist/esm/features/ajax/constants.js +5 -0
- package/dist/esm/features/ajax/instrument/index.js +106 -18
- package/dist/esm/features/generic_events/aggregate/index.js +15 -10
- package/dist/esm/features/generic_events/constants.js +3 -2
- package/dist/esm/features/jserrors/aggregate/format-stack-trace.js +2 -2
- package/dist/esm/features/jserrors/aggregate/index.js +12 -3
- package/dist/esm/features/logging/aggregate/index.js +7 -3
- package/dist/esm/features/metrics/aggregate/index.js +5 -1
- package/dist/esm/features/page_view_event/aggregate/index.js +7 -3
- package/dist/esm/features/page_view_timing/aggregate/index.js +6 -1
- package/dist/esm/features/session_replay/aggregate/index.js +7 -1
- package/dist/esm/features/session_trace/aggregate/index.js +6 -2
- package/dist/esm/features/soft_navigations/aggregate/ajax-node.js +36 -5
- package/dist/esm/features/soft_navigations/aggregate/index.js +7 -1
- package/dist/esm/features/soft_navigations/aggregate/initial-page-load-interaction.js +1 -1
- package/dist/esm/features/soft_navigations/aggregate/interaction.js +6 -4
- package/dist/esm/features/utils/aggregate-base.js +2 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/common/config/init-types.d.ts +4 -0
- package/dist/types/common/config/init-types.d.ts.map +1 -1
- package/dist/types/common/config/init.d.ts.map +1 -1
- package/dist/types/common/constants/events.d.ts +16 -0
- package/dist/types/common/constants/events.d.ts.map +1 -0
- package/dist/types/common/harvest/harvester.d.ts +4 -1
- package/dist/types/common/harvest/harvester.d.ts.map +1 -1
- package/dist/types/common/payloads/payloads.d.ts +42 -0
- package/dist/types/common/payloads/payloads.d.ts.map +1 -0
- package/dist/types/common/serialize/bel-serializer.d.ts +1 -1
- package/dist/types/common/serialize/bel-serializer.d.ts.map +1 -1
- package/dist/types/common/util/obfuscate.d.ts +23 -2
- package/dist/types/common/util/obfuscate.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-websocket.d.ts.map +1 -1
- package/dist/types/features/ajax/aggregate/gql.d.ts +8 -0
- package/dist/types/features/ajax/aggregate/gql.d.ts.map +1 -1
- package/dist/types/features/ajax/aggregate/index.d.ts +2 -0
- package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/ajax/constants.d.ts +5 -0
- package/dist/types/features/ajax/constants.d.ts.map +1 -1
- package/dist/types/features/ajax/instrument/index.d.ts.map +1 -1
- package/dist/types/features/generic_events/aggregate/index.d.ts +3 -1
- package/dist/types/features/generic_events/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/generic_events/constants.d.ts.map +1 -1
- package/dist/types/features/jserrors/aggregate/index.d.ts +8 -1
- package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/logging/aggregate/index.d.ts +3 -1
- package/dist/types/features/logging/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/metrics/aggregate/index.d.ts +2 -0
- package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/page_view_event/aggregate/index.d.ts +2 -0
- 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 +2 -0
- package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/aggregate/index.d.ts +2 -0
- package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_trace/aggregate/index.d.ts +2 -0
- package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/soft_navigations/aggregate/ajax-node.d.ts +6 -1
- package/dist/types/features/soft_navigations/aggregate/ajax-node.d.ts.map +1 -1
- package/dist/types/features/soft_navigations/aggregate/index.d.ts +3 -0
- package/dist/types/features/soft_navigations/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/soft_navigations/aggregate/interaction.d.ts +3 -1
- package/dist/types/features/soft_navigations/aggregate/interaction.d.ts.map +1 -1
- package/dist/types/features/utils/aggregate-base.d.ts +0 -1
- package/dist/types/features/utils/aggregate-base.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/common/config/init-types.js +1 -0
- package/src/common/config/init.js +2 -1
- package/src/common/constants/events.js +20 -0
- package/src/common/harvest/harvester.js +11 -4
- package/src/common/payloads/payloads.js +135 -0
- package/src/common/serialize/bel-serializer.js +4 -3
- package/src/common/util/data-size.js +2 -2
- package/src/common/util/obfuscate.js +154 -3
- package/src/common/wrap/wrap-websocket.js +2 -1
- package/src/common/wrap/wrap-xhr.js +1 -1
- package/src/features/ajax/aggregate/gql.js +42 -1
- package/src/features/ajax/aggregate/index.js +43 -13
- package/src/features/ajax/constants.js +5 -1
- package/src/features/ajax/instrument/index.js +114 -18
- package/src/features/generic_events/aggregate/index.js +14 -9
- package/src/features/generic_events/constants.js +3 -2
- package/src/features/jserrors/aggregate/format-stack-trace.js +3 -3
- package/src/features/jserrors/aggregate/index.js +12 -3
- package/src/features/logging/aggregate/index.js +7 -6
- package/src/features/metrics/aggregate/index.js +5 -1
- package/src/features/page_view_event/aggregate/index.js +6 -2
- package/src/features/page_view_timing/aggregate/index.js +6 -1
- package/src/features/session_replay/aggregate/index.js +7 -1
- package/src/features/session_trace/aggregate/index.js +6 -2
- package/src/features/soft_navigations/aggregate/ajax-node.js +26 -5
- package/src/features/soft_navigations/aggregate/index.js +7 -1
- package/src/features/soft_navigations/aggregate/initial-page-load-interaction.js +1 -1
- package/src/features/soft_navigations/aggregate/interaction.js +6 -4
- package/src/features/utils/aggregate-base.js +1 -3
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
import { addCustomAttributes, getAddStringContext, nullable, numeric } from '../../../common/serialize/bel-serializer'
|
|
6
|
+
import { createStringAdders } from '../../../common/payloads/payloads'
|
|
6
7
|
import { AJAX_ID } from '../../ajax/constants'
|
|
7
8
|
import { NODE_TYPE } from '../constants'
|
|
8
9
|
import { BelNode } from './bel-node'
|
|
@@ -25,6 +26,13 @@ export class AjaxNode extends BelNode {
|
|
|
25
26
|
this.targetAttributes = ajaxEvent.targetAttributes
|
|
26
27
|
this[AJAX_ID] = ajaxEvent[AJAX_ID] // all AjaxRequest events should have a unique identifier to allow for easier grouping and analysis in the UI
|
|
27
28
|
|
|
29
|
+
// optional payload metadata attributes
|
|
30
|
+
this.requestBody = ajaxEvent.requestBody
|
|
31
|
+
this.requestHeaders = ajaxEvent.requestHeaders
|
|
32
|
+
this.requestQuery = ajaxEvent.requestQuery
|
|
33
|
+
this.responseBody = ajaxEvent.responseBody
|
|
34
|
+
this.responseHeaders = ajaxEvent.responseHeaders
|
|
35
|
+
|
|
28
36
|
this.start = ajaxEvent.startTime
|
|
29
37
|
this.end = ajaxEvent.endTime
|
|
30
38
|
if (ajaxContext?.latestLongtaskEnd) {
|
|
@@ -33,8 +41,9 @@ export class AjaxNode extends BelNode {
|
|
|
33
41
|
} else this.callbackEnd = this.end // if no long task was observed, callbackEnd is the same as end
|
|
34
42
|
}
|
|
35
43
|
|
|
36
|
-
serialize (parentStartTimestamp, agentRef) {
|
|
37
|
-
const addString = getAddStringContext
|
|
44
|
+
serialize (parentStartTimestamp, agentRef, ajaxObfuscator) {
|
|
45
|
+
const { addString, addStringWithTruncation } = createStringAdders(getAddStringContext, ajaxObfuscator)
|
|
46
|
+
|
|
38
47
|
const nodeList = []
|
|
39
48
|
|
|
40
49
|
// IMPORTANT: The order in which addString is called matters and correlates to the order in which string shows up in the harvest payload. Do not re-order the following code.
|
|
@@ -55,11 +64,23 @@ export class AjaxNode extends BelNode {
|
|
|
55
64
|
addString(this.nodeId),
|
|
56
65
|
nullable(this.spanId, addString, true) + nullable(this.traceId, addString, true) + nullable(this.spanTimestamp, numeric)
|
|
57
66
|
]
|
|
58
|
-
|
|
59
|
-
|
|
67
|
+
// Regular attributes: obfuscate only
|
|
68
|
+
const regularAttrs = addCustomAttributes({
|
|
69
|
+
[AJAX_ID]: this[AJAX_ID],
|
|
60
70
|
...(this.targetAttributes || {}),
|
|
61
|
-
|
|
71
|
+
...(this.gql || {})
|
|
62
72
|
}, addString)
|
|
73
|
+
|
|
74
|
+
// Payload attributes: obfuscate then truncate
|
|
75
|
+
const payloadAttrs = addCustomAttributes({
|
|
76
|
+
...(this.requestBody ? { requestBody: this.requestBody } : {}),
|
|
77
|
+
...(this.requestHeaders ? { requestHeaders: this.requestHeaders } : {}),
|
|
78
|
+
...(this.requestQuery ? { requestQuery: this.requestQuery } : {}),
|
|
79
|
+
...(this.responseBody ? { responseBody: this.responseBody } : {}),
|
|
80
|
+
...(this.responseHeaders ? { responseHeaders: this.responseHeaders } : {})
|
|
81
|
+
}, addStringWithTruncation)
|
|
82
|
+
|
|
83
|
+
let allAttachedNodes = [...regularAttrs, ...payloadAttrs]
|
|
63
84
|
this.children.forEach(node => allAttachedNodes.push(node.serialize())) // no children is expected under ajax nodes at this time
|
|
64
85
|
|
|
65
86
|
fields[1] = numeric(allAttachedNodes.length)
|
|
@@ -8,10 +8,12 @@ import { webdriverDetected } from '../../../common/util/webdriver-detection'
|
|
|
8
8
|
import { loadTime } from '../../../common/vitals/load-time'
|
|
9
9
|
import { FEATURE_NAMES } from '../../../loaders/features/features'
|
|
10
10
|
import { AggregateBase } from '../../utils/aggregate-base'
|
|
11
|
+
import { Obfuscator } from '../../../common/util/obfuscate'
|
|
11
12
|
import { API_TRIGGER_NAME, FEATURE_NAME, INTERACTION_STATUS, INTERACTION_TRIGGERS, IPL_TRIGGER_NAME, NO_LONG_TASK_WINDOW, POPSTATE_MERGE_WINDOW, POPSTATE_TRIGGER } from '../constants'
|
|
12
13
|
import { AjaxNode } from './ajax-node'
|
|
13
14
|
import { InitialPageLoadInteraction } from './initial-page-load-interaction'
|
|
14
15
|
import { Interaction } from './interaction'
|
|
16
|
+
import { EVENT_TYPES } from '../../../common/constants/events'
|
|
15
17
|
|
|
16
18
|
export class Aggregate extends AggregateBase {
|
|
17
19
|
static featureName = FEATURE_NAME
|
|
@@ -20,6 +22,10 @@ export class Aggregate extends AggregateBase {
|
|
|
20
22
|
|
|
21
23
|
super.customAttributesAreSeparate = true
|
|
22
24
|
|
|
25
|
+
// Create obfuscators for browser interactions and nested AJAX requests
|
|
26
|
+
this.interactionObfuscator = new Obfuscator(agentRef, EVENT_TYPES.BI)
|
|
27
|
+
this.ajaxObfuscator = new Obfuscator(agentRef, EVENT_TYPES.AJAX)
|
|
28
|
+
|
|
23
29
|
this.interactionsToHarvest = this.events
|
|
24
30
|
this.domObserver = domObserver
|
|
25
31
|
|
|
@@ -86,7 +92,7 @@ export class Aggregate extends AggregateBase {
|
|
|
86
92
|
let firstIxnStartTime
|
|
87
93
|
const serializedIxnList = []
|
|
88
94
|
for (const interaction of eventBuffer) {
|
|
89
|
-
serializedIxnList.push(interaction.serialize(firstIxnStartTime, this.agentRef))
|
|
95
|
+
serializedIxnList.push(interaction.serialize(firstIxnStartTime, this.agentRef, this.interactionObfuscator, this.ajaxObfuscator))
|
|
90
96
|
if (firstIxnStartTime === undefined) firstIxnStartTime = Math.floor(interaction.start) // careful not to match or overwrite on 0 value!
|
|
91
97
|
}
|
|
92
98
|
return `bel.7;${serializedIxnList.join(';')}`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2020-
|
|
2
|
+
* Copyright 2020-2026 New Relic, Inc. All rights reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
import { globalScope, initialLocation } from '../../../common/constants/runtime'
|
|
@@ -133,11 +133,13 @@ export class Interaction extends BelNode {
|
|
|
133
133
|
* Serializes (BEL) the interaction data for transmission.
|
|
134
134
|
* @param {Number} firstStartTimeOfPayload timestamp
|
|
135
135
|
* @param {Agent} agentRef Pass in the agent reference directly so that the event itself doesnt need to store the pointers and ruin the evaluation of the event size by including unused object references.
|
|
136
|
+
* @param {Obfuscator} interactionObfuscator Obfuscator for BrowserInteraction event type
|
|
137
|
+
* @param {Obfuscator} ajaxObfuscator Obfuscator for AjaxRequest event type (passed to child AjaxNodes)
|
|
136
138
|
* @returns {String} A string that is the serialized representation of this interaction.
|
|
137
139
|
*/
|
|
138
|
-
serialize (firstStartTimeOfPayload, agentRef) {
|
|
140
|
+
serialize (firstStartTimeOfPayload, agentRef, interactionObfuscator, ajaxObfuscator) {
|
|
139
141
|
const isFirstIxnOfPayload = firstStartTimeOfPayload === undefined
|
|
140
|
-
const addString = getAddStringContext(
|
|
142
|
+
const addString = getAddStringContext(interactionObfuscator)
|
|
141
143
|
const nodeList = []
|
|
142
144
|
let ixnType
|
|
143
145
|
if (this.trigger === IPL_TRIGGER_NAME) ixnType = INTERACTION_TYPE.INITIAL_PAGE_LOAD
|
|
@@ -170,7 +172,7 @@ export class Interaction extends BelNode {
|
|
|
170
172
|
/* Querypack encoder+decoder quirkiness:
|
|
171
173
|
- If first ixn node of payload is being processed, its children's start time must be offset by this node's start. (firstStartTime should be undefined.)
|
|
172
174
|
- Else for subsequent ixns in the same payload, we go back to using that first ixn node's start to offset their children's start. */
|
|
173
|
-
this.children.forEach(node => allAttachedNodes.push(node.serialize(isFirstIxnOfPayload ? this.start : firstStartTimeOfPayload, agentRef))) // recursively add the serialized string of every child of this (ixn) bel node
|
|
175
|
+
this.children.forEach(node => allAttachedNodes.push(node.serialize(isFirstIxnOfPayload ? this.start : firstStartTimeOfPayload, agentRef, ajaxObfuscator))) // recursively add the serialized string of every child of this (ixn) bel node
|
|
174
176
|
|
|
175
177
|
fields[1] = numeric(allAttachedNodes.length)
|
|
176
178
|
nodeList.push(fields)
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { FeatureBase } from './feature-base'
|
|
6
6
|
import { drain } from '../../common/drain/drain'
|
|
7
|
-
import { Obfuscator } from '../../common/util/obfuscate'
|
|
8
7
|
import { FEATURE_NAMES } from '../../loaders/features/features'
|
|
9
8
|
import { Harvester } from '../../common/harvest/harvester'
|
|
10
9
|
import { EventBuffer } from './event-buffer'
|
|
@@ -182,8 +181,7 @@ export class AggregateBase extends FeatureBase {
|
|
|
182
181
|
* This method should run after checkConfiguration, which may reset the agent's info/runtime object that is used here.
|
|
183
182
|
*/
|
|
184
183
|
doOnceForAllAggregate (agentRef) {
|
|
185
|
-
|
|
186
|
-
this.obfuscator = agentRef.runtime.obfuscator
|
|
184
|
+
// Note: obfuscator is now created per-feature for their specific event types
|
|
187
185
|
|
|
188
186
|
if (!agentRef.runtime.harvester) agentRef.runtime.harvester = new Harvester(agentRef)
|
|
189
187
|
}
|