@newrelic/browser-agent 1.311.0 → 1.312.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 +14 -0
- package/dist/cjs/common/constants/agent-constants.js +4 -5
- package/dist/cjs/common/constants/env.cdn.js +2 -2
- package/dist/cjs/common/constants/env.npm.js +2 -2
- package/dist/cjs/common/util/script-tracker.js +2 -0
- package/dist/cjs/common/util/stringify.js +6 -21
- package/dist/cjs/common/util/v2.js +90 -6
- package/dist/cjs/common/wrap/wrap-fetch.js +10 -5
- package/dist/cjs/common/wrap/wrap-function.js +17 -9
- package/dist/cjs/common/wrap/wrap-logger.js +6 -4
- package/dist/cjs/common/wrap/wrap-xhr.js +3 -1
- package/dist/cjs/features/ajax/aggregate/index.js +24 -6
- package/dist/cjs/features/ajax/instrument/index.js +12 -10
- package/dist/cjs/features/generic_events/instrument/index.js +3 -3
- package/dist/cjs/features/logging/aggregate/index.js +12 -7
- package/dist/cjs/features/logging/instrument/index.js +6 -4
- package/dist/cjs/features/logging/shared/utils.js +4 -4
- package/dist/cjs/features/soft_navigations/aggregate/ajax-node.js +6 -3
- package/dist/cjs/loaders/api/register.js +24 -23
- package/dist/cjs/loaders/api/wrapLogger.js +2 -2
- package/dist/esm/common/constants/agent-constants.js +4 -5
- package/dist/esm/common/constants/env.cdn.js +2 -2
- package/dist/esm/common/constants/env.npm.js +2 -2
- package/dist/esm/common/util/script-tracker.js +2 -2
- package/dist/esm/common/util/stringify.js +6 -21
- package/dist/esm/common/util/v2.js +86 -6
- package/dist/esm/common/wrap/wrap-fetch.js +10 -5
- package/dist/esm/common/wrap/wrap-function.js +17 -9
- package/dist/esm/common/wrap/wrap-logger.js +6 -4
- package/dist/esm/common/wrap/wrap-xhr.js +3 -1
- package/dist/esm/features/ajax/aggregate/index.js +24 -6
- package/dist/esm/features/ajax/instrument/index.js +12 -10
- package/dist/esm/features/generic_events/instrument/index.js +3 -3
- package/dist/esm/features/logging/aggregate/index.js +13 -8
- package/dist/esm/features/logging/instrument/index.js +6 -4
- package/dist/esm/features/logging/shared/utils.js +4 -4
- package/dist/esm/features/soft_navigations/aggregate/ajax-node.js +6 -3
- package/dist/esm/loaders/api/register.js +24 -23
- package/dist/esm/loaders/api/wrapLogger.js +2 -2
- package/dist/types/common/constants/agent-constants.d.ts.map +1 -1
- package/dist/types/common/util/script-tracker.d.ts +11 -0
- package/dist/types/common/util/script-tracker.d.ts.map +1 -1
- package/dist/types/common/util/stringify.d.ts.map +1 -1
- package/dist/types/common/util/v2.d.ts +37 -0
- package/dist/types/common/util/v2.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-fetch.d.ts +1 -1
- package/dist/types/common/wrap/wrap-fetch.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-function.d.ts +1 -1
- package/dist/types/common/wrap/wrap-function.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-logger.d.ts +1 -1
- package/dist/types/common/wrap/wrap-logger.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-xhr.d.ts +1 -1
- package/dist/types/common/wrap/wrap-xhr.d.ts.map +1 -1
- package/dist/types/features/ajax/aggregate/index.d.ts +2 -1
- package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/ajax/instrument/index.d.ts.map +1 -1
- package/dist/types/features/logging/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/logging/instrument/index.d.ts.map +1 -1
- package/dist/types/features/logging/shared/utils.d.ts +2 -2
- package/dist/types/features/logging/shared/utils.d.ts.map +1 -1
- package/dist/types/features/soft_navigations/aggregate/ajax-node.d.ts +1 -0
- package/dist/types/features/soft_navigations/aggregate/ajax-node.d.ts.map +1 -1
- package/dist/types/loaders/api/register.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/common/constants/agent-constants.js +4 -5
- package/src/common/util/script-tracker.js +2 -2
- package/src/common/util/stringify.js +6 -23
- package/src/common/util/v2.js +84 -7
- package/src/common/wrap/wrap-fetch.js +12 -5
- package/src/common/wrap/wrap-function.js +16 -9
- package/src/common/wrap/wrap-logger.js +6 -4
- package/src/common/wrap/wrap-xhr.js +3 -1
- package/src/features/ajax/aggregate/index.js +22 -6
- package/src/features/ajax/instrument/index.js +13 -10
- package/src/features/generic_events/instrument/index.js +3 -3
- package/src/features/logging/aggregate/index.js +13 -14
- package/src/features/logging/instrument/index.js +6 -4
- package/src/features/logging/shared/utils.js +4 -4
- package/src/features/soft_navigations/aggregate/ajax-node.js +6 -3
- package/src/loaders/api/register.js +19 -12
- package/src/loaders/api/wrapLogger.js +2 -2
|
@@ -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 { addCustomAttributes, getAddStringContext, nullable, numeric } from '../../../common/serialize/bel-serializer'
|
|
@@ -21,6 +21,7 @@ export class AjaxNode extends BelNode {
|
|
|
21
21
|
this.traceId = ajaxEvent.traceId
|
|
22
22
|
this.spanTimestamp = ajaxEvent.spanTimestamp
|
|
23
23
|
this.gql = ajaxEvent.gql
|
|
24
|
+
this.targetAttributes = ajaxEvent.targetAttributes
|
|
24
25
|
|
|
25
26
|
this.start = ajaxEvent.startTime
|
|
26
27
|
this.end = ajaxEvent.endTime
|
|
@@ -52,8 +53,10 @@ export class AjaxNode extends BelNode {
|
|
|
52
53
|
addString(this.nodeId),
|
|
53
54
|
nullable(this.spanId, addString, true) + nullable(this.traceId, addString, true) + nullable(this.spanTimestamp, numeric)
|
|
54
55
|
]
|
|
55
|
-
let allAttachedNodes =
|
|
56
|
-
|
|
56
|
+
let allAttachedNodes = addCustomAttributes({
|
|
57
|
+
...(this.gql || {}),
|
|
58
|
+
...(this.targetAttributes || {})
|
|
59
|
+
}, addString)
|
|
57
60
|
this.children.forEach(node => allAttachedNodes.push(node.serialize())) // no children is expected under ajax nodes at this time
|
|
58
61
|
|
|
59
62
|
fields[1] = numeric(allAttachedNodes.length)
|
|
@@ -18,6 +18,7 @@ import { measure } from './measure'
|
|
|
18
18
|
import { recordCustomEvent } from './recordCustomEvent'
|
|
19
19
|
import { subscribeToPageUnload } from '../../common/window/page-visibility'
|
|
20
20
|
import { findScriptTimings } from '../../common/util/script-tracker'
|
|
21
|
+
import { generateRandomHexString } from '../../common/ids/unique-id'
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
* @typedef {import('./register-api-types').RegisterAPI} RegisterAPI
|
|
@@ -48,15 +49,31 @@ function register (agentRef, target, parent) {
|
|
|
48
49
|
warn(54, 'newrelic.register')
|
|
49
50
|
|
|
50
51
|
target ||= {}
|
|
52
|
+
target.instance = generateRandomHexString(8)
|
|
51
53
|
target.type = V2_TYPES.MFE
|
|
52
54
|
target.licenseKey ||= agentRef.info.licenseKey // will inherit the license key from the container agent if not provided for brevity. A future state may dictate that we need different license keys to do different things.
|
|
53
55
|
target.blocked = false
|
|
54
|
-
target.parent = parent || {}
|
|
55
56
|
if (typeof target.tags !== 'object' || target.tags === null || Array.isArray(target.tags)) target.tags = {}
|
|
57
|
+
target.parent = parent || {
|
|
58
|
+
get id () { return agentRef.runtime.appMetadata.agents[0].entityGuid }, // getter because this is asyncronously set
|
|
59
|
+
type: V2_TYPES.BA
|
|
60
|
+
}
|
|
56
61
|
|
|
57
62
|
const timings = findScriptTimings()
|
|
58
63
|
|
|
59
64
|
const attrs = {}
|
|
65
|
+
Object.defineProperty(target, 'attributes', {
|
|
66
|
+
get () {
|
|
67
|
+
return {
|
|
68
|
+
...attrs,
|
|
69
|
+
'source.id': target.id,
|
|
70
|
+
'source.name': target.name,
|
|
71
|
+
'source.type': target.type,
|
|
72
|
+
'parent.type': target.parent?.type || V2_TYPES.BA,
|
|
73
|
+
'parent.id': target.parent?.id
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
})
|
|
60
77
|
|
|
61
78
|
// Process tags object and add to attrs, excluding protected keys
|
|
62
79
|
Object.entries(target.tags).forEach(([key, value]) => {
|
|
@@ -113,7 +130,7 @@ function register (agentRef, target, parent) {
|
|
|
113
130
|
setUserId: (value) => setLocalValue('enduser.id', value),
|
|
114
131
|
/** metadata */
|
|
115
132
|
metadata: {
|
|
116
|
-
customAttributes
|
|
133
|
+
get customAttributes () { return attrs },
|
|
117
134
|
target,
|
|
118
135
|
timings
|
|
119
136
|
}
|
|
@@ -180,16 +197,6 @@ function register (agentRef, target, parent) {
|
|
|
180
197
|
const timestamp = now()
|
|
181
198
|
handle(SUPPORTABILITY_METRIC_CHANNEL, [`API/register/${methodToCall.name}/called`], undefined, FEATURE_NAMES.metrics, agentRef.ee)
|
|
182
199
|
try {
|
|
183
|
-
const shouldDuplicate = agentRef.init.api.duplicate_registered_data && methodToCall !== register
|
|
184
|
-
if (shouldDuplicate) {
|
|
185
|
-
let duplicatedArgs = args
|
|
186
|
-
if (args[1] instanceof Object) {
|
|
187
|
-
const childAttrs = { 'child.id': target.id, 'child.type': target.type }
|
|
188
|
-
if ('customAttributes' in args[1]) duplicatedArgs = [args[0], { ...args[1], customAttributes: { ...args[1].customAttributes, ...childAttrs } }, ...args.slice(2)]
|
|
189
|
-
else duplicatedArgs = [args[0], { ...args[1], ...childAttrs }, ...args.slice(2)]
|
|
190
|
-
}
|
|
191
|
-
methodToCall(...duplicatedArgs, undefined, timestamp)
|
|
192
|
-
}
|
|
193
200
|
return methodToCall(...args, target, timestamp) // always report to target
|
|
194
201
|
} catch (err) {
|
|
195
202
|
warn(50, err)
|
|
@@ -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 { wrapLogger } from '../../common/wrap/wrap-logger'
|
|
@@ -9,6 +9,6 @@ import { setupAPI } from './sharedHandlers'
|
|
|
9
9
|
|
|
10
10
|
export function setupWrapLoggerAPI (agent) {
|
|
11
11
|
setupAPI(WRAP_LOGGER, (parent, functionName, { customAttributes = {}, level = LOG_LEVELS.INFO } = {}) => {
|
|
12
|
-
wrapLogger(agent.ee, parent, functionName, { customAttributes, level }, false)
|
|
12
|
+
wrapLogger(agent.ee, parent, functionName, { customAttributes, level }, false, agent)
|
|
13
13
|
}, agent)
|
|
14
14
|
}
|