@newrelic/browser-agent 1.273.0 → 1.274.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.
Files changed (33) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/common/constants/env.cdn.js +2 -2
  3. package/dist/cjs/common/constants/env.npm.js +2 -2
  4. package/dist/cjs/features/session_replay/shared/recorder.js +0 -7
  5. package/dist/cjs/features/utils/agent-session.js +14 -19
  6. package/dist/cjs/features/utils/instrument-base.js +1 -1
  7. package/dist/cjs/loaders/agent-base.js +6 -103
  8. package/dist/cjs/loaders/micro-agent-base.js +117 -0
  9. package/dist/cjs/loaders/micro-agent.js +43 -56
  10. package/dist/esm/common/constants/env.cdn.js +2 -2
  11. package/dist/esm/common/constants/env.npm.js +2 -2
  12. package/dist/esm/features/session_replay/shared/recorder.js +0 -7
  13. package/dist/esm/features/utils/agent-session.js +14 -19
  14. package/dist/esm/features/utils/instrument-base.js +1 -1
  15. package/dist/esm/loaders/agent-base.js +6 -103
  16. package/dist/esm/loaders/micro-agent-base.js +110 -0
  17. package/dist/esm/loaders/micro-agent.js +43 -56
  18. package/dist/types/features/session_replay/shared/recorder.d.ts.map +1 -1
  19. package/dist/types/features/utils/agent-session.d.ts +1 -1
  20. package/dist/types/features/utils/agent-session.d.ts.map +1 -1
  21. package/dist/types/loaders/agent-base.d.ts +5 -76
  22. package/dist/types/loaders/agent-base.d.ts.map +1 -1
  23. package/dist/types/loaders/micro-agent-base.d.ts +75 -0
  24. package/dist/types/loaders/micro-agent-base.d.ts.map +1 -0
  25. package/dist/types/loaders/micro-agent.d.ts +4 -5
  26. package/dist/types/loaders/micro-agent.d.ts.map +1 -1
  27. package/package.json +2 -2
  28. package/src/features/session_replay/shared/recorder.js +0 -7
  29. package/src/features/utils/agent-session.js +12 -18
  30. package/src/features/utils/instrument-base.js +1 -1
  31. package/src/loaders/agent-base.js +6 -104
  32. package/src/loaders/micro-agent-base.js +113 -0
  33. package/src/loaders/micro-agent.js +42 -55
@@ -82,7 +82,7 @@ export class InstrumentBase extends FeatureBase {
82
82
  const {
83
83
  setupAgentSession
84
84
  } = await import(/* webpackChunkName: "session-manager" */'./agent-session');
85
- session = setupAgentSession(this.agentIdentifier);
85
+ session = setupAgentSession(agentRef);
86
86
  }
