@newrelic/browser-agent 1.289.0 → 1.290.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 +10 -0
- package/README.md +32 -0
- package/dist/cjs/common/constants/env.cdn.js +1 -1
- package/dist/cjs/common/constants/env.npm.js +1 -1
- package/dist/cjs/features/ajax/instrument/index.js +5 -5
- package/dist/cjs/features/generic_events/aggregate/index.js +1 -0
- package/dist/cjs/features/generic_events/aggregate/user-actions/aggregated-user-action.js +2 -0
- package/dist/cjs/features/generic_events/instrument/index.js +15 -5
- package/dist/cjs/features/jserrors/instrument/index.js +15 -5
- package/dist/cjs/features/logging/instrument/index.js +13 -5
- package/dist/cjs/features/metrics/instrument/index.js +5 -5
- package/dist/cjs/features/page_action/instrument/index.js +1 -5
- package/dist/cjs/features/page_view_event/instrument/index.js +8 -6
- package/dist/cjs/features/page_view_timing/instrument/index.js +5 -5
- package/dist/cjs/features/session_replay/instrument/index.js +10 -4
- package/dist/cjs/features/session_trace/instrument/index.js +10 -6
- package/dist/cjs/features/soft_navigations/instrument/index.js +9 -5
- package/dist/cjs/features/spa/instrument/index.js +8 -6
- package/dist/cjs/features/utils/instrument-base.js +27 -23
- package/dist/cjs/loaders/agent-base.js +4 -95
- package/dist/cjs/loaders/agent.js +11 -0
- package/dist/cjs/loaders/api/addPageAction.js +23 -0
- package/dist/cjs/loaders/api/addRelease.js +20 -0
- package/dist/cjs/loaders/api/addToTrace.js +29 -0
- package/dist/cjs/loaders/api/constants.js +32 -0
- package/dist/cjs/loaders/api/finished.js +31 -0
- package/dist/cjs/loaders/api/interaction.js +58 -0
- package/dist/cjs/loaders/api/log.js +26 -0
- package/dist/cjs/loaders/api/noticeError.js +30 -0
- package/dist/cjs/loaders/api/pauseReplay.js +20 -0
- package/dist/cjs/loaders/api/recordCustomEvent.js +21 -0
- package/dist/cjs/loaders/api/recordReplay.js +20 -0
- package/dist/cjs/loaders/api/register.js +182 -0
- package/dist/cjs/loaders/api/setApplicationVersion.js +28 -0
- package/dist/cjs/loaders/api/setCustomAttribute.js +27 -0
- package/dist/cjs/loaders/api/setErrorHandler.js +18 -0
- package/dist/cjs/loaders/api/setPageViewName.js +23 -0
- package/dist/cjs/loaders/api/setUserId.js +28 -0
- package/dist/cjs/loaders/api/sharedHandlers.js +76 -0
- package/dist/cjs/loaders/api/start.js +18 -0
- package/dist/cjs/loaders/api/topLevelCallers.js +29 -0
- package/dist/cjs/loaders/api/wrapLogger.js +26 -0
- package/dist/cjs/loaders/api-base.js +224 -0
- package/dist/cjs/loaders/configure/configure.js +2 -4
- package/dist/cjs/loaders/micro-agent-base.js +3 -134
- package/dist/cjs/loaders/micro-agent.js +34 -6
- package/dist/esm/common/constants/env.cdn.js +1 -1
- package/dist/esm/common/constants/env.npm.js +1 -1
- package/dist/esm/features/ajax/instrument/index.js +3 -3
- package/dist/esm/features/generic_events/aggregate/index.js +1 -0
- package/dist/esm/features/generic_events/aggregate/user-actions/aggregated-user-action.js +2 -0
- package/dist/esm/features/generic_events/instrument/index.js +13 -3
- package/dist/esm/features/jserrors/instrument/index.js +13 -3
- package/dist/esm/features/logging/instrument/index.js +11 -3
- package/dist/esm/features/metrics/instrument/index.js +3 -3
- package/dist/esm/features/page_action/instrument/index.js +1 -5
- package/dist/esm/features/page_view_event/instrument/index.js +7 -3
- package/dist/esm/features/page_view_timing/instrument/index.js +3 -3
- package/dist/esm/features/session_replay/instrument/index.js +10 -4
- package/dist/esm/features/session_trace/instrument/index.js +9 -3
- package/dist/esm/features/soft_navigations/instrument/index.js +7 -3
- package/dist/esm/features/spa/instrument/index.js +7 -3
- package/dist/esm/features/utils/instrument-base.js +27 -23
- package/dist/esm/loaders/agent-base.js +4 -95
- package/dist/esm/loaders/agent.js +10 -0
- package/dist/esm/loaders/api/addPageAction.js +15 -0
- package/dist/esm/loaders/api/addRelease.js +13 -0
- package/dist/esm/loaders/api/addToTrace.js +22 -0
- package/dist/esm/loaders/api/constants.js +26 -0
- package/dist/esm/loaders/api/finished.js +24 -0
- package/dist/esm/loaders/api/interaction.js +52 -0
- package/dist/esm/loaders/api/log.js +19 -0
- package/dist/esm/loaders/api/noticeError.js +22 -0
- package/dist/esm/loaders/api/pauseReplay.js +13 -0
- package/dist/esm/loaders/api/recordCustomEvent.js +14 -0
- package/dist/esm/loaders/api/recordReplay.js +13 -0
- package/dist/esm/loaders/api/register.js +175 -0
- package/dist/esm/loaders/api/setApplicationVersion.js +21 -0
- package/dist/esm/loaders/api/setCustomAttribute.js +20 -0
- package/dist/esm/loaders/api/setErrorHandler.js +11 -0
- package/dist/esm/loaders/api/setPageViewName.js +16 -0
- package/dist/esm/loaders/api/setUserId.js +21 -0
- package/dist/esm/loaders/api/sharedHandlers.js +69 -0
- package/dist/esm/loaders/api/start.js +11 -0
- package/dist/esm/loaders/api/topLevelCallers.js +22 -0
- package/dist/esm/loaders/api/wrapLogger.js +19 -0
- package/dist/esm/loaders/api-base.js +217 -0
- package/dist/esm/loaders/configure/configure.js +2 -4
- package/dist/esm/loaders/micro-agent-base.js +3 -134
- package/dist/esm/loaders/micro-agent.js +34 -6
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/features/ajax/instrument/index.d.ts +1 -1
- package/dist/types/features/ajax/instrument/index.d.ts.map +1 -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 +1 -0
- package/dist/types/features/generic_events/aggregate/user-actions/aggregated-user-action.d.ts.map +1 -1
- package/dist/types/features/generic_events/instrument/index.d.ts +1 -1
- package/dist/types/features/generic_events/instrument/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/instrument/index.d.ts +1 -1
- package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -1
- package/dist/types/features/logging/instrument/index.d.ts +1 -1
- package/dist/types/features/logging/instrument/index.d.ts.map +1 -1
- package/dist/types/features/metrics/instrument/index.d.ts +1 -1
- package/dist/types/features/metrics/instrument/index.d.ts.map +1 -1
- package/dist/types/features/page_action/instrument/index.d.ts +0 -1
- package/dist/types/features/page_action/instrument/index.d.ts.map +1 -1
- package/dist/types/features/page_view_event/instrument/index.d.ts +1 -1
- package/dist/types/features/page_view_event/instrument/index.d.ts.map +1 -1
- package/dist/types/features/page_view_timing/instrument/index.d.ts +1 -1
- package/dist/types/features/page_view_timing/instrument/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/instrument/index.d.ts +1 -1
- package/dist/types/features/session_replay/instrument/index.d.ts.map +1 -1
- package/dist/types/features/session_trace/instrument/index.d.ts +1 -1
- package/dist/types/features/session_trace/instrument/index.d.ts.map +1 -1
- package/dist/types/features/soft_navigations/instrument/index.d.ts +1 -1
- package/dist/types/features/soft_navigations/instrument/index.d.ts.map +1 -1
- package/dist/types/features/spa/instrument/index.d.ts +1 -1
- package/dist/types/features/spa/instrument/index.d.ts.map +1 -1
- package/dist/types/features/utils/instrument-base.d.ts +9 -7
- package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
- package/dist/types/loaders/agent-base.d.ts +3 -71
- 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/addPageAction.d.ts +3 -0
- package/dist/types/loaders/api/addPageAction.d.ts.map +1 -0
- package/dist/types/loaders/api/addRelease.d.ts +2 -0
- package/dist/types/loaders/api/addRelease.d.ts.map +1 -0
- package/dist/types/loaders/api/addToTrace.d.ts +2 -0
- package/dist/types/loaders/api/addToTrace.d.ts.map +1 -0
- package/dist/types/loaders/api/constants.d.ts +27 -0
- package/dist/types/loaders/api/constants.d.ts.map +1 -0
- package/dist/types/loaders/api/finished.d.ts +2 -0
- package/dist/types/loaders/api/finished.d.ts.map +1 -0
- package/dist/types/loaders/api/interaction.d.ts +2 -0
- package/dist/types/loaders/api/interaction.d.ts.map +1 -0
- package/dist/types/loaders/api/log.d.ts +6 -0
- package/dist/types/loaders/api/log.d.ts.map +1 -0
- package/dist/types/loaders/api/noticeError.d.ts +3 -0
- package/dist/types/loaders/api/noticeError.d.ts.map +1 -0
- package/dist/types/loaders/api/pauseReplay.d.ts +2 -0
- package/dist/types/loaders/api/pauseReplay.d.ts.map +1 -0
- package/dist/types/loaders/api/recordCustomEvent.d.ts +2 -0
- package/dist/types/loaders/api/recordCustomEvent.d.ts.map +1 -0
- package/dist/types/loaders/api/recordReplay.d.ts +2 -0
- package/dist/types/loaders/api/recordReplay.d.ts.map +1 -0
- package/dist/types/loaders/api/register.d.ts +20 -0
- package/dist/types/loaders/api/register.d.ts.map +1 -0
- package/dist/types/loaders/api/setApplicationVersion.d.ts +2 -0
- package/dist/types/loaders/api/setApplicationVersion.d.ts.map +1 -0
- package/dist/types/loaders/api/setCustomAttribute.d.ts +2 -0
- package/dist/types/loaders/api/setCustomAttribute.d.ts.map +1 -0
- package/dist/types/loaders/api/setErrorHandler.d.ts +2 -0
- package/dist/types/loaders/api/setErrorHandler.d.ts.map +1 -0
- package/dist/types/loaders/api/setPageViewName.d.ts +2 -0
- package/dist/types/loaders/api/setPageViewName.d.ts.map +1 -0
- package/dist/types/loaders/api/setUserId.d.ts +2 -0
- package/dist/types/loaders/api/setUserId.d.ts.map +1 -0
- package/dist/types/loaders/api/sharedHandlers.d.ts +20 -0
- package/dist/types/loaders/api/sharedHandlers.d.ts.map +1 -0
- package/dist/types/loaders/api/start.d.ts +2 -0
- package/dist/types/loaders/api/start.d.ts.map +1 -0
- package/dist/types/loaders/api/topLevelCallers.d.ts +2 -0
- package/dist/types/loaders/api/topLevelCallers.d.ts.map +1 -0
- package/dist/types/loaders/api/wrapLogger.d.ts +2 -0
- package/dist/types/loaders/api/wrapLogger.d.ts.map +1 -0
- package/dist/types/loaders/api-base.d.ts +169 -0
- package/dist/types/loaders/api-base.d.ts.map +1 -0
- package/dist/types/loaders/configure/configure.d.ts.map +1 -1
- package/dist/types/loaders/micro-agent-base.d.ts +2 -95
- package/dist/types/loaders/micro-agent-base.d.ts.map +1 -1
- package/dist/types/loaders/micro-agent.d.ts +1 -1
- package/dist/types/loaders/micro-agent.d.ts.map +1 -1
- package/package.json +6 -1
- package/src/features/ajax/instrument/index.js +3 -3
- package/src/features/generic_events/aggregate/index.js +1 -0
- package/src/features/generic_events/aggregate/user-actions/aggregated-user-action.js +2 -0
- package/src/features/generic_events/instrument/index.js +13 -3
- package/src/features/jserrors/instrument/index.js +13 -3
- package/src/features/logging/instrument/index.js +11 -3
- package/src/features/metrics/instrument/index.js +3 -3
- package/src/features/page_action/instrument/index.js +1 -3
- package/src/features/page_view_event/instrument/index.js +7 -3
- package/src/features/page_view_timing/instrument/index.js +3 -3
- package/src/features/session_replay/instrument/index.js +11 -4
- package/src/features/session_trace/instrument/index.js +10 -3
- package/src/features/soft_navigations/instrument/index.js +8 -3
- package/src/features/spa/instrument/index.js +8 -3
- package/src/features/utils/instrument-base.js +27 -20
- package/src/loaders/agent-base.js +4 -96
- package/src/loaders/agent.js +11 -0
- package/src/loaders/api/addPageAction.js +17 -0
- package/src/loaders/api/addRelease.js +14 -0
- package/src/loaders/api/addToTrace.js +25 -0
- package/src/loaders/api/constants.js +28 -0
- package/src/loaders/api/finished.js +19 -0
- package/src/loaders/api/interaction.js +59 -0
- package/src/loaders/api/log.js +18 -0
- package/src/loaders/api/noticeError.js +26 -0
- package/src/loaders/api/pauseReplay.js +14 -0
- package/src/loaders/api/recordCustomEvent.js +15 -0
- package/src/loaders/api/recordReplay.js +14 -0
- package/src/loaders/api/register.js +168 -0
- package/src/loaders/api/setApplicationVersion.js +22 -0
- package/src/loaders/api/setCustomAttribute.js +21 -0
- package/src/loaders/api/setErrorHandler.js +12 -0
- package/src/loaders/api/setPageViewName.js +17 -0
- package/src/loaders/api/setUserId.js +22 -0
- package/src/loaders/api/sharedHandlers.js +63 -0
- package/src/loaders/api/start.js +12 -0
- package/src/loaders/api/topLevelCallers.js +24 -0
- package/src/loaders/api/wrapLogger.js +14 -0
- package/src/loaders/api-base.js +218 -0
- package/src/loaders/configure/configure.js +2 -3
- package/src/loaders/micro-agent-base.js +3 -136
- package/src/loaders/micro-agent.js +34 -4
- package/tools/bundler-tools/bundler-tools.js +27 -0
- package/tools/bundler-tools/bundler-tools.mjs +23 -0
- package/dist/cjs/features/utils/lazy-feature-loader.js +0 -53
- package/dist/cjs/loaders/api/api-methods.js +0 -14
- package/dist/cjs/loaders/api/api.js +0 -259
- package/dist/cjs/loaders/api/apiAsync.js +0 -63
- package/dist/esm/features/utils/lazy-feature-loader.js +0 -47
- package/dist/esm/loaders/api/api-methods.js +0 -7
- package/dist/esm/loaders/api/api.js +0 -251
- package/dist/esm/loaders/api/apiAsync.js +0 -56
- package/dist/types/features/utils/lazy-feature-loader.d.ts +0 -13
- package/dist/types/features/utils/lazy-feature-loader.d.ts.map +0 -1
- package/dist/types/loaders/api/api-methods.d.ts +0 -3
- package/dist/types/loaders/api/api-methods.d.ts.map +0 -1
- package/dist/types/loaders/api/api.d.ts +0 -3
- package/dist/types/loaders/api/api.d.ts.map +0 -1
- package/dist/types/loaders/api/apiAsync.d.ts +0 -2
- package/dist/types/loaders/api/apiAsync.d.ts.map +0 -1
- package/src/features/utils/lazy-feature-loader.js +0 -47
- package/src/loaders/api/api-methods.js +0 -16
- package/src/loaders/api/api.js +0 -264
- package/src/loaders/api/apiAsync.js +0 -56
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ApiBase = void 0;
|
|
7
|
+
var _console = require("../common/util/console");
|
|
8
|
+
var _constants = require("./api/constants");
|
|
9
|
+
/**
|
|
10
|
+
* Copyright 2020-2025 New Relic, Inc. All rights reserved.
|
|
11
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {import('./api/interaction-types').InteractionInstance} InteractionInstance
|
|
16
|
+
*/
|
|
17
|
+
class ApiBase {
|
|
18
|
+
#callMethod(methodName, ...args) {
|
|
19
|
+
if (this[methodName] === ApiBase.prototype[methodName]) (0, _console.warn)(35, methodName);else return this[methodName](...args);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// MicroAgent class custom defines its own start
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Reports a browser PageAction event along with a name and optional attributes.
|
|
26
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/addpageaction/}
|
|
27
|
+
* @param {string} name Name or category of the action. Reported as the actionName attribute.
|
|
28
|
+
* @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.
|
|
29
|
+
*/
|
|
30
|
+
addPageAction(name, attributes) {
|
|
31
|
+
return this.#callMethod(_constants.ADD_PAGE_ACTION, name, attributes);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @experimental
|
|
36
|
+
* IMPORTANT: This feature is being developed for use internally and is not in a public-facing production-ready state.
|
|
37
|
+
* It is not recommended for use in production environments and will not receive support for issues.
|
|
38
|
+
*
|
|
39
|
+
* Registers an external caller to report through the base agent to a different target than the base agent.
|
|
40
|
+
* @param {object} target the target object to report data to
|
|
41
|
+
* @param {string} target.licenseKey The licenseKey to report data to
|
|
42
|
+
* @param {string} target.applicationID The applicationID to report data to
|
|
43
|
+
* @param {string=} target.entityGuid The entityGuid to report data to
|
|
44
|
+
* @returns {object} Returns an object that contains the available API methods and configurations to use with the external caller. See loaders/api/api.js for more information.
|
|
45
|
+
*/
|
|
46
|
+
register(target) {
|
|
47
|
+
return this.#callMethod(_constants.REGISTER, target);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Records a custom event with a specified eventType and attributes.
|
|
52
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/recordCustomEvent/}
|
|
53
|
+
* @param {string} eventType The eventType to store the event as.
|
|
54
|
+
* @param {object} [attributes] JSON object with one or more key/value pairs. For example: {key:"value"}.
|
|
55
|
+
*/
|
|
56
|
+
recordCustomEvent(eventType, attributes) {
|
|
57
|
+
return this.#callMethod(_constants.RECORD_CUSTOM_EVENT, eventType, attributes);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Groups page views to help URL structure or to capture the URL's routing information.
|
|
62
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setpageviewname/}
|
|
63
|
+
* @param {string} name The page name you want to use. Use alphanumeric characters.
|
|
64
|
+
* @param {string} [host] Default is http://custom.transaction. Typically set host to your site's domain URI.
|
|
65
|
+
*/
|
|
66
|
+
setPageViewName(name, host) {
|
|
67
|
+
return this.#callMethod(_constants.SET_PAGE_VIEW_NAME, name, host);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Adds a user-defined attribute name and value to subsequent events on the page.
|
|
72
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setcustomattribute/}
|
|
73
|
+
* @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.
|
|
74
|
+
* @param {string|number|boolean|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, Integers and Booleans. Passing a null value unsets any existing attribute of the same name.
|
|
75
|
+
* @param {boolean} [persist] Default false. If 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.
|
|
76
|
+
*/
|
|
77
|
+
setCustomAttribute(name, value, persist) {
|
|
78
|
+
return this.#callMethod(_constants.SET_CUSTOM_ATTRIBUTE, name, value, persist);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Identifies a browser error without disrupting your app's operations.
|
|
83
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/noticeerror/}
|
|
84
|
+
* @param {Error|string} error Provide a meaningful error message that you can use when analyzing data on browser's JavaScript errors page.
|
|
85
|
+
* @param {object} [customAttributes] An object containing name/value pairs representing custom attributes.
|
|
86
|
+
*/
|
|
87
|
+
noticeError(error, customAttributes) {
|
|
88
|
+
return this.#callMethod(_constants.NOTICE_ERROR, error, customAttributes);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Adds a user-defined identifier string to subsequent events on the page.
|
|
93
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setuserid/}
|
|
94
|
+
* @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.
|
|
95
|
+
*/
|
|
96
|
+
setUserId(value) {
|
|
97
|
+
return this.#callMethod(_constants.SET_USER_ID, value);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Adds a user-defined application version string to subsequent events on the page.
|
|
102
|
+
* This decorates all payloads with an attribute of `application.version` which is queryable in NR1.
|
|
103
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setapplicationversion/}
|
|
104
|
+
* @param {string|null} value A string identifier for the application version, useful for
|
|
105
|
+
* tying all browser events to a specific release tag. The value parameter does not
|
|
106
|
+
* have to be unique. Passing a null value unsets any existing value.
|
|
107
|
+
*/
|
|
108
|
+
setApplicationVersion(value) {
|
|
109
|
+
return this.#callMethod(_constants.SET_APPLICATION_VERSION, value);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Allows selective ignoring and grouping of known errors that the browser agent captures.
|
|
114
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/seterrorhandler/}
|
|
115
|
+
* @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.
|
|
116
|
+
*/
|
|
117
|
+
setErrorHandler(callback) {
|
|
118
|
+
return this.#callMethod(_constants.SET_ERROR_HANDLER, callback);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Adds a unique name and ID to identify releases with multiple JavaScript bundles on the same page.
|
|
123
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/addrelease/}
|
|
124
|
+
* @param {string} name A short description of the component; for example, the name of a project, application, file, or library.
|
|
125
|
+
* @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.
|
|
126
|
+
*/
|
|
127
|
+
addRelease(name, id) {
|
|
128
|
+
return this.#callMethod(_constants.ADD_RELEASE, name, id);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Capture a single log.
|
|
133
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/log/}
|
|
134
|
+
* @param {string} message String to be captured as log message
|
|
135
|
+
* @param {{customAttributes?: object, level?: 'ERROR'|'TRACE'|'DEBUG'|'INFO'|'WARN'}} [options] customAttributes defaults to `{}` if not assigned, level defaults to `info` if not assigned.
|
|
136
|
+
*/
|
|
137
|
+
log(message, options) {
|
|
138
|
+
return this.#callMethod(_constants.LOG, message, options);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Starts any and all features that are not running yet in "autoStart" mode
|
|
143
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/start/}
|
|
144
|
+
*/
|
|
145
|
+
start() {
|
|
146
|
+
return this.#callMethod(_constants.START);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Records an additional time point as "finished" in a session trace and adds a page action.
|
|
151
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/finished/}
|
|
152
|
+
* @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.
|
|
153
|
+
*/
|
|
154
|
+
finished(timeStamp) {
|
|
155
|
+
return this.#callMethod(_constants.FINISHED, timeStamp);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Forces a replay to record. If a replay is already actively recording, this call will be ignored.
|
|
160
|
+
* If a recording has not been started, a new one will be created. If a recording has been started, but is currently not recording, it will resume recording.
|
|
161
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/recordReplay/}
|
|
162
|
+
*/
|
|
163
|
+
recordReplay() {
|
|
164
|
+
return this.#callMethod(_constants.RECORD_REPLAY);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Forces an active replay to pause recording. If a replay is already actively recording, this call will cause the recording to pause.
|
|
169
|
+
* If a recording is not currently recording, this call will be ignored. This API will pause both manual and automatic replays that are in progress.
|
|
170
|
+
* The only way to resume recording after manually pausing a replay is to manually record again using the recordReplay() API.
|
|
171
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/pauseReplay/}
|
|
172
|
+
*/
|
|
173
|
+
pauseReplay() {
|
|
174
|
+
return this.#callMethod(_constants.PAUSE_REPLAY);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Adds a JavaScript object with a custom name, start time, etc. to an in-progress session trace.
|
|
179
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/addtotrace/}
|
|
180
|
+
* @param {{name: string, start: number, end?: number, origin?: string, type?: string}} customAttributes Supply a JavaScript object with these required and optional name/value pairs:
|
|
181
|
+
*
|
|
182
|
+
* - Required name/value pairs: name, start
|
|
183
|
+
* - Optional name/value pairs: end, origin, type
|
|
184
|
+
* - Note: Does not apply to MicroAgent
|
|
185
|
+
*
|
|
186
|
+
* 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.
|
|
187
|
+
*/
|
|
188
|
+
addToTrace(customAttributes) {
|
|
189
|
+
return this.#callMethod(_constants.ADD_TO_TRACE, customAttributes);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Gives SPA routes more accurate names than default names. Monitors specific routes rather than by default grouping.
|
|
194
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setcurrentroutename/}
|
|
195
|
+
* @param {string} name Current route name for the page.
|
|
196
|
+
* - Note: Does not apply to MicroAgent
|
|
197
|
+
*/
|
|
198
|
+
setCurrentRouteName(name) {
|
|
199
|
+
return this.#callMethod(_constants.SET_CURRENT_ROUTE_NAME, name);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Returns a new API object that is bound to the current SPA interaction.
|
|
204
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/interaction/}
|
|
205
|
+
* @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.
|
|
206
|
+
* - Note: Does not apply to MicroAgent
|
|
207
|
+
* - Deprecation Notice: interaction.createTracer is deprecated. See https://docs.newrelic.com/eol/2024/04/eol-04-24-24-createtracer/ for more information.
|
|
208
|
+
*/
|
|
209
|
+
interaction() {
|
|
210
|
+
return this.#callMethod(_constants.INTERACTION);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Wrap a logger function to capture a log each time the function is invoked with the message and arguments passed
|
|
215
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/wraplogger/}
|
|
216
|
+
* @param {object} parent The parent object containing the logger method
|
|
217
|
+
* @param {string} functionName The property name of the function in the parent object to be wrapped
|
|
218
|
+
* @param {{customAttributes?: object, level?: 'ERROR'|'TRACE'|'DEBUG'|'INFO'|'WARN'}} [options] customAttributes defaults to `{}` if not assigned, level defaults to `info` if not assigned.
|
|
219
|
+
*/
|
|
220
|
+
wrapLogger(parent, functionName, options) {
|
|
221
|
+
return this.#callMethod(_constants.WRAP_LOGGER, parent, functionName, options);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
exports.ApiBase = ApiBase;
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.configure = configure;
|
|
7
|
-
var
|
|
7
|
+
var _topLevelCallers = require("../api/topLevelCallers");
|
|
8
8
|
var _nreum = require("../../common/window/nreum");
|
|
9
9
|
var _info = require("../../common/config/info");
|
|
10
10
|
var _init = require("../../common/config/init");
|
|
@@ -59,7 +59,7 @@ function configure(agent, opts = {}, loaderType, forceDrain) {
|
|
|
59
59
|
internalTrafficList.push(updatedInit.proxy.assets);
|
|
60
60
|
}
|
|
61
61
|
if (updatedInit.proxy.beacon) internalTrafficList.push(updatedInit.proxy.beacon);
|
|
62
|
-
(0,
|
|
62
|
+
(0, _topLevelCallers.setTopLevelCallers)(agent); // no need to set global APIs on newrelic obj more than once
|
|
63
63
|
(0, _nreum.addToNREUM)('activatedFeatures', _featureFlags.activatedFeatures);
|
|
64
64
|
|
|
65
65
|
// Update if soft_navigations is allowed to run AND part of this agent build, used to override old spa functions.
|
|
@@ -72,8 +72,6 @@ function configure(agent, opts = {}, loaderType, forceDrain) {
|
|
|
72
72
|
if (!alreadySetOnce.has(agent.agentIdentifier)) {
|
|
73
73
|
agent.ee = _contextualEe.ee.get(agent.agentIdentifier);
|
|
74
74
|
agent.exposed = exposed;
|
|
75
|
-
(0, _api.setAPI)(agent, forceDrain); // assign our API functions to the agent instance
|
|
76
|
-
|
|
77
75
|
(0, _globalEvent.dispatchGlobalEvent)({
|
|
78
76
|
agentIdentifier: agent.agentIdentifier,
|
|
79
77
|
drained: !!_featureFlags.activatedFeatures?.[agent.agentIdentifier],
|
|
@@ -4,145 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.MicroAgentBase = void 0;
|
|
7
|
-
var _console = require("../common/util/console");
|
|
8
7
|
var _uniqueId = require("../common/ids/unique-id");
|
|
8
|
+
var _apiBase = require("./api-base");
|
|
9
9
|
/**
|
|
10
10
|
* Copyright 2020-2025 New Relic, Inc. All rights reserved.
|
|
11
11
|
* SPDX-License-Identifier: Apache-2.0
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
class MicroAgentBase {
|
|
15
|
-
agentIdentifier;
|
|
16
|
-
constructor() {
|
|
17
|
-
this.agentIdentifier = (0, _uniqueId.generateRandomHexString)(16);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Tries to execute the api and generates a generic warning message with the api name injected if unsuccessful
|
|
22
|
-
* @param {string} methodName
|
|
23
|
-
* @param {...any} args
|
|
24
|
-
*/
|
|
25
|
-
#callMethod(methodName, ...args) {
|
|
26
|
-
if (this[methodName] === MicroAgentBase.prototype[methodName]) (0, _console.warn)(35, methodName);else return this[methodName](...args);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// MicroAgent class custom defines its own start
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Reports a browser PageAction event along with a name and optional attributes.
|
|
33
|
-
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/addpageaction/}
|
|
34
|
-
* @param {string} name Name or category of the action. Reported as the actionName attribute.
|
|
35
|
-
* @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.
|
|
36
|
-
*/
|
|
37
|
-
addPageAction(name, attributes) {
|
|
38
|
-
return this.#callMethod('addPageAction', name, attributes);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* @experimental
|
|
43
|
-
* IMPORTANT: This feature is being developed for use internally and is not in a public-facing production-ready state.
|
|
44
|
-
* It is not recommended for use in production environments and will not receive support for issues.
|
|
45
|
-
*
|
|
46
|
-
* Registers an external caller to report through the base agent to a different target than the base agent.
|
|
47
|
-
* @param {object} target the target object to report data to
|
|
48
|
-
* @param {string} target.licenseKey The licenseKey to report data to
|
|
49
|
-
* @param {string} target.applicationID The applicationID to report data to
|
|
50
|
-
* @param {string=} target.entityGuid The entityGuid to report data to
|
|
51
|
-
* @returns {object} Returns an object that contains the available API methods and configurations to use with the external caller. See loaders/api/api.js for more information.
|
|
52
|
-
*/
|
|
53
|
-
register(target) {
|
|
54
|
-
return this.#callMethod('register', target);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Records a custom event with a specified eventType and attributes.
|
|
59
|
-
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/recordCustomEvent/}
|
|
60
|
-
* @param {string} eventType The eventType to store the event as.
|
|
61
|
-
* @param {object} [attributes] JSON object with one or more key/value pairs. For example: {key:"value"}.
|
|
62
|
-
*/
|
|
63
|
-
recordCustomEvent(eventType, attributes) {
|
|
64
|
-
return this.#callMethod('recordCustomEvent', eventType, attributes);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Groups page views to help URL structure or to capture the URL's routing information.
|
|
69
|
-
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setpageviewname/}
|
|
70
|
-
* @param {string} name The page name you want to use. Use alphanumeric characters.
|
|
71
|
-
* @param {string} [host] Default is http://custom.transaction. Typically set host to your site's domain URI.
|
|
72
|
-
*/
|
|
73
|
-
setPageViewName(name, host) {
|
|
74
|
-
return this.#callMethod('setPageViewName', name, host);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Adds a user-defined attribute name and value to subsequent events on the page.
|
|
79
|
-
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setcustomattribute/}
|
|
80
|
-
* @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.
|
|
81
|
-
* @param {string|number|boolean|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, Integers and Booleans. Passing a null value unsets any existing attribute of the same name.
|
|
82
|
-
* @param {boolean} [persist] Default false. If 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.
|
|
83
|
-
*/
|
|
84
|
-
setCustomAttribute(name, value, persist) {
|
|
85
|
-
return this.#callMethod('setCustomAttribute', name, value, persist);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Identifies a browser error without disrupting your app's operations.
|
|
90
|
-
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/noticeerror/}
|
|
91
|
-
* @param {Error|string} error Provide a meaningful error message that you can use when analyzing data on browser's JavaScript errors page.
|
|
92
|
-
* @param {object} [customAttributes] An object containing name/value pairs representing custom attributes.
|
|
93
|
-
*/
|
|
94
|
-
noticeError(error, customAttributes) {
|
|
95
|
-
return this.#callMethod('noticeError', error, customAttributes);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Adds a user-defined identifier string to subsequent events on the page.
|
|
100
|
-
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setuserid/}
|
|
101
|
-
* @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.
|
|
102
|
-
*/
|
|
103
|
-
setUserId(value) {
|
|
104
|
-
return this.#callMethod('setUserId', value);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Adds a user-defined application version string to subsequent events on the page.
|
|
109
|
-
* This decorates all payloads with an attribute of `application.version` which is queryable in NR1.
|
|
110
|
-
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setapplicationversion/}
|
|
111
|
-
* @param {string|null} value A string identifier for the application version, useful for
|
|
112
|
-
* tying all browser events to a specific release tag. The value parameter does not
|
|
113
|
-
* have to be unique. Passing a null value unsets any existing value.
|
|
114
|
-
*/
|
|
115
|
-
setApplicationVersion(value) {
|
|
116
|
-
return this.#callMethod('setApplicationVersion', value);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Allows selective ignoring and grouping of known errors that the browser agent captures.
|
|
121
|
-
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/seterrorhandler/}
|
|
122
|
-
* @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.
|
|
123
|
-
*/
|
|
124
|
-
setErrorHandler(callback) {
|
|
125
|
-
return this.#callMethod('setErrorHandler', callback);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Adds a unique name and ID to identify releases with multiple JavaScript bundles on the same page.
|
|
130
|
-
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/addrelease/}
|
|
131
|
-
* @param {string} name A short description of the component; for example, the name of a project, application, file, or library.
|
|
132
|
-
* @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.
|
|
133
|
-
*/
|
|
134
|
-
addRelease(name, id) {
|
|
135
|
-
return this.#callMethod('addRelease', name, id);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Capture a single log.
|
|
140
|
-
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/log/}
|
|
141
|
-
* @param {string} message String to be captured as log message
|
|
142
|
-
* @param {{customAttributes?: object, level?: 'ERROR'|'TRACE'|'DEBUG'|'INFO'|'WARN'}} [options] customAttributes defaults to `{}` if not assigned, level defaults to `info` if not assigned.
|
|
143
|
-
*/
|
|
144
|
-
log(message, options) {
|
|
145
|
-
return this.#callMethod('log', message, options);
|
|
146
|
-
}
|
|
14
|
+
class MicroAgentBase extends _apiBase.ApiBase {
|
|
15
|
+
agentIdentifier = (0, _uniqueId.generateRandomHexString)(16);
|
|
147
16
|
}
|
|
148
17
|
exports.MicroAgentBase = MicroAgentBase;
|
|
@@ -11,17 +11,30 @@ var _nreum = require("../common/window/nreum");
|
|
|
11
11
|
var _features = require("./features/features");
|
|
12
12
|
var _console = require("../common/util/console");
|
|
13
13
|
var _microAgentBase = require("./micro-agent-base");
|
|
14
|
+
var _setCustomAttribute = require("./api/setCustomAttribute");
|
|
15
|
+
var _setUserId = require("./api/setUserId");
|
|
16
|
+
var _setApplicationVersion = require("./api/setApplicationVersion");
|
|
17
|
+
var _start = require("./api/start");
|
|
18
|
+
var _noticeError = require("./api/noticeError");
|
|
19
|
+
var _setErrorHandler = require("./api/setErrorHandler");
|
|
20
|
+
var _addRelease = require("./api/addRelease");
|
|
21
|
+
var _addPageAction = require("./api/addPageAction");
|
|
22
|
+
var _recordCustomEvent = require("./api/recordCustomEvent");
|
|
23
|
+
var _finished = require("./api/finished");
|
|
24
|
+
var _log = require("./api/log");
|
|
25
|
+
var _wrapLogger = require("./api/wrapLogger");
|
|
14
26
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
27
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } /**
|
|
16
28
|
* Copyright 2020-2025 New Relic, Inc. All rights reserved.
|
|
17
29
|
* SPDX-License-Identifier: Apache-2.0
|
|
18
30
|
*/ // loader files
|
|
19
31
|
// core files
|
|
32
|
+
// api files that are not auto-instrumented
|
|
20
33
|
const nonAutoFeatures = [_features.FEATURE_NAMES.jserrors, _features.FEATURE_NAMES.genericEvents, _features.FEATURE_NAMES.metrics, _features.FEATURE_NAMES.logging];
|
|
21
34
|
|
|
22
35
|
/**
|
|
23
36
|
* @deprecated This feature has been deprecated and will be removed in a future release. A future product centralizing around a single agent instance will be released as a replacement, at which time this loader will be removed.
|
|
24
|
-
* A minimal agent class designed to only respond to manual user input. As such, this class does not
|
|
37
|
+
* --- A minimal agent class designed to only respond to manual user input. As such, this class does not
|
|
25
38
|
* automatically instrument. Instead, each MicroAgent instance will lazy load the required features and can support loading multiple instances on one page.
|
|
26
39
|
* Out of the box, it can manually handle and report Page View, Page Action, and Error events.
|
|
27
40
|
*/
|
|
@@ -40,6 +53,25 @@ class MicroAgent extends _microAgentBase.MicroAgentBase {
|
|
|
40
53
|
}
|
|
41
54
|
}, options.loaderType || 'micro-agent');
|
|
42
55
|
|
|
56
|
+
/** assign base agent-level API definitions */
|
|
57
|
+
(0, _setCustomAttribute.setupSetCustomAttributeAPI)(this);
|
|
58
|
+
(0, _setUserId.setupSetUserIdAPI)(this);
|
|
59
|
+
(0, _setApplicationVersion.setupSetApplicationVersionAPI)(this);
|
|
60
|
+
(0, _start.setupStartAPI)(this);
|
|
61
|
+
|
|
62
|
+
/** feature APIs that wont get set up automatically for the micro agent since it skips the inst file */
|
|
63
|
+
/** jserrors */
|
|
64
|
+
(0, _noticeError.setupNoticeErrorAPI)(this);
|
|
65
|
+
(0, _setErrorHandler.setupSetErrorHandlerAPI)(this);
|
|
66
|
+
(0, _addRelease.setupAddReleaseAPI)(this);
|
|
67
|
+
/** generic events */
|
|
68
|
+
(0, _addPageAction.setupAddPageActionAPI)(this);
|
|
69
|
+
(0, _recordCustomEvent.setupRecordCustomEventAPI)(this);
|
|
70
|
+
(0, _finished.setupFinishedAPI)(this);
|
|
71
|
+
/** logging */
|
|
72
|
+
(0, _log.setupLogAPI)(this);
|
|
73
|
+
(0, _wrapLogger.setupWrapLoggerAPI)(this);
|
|
74
|
+
|
|
43
75
|
/**
|
|
44
76
|
* Starts a set of agent features if not running in "autoStart" mode
|
|
45
77
|
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/start/}
|
|
@@ -62,11 +94,7 @@ class MicroAgent extends _microAgentBase.MicroAgentBase {
|
|
|
62
94
|
so as to avoid the race condition of things like session and sharedAggregator not being ready by features that uses them right away. */
|
|
63
95
|
nonAutoFeatures.forEach(f => {
|
|
64
96
|
if (enabledFeatures[f] && featureNames.includes(f)) {
|
|
65
|
-
Promise
|
|
66
|
-
lazyFeatureLoader
|
|
67
|
-
}) => {
|
|
68
|
-
return lazyFeatureLoader(f, 'aggregate');
|
|
69
|
-
}).then(({
|
|
97
|
+
(specifier => new Promise(r => r(specifier)).then(s => _interopRequireWildcard(require(s))))("../features/".concat(f, "/aggregate")).then(({
|
|
70
98
|
Aggregate
|
|
71
99
|
}) => {
|
|
72
100
|
this.features[f] = new Aggregate(this);
|
|
@@ -26,8 +26,8 @@ var origXHR = gosNREUMOriginals().o.XHR;
|
|
|
26
26
|
const NR_CAT_HEADER = 'X-NewRelic-App-Data';
|
|
27
27
|
export class Instrument extends InstrumentBase {
|
|
28
28
|
static featureName = FEATURE_NAME;
|
|
29
|
-
constructor(agentRef
|
|
30
|
-
super(agentRef, FEATURE_NAME
|
|
29
|
+
constructor(agentRef) {
|
|
30
|
+
super(agentRef, FEATURE_NAME);
|
|
31
31
|
this.dt = new DT(agentRef);
|
|
32
32
|
this.handler = (type, args, ctx, group) => handle(type, args, ctx, group, this.ee);
|
|
33
33
|
|
|
@@ -65,7 +65,7 @@ export class Instrument extends InstrumentBase {
|
|
|
65
65
|
wrapFetch(this.ee);
|
|
66
66
|
wrapXhr(this.ee);
|
|
67
67
|
subscribeToEvents(agentRef, this.ee, this.handler, this.dt);
|
|
68
|
-
this.importAggregator(agentRef);
|
|
68
|
+
this.importAggregator(agentRef, () => import(/* webpackChunkName: "ajax-aggregate" */'../aggregate/index.js'));
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
function subscribeToEvents(agentRef, ee, handler, dt) {
|
|
@@ -76,6 +76,7 @@ export class Aggregate extends AggregateBase {
|
|
|
76
76
|
actionMs: aggregatedUserAction.relativeMs,
|
|
77
77
|
rageClick: aggregatedUserAction.rageClick,
|
|
78
78
|
target: aggregatedUserAction.selectorPath,
|
|
79
|
+
currentUrl: aggregatedUserAction.currentUrl,
|
|
79
80
|
...(isIFrameWindow(window) && {
|
|
80
81
|
iframe: true
|
|
81
82
|
}),
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
import { RAGE_CLICK_THRESHOLD_EVENTS, RAGE_CLICK_THRESHOLD_MS } from '../../constants';
|
|
6
|
+
import { cleanURL } from '../../../../common/url/clean-url';
|
|
6
7
|
export class AggregatedUserAction {
|
|
7
8
|
constructor(evt, selectorPath, nearestTargetFields) {
|
|
8
9
|
this.event = evt;
|
|
@@ -12,6 +13,7 @@ export class AggregatedUserAction {
|
|
|
12
13
|
this.selectorPath = selectorPath;
|
|
13
14
|
this.rageClick = undefined;
|
|
14
15
|
this.nearestTargetFields = nearestTargetFields;
|
|
16
|
+
this.currentUrl = cleanURL('' + location);
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
/**
|
|
@@ -7,14 +7,24 @@ import { globalScope, isBrowserScope } from '../../../common/constants/runtime';
|
|
|
7
7
|
import { handle } from '../../../common/event-emitter/handle';
|
|
8
8
|
import { windowAddEventListener } from '../../../common/event-listener/event-listener-opts';
|
|
9
9
|
import { debounce } from '../../../common/util/invoke';
|
|
10
|
+
import { setupAddPageActionAPI } from '../../../loaders/api/addPageAction';
|
|
11
|
+
import { setupFinishedAPI } from '../../../loaders/api/finished';
|
|
12
|
+
import { setupRecordCustomEventAPI } from '../../../loaders/api/recordCustomEvent';
|
|
13
|
+
import { setupRegisterAPI } from '../../../loaders/api/register';
|
|
10
14
|
import { InstrumentBase } from '../../utils/instrument-base';
|
|
11
15
|
import { FEATURE_NAME, OBSERVED_EVENTS, OBSERVED_WINDOW_EVENTS } from '../constants';
|
|
12
16
|
export class Instrument extends InstrumentBase {
|
|
13
17
|
static featureName = FEATURE_NAME;
|
|
14
|
-
constructor(agentRef
|
|
15
|
-
super(agentRef, FEATURE_NAME
|
|
18
|
+
constructor(agentRef) {
|
|
19
|
+
super(agentRef, FEATURE_NAME);
|
|
16
20
|
/** config values that gate whether the generic events aggregator should be imported at all */
|
|
17
21
|
const genericEventSourceConfigs = [agentRef.init.page_action.enabled, agentRef.init.performance.capture_marks, agentRef.init.performance.capture_measures, agentRef.init.user_actions.enabled, agentRef.init.performance.resources.enabled];
|
|
22
|
+
|
|
23
|
+
/** feature specific APIs */
|
|
24
|
+
setupAddPageActionAPI(agentRef);
|
|
25
|
+
setupRecordCustomEventAPI(agentRef);
|
|
26
|
+
setupFinishedAPI(agentRef);
|
|
27
|
+
setupRegisterAPI(agentRef);
|
|
18
28
|
if (isBrowserScope) {
|
|
19
29
|
if (agentRef.init.user_actions.enabled) {
|
|
20
30
|
OBSERVED_EVENTS.forEach(eventType => windowAddEventListener(eventType, evt => handle('ua', [evt], undefined, this.featureName, this.ee), true));
|
|
@@ -43,7 +53,7 @@ export class Instrument extends InstrumentBase {
|
|
|
43
53
|
}
|
|
44
54
|
|
|
45
55
|
/** If any of the sources are active, import the aggregator. otherwise deregister */
|
|
46
|
-
if (genericEventSourceConfigs.some(x => x)) this.importAggregator(agentRef);else this.deregisterDrain();
|
|
56
|
+
if (genericEventSourceConfigs.some(x => x)) this.importAggregator(agentRef, () => import(/* webpackChunkName: "generic_events-aggregate" */'../aggregate'));else this.deregisterDrain();
|
|
47
57
|
}
|
|
48
58
|
}
|
|
49
59
|
export const GenericEvents = Instrument;
|
|
@@ -11,11 +11,21 @@ import { eventListenerOpts } from '../../../common/event-listener/event-listener
|
|
|
11
11
|
import { now } from '../../../common/timing/now';
|
|
12
12
|
import { SR_EVENT_EMITTER_TYPES } from '../../session_replay/constants';
|
|
13
13
|
import { castError, castErrorEvent, castPromiseRejectionEvent } from '../shared/cast-error';
|
|
14
|
+
import { setupNoticeErrorAPI } from '../../../loaders/api/noticeError';
|
|
15
|
+
import { setupSetErrorHandlerAPI } from '../../../loaders/api/setErrorHandler';
|
|
16
|
+
import { setupAddReleaseAPI } from '../../../loaders/api/addRelease';
|
|
17
|
+
import { setupRegisterAPI } from '../../../loaders/api/register';
|
|
14
18
|
export class Instrument extends InstrumentBase {
|
|
15
19
|
static featureName = FEATURE_NAME;
|
|
16
20
|
#replayRunning = false;
|
|
17
|
-
constructor(agentRef
|
|
18
|
-
super(agentRef, FEATURE_NAME
|
|
21
|
+
constructor(agentRef) {
|
|
22
|
+
super(agentRef, FEATURE_NAME);
|
|
23
|
+
|
|
24
|
+
/** feature specific APIs */
|
|
25
|
+
setupNoticeErrorAPI(agentRef);
|
|
26
|
+
setupSetErrorHandlerAPI(agentRef);
|
|
27
|
+
setupAddReleaseAPI(agentRef);
|
|
28
|
+
setupRegisterAPI(agentRef);
|
|
19
29
|
try {
|
|
20
30
|
// this try-catch can be removed when IE11 is completely unsupported & gone
|
|
21
31
|
this.removeOnAbort = new AbortController();
|
|
@@ -38,7 +48,7 @@ export class Instrument extends InstrumentBase {
|
|
|
38
48
|
handle('err', [castErrorEvent(errorEvent), now(), false, {}, this.#replayRunning], undefined, this.featureName, this.ee);
|
|
39
49
|
}, eventListenerOpts(false, this.removeOnAbort?.signal));
|
|
40
50
|
this.abortHandler = this.#abort; // we also use this as a flag to denote that the feature is active or on and handling errors
|
|
41
|
-
this.importAggregator(agentRef);
|
|
51
|
+
this.importAggregator(agentRef, () => import(/* webpackChunkName: "jserrors-aggregate" */'../aggregate'));
|
|
42
52
|
}
|
|
43
53
|
|
|
44
54
|
/** Restoration and resource release tasks to be done if JS error loader is being aborted. Unwind changes to globals. */
|
|
@@ -7,10 +7,18 @@ import { FEATURE_NAME } from '../constants';
|
|
|
7
7
|
import { bufferLog } from '../shared/utils';
|
|
8
8
|
import { wrapLogger } from '../../../common/wrap/wrap-logger';
|
|
9
9
|
import { globalScope } from '../../../common/constants/runtime';
|
|
10
|
+
import { setupLogAPI } from '../../../loaders/api/log';
|
|
11
|
+
import { setupWrapLoggerAPI } from '../../../loaders/api/wrapLogger';
|
|
12
|
+
import { setupRegisterAPI } from '../../../loaders/api/register';
|
|
10
13
|
export class Instrument extends InstrumentBase {
|
|
11
14
|
static featureName = FEATURE_NAME;
|
|
12
|
-
constructor(agentRef
|
|
13
|
-
super(agentRef, FEATURE_NAME
|
|
15
|
+
constructor(agentRef) {
|
|
16
|
+
super(agentRef, FEATURE_NAME);
|
|
17
|
+
|
|
18
|
+
/** feature specific APIs */
|
|
19
|
+
setupLogAPI(agentRef);
|
|
20
|
+
setupWrapLoggerAPI(agentRef);
|
|
21
|
+
setupRegisterAPI(agentRef);
|
|
14
22
|
const instanceEE = this.ee;
|
|
15
23
|
wrapLogger(instanceEE, globalScope.console, 'log', {
|
|
16
24
|
level: 'info'
|
|
@@ -38,7 +46,7 @@ export class Instrument extends InstrumentBase {
|
|
|
38
46
|
} = this;
|
|
39
47
|
bufferLog(instanceEE, message, customAttributes, level);
|
|
40
48
|
});
|
|
41
|
-
this.importAggregator(agentRef);
|
|
49
|
+
this.importAggregator(agentRef, () => import(/* webpackChunkName: "logging-aggregate" */'../aggregate'));
|
|
42
50
|
}
|
|
43
51
|
}
|
|
44
52
|
export const Logging = Instrument;
|