@newrelic/browser-agent 1.246.1 → 1.247.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 +12 -0
- package/README.md +10 -2
- package/dist/cjs/common/config/state/info.js +2 -1
- package/dist/cjs/common/config/state/init.js +2 -1
- package/dist/cjs/common/config/state/loader-config.js +2 -1
- package/dist/cjs/common/config/state/runtime.js +2 -1
- 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 -1
- package/dist/cjs/common/dispatch/global-event.js +19 -0
- package/dist/cjs/common/session/session-entity.js +14 -9
- package/dist/cjs/common/util/feature-flags.js +17 -12
- package/dist/cjs/common/window/load.js +1 -0
- package/dist/cjs/common/window/nreum.js +18 -17
- package/dist/cjs/features/metrics/aggregate/index.js +4 -2
- package/dist/cjs/features/session_replay/aggregate/index.js +56 -16
- package/dist/cjs/features/session_trace/aggregate/index.js +32 -18
- package/dist/cjs/features/spa/aggregate/index.js +2 -1
- package/dist/cjs/features/utils/aggregate-base.js +3 -1
- package/dist/cjs/loaders/agent-base.js +19 -0
- package/dist/cjs/loaders/agent.js +6 -4
- package/dist/cjs/loaders/api/api.js +10 -1
- package/dist/cjs/loaders/configure/configure.js +14 -13
- package/dist/cjs/loaders/configure/nonce.js +13 -0
- package/dist/cjs/loaders/configure/nonce.npm.js +2 -0
- package/dist/cjs/loaders/micro-agent.js +5 -4
- package/dist/esm/common/config/state/info.js +3 -2
- package/dist/esm/common/config/state/init.js +3 -2
- package/dist/esm/common/config/state/loader-config.js +3 -2
- package/dist/esm/common/config/state/runtime.js +3 -2
- 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 -0
- package/dist/esm/common/dispatch/global-event.js +13 -0
- package/dist/esm/common/session/session-entity.js +14 -9
- package/dist/esm/common/util/feature-flags.js +17 -12
- package/dist/esm/common/window/load.js +1 -1
- package/dist/esm/common/window/nreum.js +16 -16
- package/dist/esm/features/metrics/aggregate/index.js +4 -2
- package/dist/esm/features/session_replay/aggregate/index.js +56 -16
- package/dist/esm/features/session_trace/aggregate/index.js +32 -18
- package/dist/esm/features/spa/aggregate/index.js +2 -1
- package/dist/esm/features/utils/aggregate-base.js +3 -1
- package/dist/esm/loaders/agent-base.js +19 -0
- package/dist/esm/loaders/agent.js +7 -5
- package/dist/esm/loaders/api/api.js +10 -1
- package/dist/esm/loaders/configure/configure.js +15 -14
- package/dist/esm/loaders/configure/nonce.js +11 -0
- package/dist/esm/loaders/configure/nonce.npm.js +1 -0
- package/dist/esm/loaders/micro-agent.js +6 -5
- package/dist/types/common/config/state/info.d.ts.map +1 -1
- package/dist/types/common/config/state/init.d.ts.map +1 -1
- package/dist/types/common/config/state/loader-config.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 -0
- package/dist/types/common/constants/runtime.d.ts.map +1 -1
- package/dist/types/common/dispatch/global-event.d.ts +2 -0
- package/dist/types/common/dispatch/global-event.d.ts.map +1 -0
- package/dist/types/common/session/session-entity.d.ts +1 -0
- package/dist/types/common/session/session-entity.d.ts.map +1 -1
- package/dist/types/common/util/feature-flags.d.ts.map +1 -1
- package/dist/types/common/window/load.d.ts +1 -0
- package/dist/types/common/window/load.d.ts.map +1 -1
- package/dist/types/common/window/nreum.d.ts +7 -1
- package/dist/types/common/window/nreum.d.ts.map +1 -1
- package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/aggregate/index.d.ts +11 -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/aggregate/index.d.ts.map +1 -1
- package/dist/types/loaders/agent-base.d.ts +13 -0
- 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 +2 -0
- package/dist/types/loaders/api/api.d.ts.map +1 -1
- package/dist/types/loaders/configure/configure.d.ts +4 -11
- package/dist/types/loaders/configure/configure.d.ts.map +1 -1
- package/dist/types/loaders/configure/nonce.d.ts +1 -0
- package/dist/types/loaders/configure/nonce.d.ts.map +1 -0
- package/dist/types/loaders/configure/nonce.npm.d.ts +1 -0
- package/dist/types/loaders/configure/nonce.npm.d.ts.map +1 -0
- package/dist/types/loaders/micro-agent.d.ts +2 -2
- package/dist/types/loaders/micro-agent.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/common/config/state/info.js +3 -2
- package/src/common/config/state/init.js +3 -2
- package/src/common/config/state/loader-config.js +3 -2
- package/src/common/config/state/runtime.js +3 -2
- package/src/common/constants/runtime.js +2 -0
- package/src/common/dispatch/global-event.js +12 -0
- package/src/common/session/session-entity.js +13 -9
- package/src/common/util/feature-flags.js +15 -12
- package/src/common/window/__mocks__/nreum.js +2 -1
- package/src/common/window/load.js +1 -1
- package/src/common/window/nreum.js +15 -18
- package/src/features/metrics/aggregate/index.js +5 -1
- package/src/features/session_replay/aggregate/index.js +63 -20
- package/src/features/session_trace/aggregate/index.js +31 -14
- package/src/features/spa/aggregate/index.js +2 -1
- package/src/features/utils/aggregate-base.js +1 -1
- package/src/loaders/agent-base.js +19 -0
- package/src/loaders/agent.js +5 -5
- package/src/loaders/api/api.js +12 -1
- package/src/loaders/configure/configure.js +17 -15
- package/src/loaders/configure/nonce.js +12 -0
- package/src/loaders/configure/nonce.npm.js +1 -0
- package/src/loaders/micro-agent.js +5 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { setAPI, setTopLevelCallers } from '../api/api'
|
|
2
|
-
import { addToNREUM, gosCDN
|
|
2
|
+
import { addToNREUM, gosCDN } from '../../common/window/nreum'
|
|
3
3
|
import { getConfiguration, setConfiguration, setInfo, setLoaderConfig, setRuntime } from '../../common/config/config'
|
|
4
4
|
import { activatedFeatures } from '../../common/util/feature-flags'
|
|
5
5
|
import { isWorkerScope } from '../../common/constants/runtime'
|
|
@@ -7,7 +7,10 @@ import { redefinePublicPath } from './public-path'
|
|
|
7
7
|
|
|
8
8
|
let alreadySetOnce = false // the configure() function can run multiple times in agent lifecycle
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Sets or re-sets the agent's configuration values from global settings. This also attach those as properties to the agent instance.
|
|
12
|
+
*/
|
|
13
|
+
export function configure (agent, opts = {}, loaderType, forceDrain) {
|
|
11
14
|
// eslint-disable-next-line camelcase
|
|
12
15
|
let { init, info, loader_config, runtime = { loaderType }, exposed = true } = opts
|
|
13
16
|
const nr = gosCDN()
|
|
@@ -18,38 +21,37 @@ export function configure (agentIdentifier, opts = {}, loaderType, forceDrain) {
|
|
|
18
21
|
loader_config = nr.loader_config
|
|
19
22
|
}
|
|
20
23
|
|
|
21
|
-
setConfiguration(agentIdentifier, init || {})
|
|
24
|
+
setConfiguration(agent.agentIdentifier, init || {})
|
|
22
25
|
// eslint-disable-next-line camelcase
|
|
23
|
-
setLoaderConfig(agentIdentifier, loader_config || {})
|
|
26
|
+
setLoaderConfig(agent.agentIdentifier, loader_config || {})
|
|
24
27
|
|
|
25
28
|
info.jsAttributes ??= {}
|
|
26
29
|
if (isWorkerScope) { // add a default attr to all worker payloads
|
|
27
30
|
info.jsAttributes.isWorker = true
|
|
28
31
|
}
|
|
29
|
-
setInfo(agentIdentifier, info)
|
|
32
|
+
setInfo(agent.agentIdentifier, info)
|
|
30
33
|
|
|
31
|
-
const updatedInit = getConfiguration(agentIdentifier)
|
|
34
|
+
const updatedInit = getConfiguration(agent.agentIdentifier)
|
|
32
35
|
const internalTrafficList = [info.beacon, info.errorBeacon]
|
|
36
|
+
|
|
33
37
|
if (!alreadySetOnce) {
|
|
34
|
-
alreadySetOnce = true
|
|
35
38
|
if (updatedInit.proxy.assets) {
|
|
36
39
|
redefinePublicPath(updatedInit.proxy.assets)
|
|
37
40
|
internalTrafficList.push(updatedInit.proxy.assets)
|
|
38
41
|
}
|
|
39
42
|
if (updatedInit.proxy.beacon) internalTrafficList.push(updatedInit.proxy.beacon)
|
|
43
|
+
|
|
44
|
+
setTopLevelCallers() // no need to set global APIs on newrelic obj more than once
|
|
45
|
+
addToNREUM('activatedFeatures', activatedFeatures)
|
|
40
46
|
}
|
|
41
47
|
|
|
42
48
|
runtime.denyList = [
|
|
43
49
|
...(updatedInit.ajax.deny_list || []),
|
|
44
50
|
...(updatedInit.ajax.block_internal ? internalTrafficList : [])
|
|
45
51
|
]
|
|
46
|
-
setRuntime(agentIdentifier, runtime)
|
|
47
|
-
|
|
48
|
-
setTopLevelCallers()
|
|
49
|
-
const api = setAPI(agentIdentifier, forceDrain)
|
|
50
|
-
gosNREUMInitializedAgents(agentIdentifier, api, 'api')
|
|
51
|
-
gosNREUMInitializedAgents(agentIdentifier, exposed, 'exposed')
|
|
52
|
-
addToNREUM('activatedFeatures', activatedFeatures)
|
|
52
|
+
setRuntime(agent.agentIdentifier, runtime)
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
if (agent.api === undefined) agent.api = setAPI(agent.agentIdentifier, forceDrain)
|
|
55
|
+
if (agent.exposed === undefined) agent.exposed = exposed
|
|
56
|
+
alreadySetOnce = true
|
|
55
57
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/* global __webpack_require__ */
|
|
2
|
+
|
|
3
|
+
__webpack_require__.nc = (() => {
|
|
4
|
+
try {
|
|
5
|
+
return document?.currentScript?.nonce
|
|
6
|
+
} catch (ex) {
|
|
7
|
+
// Swallow error and proceed like nonce is not defined
|
|
8
|
+
// This will happen when the agent is loaded in a worker scope
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return ''
|
|
12
|
+
})()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// We don't support setting automating the nonce attribute in the npm package
|
|
@@ -4,7 +4,7 @@ import { getEnabledFeatures } from './features/enabled-features'
|
|
|
4
4
|
import { configure } from './configure/configure'
|
|
5
5
|
// core files
|
|
6
6
|
import { Aggregator } from '../common/aggregate/aggregator'
|
|
7
|
-
import {
|
|
7
|
+
import { setNREUMInitializedAgent } from '../common/window/nreum'
|
|
8
8
|
import { generateRandomHexString } from '../common/ids/unique-id'
|
|
9
9
|
import { getConfiguration, getConfigurationValue, getInfo, getLoaderConfig, getRuntime } from '../common/config/config'
|
|
10
10
|
import { FEATURE_NAMES } from './features/features'
|
|
@@ -34,8 +34,10 @@ export class MicroAgent extends AgentBase {
|
|
|
34
34
|
this.agentIdentifier = agentIdentifier
|
|
35
35
|
this.sharedAggregator = new Aggregator({ agentIdentifier: this.agentIdentifier })
|
|
36
36
|
this.features = {}
|
|
37
|
+
setNREUMInitializedAgent(agentIdentifier, this)
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
configure(this, { ...options, runtime: { isolatedBacklog: true } }, options.loaderType || 'micro-agent')
|
|
40
|
+
Object.assign(this, this.api) // the APIs should be available at the class level for micro-agent
|
|
39
41
|
|
|
40
42
|
/**
|
|
41
43
|
* Starts a set of agent features if not running in "autoStart" mode
|
|
@@ -91,8 +93,7 @@ export class MicroAgent extends AgentBase {
|
|
|
91
93
|
}
|
|
92
94
|
})
|
|
93
95
|
})
|
|
94
|
-
|
|
95
|
-
return this
|
|
96
|
+
return true
|
|
96
97
|
} catch (err) {
|
|
97
98
|
warn('Failed to initialize instrument classes.', err)
|
|
98
99
|
return false
|