87
87
  } catch (e) {
88
88
  warn(20, e);
@@ -2,18 +2,13 @@
2
2
 
3
3
  import { warn } from '../common/util/console';
4
4
  import { SR_EVENT_EMITTER_TYPES } from '../features/session_replay/constants';
5
- import { generateRandomHexString } from '../common/ids/unique-id';
5
+ import { MicroAgentBase } from './micro-agent-base';
6
6
 
7
7
  /**
8
8
  * @typedef {import('./api/interaction-types').InteractionInstance} InteractionInstance
9
9
  */
10
10
 
11
- export class AgentBase {
12
- agentIdentifier;
13
- constructor(agentIdentifier = generateRandomHexString(16)) {
14
- this.agentIdentifier = agentIdentifier;
15
- }
16
-
11
+ export class AgentBase extends MicroAgentBase {
17
12
  /**
18
13
  * Tries to execute the api and generates a generic warning message with the api name injected if unsuccessful
19
14
  * @param {string} methodName
@@ -24,74 +19,11 @@ export class AgentBase {
24
19
  }
25
20
 
26
21
  /**
27
- * Reports a browser PageAction event along with a name and optional attributes.
28
- * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/addpageaction/}
29
- * @param {string} name Name or category of the action. Reported as the actionName attribute.
30
- * @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.
31
- */
32
- addPageAction(name, attributes) {
33
- return this.#callMethod('addPageAction', name, attributes);
34
- }
35
-
36
- /**
37
- * Groups page views to help URL structure or to capture the URL's routing information.
38
- * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setpageviewname/}
39
- * @param {string} name The page name you want to use. Use alphanumeric characters.
40
- * @param {string} [host] Default is http://custom.transaction. Typically set host to your site's domain URI.
41
- */
42
- setPageViewName(name, host) {
43
- return this.#callMethod('setPageViewName', name, host);
44
- }
45
-
46
- /**
47
- * Adds a user-defined attribute name and value to subsequent events on the page.
48
- * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setcustomattribute/}
49
- * @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.
50
- * @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.
51
- * @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.
52
- */
53
- setCustomAttribute(name, value, persist) {
54
- return this.#callMethod('setCustomAttribute', name, value, persist);
55
- }
56
-
57
- /**
58
- * Identifies a browser error without disrupting your app's operations.
59
- * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/noticeerror/}
60
- * @param {Error|string} error Provide a meaningful error message that you can use when analyzing data on browser's JavaScript errors page.
61
- * @param {object} [customAttributes] An object containing name/value pairs representing custom attributes.
62
- */
63
- noticeError(error, customAttributes) {
64
- return this.#callMethod('noticeError', error, customAttributes);
65
- }
66
-
67
- /**
68
- * Adds a user-defined identifier string to subsequent events on the page.
69
- * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setuserid/}
70
- * @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.
71
- */
72
- setUserId(value) {
73
- return this.#callMethod('setUserId', value);
74
- }
75
-
76
- /**
77
- * Adds a user-defined application version string to subsequent events on the page.
78
- * This decorates all payloads with an attribute of `application.version` which is queryable in NR1.
79
- * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setapplicationversion/}
80
- * @param {string|null} value A string identifier for the application version, useful for
81
- * tying all browser events to a specific release tag. The value parameter does not
82
- * have to be unique. Passing a null value unsets any existing value.
83
- */
84
- setApplicationVersion(value) {
85
- return this.#callMethod('setApplicationVersion', value);
86
- }
87
-
88
- /**
89
- * Allows selective ignoring and grouping of known errors that the browser agent captures.
90
- * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/seterrorhandler/}
91
- * @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.
22
+ * Starts any and all features that are not running yet in "autoStart" mode
23
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/start/}
92
24
  */
93
- setErrorHandler(callback) {
94
- return this.#callMethod('setErrorHandler', callback);
25
+ start() {
26
+ return this.#callMethod('start');
95
27
  }
96
28
 
97
29
  /**
@@ -103,25 +35,6 @@ export class AgentBase {
103
35
  return this.#callMethod('finished', timeStamp);
104
36
  }
105
37
 
106
- /**
107
- * Adds a unique name and ID to identify releases with multiple JavaScript bundles on the same page.
108
- * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/addrelease/}
109
- * @param {string} name A short description of the component; for example, the name of a project, application, file, or library.
110
- * @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.
111
- */
112
- addRelease(name, id) {
113
- return this.#callMethod('addRelease', name, id);
114
- }
115
-
116
- /**
117
- * Starts a set of agent features if not running in "autoStart" mode
118
- * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/start/}
119
- * @param {string|string[]} [featureNames] The name(s) of the features to start. If no name(s) are passed, all features will be started
120
- */
121
- start(featureNames) {
122
- return this.#callMethod('start', featureNames);
123
- }
124
-
125
38
  /**
126
39
  * Forces a replay to record. If a replay is already actively recording, this call will be ignored.
127
40
  * 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.
@@ -177,16 +90,6 @@ export class AgentBase {
177
90
  return this.#callMethod('interaction');
178
91
  }
179
92
 
180
- /**
181
- * Capture a single log.
182
- * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/log/}
183
- * @param {string} message String to be captured as log message
184
- * @param {{customAttributes?: object, level?: 'ERROR'|'TRACE'|'DEBUG'|'INFO'|'WARN'}} [options] customAttributes defaults to `{}` if not assigned, level defaults to `info` if not assigned.
185
- */
186
- log(message, options) {
187
- return this.#callMethod('log', message, options);
188
- }
189
-
190
93
  /**
191
94
  * Wrap a logger function to capture a log each time the function is invoked with the message and arguments passed
192
95
  * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/wraplogger/}
@@ -0,0 +1,110 @@
1
+ import { warn } from '../common/util/console';
2
+ import { generateRandomHexString } from '../common/ids/unique-id';
3
+ export class MicroAgentBase {
4
+ agentIdentifier;
5
+ constructor(agentIdentifier = generateRandomHexString(16)) {
6
+ this.agentIdentifier = agentIdentifier;
7
+ }
8
+
9
+ /**
10
+ * Tries to execute the api and generates a generic warning message with the api name injected if unsuccessful
11
+ * @param {string} methodName
12
+ * @param {...any} args
13
+ */
14
+ #callMethod(methodName, ...args) {
15
+ if (typeof this.api?.[methodName] !== 'function') warn(35, methodName);else return this.api[methodName](...args);
16
+ }
17
+
18
+ // MicroAgent class custom defines its own start
19
+
20
+ /**
21
+ * Reports a browser PageAction event along with a name and optional attributes.
22
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/addpageaction/}
23
+ * @param {string} name Name or category of the action. Reported as the actionName attribute.
24
+ * @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.
25
+ */
26
+ addPageAction(name, attributes) {
27
+ return this.#callMethod('addPageAction', name, attributes);
28
+ }
29
+
30
+ /**
31
+ * Groups page views to help URL structure or to capture the URL's routing information.
32
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setpageviewname/}
33
+ * @param {string} name The page name you want to use. Use alphanumeric characters.
34
+ * @param {string} [host] Default is http://custom.transaction. Typically set host to your site's domain URI.
35
+ */
36
+ setPageViewName(name, host) {
37
+ return this.#callMethod('setPageViewName', name, host);
38
+ }
39
+
40
+ /**
41
+ * Adds a user-defined attribute name and value to subsequent events on the page.
42
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setcustomattribute/}
43
+ * @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.
44
+ * @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.
45
+ * @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.
46
+ */
47
+ setCustomAttribute(name, value, persist) {
48
+ return this.#callMethod('setCustomAttribute', name, value, persist);
49
+ }
50
+
51
+ /**
52
+ * Identifies a browser error without disrupting your app's operations.
53
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/noticeerror/}
54
+ * @param {Error|string} error Provide a meaningful error message that you can use when analyzing data on browser's JavaScript errors page.
55
+ * @param {object} [customAttributes] An object containing name/value pairs representing custom attributes.
56
+ */
57
+ noticeError(error, customAttributes) {
58
+ return this.#callMethod('noticeError', error, customAttributes);
59
+ }
60
+
61
+ /**
62
+ * Adds a user-defined identifier string to subsequent events on the page.
63
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setuserid/}
64
+ * @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.
65
+ */
66
+ setUserId(value) {
67
+ return this.#callMethod('setUserId', value);
68
+ }
69
+
70
+ /**
71
+ * Adds a user-defined application version string to subsequent events on the page.
72
+ * This decorates all payloads with an attribute of `application.version` which is queryable in NR1.
73
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setapplicationversion/}
74
+ * @param {string|null} value A string identifier for the application version, useful for
75
+ * tying all browser events to a specific release tag. The value parameter does not
76
+ * have to be unique. Passing a null value unsets any existing value.
77
+ */
78
+ setApplicationVersion(value) {
79
+ return this.#callMethod('setApplicationVersion', value);
80
+ }
81
+
82
+ /**
83
+ * Allows selective ignoring and grouping of known errors that the browser agent captures.
84
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/seterrorhandler/}
85
+ * @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.
86
+ */
87
+ setErrorHandler(callback) {
88
+ return this.#callMethod('setErrorHandler', callback);
89
+ }
90
+
91
+ /**
92
+ * Adds a unique name and ID to identify releases with multiple JavaScript bundles on the same page.
93
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/addrelease/}
94
+ * @param {string} name A short description of the component; for example, the name of a project, application, file, or library.
95
+ * @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.
96
+ */
97
+ addRelease(name, id) {
98
+ return this.#callMethod('addRelease', name, id);
99
+ }
100
+
101
+ /**
102
+ * Capture a single log.
103
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/log/}
104
+ * @param {string} message String to be captured as log message
105
+ * @param {{customAttributes?: object, level?: 'ERROR'|'TRACE'|'DEBUG'|'INFO'|'WARN'}} [options] customAttributes defaults to `{}` if not assigned, level defaults to `info` if not assigned.
106
+ */
107
+ log(message, options) {
108
+ return this.#callMethod('log', message, options);
109
+ }
110
+ }
@@ -4,13 +4,9 @@ import { getEnabledFeatures } from './features/enabled-features';
4
4
  import { configure } from './configure/configure';
5
5
  // core files
6
6
  import { setNREUMInitializedAgent } from '../common/window/nreum';
7
- import { getInfo } from '../common/config/info';
8
- import { getConfiguration, getConfigurationValue } from '../common/config/init';
9
- import { getLoaderConfig } from '../common/config/loader-config';
10
- import { getRuntime } from '../common/config/runtime';
11
7
  import { FEATURE_NAMES } from './features/features';
12
8
  import { warn } from '../common/util/console';
13
- import { AgentBase } from './agent-base';
9
+ import { MicroAgentBase } from './micro-agent-base';
14
10
  const nonAutoFeatures = [FEATURE_NAMES.jserrors, FEATURE_NAMES.genericEvents, FEATURE_NAMES.metrics, FEATURE_NAMES.logging];
15
11
 
16
12
  /**
@@ -18,7 +14,7 @@ const nonAutoFeatures = [FEATURE_NAMES.jserrors, FEATURE_NAMES.genericEvents, FE
18
14
  * automatically instrument. Instead, each MicroAgent instance will lazy load the required features and can support loading multiple instances on one page.
19
15
  * Out of the box, it can manually handle and report Page View, Page Action, and Error events.
20
16
  */
21
- export class MicroAgent extends AgentBase {
17
+ export class MicroAgent extends MicroAgentBase {
22
18
  /**
23
19
  * @param {Object} options - Specifies features and runtime configuration,
24
20
  * @param {string=} agentIdentifier - The optional unique ID of the agent.
@@ -38,60 +34,51 @@ export class MicroAgent extends AgentBase {
38
34
  /**
39
35
  * Starts a set of agent features if not running in "autoStart" mode
40
36
  * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/start/}
41
- * @param {string|string[]|undefined} name The feature name(s) to start. If no name(s) are passed, all features will be started
37
+ * @param {string|string[]} [featureNames] The feature name(s) to start. If no name(s) are passed, all features will be started
42
38
  */
43
- this.start = features => this.run(features);
44
- this.run(nonAutoFeatures.filter(featureName => getConfigurationValue(this.agentIdentifier, "".concat(featureName, ".autoStart"))));
39
+ this.start = featureNames => {
40
+ try {
41
+ if (featureNames === undefined || Array.isArray(featureNames) && featureNames.length === 0) featureNames = nonAutoFeatures;else if (typeof featureNames === 'string') featureNames = [featureNames];
42
+ if (featureNames.some(f => !nonAutoFeatures.includes(f))) warn(37, nonAutoFeatures);
43
+ const enabledFeatures = getEnabledFeatures(this.agentIdentifier);
44
+ try {
45
+ // a biproduct of doing this is that the "session manager" is automatically handled through importing this feature
46
+ this.features.page_view_event = new PVE(this);
47
+ } catch (err) {
48
+ warn(24, err);
49
+ }
50
+ this.features.page_view_event.onAggregateImported.then(() => {
51
+ /* The following features do not import an "instrument" file, meaning they are only hooked up to the API.
52
+ Since the missing instrument-base class handles drain-gating (racing behavior) and PVE handles some setup, these are chained until after PVE has finished initializing
53
+ so as to avoid the race condition of things like session and sharedAggregator not being ready by features that uses them right away. */
54
+ nonAutoFeatures.forEach(f => {
55
+ if (enabledFeatures[f] && featureNames.includes(f)) {
56
+ import(/* webpackChunkName: "lazy-feature-loader" */'../features/utils/lazy-feature-loader').then(({
57
+ lazyFeatureLoader
58
+ }) => {
59
+ return lazyFeatureLoader(f, 'aggregate');
60
+ }).then(({
61
+ Aggregate
62
+ }) => {
63
+ this.features[f] = new Aggregate(this);
64
+ }).catch(err => warn(25, err));
65
+ }
66
+ });
67
+ });
68
+ return true;
69
+ } catch (err) {
70
+ warn(26, err);
71
+ return false;
72
+ }
73
+ };
74
+ this.start(nonAutoFeatures.filter(featureName => !!this.init[featureName].autoStart));
45
75
  }
46
76
  get config() {
47
77
  return {
48
- info: getInfo(this.agentIdentifier),
49
- init: getConfiguration(this.agentIdentifier),
50
- loader_config: getLoaderConfig(this.agentIdentifier),
51
- runtime: getRuntime(this.agentIdentifier)
78
+ info: this.info,
79
+ init: this.init,
80
+ loader_config: this.loader_config,
81
+ runtime: this.runtime
52
82
  };
53
83
  }
54
- run(features) {
55
- try {
56
- const featNames = nonAutoFeatures;
57
- if (features === undefined) features = featNames;else {
58
- features = Array.isArray(features) && features.length ? features : [features];
59
- if (features.some(f => !featNames.includes(f))) return warn(37, featNames);
60
- if (!features.includes(FEATURE_NAMES.pageViewEvent)) features.push(FEATURE_NAMES.pageViewEvent);
61
- }
62
- } catch (err) {
63
- warn(23, err);
64
- }
65
- try {
66
- const enabledFeatures = getEnabledFeatures(this.agentIdentifier);
67
- try {
68
- // a biproduct of doing this is that the "session manager" is automatically handled through importing this feature
69
- this.features.page_view_event = new PVE(this);
70
- } catch (err) {
71
- warn(24, err);
72
- }
73
- this.features.page_view_event.onAggregateImported.then(() => {
74
- /* The following features do not import an "instrument" file, meaning they are only hooked up to the API.
75
- Since the missing instrument-base class handles drain-gating (racing behavior) and PVE handles some setup, these are chained until after PVE has finished initializing
76
- so as to avoid the race condition of things like session and sharedAggregator not being ready by features that uses them right away. */
77
- nonAutoFeatures.forEach(f => {
78
- if (enabledFeatures[f] && features.includes(f)) {
79
- import(/* webpackChunkName: "lazy-feature-loader" */'../features/utils/lazy-feature-loader').then(({
80
- lazyFeatureLoader
81
- }) => {
82
- return lazyFeatureLoader(f, 'aggregate');
83
- }).then(({
84
- Aggregate
85
- }) => {
86
- this.features[f] = new Aggregate(this);
87
- }).catch(err => warn(25, err));
88
- }
89
- });
90
- });
91
- return true;
92
- } catch (err) {
93
- warn(26, err);
94
- return false;
95
- }
96
- }
97
84
  }
@@ -1 +1 @@
1
- {"version":3,"file":"recorder.d.ts","sourceRoot":"","sources":["../../../../../src/features/session_replay/shared/recorder.js"],"names":[],"mappings":"AAaA;IAUE,yBAkBC;IAdC,iEAAiE;IACjE,mBAAsB;IACtB,6DAA6D;IAC7D,oCAAuC;IACvC,+IAA+I;IAC/I,yBAA4B;IAC5B,kIAAkI;IAClI,kBAAqB;IACrB,sDAAsD;IACtD,YAAoB;IACpB,0FAA0F;IAC1F,eAAqG;IACrG,uIAAuI;IACvI,0BAAyE;IAG3E;;;;;;;;;MAmBC;IAED,mFAAmF;IACnF,oBAKC;IAED,qDAAqD;IACrD,uBA2CC;IAED;;;;;OAKG;IACH,aAHW,GAAC,cACD,GAAC,QAgCX;IAED,0HAA0H;IAC1H,yCAoDC;IA1CG,8BAAoB;IA4CxB,0HAA0H;IAC1H,yBAOC;IAED,wBAEC;IAED,gCAAgC;IAChC,uCAGC;IAED;;;SAGK;IACL,oCAGC;;CACF;+BA3O8B,mBAAmB"}
1
+ {"version":3,"file":"recorder.d.ts","sourceRoot":"","sources":["../../../../../src/features/session_replay/shared/recorder.js"],"names":[],"mappings":"AAaA;IAUE,yBAkBC;IAdC,iEAAiE;IACjE,mBAAsB;IACtB,6DAA6D;IAC7D,oCAAuC;IACvC,+IAA+I;IAC/I,yBAA4B;IAC5B,kIAAkI;IAClI,kBAAqB;IACrB,sDAAsD;IACtD,YAAoB;IACpB,0FAA0F;IAC1F,eAAqG;IACrG,uIAAuI;IACvI,0BAAyE;IAG3E;;;;;;;;;MAmBC;IAED,mFAAmF;IACnF,oBAKC;IAED,qDAAqD;IACrD,uBAoCC;IAED;;;;;OAKG;IACH,aAHW,GAAC,cACD,GAAC,QAgCX;IAED,0HAA0H;IAC1H,yCAoDC;IA1CG,8BAAoB;IA4CxB,0HAA0H;IAC1H,yBAOC;IAED,wBAEC;IAED,gCAAgC;IAChC,uCAGC;IAED;;;SAGK;IACL,oCAGC;;CACF;+BApO8B,mBAAmB"}
@@ -1,2 +1,2 @@
1
- export function setupAgentSession(agentIdentifier: any): any;
1
+ export function setupAgentSession(agentRef: any): any;
2
2
  //# sourceMappingURL=agent-session.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent-session.d.ts","sourceRoot":"","sources":["../../../../src/features/utils/agent-session.js"],"names":[],"mappings":"AAWA,6DAwCC"}
1
+ {"version":3,"file":"agent-session.d.ts","sourceRoot":"","sources":["../../../../src/features/utils/agent-session.js"],"names":[],"mappings":"AAOA,sDAsCC"}
@@ -1,80 +1,18 @@
1
1
  /**
2
2
  * @typedef {import('./api/interaction-types').InteractionInstance} InteractionInstance
3
3
  */
4
- export class AgentBase {
5
- constructor(agentIdentifier?: string);
6
- agentIdentifier: string;
4
+ export class AgentBase extends MicroAgentBase {
7
5
  /**
8
- * Reports a browser PageAction event along with a name and optional attributes.
9
- * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/addpageaction/}
10
- * @param {string} name Name or category of the action. Reported as the actionName attribute.
11
- * @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.
12
- */
13
- addPageAction(name: string, attributes?: object | undefined): any;
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: string, host?: string | undefined): any;
21
- /**
22
- * Adds a user-defined attribute name and value to subsequent events on the page.
23
- * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setcustomattribute/}
24
- * @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.
25
- * @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.
26
- * @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.
27
- */
28
- setCustomAttribute(name: string, value: string | number | boolean | null, persist?: boolean | undefined): any;
29
- /**
30
- * Identifies a browser error without disrupting your app's operations.
31
- * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/noticeerror/}
32
- * @param {Error|string} error Provide a meaningful error message that you can use when analyzing data on browser's JavaScript errors page.
33
- * @param {object} [customAttributes] An object containing name/value pairs representing custom attributes.
34
- */
35
- noticeError(error: Error | string, customAttributes?: object | undefined): any;
36
- /**
37
- * Adds a user-defined identifier string to subsequent events on the page.
38
- * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setuserid/}
39
- * @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.
40
- */
41
- setUserId(value: string | null): any;
42
- /**
43
- * Adds a user-defined application version string to subsequent events on the page.
44
- * This decorates all payloads with an attribute of `application.version` which is queryable in NR1.
45
- * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setapplicationversion/}
46
- * @param {string|null} value A string identifier for the application version, useful for
47
- * tying all browser events to a specific release tag. The value parameter does not
48
- * have to be unique. Passing a null value unsets any existing value.
6
+ * Starts any and all features that are not running yet in "autoStart" mode
7
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/start/}
49
8
  */
50
- setApplicationVersion(value: string | null): any;
51
- /**
52
- * Allows selective ignoring and grouping of known errors that the browser agent captures.
53
- * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/seterrorhandler/}
54
- * @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.
55
- */
56
- setErrorHandler(callback: (error: Error | string) => boolean | {
57
- group: string;
58
- }): any;
9
+ start(): any;
59
10
  /**
60
11
  * Records an additional time point as "finished" in a session trace and adds a page action.
61
12
  * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/finished/}
62
13
  * @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.
63
14
  */
64
15
  finished(timeStamp?: number | undefined): any;
65
- /**
66
- * Adds a unique name and ID to identify releases with multiple JavaScript bundles on the same page.
67
- * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/addrelease/}
68
- * @param {string} name A short description of the component; for example, the name of a project, application, file, or library.
69
- * @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.
70
- */
71
- addRelease(name: string, id: string): any;
72
- /**
73
- * Starts a set of agent features if not running in "autoStart" mode
74
- * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/start/}
75
- * @param {string|string[]} [featureNames] The name(s) of the features to start. If no name(s) are passed, all features will be started
76
- */
77
- start(featureNames?: string | string[] | undefined): any;
78
16
  /**
79
17
  * Forces a replay to record. If a replay is already actively recording, this call will be ignored.
80
18
  * 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.
@@ -121,16 +59,6 @@ export class AgentBase {
121
59
  * - Deprecation Notice: interaction.createTracer is deprecated. See https://docs.newrelic.com/eol/2024/04/eol-04-24-24-createtracer/ for more information.
122
60
  */
123
61
  interaction(): InteractionInstance;
124
- /**
125
- * Capture a single log.
126
- * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/log/}
127
- * @param {string} message String to be captured as log message
128
- * @param {{customAttributes?: object, level?: 'ERROR'|'TRACE'|'DEBUG'|'INFO'|'WARN'}} [options] customAttributes defaults to `{}` if not assigned, level defaults to `info` if not assigned.
129
- */
130
- log(message: string, options?: {
131
- customAttributes?: object;
132
- level?: "ERROR" | "TRACE" | "DEBUG" | "INFO" | "WARN";
133
- } | undefined): any;
134
62
  /**
135
63
  * Wrap a logger function to capture a log each time the function is invoked with the message and arguments passed
136
64
  * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/wraplogger/}
@@ -145,4 +73,5 @@ export class AgentBase {
145
73
  #private;
146
74
  }
147
75
  export type InteractionInstance = import("./api/interaction-types").InteractionInstance;
76
+ import { MicroAgentBase } from './micro-agent-base';
148
77
  //# sourceMappingURL=agent-base.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent-base.d.ts","sourceRoot":"","sources":["../../../src/loaders/agent-base.js"],"names":[],"mappings":"AAMA;;GAEG;AAEH;IAGE,sCAEC;IAJD,wBAAe;IAgBf;;;;;OAKG;IACH,oBAHW,MAAM,wCAKhB;IAED;;;;;OAKG;IACH,sBAHW,MAAM,kCAKhB;IAED;;;;;;OAMG;IACH,yBAJW,MAAM,SACN,MAAM,GAAC,MAAM,GAAC,OAAO,GAAC,IAAI,sCAKpC;IAED;;;;;OAKG;IACH,mBAHW,KAAK,GAAC,MAAM,8CAKtB;IAED;;;;OAIG;IACH,iBAFW,MAAM,GAAC,IAAI,OAIrB;IAED;;;;;;;OAOG;IACH,6BAJW,MAAM,GAAC,IAAI,OAMrB;IAED;;;;OAIG;IACH,0BAFW,CAAC,KAAK,EAAE,KAAK,GAAC,MAAM,KAAK,OAAO,GAAG;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,OAI9D;IAED;;;;OAIG;IACH,8CAEC;IAED;;;;;OAKG;IACH,iBAHW,MAAM,MACN,MAAM,OAIhB;IAED;;;;OAIG;IACH,yDAEC;IAED;;;;OAIG;IACH,oBAEC;IAED;;;;;OAKG;IACH,mBAEC;IAED;;;;;;;;;;OAUG;IACH,6BARW;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAC,OAUrF;IAED;;;;;OAKG;IACH,0BAHW,MAAM,OAKhB;IAED;;;;;;MAME;IACF,eAJa,mBAAmB,CAM/B;IAED;;;;;MAKE;IACF,aAHW,MAAM;2BACc,MAAM;gBAAU,OAAO,GAAC,OAAO,GAAC,OAAO,GAAC,MAAM,GAAC,MAAM;wBAInF;IAED;;;;;;MAME;IACF,mBAJW,MAAM,gBACN,MAAM;2BACc,MAAM;gBAAU,OAAO,GAAC,OAAO,GAAC,OAAO,GAAC,MAAM,GAAC,MAAM;wBAInF;;CACF;kCAlMY,OAAO,yBAAyB,EAAE,mBAAmB"}
1
+ {"version":3,"file":"agent-base.d.ts","sourceRoot":"","sources":["../../../src/loaders/agent-base.js"],"names":[],"mappings":"AAMA;;GAEG;AAEH;IAWE;;;OAGG;IACH,aAEC;IAED;;;;OAIG;IACH,8CAEC;IAED;;;;OAIG;IACH,oBAEC;IAED;;;;;OAKG;IACH,mBAEC;IAED;;;;;;;;;;OAUG;IACH,6BARW;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAC,OAUrF;IAED;;;;;OAKG;IACH,0BAHW,MAAM,OAKhB;IAED;;;;;;MAME;IACF,eAJa,mBAAmB,CAM/B;IAED;;;;;;MAME;IACF,mBAJW,MAAM,gBACN,MAAM;2BACc,MAAM;gBAAU,OAAO,GAAC,OAAO,GAAC,OAAO,GAAC,MAAM,GAAC,MAAM;wBAInF;;CACF;kCAhGY,OAAO,yBAAyB,EAAE,mBAAmB;+BAHnC,oBAAoB"}
@@ -0,0 +1,75 @@
1
+ export class MicroAgentBase {
2
+ constructor(agentIdentifier?: string);
3
+ agentIdentifier: string;
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: string, attributes?: object | undefined): any;
11
+ /**
12
+ * Groups page views to help URL structure or to capture the URL's routing information.
13
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setpageviewname/}
14
+ * @param {string} name The page name you want to use. Use alphanumeric characters.
15
+ * @param {string} [host] Default is http://custom.transaction. Typically set host to your site's domain URI.
16
+ */
17
+ setPageViewName(name: string, host?: string | undefined): any;
18
+ /**
19
+ * Adds a user-defined attribute name and value to subsequent events on the page.
20
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setcustomattribute/}
21
+ * @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.
22
+ * @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.
23
+ * @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.
24
+ */
25
+ setCustomAttribute(name: string, value: string | number | boolean | null, persist?: boolean | undefined): any;
26
+ /**
27
+ * Identifies a browser error without disrupting your app's operations.
28
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/noticeerror/}
29
+ * @param {Error|string} error Provide a meaningful error message that you can use when analyzing data on browser's JavaScript errors page.
30
+ * @param {object} [customAttributes] An object containing name/value pairs representing custom attributes.
31
+ */
32
+ noticeError(error: Error | string, customAttributes?: object | undefined): any;
33
+ /**
34
+ * Adds a user-defined identifier string to subsequent events on the page.
35
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setuserid/}
36
+ * @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.
37
+ */
38
+ setUserId(value: string | null): any;
39
+ /**
40
+ * Adds a user-defined application version string to subsequent events on the page.
41
+ * This decorates all payloads with an attribute of `application.version` which is queryable in NR1.
42
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setapplicationversion/}
43
+ * @param {string|null} value A string identifier for the application version, useful for
44
+ * tying all browser events to a specific release tag. The value parameter does not
45
+ * have to be unique. Passing a null value unsets any existing value.
46
+ */
47
+ setApplicationVersion(value: string | null): any;
48
+ /**
49
+ * Allows selective ignoring and grouping of known errors that the browser agent captures.
50
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/seterrorhandler/}
51
+ * @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.
52
+ */
53
+ setErrorHandler(callback: (error: Error | string) => boolean | {
54
+ group: string;
55
+ }): any;
56
+ /**
57
+ * Adds a unique name and ID to identify releases with multiple JavaScript bundles on the same page.
58
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/addrelease/}
59
+ * @param {string} name A short description of the component; for example, the name of a project, application, file, or library.
60
+ * @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.
61
+ */
62
+ addRelease(name: string, id: string): any;
63
+ /**
64
+ * Capture a single log.
65
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/log/}
66
+ * @param {string} message String to be captured as log message
67
+ * @param {{customAttributes?: object, level?: 'ERROR'|'TRACE'|'DEBUG'|'INFO'|'WARN'}} [options] customAttributes defaults to `{}` if not assigned, level defaults to `info` if not assigned.
68
+ */
69
+ log(message: string, options?: {
70
+ customAttributes?: object;
71
+ level?: "ERROR" | "TRACE" | "DEBUG" | "INFO" | "WARN";
72
+ } | undefined): any;
73
+ #private;
74
+ }
75
+ //# sourceMappingURL=micro-agent-base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"micro-agent-base.d.ts","sourceRoot":"","sources":["../../../src/loaders/micro-agent-base.js"],"names":[],"mappings":"AAGA;IAGE,sCAEC;IAJD,wBAAe;IAkBf;;;;;OAKG;IACH,oBAHW,MAAM,wCAKhB;IAED;;;;;OAKG;IACH,sBAHW,MAAM,kCAKhB;IAED;;;;;;OAMG;IACH,yBAJW,MAAM,SACN,MAAM,GAAC,MAAM,GAAC,OAAO,GAAC,IAAI,sCAKpC;IAED;;;;;OAKG;IACH,mBAHW,KAAK,GAAC,MAAM,8CAKtB;IAED;;;;OAIG;IACH,iBAFW,MAAM,GAAC,IAAI,OAIrB;IAED;;;;;;;OAOG;IACH,6BAJW,MAAM,GAAC,IAAI,OAMrB;IAED;;;;OAIG;IACH,0BAFW,CAAC,KAAK,EAAE,KAAK,GAAC,MAAM,KAAK,OAAO,GAAG;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,OAI9D;IAED;;;;;OAKG;IACH,iBAHW,MAAM,MACN,MAAM,OAIhB;IAED;;;;;MAKE;IACF,aAHW,MAAM;2BACc,MAAM;gBAAU,OAAO,GAAC,OAAO,GAAC,OAAO,GAAC,MAAM,GAAC,MAAM;wBAInF;;CACF"}
@@ -3,7 +3,7 @@
3
3
  * automatically instrument. Instead, each MicroAgent instance will lazy load the required features and can support loading multiple instances on one page.
4
4
  * Out of the box, it can manually handle and report Page View, Page Action, and Error events.
5
5
  */
6
- export class MicroAgent extends AgentBase {
6
+ export class MicroAgent extends MicroAgentBase {
7
7
  /**
8
8
  * @param {Object} options - Specifies features and runtime configuration,
9
9
  * @param {string=} agentIdentifier - The optional unique ID of the agent.
@@ -13,16 +13,15 @@ export class MicroAgent extends AgentBase {
13
13
  /**
14
14
  * Starts a set of agent features if not running in "autoStart" mode
15
15
  * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/start/}
16
- * @param {string|string[]|undefined} name The feature name(s) to start. If no name(s) are passed, all features will be started
16
+ * @param {string|string[]} [featureNames] The feature name(s) to start. If no name(s) are passed, all features will be started
17
17
  */
18
- start: (features: any) => boolean | void;
18
+ start: (featureNames?: string | string[] | undefined) => boolean;
19
19
  get config(): {
20
20
  info: any;
21
21
  init: any;
22
22
  loader_config: any;
23
23
  runtime: any;
24
24
  };
25
- run(features: any): boolean | void;
26
25
  }
27
- import { AgentBase } from './agent-base';
26
+ import { MicroAgentBase } from './micro-agent-base';
28
27
  //# sourceMappingURL=micro-agent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"micro-agent.d.ts","sourceRoot":"","sources":["../../../src/loaders/micro-agent.js"],"names":[],"mappings":"AAqBA;;;;GAIG;AACH;IACE;;;OAGG;IACH,qBAHW,MAAM,oBACN,MAAM,YAAC,EAkBjB;IAbC,aAAkB;IAMlB;;;;OAIG;IACH,yCAA2C;IAI7C;;;;;MAOC;IAED,mCA0CC;CACF;0BAzFyB,cAAc"}
1
+ {"version":3,"file":"micro-agent.d.ts","sourceRoot":"","sources":["../../../src/loaders/micro-agent.js"],"names":[],"mappings":"AAiBA;;;;GAIG;AACH;IACE;;;OAGG;IACH,qBAHW,MAAM,oBACN,MAAM,YAAC,EAqDjB;IAhDC,aAAkB;IAMlB;;;;OAIG;IACH,iEAkCC;IAKH;;;;;MAOC;CACF;+BAhF8B,oBAAoB"}