@newrelic/browser-agent 1.236.0 → 1.237.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/dist/cjs/common/config/state/init.js +1 -0
- 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/deny-list/deny-list.js +14 -10
- package/dist/cjs/common/harvest/harvest.js +7 -20
- package/dist/cjs/common/util/submit-data.js +4 -36
- package/dist/cjs/common/wrap/wrap-jsonp.js +12 -6
- package/dist/cjs/features/ajax/aggregate/index.js +24 -27
- package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.js +1 -1
- package/dist/cjs/features/jserrors/constants.js +2 -4
- package/dist/cjs/features/jserrors/instrument/index.js +79 -88
- package/dist/cjs/features/jserrors/instrument/uncaught-error.js +22 -0
- package/dist/cjs/features/page_view_event/aggregate/initialized-features.js +23 -19
- package/dist/cjs/features/session_replay/aggregate/index.js +65 -34
- package/dist/cjs/features/session_trace/aggregate/index.js +3 -4
- package/dist/cjs/features/utils/instrument-base.js +6 -8
- package/dist/cjs/loaders/agent-base.js +87 -0
- package/dist/cjs/loaders/agent.js +41 -1
- package/dist/cjs/loaders/api/api.js +1 -1
- package/dist/cjs/loaders/api/interaction-types.js +87 -0
- package/dist/cjs/loaders/configure/configure.js +2 -1
- package/dist/cjs/loaders/micro-agent.js +3 -1
- package/dist/esm/common/config/state/init.js +1 -0
- package/dist/esm/common/config/state/runtime.js +2 -1
- package/dist/esm/common/constants/env.cdn.js +1 -1
- package/dist/esm/common/constants/env.npm.js +1 -1
- package/dist/esm/common/deny-list/deny-list.js +14 -10
- package/dist/esm/common/harvest/harvest.js +6 -20
- package/dist/esm/common/util/submit-data.js +4 -35
- package/dist/esm/common/wrap/wrap-jsonp.js +12 -6
- package/dist/esm/features/ajax/aggregate/index.js +25 -28
- package/dist/esm/features/jserrors/aggregate/compute-stack-trace.js +1 -1
- package/dist/esm/features/jserrors/constants.js +1 -2
- package/dist/esm/features/jserrors/instrument/index.js +78 -87
- package/dist/esm/features/jserrors/instrument/uncaught-error.js +15 -0
- package/dist/esm/features/page_view_event/aggregate/initialized-features.js +23 -19
- package/dist/esm/features/session_replay/aggregate/index.js +65 -34
- package/dist/esm/features/session_trace/aggregate/index.js +3 -4
- package/dist/esm/features/utils/instrument-base.js +7 -9
- package/dist/esm/loaders/agent-base.js +80 -0
- package/dist/esm/loaders/agent.js +41 -1
- package/dist/esm/loaders/api/api.js +1 -1
- package/dist/esm/loaders/api/interaction-types.js +80 -0
- package/dist/esm/loaders/configure/configure.js +3 -2
- package/dist/esm/loaders/micro-agent.js +3 -1
- package/dist/types/common/config/state/runtime.d.ts.map +1 -1
- package/dist/types/common/event-emitter/register-handler.d.ts +1 -1
- package/dist/types/common/harvest/harvest.d.ts.map +1 -1
- package/dist/types/common/session/session-entity.d.ts +6 -6
- package/dist/types/common/util/submit-data.d.ts +2 -20
- package/dist/types/common/util/submit-data.d.ts.map +1 -1
- package/dist/types/common/window/nreum.d.ts +2 -2
- package/dist/types/common/wrap/wrap-jsonp.d.ts.map +1 -1
- package/dist/types/features/ajax/aggregate/index.d.ts +5 -5
- package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/constants.d.ts +0 -1
- package/dist/types/features/jserrors/constants.d.ts.map +1 -1
- package/dist/types/features/jserrors/instrument/index.d.ts +0 -13
- package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/instrument/uncaught-error.d.ts +15 -0
- package/dist/types/features/jserrors/instrument/uncaught-error.d.ts.map +1 -0
- package/dist/types/features/metrics/aggregate/endpoint-map.d.ts +5 -5
- package/dist/types/features/page_view_event/aggregate/initialized-features.d.ts.map +1 -1
- package/dist/types/features/session_replay/aggregate/index.d.ts +16 -30
- 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/utils/instrument-base.d.ts.map +1 -1
- package/dist/types/loaders/agent-base.d.ts +59 -0
- package/dist/types/loaders/agent-base.d.ts.map +1 -0
- package/dist/types/loaders/agent.d.ts +35 -1
- package/dist/types/loaders/agent.d.ts.map +1 -1
- package/dist/types/loaders/api/interaction-types.d.ts +122 -0
- package/dist/types/loaders/api/interaction-types.d.ts.map +1 -0
- package/dist/types/loaders/configure/configure.d.ts.map +1 -1
- package/dist/types/loaders/features/features.d.ts +9 -9
- package/dist/types/loaders/micro-agent.d.ts +3 -2
- package/dist/types/loaders/micro-agent.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/common/config/state/init.js +1 -1
- package/src/common/config/state/runtime.js +2 -1
- package/src/common/deny-list/deny-list.js +11 -11
- package/src/common/deny-list/deny-list.test.js +31 -0
- package/src/common/harvest/harvest.js +7 -16
- package/src/common/harvest/harvest.test.js +16 -36
- package/src/common/util/__mocks__/submit-data.js +0 -1
- package/src/common/util/submit-data.js +2 -24
- package/src/common/util/submit-data.test.js +0 -56
- package/src/common/wrap/wrap-jsonp.js +11 -6
- package/src/features/ajax/aggregate/index.js +25 -31
- package/src/features/jserrors/aggregate/compute-stack-trace.js +1 -1
- package/src/features/jserrors/constants.js +0 -1
- package/src/features/jserrors/instrument/index.js +91 -87
- package/src/features/jserrors/instrument/uncaught-error.js +15 -0
- package/src/features/page_view_event/aggregate/initialized-features.js +18 -14
- package/src/features/session_replay/aggregate/index.component-test.js +17 -56
- package/src/features/session_replay/aggregate/index.js +47 -28
- package/src/features/session_trace/aggregate/index.js +3 -4
- package/src/features/utils/instrument-base.js +6 -9
- package/src/features/utils/instrument-base.test.js +7 -0
- package/src/loaders/agent-base.js +81 -0
- package/src/loaders/agent.js +42 -1
- package/src/loaders/api/api.js +1 -1
- package/src/loaders/api/interaction-types.js +80 -0
- package/src/loaders/configure/configure.js +4 -3
- package/src/loaders/micro-agent.js +4 -1
- package/dist/cjs/features/jserrors/instrument/debug.js +0 -40
- package/dist/esm/features/jserrors/instrument/debug.js +0 -38
- package/dist/types/features/jserrors/instrument/debug.d.ts +0 -2
- package/dist/types/features/jserrors/instrument/debug.d.ts.map +0 -1
- package/src/features/jserrors/instrument/debug.js +0 -36
|
@@ -31,6 +31,13 @@ jest.mock('../../common/config/config', () => ({
|
|
|
31
31
|
__esModule: true,
|
|
32
32
|
getConfigurationValue: jest.fn()
|
|
33
33
|
}))
|
|
34
|
+
jest.mock('../../common/config/config', () => ({
|
|
35
|
+
__esModule: true,
|
|
36
|
+
getConfigurationValue: jest.fn(),
|
|
37
|
+
originals: {
|
|
38
|
+
MO: jest.fn()
|
|
39
|
+
}
|
|
40
|
+
}))
|
|
34
41
|
jest.mock('./feature-base', () => ({
|
|
35
42
|
__esModule: true,
|
|
36
43
|
FeatureBase: jest.fn(function (...args) {
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { warn } from '../common/util/console'
|
|
2
|
+
|
|
3
|
+
export class AgentBase {
|
|
4
|
+
/**
|
|
5
|
+
* Reports a browser PageAction event along with a name and optional attributes.
|
|
6
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/addpageaction/}
|
|
7
|
+
* @param {string} name Name or category of the action. Reported as the actionName attribute.
|
|
8
|
+
* @param {object} [attributes] JSON object with one or more key/value pairs. For example: {key:"value"}. The key is reported as its own PageAction attribute with the specified values.
|
|
9
|
+
*/
|
|
10
|
+
addPageAction (name, attributes) {
|
|
11
|
+
warn('Call to agent api addPageAction failed. The session trace feature is not currently initialized.')
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Groups page views to help URL structure or to capture the URL's routing information.
|
|
16
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setpageviewname/}
|
|
17
|
+
* @param {string} name The page name you want to use. Use alphanumeric characters.
|
|
18
|
+
* @param {string} [host] Default is http://custom.transaction. Typically set host to your site's domain URI.
|
|
19
|
+
*/
|
|
20
|
+
setPageViewName (name, host) {
|
|
21
|
+
warn('Call to agent api setPageViewName failed. The page view feature is not currently initialized.')
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Adds a user-defined attribute name and value to subsequent events on the page.
|
|
26
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setcustomattribute/}
|
|
27
|
+
* @param {string} name Name of the attribute. Appears as column in the PageView event. It will also appear as a column in the PageAction event if you are using it.
|
|
28
|
+
* @param {string|number|null} value Value of the attribute. Appears as the value in the named attribute column in the PageView event. It will appear as a column in the PageAction event if you are using it. Custom attribute values cannot be complex objects, only simple types such as Strings and Integers.
|
|
29
|
+
* @param {boolean} [persist] Default false. f set to true, the name-value pair will also be set into the browser's storage API. Then on the following instrumented pages that load within the same session, the pair will be re-applied as a custom attribute.
|
|
30
|
+
*/
|
|
31
|
+
setCustomAttribute (name, value, persist) {
|
|
32
|
+
warn('Call to agent api setCustomAttribute failed. The js errors feature is not currently initialized.')
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Identifies a browser error without disrupting your app's operations.
|
|
37
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/noticeerror/}
|
|
38
|
+
* @param {Error|string} error Provide a meaningful error message that you can use when analyzing data on browser's JavaScript errors page.
|
|
39
|
+
* @param {object} [customAttributes] An object containing name/value pairs representing custom attributes.
|
|
40
|
+
*/
|
|
41
|
+
noticeError (error, customAttributes) {
|
|
42
|
+
warn('Call to agent api noticeError failed. The js errors feature is not currently initialized.')
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Adds a user-defined identifier string to subsequent events on the page.
|
|
47
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setuserid/}
|
|
48
|
+
* @param {string|null} value A string identifier for the end-user, useful for tying all browser events to specific users. The value parameter does not have to be unique. If IDs should be unique, the caller is responsible for that validation. Passing a null value unsets any existing user ID.
|
|
49
|
+
*/
|
|
50
|
+
setUserId (value) {
|
|
51
|
+
warn('Call to agent api setUserId failed. The js errors feature is not currently initialized.')
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Allows selective ignoring and grouping of known errors that the browser agent captures.
|
|
56
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/seterrorhandler/}
|
|
57
|
+
* @param {(error: Error|string) => boolean | { group: string }} callback When an error occurs, the callback is called with the error object as a parameter. The callback will be called with each error, so it is not specific to one error.
|
|
58
|
+
*/
|
|
59
|
+
setErrorHandler (callback) {
|
|
60
|
+
warn('Call to agent api setErrorHandler failed. The js errors feature is not currently initialized.')
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Records an additional time point as "finished" in a session trace, and sends the event to New Relic.
|
|
65
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/finished/}
|
|
66
|
+
* @param {number} [timeStamp] Defaults to the current time of the call. If used, this marks the time that the page is "finished" according to your own criteria.
|
|
67
|
+
*/
|
|
68
|
+
finished (timeStamp) {
|
|
69
|
+
warn('Call to agent api finished failed. The page action feature is not currently initialized.')
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Adds a unique name and ID to identify releases with multiple JavaScript bundles on the same page.
|
|
74
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/addrelease/}
|
|
75
|
+
* @param {string} name A short description of the component; for example, the name of a project, application, file, or library.
|
|
76
|
+
* @param {string} id The ID or version of this release; for example, a version number, build number from your CI environment, GitHub SHA, GUID, or a hash of the contents.
|
|
77
|
+
*/
|
|
78
|
+
addRelease (name, id) {
|
|
79
|
+
warn('Call to agent api addRelease failed. The agent is not currently initialized.')
|
|
80
|
+
}
|
|
81
|
+
}
|
package/src/loaders/agent.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// loader files
|
|
2
|
+
import { AgentBase } from './agent-base'
|
|
2
3
|
import { getEnabledFeatures } from './features/enabled-features'
|
|
3
4
|
import { configure } from './configure/configure'
|
|
4
5
|
import { getFeatureDependencyNames } from './features/featureDependencies'
|
|
@@ -14,12 +15,18 @@ import { warn } from '../common/util/console'
|
|
|
14
15
|
import { stringify } from '../common/util/stringify'
|
|
15
16
|
import { globalScope } from '../common/constants/runtime'
|
|
16
17
|
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {import('./api/interaction-types').InteractionInstance} InteractionInstance
|
|
20
|
+
*/
|
|
21
|
+
|
|
17
22
|
/**
|
|
18
23
|
* A flexible class that may be used to compose an agent from a select subset of feature modules. In applications
|
|
19
24
|
* sensitive to network load, this may result in smaller builds with slightly lower performance impact.
|
|
20
25
|
*/
|
|
21
|
-
export class Agent {
|
|
26
|
+
export class Agent extends AgentBase {
|
|
22
27
|
constructor (options, agentIdentifier = generateRandomHexString(16)) {
|
|
28
|
+
super()
|
|
29
|
+
|
|
23
30
|
if (!globalScope) {
|
|
24
31
|
// We could not determine the runtime environment. Short-circuite the agent here
|
|
25
32
|
// to avoid possible exceptions later that may cause issues with customer's application.
|
|
@@ -84,4 +91,38 @@ export class Agent {
|
|
|
84
91
|
return false
|
|
85
92
|
}
|
|
86
93
|
}
|
|
94
|
+
|
|
95
|
+
/* Below API methods are only available on a standard agent and not the micro agent */
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Adds a JavaScript object with a custom name, start time, etc. to an in-progress session trace.
|
|
99
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/addtotrace/}
|
|
100
|
+
* @param {{name: string, start: number, end?: number, origin?: string, type?: string}} customAttributes Supply a JavaScript object with these required and optional name/value pairs:
|
|
101
|
+
*
|
|
102
|
+
* - Required name/value pairs: name, start
|
|
103
|
+
* - Optional name/value pairs: end, origin, type
|
|
104
|
+
*
|
|
105
|
+
* If you are sending the same event object to New Relic as a PageAction, omit the TYPE attribute. (type is a string to describe what type of event you are marking inside of a session trace.) If included, it will override the event type and cause the PageAction event to be sent incorrectly. Instead, use the name attribute for event information.
|
|
106
|
+
*/
|
|
107
|
+
addToTrace (customAttributes) {
|
|
108
|
+
warn('Call to agent api addToTrace failed. The page action feature is not currently initialized.')
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Gives SPA routes more accurate names than default names. Monitors specific routes rather than by default grouping.
|
|
113
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setcurrentroutename/}
|
|
114
|
+
* @param {string} name Current route name for the page.
|
|
115
|
+
*/
|
|
116
|
+
setCurrentRouteName (name) {
|
|
117
|
+
warn('Call to agent api setCurrentRouteName failed. The spa feature is not currently initialized.')
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Returns a new API object that is bound to the current SPA interaction.
|
|
122
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/interaction/}
|
|
123
|
+
* @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.
|
|
124
|
+
*/
|
|
125
|
+
interaction () {
|
|
126
|
+
warn('Call to agent api interaction failed. The spa feature is not currently initialized.')
|
|
127
|
+
}
|
|
87
128
|
}
|
package/src/loaders/api/api.js
CHANGED
|
@@ -127,7 +127,7 @@ export function setAPI (agentIdentifier, forceDrain) {
|
|
|
127
127
|
try {
|
|
128
128
|
return cb.apply(this, arguments)
|
|
129
129
|
} catch (err) {
|
|
130
|
-
tracerEE.emit('fn-err', [arguments, this,
|
|
130
|
+
tracerEE.emit('fn-err', [arguments, this, err], contextStore)
|
|
131
131
|
// the error came from outside the agent, so don't swallow
|
|
132
132
|
throw err
|
|
133
133
|
} finally {
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef InteractionInstance
|
|
3
|
+
* @property {actionText} actionText
|
|
4
|
+
* @property {createTracer} createTracer
|
|
5
|
+
* @property {end} end
|
|
6
|
+
* @property {getContext} getContext
|
|
7
|
+
* @property {ignore} ignore
|
|
8
|
+
* @property {onEnd} onEnd
|
|
9
|
+
* @property {onEnd} save
|
|
10
|
+
* @property {setAttribute} setAttribute
|
|
11
|
+
* @property {setName} setName
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Sets the text value of the HTML element that was clicked to start a browser interaction.
|
|
16
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/actiontext/}
|
|
17
|
+
* @callback actionText
|
|
18
|
+
* @param {string} value The text value of the HTML element that represents the action that started the interaction.
|
|
19
|
+
* @returns {InteractionInstance} Returns the same interaction object allowing method chaining.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Times sub-components of a SPA interaction separately, including wait time and JS execution time.
|
|
24
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/createtracer/}
|
|
25
|
+
* @callback createTracer
|
|
26
|
+
* @param {string} name This will be used as the name of the tracer.
|
|
27
|
+
* @param {string} [callback] A callback that contains the synchronous work to run at the end of the async work. To execute this callback, call the wrapper function returned using createTracer().
|
|
28
|
+
* @returns {Function} Returns a method that wraps the original callback. When this method is invoked, it calls the original callback and ends the async timing.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Ends the SPA interaction at the current time.
|
|
33
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/end/}
|
|
34
|
+
* @callback end
|
|
35
|
+
* @returns {InteractionInstance} Returns the same interaction object allowing method chaining.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Stores values for the current SPA interaction asynchronously in browser.
|
|
40
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/getcontext/}
|
|
41
|
+
* @callback getContext
|
|
42
|
+
* @param {(ctx: object) => void} callback This function is called when the interaction ends. It is called with one parameter, which is the interaction context.
|
|
43
|
+
* @returns {InteractionInstance} Returns the same interaction object allowing method chaining.
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Change the values associated with a SPA interaction before the interaction is saved.
|
|
48
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/onend/}
|
|
49
|
+
* @callback onEnd
|
|
50
|
+
* @param {(ctx: object) => void} callback This function is called when the interaction ends. It is called with one parameter, which is the interaction context.
|
|
51
|
+
* @returns {InteractionInstance} Returns the same interaction object allowing method chaining.
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Ensures a SPA browser interaction will be saved when it ends.
|
|
56
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/save/}
|
|
57
|
+
* @callback save
|
|
58
|
+
* @returns {InteractionInstance} Returns the same interaction object allowing method chaining.
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Adds a custom SPA attribute only to the current interaction in browser.
|
|
63
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setattribute/}
|
|
64
|
+
* @callback setAttribute
|
|
65
|
+
* @param {string} key Used as the attribute name on the BrowserInteraction event.
|
|
66
|
+
* @param {any} key Used as the attribute value on the BrowserInteraction event. This can be a string, number, boolean, or object. If it is an object, New Relic serializes it to a JSON string.
|
|
67
|
+
* @returns {InteractionInstance} Returns the same interaction object allowing method chaining.
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Sets the name and trigger of a SPA's browser interaction that is not a route change or URL change.
|
|
72
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setname/}
|
|
73
|
+
* @callback setName
|
|
74
|
+
* @param {string} name If null, the name will be set using the targetGroupedUrl attribute. If not null, this will set the browserInteractionName attribute in the BrowserInteraction event.
|
|
75
|
+
* @param {string} [trigger] If not null, this will set the TRIGGER attribute on the BrowserInteraction event.
|
|
76
|
+
* @returns {InteractionInstance} Returns the same interaction object allowing method chaining.
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
/* istanbul ignore next */
|
|
80
|
+
export const unused = {}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { setAPI, setTopLevelCallers } from '../api/api'
|
|
2
2
|
import { addToNREUM, gosCDN, gosNREUMInitializedAgents } from '../../common/window/nreum'
|
|
3
3
|
import { setConfiguration, setInfo, setLoaderConfig, setRuntime } from '../../common/config/config'
|
|
4
|
-
import {
|
|
4
|
+
import { activatedFeatures } from '../../common/util/feature-flags'
|
|
5
5
|
import { isWorkerScope } from '../../common/constants/runtime'
|
|
6
6
|
|
|
7
7
|
export function configure (agentIdentifier, opts = {}, loaderType, forceDrain) {
|
|
@@ -15,15 +15,16 @@ export function configure (agentIdentifier, opts = {}, loaderType, forceDrain) {
|
|
|
15
15
|
|
|
16
16
|
setConfiguration(agentIdentifier, init || {})
|
|
17
17
|
setLoaderConfig(agentIdentifier, loader_config || {})
|
|
18
|
-
setRuntime(agentIdentifier, runtime)
|
|
19
18
|
|
|
20
19
|
info.jsAttributes ??= {}
|
|
21
20
|
if (isWorkerScope) { // add a default attr to all worker payloads
|
|
22
21
|
info.jsAttributes.isWorker = true
|
|
23
22
|
}
|
|
24
|
-
|
|
25
23
|
setInfo(agentIdentifier, info)
|
|
26
24
|
|
|
25
|
+
runtime.denyList = init.ajax?.block_internal ? (init.ajax.deny_list || []).concat(info.beacon, info.errorBeacon) : init.ajax?.deny_list
|
|
26
|
+
setRuntime(agentIdentifier, runtime)
|
|
27
|
+
|
|
27
28
|
setTopLevelCallers()
|
|
28
29
|
const api = setAPI(agentIdentifier, forceDrain)
|
|
29
30
|
gosNREUMInitializedAgents(agentIdentifier, api, 'api')
|
|
@@ -10,6 +10,7 @@ import { getConfiguration, getInfo, getLoaderConfig, getRuntime } from '../commo
|
|
|
10
10
|
import { FEATURE_NAMES } from './features/features'
|
|
11
11
|
import { warn } from '../common/util/console'
|
|
12
12
|
import { onWindowLoad } from '../common/window/load'
|
|
13
|
+
import { AgentBase } from './agent-base'
|
|
13
14
|
|
|
14
15
|
const nonAutoFeatures = [
|
|
15
16
|
FEATURE_NAMES.jserrors,
|
|
@@ -22,12 +23,14 @@ const nonAutoFeatures = [
|
|
|
22
23
|
* automatically instrument. Instead, each MicroAgent instance will lazy load the required features and can support loading multiple instances on one page.
|
|
23
24
|
* Out of the box, it can manually handle and report Page View, Page Action, and Error events.
|
|
24
25
|
*/
|
|
25
|
-
export class MicroAgent {
|
|
26
|
+
export class MicroAgent extends AgentBase {
|
|
26
27
|
/**
|
|
27
28
|
* @param {Object} options - Specifies features and runtime configuration,
|
|
28
29
|
* @param {string=} agentIdentifier - The optional unique ID of the agent.
|
|
29
30
|
*/
|
|
30
31
|
constructor (options, agentIdentifier = generateRandomHexString(16)) {
|
|
32
|
+
super()
|
|
33
|
+
|
|
31
34
|
this.agentIdentifier = agentIdentifier
|
|
32
35
|
this.sharedAggregator = new Aggregator({ agentIdentifier: this.agentIdentifier })
|
|
33
36
|
this.features = {}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _contextualEe = require("../../../common/event-emitter/contextual-ee");
|
|
4
|
-
var _mapOwn = require("../../../common/util/map-own");
|
|
5
|
-
/*
|
|
6
|
-
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
7
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var flags = {};
|
|
11
|
-
var flagArr;
|
|
12
|
-
try {
|
|
13
|
-
flagArr = localStorage.getItem('__nr_flags').split(',');
|
|
14
|
-
if (console && typeof console.log === 'function') {
|
|
15
|
-
flags.console = true;
|
|
16
|
-
if (flagArr.indexOf('dev') !== -1) flags.dev = true;
|
|
17
|
-
if (flagArr.indexOf('nr_dev') !== -1) flags.nrDev = true;
|
|
18
|
-
}
|
|
19
|
-
} catch (err) {
|
|
20
|
-
// no op
|
|
21
|
-
}
|
|
22
|
-
if (flags.nrDev) _contextualEe.ee.on('internal-error', function (err) {
|
|
23
|
-
log(err.stack);
|
|
24
|
-
});
|
|
25
|
-
if (flags.dev) _contextualEe.ee.on('fn-err', function (args, origThis, err) {
|
|
26
|
-
log(err.stack);
|
|
27
|
-
});
|
|
28
|
-
if (flags.dev) {
|
|
29
|
-
log('NR AGENT IN DEVELOPMENT MODE');
|
|
30
|
-
log('flags: ' + (0, _mapOwn.mapOwn)(flags, function (key, val) {
|
|
31
|
-
return key;
|
|
32
|
-
}).join(', '));
|
|
33
|
-
}
|
|
34
|
-
function log(message) {
|
|
35
|
-
try {
|
|
36
|
-
if (flags.console) log(message);
|
|
37
|
-
} catch (err) {
|
|
38
|
-
// no op
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
3
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { ee } from '../../../common/event-emitter/contextual-ee';
|
|
7
|
-
import { mapOwn } from '../../../common/util/map-own';
|
|
8
|
-
var flags = {};
|
|
9
|
-
var flagArr;
|
|
10
|
-
try {
|
|
11
|
-
flagArr = localStorage.getItem('__nr_flags').split(',');
|
|
12
|
-
if (console && typeof console.log === 'function') {
|
|
13
|
-
flags.console = true;
|
|
14
|
-
if (flagArr.indexOf('dev') !== -1) flags.dev = true;
|
|
15
|
-
if (flagArr.indexOf('nr_dev') !== -1) flags.nrDev = true;
|
|
16
|
-
}
|
|
17
|
-
} catch (err) {
|
|
18
|
-
// no op
|
|
19
|
-
}
|
|
20
|
-
if (flags.nrDev) ee.on('internal-error', function (err) {
|
|
21
|
-
log(err.stack);
|
|
22
|
-
});
|
|
23
|
-
if (flags.dev) ee.on('fn-err', function (args, origThis, err) {
|
|
24
|
-
log(err.stack);
|
|
25
|
-
});
|
|
26
|
-
if (flags.dev) {
|
|
27
|
-
log('NR AGENT IN DEVELOPMENT MODE');
|
|
28
|
-
log('flags: ' + mapOwn(flags, function (key, val) {
|
|
29
|
-
return key;
|
|
30
|
-
}).join(', '));
|
|
31
|
-
}
|
|
32
|
-
function log(message) {
|
|
33
|
-
try {
|
|
34
|
-
if (flags.console) log(message);
|
|
35
|
-
} catch (err) {
|
|
36
|
-
// no op
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../../../../src/features/jserrors/instrument/debug.js"],"names":[],"mappings":""}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
3
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { ee } from '../../../common/event-emitter/contextual-ee'
|
|
7
|
-
import { mapOwn } from '../../../common/util/map-own'
|
|
8
|
-
|
|
9
|
-
var flags = {}
|
|
10
|
-
var flagArr
|
|
11
|
-
|
|
12
|
-
try {
|
|
13
|
-
flagArr = localStorage.getItem('__nr_flags').split(',')
|
|
14
|
-
if (console && typeof console.log === 'function') {
|
|
15
|
-
flags.console = true
|
|
16
|
-
if (flagArr.indexOf('dev') !== -1) flags.dev = true
|
|
17
|
-
if (flagArr.indexOf('nr_dev') !== -1) flags.nrDev = true
|
|
18
|
-
}
|
|
19
|
-
} catch (err) {
|
|
20
|
-
// no op
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (flags.nrDev) ee.on('internal-error', function (err) { log(err.stack) })
|
|
24
|
-
if (flags.dev) ee.on('fn-err', function (args, origThis, err) { log(err.stack) })
|
|
25
|
-
if (flags.dev) {
|
|
26
|
-
log('NR AGENT IN DEVELOPMENT MODE')
|
|
27
|
-
log('flags: ' + mapOwn(flags, function (key, val) { return key }).join(', '))
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function log (message) {
|
|
31
|
-
try {
|
|
32
|
-
if (flags.console) log(message)
|
|
33
|
-
} catch (err) {
|
|
34
|
-
// no op
|
|
35
|
-
}
|
|
36
|
-
}
|