@newrelic/browser-agent 1.299.0 → 1.300.0-rc.1

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 (30) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/common/config/init.js +2 -14
  3. package/dist/cjs/common/constants/env.cdn.js +1 -1
  4. package/dist/cjs/common/constants/env.npm.js +1 -1
  5. package/dist/cjs/common/harvest/harvester.js +4 -3
  6. package/dist/cjs/features/generic_events/constants.js +0 -2
  7. package/dist/cjs/features/logging/aggregate/index.js +3 -3
  8. package/dist/cjs/loaders/api-base.js +4 -2
  9. package/dist/cjs/loaders/micro-agent.js +17 -1
  10. package/dist/esm/common/config/init.js +2 -14
  11. package/dist/esm/common/constants/env.cdn.js +1 -1
  12. package/dist/esm/common/constants/env.npm.js +1 -1
  13. package/dist/esm/common/harvest/harvester.js +4 -3
  14. package/dist/esm/features/generic_events/constants.js +0 -2
  15. package/dist/esm/features/logging/aggregate/index.js +3 -3
  16. package/dist/esm/loaders/api-base.js +4 -2
  17. package/dist/esm/loaders/micro-agent.js +17 -1
  18. package/dist/types/common/config/init.d.ts.map +1 -1
  19. package/dist/types/features/generic_events/constants.d.ts +0 -2
  20. package/dist/types/features/logging/aggregate/index.d.ts.map +1 -1
  21. package/dist/types/loaders/api-base.d.ts +5 -1
  22. package/dist/types/loaders/api-base.d.ts.map +1 -1
  23. package/dist/types/loaders/micro-agent.d.ts.map +1 -1
  24. package/package.json +3 -3
  25. package/src/common/config/init.js +2 -6
  26. package/src/common/harvest/harvester.js +4 -3
  27. package/src/features/generic_events/constants.js +0 -2
  28. package/src/features/logging/aggregate/index.js +2 -3
  29. package/src/loaders/api-base.js +4 -2
  30. package/src/loaders/micro-agent.js +17 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,20 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.300.0](https://github.com/newrelic/newrelic-browser-agent/compare/v1.299.0...v1.300.0) (2025-10-14)
7
+
8
+
9
+ ### Features
10
+
11
+ * Reduce hasReplay attribute false positive rate ([#1586](https://github.com/newrelic/newrelic-browser-agent/issues/1586)) ([82f1d55](https://github.com/newrelic/newrelic-browser-agent/commit/82f1d55c8a008c3219132afe471acf05b7783743))
12
+ * Remove usage of the marks and measures feature flag ([#1589](https://github.com/newrelic/newrelic-browser-agent/issues/1589)) ([cefd898](https://github.com/newrelic/newrelic-browser-agent/commit/cefd898a8e8ab35004f29e42236f096f3e6e220b))
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * Address issues with dynamic require and Rollup.js ([#1584](https://github.com/newrelic/newrelic-browser-agent/issues/1584)) ([91fd4b9](https://github.com/newrelic/newrelic-browser-agent/commit/91fd4b946f8db4fd939abd95706e2cc60c1c170b))
18
+ * Update typings for interaction API to reflect waitForEnd ([#1591](https://github.com/newrelic/newrelic-browser-agent/issues/1591)) ([c930208](https://github.com/newrelic/newrelic-browser-agent/commit/c930208c0e8e9cb9affa9e6f664d3a28b132b66c))
19
+
6
20
  ## [1.299.0](https://github.com/newrelic/newrelic-browser-agent/compare/v1.298.0...v1.299.0) (2025-10-07)
7
21
 
8
22
 
@@ -27,8 +27,6 @@ const InitModelFn = () => {
27
27
  const hiddenState = {
28
28
  feature_flags: [],
29
29
  experimental: {
30
- marks: false,
31
- measures: false,
32
30
  resources: false
33
31
  },
34
32
  mask_selector: '*',
@@ -109,18 +107,8 @@ const InitModelFn = () => {
109
107
  autoStart: true
110
108
  },
111
109
  performance: {
112
- get capture_marks() {
113
- return hiddenState.feature_flags.includes(_constants.FEATURE_FLAGS.MARKS) || hiddenState.experimental.marks;
114
- },
115
- set capture_marks(val) {
116
- hiddenState.experimental.marks = val;
117
- },
118
- get capture_measures() {
119
- return hiddenState.feature_flags.includes(_constants.FEATURE_FLAGS.MEASURES) || hiddenState.experimental.measures;
120
- },
121
- set capture_measures(val) {
122
- hiddenState.experimental.measures = val;
123
- },
110
+ capture_marks: false,
111
+ capture_measures: false,
124
112
  capture_detail: true,
125
113
  resources: {
126
114
  get enabled() {
@@ -17,7 +17,7 @@ exports.VERSION = exports.RRWEB_VERSION = exports.DIST_METHOD = exports.BUILD_EN
17
17
  /**
18
18
  * Exposes the version of the agent
19
19
  */
20
- const VERSION = exports.VERSION = "1.299.0";
20
+ const VERSION = exports.VERSION = "1.300.0-rc.1";
21
21
 
22
22
  /**
23
23
  * Exposes the build type of the agent
@@ -17,7 +17,7 @@ exports.VERSION = exports.RRWEB_VERSION = exports.DIST_METHOD = exports.BUILD_EN
17
17
  /**
18
18
  * Exposes the version of the agent
19
19
  */
20
- const VERSION = exports.VERSION = "1.299.0";
20
+ const VERSION = exports.VERSION = "1.300.0-rc.1";
21
21
 
22
22
  /**
23
23
  * Exposes the build type of the agent
@@ -300,11 +300,12 @@ function cleanPayload(payload = {}) {
300
300
  // The stuff that gets sent every time.
301
301
  function baseQueryString(agentRef, qs, endpoint, applicationID) {
302
302
  const ref = agentRef.runtime.obfuscator.obfuscateString((0, _cleanUrl.cleanURL)('' + _runtime.globalScope.location));
303
- const hr = agentRef.runtime.session?.state.sessionReplayMode === 1 && endpoint !== _features.JSERRORS;
304
- const ht = agentRef.runtime.session?.state.sessionTraceMode === 1 && ![_features.LOGS, _features.BLOBS].includes(endpoint);
303
+ const session = agentRef.runtime.session;
304
+ const hr = !!session?.state.sessionReplaySentFirstChunk && session?.state.sessionReplayMode === 1 && endpoint !== _features.JSERRORS;
305
+ const ht = !!session?.state.traceHarvestStarted && session?.state.sessionTraceMode === 1 && ![_features.LOGS, _features.BLOBS].includes(endpoint);
305
306
  const qps = ['a=' + applicationID, (0, _encode.param)('sa', agentRef.info.sa ? '' + agentRef.info.sa : ''), (0, _encode.param)('v', _env.VERSION), transactionNameParam(), (0, _encode.param)('ct', agentRef.runtime.customTransaction), '&rst=' + (0, _now.now)(), '&ck=0',
306
307
  // ck param DEPRECATED - still expected by backend
307
- '&s=' + (agentRef.runtime.session?.state.value || '0'),
308
+ '&s=' + (session?.state.value || '0'),
308
309
  // the 0 id encaps all untrackable and default traffic
309
310
  (0, _encode.param)('ref', ref), (0, _encode.param)('ptid', agentRef.runtime.ptid ? '' + agentRef.runtime.ptid : '')];
310
311
  if (hr) qps.push((0, _encode.param)('hr', '1', qs));
@@ -18,7 +18,5 @@ const RAGE_CLICK_THRESHOLD_MS = exports.RAGE_CLICK_THRESHOLD_MS = 1000;
18
18
  const FRUSTRATION_TIMEOUT_MS = exports.FRUSTRATION_TIMEOUT_MS = 2000;
19
19
  const RESERVED_EVENT_TYPES = exports.RESERVED_EVENT_TYPES = ['PageAction', 'UserAction', 'BrowserPerformance'];
20
20
  const FEATURE_FLAGS = exports.FEATURE_FLAGS = {
21
- MARKS: 'experimental.marks',
22
- MEASURES: 'experimental.measures',
23
21
  RESOURCES: 'experimental.resources'
24
22
  };
@@ -99,6 +99,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
99
99
  common: {
100
100
  /** Attributes in the `common` section are added to `all` logs generated in the payload */
101
101
  attributes: {
102
+ ...this.agentRef.info.jsAttributes,
103
+ // user-provided custom attributes
102
104
  'entity.guid': target.entityGuid,
103
105
  // browser entity guid as provided API target OR the default from RUM response if not supplied
104
106
  ...(sessionEntity && {
@@ -119,9 +121,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
119
121
  // The following 3 attributes are evaluated and dropped at ingest processing time and do not get stored on NRDB:
120
122
  'instrumentation.provider': 'browser',
121
123
  'instrumentation.version': this.agentRef.runtime.version,
122
- 'instrumentation.name': this.agentRef.runtime.loaderType,
123
- // Custom attributes
124
- ...this.agentRef.info.jsAttributes
124
+ 'instrumentation.name': this.agentRef.runtime.loaderType
125
125
  }
126
126
  },
127
127
  /** logs section contains individual unique log entries */
@@ -202,12 +202,14 @@ class ApiBase {
202
202
  /**
203
203
  * Returns a new API object that is bound to the current SPA interaction.
204
204
  * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/interaction/}
205
+ * @param {Object} [opts] Options to configure the new or existing interaction with
206
+ * @param {boolean} [opts.waitForEnd=false] To forcibly keep the interaction open until the `.end` method is called on its handle, set to true. Defaults to false. After an interaction is earmarked with this, it cannot be undone.
205
207
  * @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
208
  * - Note: Does not apply to MicroAgent
207
209
  * - Deprecation Notice: interaction.createTracer is deprecated. See https://docs.newrelic.com/eol/2024/04/eol-04-24-24-createtracer/ for more information.
208
210
  */
209
- interaction() {
210
- return this.#callMethod(_constants.INTERACTION);
211
+ interaction(opts) {
212
+ return this.#callMethod(_constants.INTERACTION, opts);
211
213
  }
212
214
 
213
215
  /**
@@ -97,7 +97,23 @@ class MicroAgent extends _microAgentBase.MicroAgentBase {
97
97
  so as to avoid the race condition of things like session and sharedAggregator not being ready by features that uses them right away. */
98
98
  nonAutoFeatures.forEach(f => {
99
99
  if (enabledFeatures[f] && featureNames.includes(f)) {
100
- (specifier => new Promise(r => r(specifier)).then(s => _interopRequireWildcard(require(s))))("../features/".concat(f, "/aggregate")).then(({
100
+ let lazyImport;
101
+ /** Define these imports with static strings to not break tools like roll-up */
102
+ switch (f) {
103
+ case 'jserrors':
104
+ lazyImport = Promise.resolve().then(() => _interopRequireWildcard(require('../features/jserrors/aggregate')));
105
+ break;
106
+ case 'generic_events':
107
+ lazyImport = Promise.resolve().then(() => _interopRequireWildcard(require('../features/generic_events/aggregate')));
108
+ break;
109
+ case 'metrics':
110
+ lazyImport = Promise.resolve().then(() => _interopRequireWildcard(require('../features/metrics/aggregate')));
111
+ break;
112
+ case 'logging':
113
+ lazyImport = Promise.resolve().then(() => _interopRequireWildcard(require('../features/logging/aggregate')));
114
+ break;
115
+ }
116
+ lazyImport.then(({
101
117
  Aggregate
102
118
  }) => {
103
119
  this.features[f] = new Aggregate(this);
@@ -21,8 +21,6 @@ const InitModelFn = () => {
21
21
  const hiddenState = {
22
22
  feature_flags: [],
23
23
  experimental: {
24
- marks: false,
25
- measures: false,
26
24
  resources: false
27
25
  },
28
26
  mask_selector: '*',
@@ -103,18 +101,8 @@ const InitModelFn = () => {
103
101
  autoStart: true
104
102
  },
105
103
  performance: {
106
- get capture_marks() {
107
- return hiddenState.feature_flags.includes(FEATURE_FLAGS.MARKS) || hiddenState.experimental.marks;
108
- },
109
- set capture_marks(val) {
110
- hiddenState.experimental.marks = val;
111
- },
112
- get capture_measures() {
113
- return hiddenState.feature_flags.includes(FEATURE_FLAGS.MEASURES) || hiddenState.experimental.measures;
114
- },
115
- set capture_measures(val) {
116
- hiddenState.experimental.measures = val;
117
- },
104
+ capture_marks: false,
105
+ capture_measures: false,
118
106
  capture_detail: true,
119
107
  resources: {
120
108
  get enabled() {
@@ -11,7 +11,7 @@
11
11
  /**
12
12
  * Exposes the version of the agent
13
13
  */
14
- export const VERSION = "1.299.0";
14
+ export const VERSION = "1.300.0-rc.1";
15
15
 
16
16
  /**
17
17
  * Exposes the build type of the agent
@@ -11,7 +11,7 @@
11
11
  /**
12
12
  * Exposes the version of the agent
13
13
  */
14
- export const VERSION = "1.299.0";
14
+ export const VERSION = "1.300.0-rc.1";
15
15
 
16
16
  /**
17
17
  * Exposes the build type of the agent
@@ -292,11 +292,12 @@ function cleanPayload(payload = {}) {
292
292
  // The stuff that gets sent every time.
293
293
  function baseQueryString(agentRef, qs, endpoint, applicationID) {
294
294
  const ref = agentRef.runtime.obfuscator.obfuscateString(cleanURL('' + globalScope.location));
295
- const hr = agentRef.runtime.session?.state.sessionReplayMode === 1 && endpoint !== JSERRORS;
296
- const ht = agentRef.runtime.session?.state.sessionTraceMode === 1 && ![LOGS, BLOBS].includes(endpoint);
295
+ const session = agentRef.runtime.session;
296
+ const hr = !!session?.state.sessionReplaySentFirstChunk && session?.state.sessionReplayMode === 1 && endpoint !== JSERRORS;
297
+ const ht = !!session?.state.traceHarvestStarted && session?.state.sessionTraceMode === 1 && ![LOGS, BLOBS].includes(endpoint);
297
298
  const qps = ['a=' + applicationID, param('sa', agentRef.info.sa ? '' + agentRef.info.sa : ''), param('v', VERSION), transactionNameParam(), param('ct', agentRef.runtime.customTransaction), '&rst=' + now(), '&ck=0',
298
299
  // ck param DEPRECATED - still expected by backend
299
- '&s=' + (agentRef.runtime.session?.state.value || '0'),
300
+ '&s=' + (session?.state.value || '0'),
300
301
  // the 0 id encaps all untrackable and default traffic
301
302
  param('ref', ref), param('ptid', agentRef.runtime.ptid ? '' + agentRef.runtime.ptid : '')];
302
303
  if (hr) qps.push(param('hr', '1', qs));
@@ -11,7 +11,5 @@ export const RAGE_CLICK_THRESHOLD_MS = 1000;
11
11
  export const FRUSTRATION_TIMEOUT_MS = 2000;
12
12
  export const RESERVED_EVENT_TYPES = ['PageAction', 'UserAction', 'BrowserPerformance'];
13
13
  export const FEATURE_FLAGS = {
14
- MARKS: 'experimental.marks',
15
- MEASURES: 'experimental.measures',
16
14
  RESOURCES: 'experimental.resources'
17
15
  };
@@ -92,6 +92,8 @@ export class Aggregate extends AggregateBase {
92
92
  common: {
93
93
  /** Attributes in the `common` section are added to `all` logs generated in the payload */
94
94
  attributes: {
95
+ ...this.agentRef.info.jsAttributes,
96
+ // user-provided custom attributes
95
97
  'entity.guid': target.entityGuid,
96
98
  // browser entity guid as provided API target OR the default from RUM response if not supplied
97
99
  ...(sessionEntity && {
@@ -112,9 +114,7 @@ export class Aggregate extends AggregateBase {
112
114
  // The following 3 attributes are evaluated and dropped at ingest processing time and do not get stored on NRDB:
113
115
  'instrumentation.provider': 'browser',
114
116
  'instrumentation.version': this.agentRef.runtime.version,
115
- 'instrumentation.name': this.agentRef.runtime.loaderType,
116
- // Custom attributes
117
- ...this.agentRef.info.jsAttributes
117
+ 'instrumentation.name': this.agentRef.runtime.loaderType
118
118
  }
119
119
  },
120
120
  /** logs section contains individual unique log entries */
@@ -196,12 +196,14 @@ export class ApiBase {
196
196
  /**
197
197
  * Returns a new API object that is bound to the current SPA interaction.
198
198
  * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/interaction/}
199
+ * @param {Object} [opts] Options to configure the new or existing interaction with
200
+ * @param {boolean} [opts.waitForEnd=false] To forcibly keep the interaction open until the `.end` method is called on its handle, set to true. Defaults to false. After an interaction is earmarked with this, it cannot be undone.
199
201
  * @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.
200
202
  * - Note: Does not apply to MicroAgent
201
203
  * - Deprecation Notice: interaction.createTracer is deprecated. See https://docs.newrelic.com/eol/2024/04/eol-04-24-24-createtracer/ for more information.
202
204
  */
203
- interaction() {
204
- return this.#callMethod(INTERACTION);
205
+ interaction(opts) {
206
+ return this.#callMethod(INTERACTION, opts);
205
207
  }
206
208
 
207
209
  /**
@@ -92,7 +92,23 @@ export class MicroAgent extends MicroAgentBase {
92
92
  so as to avoid the race condition of things like session and sharedAggregator not being ready by features that uses them right away. */
93
93
  nonAutoFeatures.forEach(f => {
94
94
  if (enabledFeatures[f] && featureNames.includes(f)) {
95
- import("../features/".concat(f, "/aggregate")).then(({
95
+ let lazyImport;
96
+ /** Define these imports with static strings to not break tools like roll-up */
97
+ switch (f) {
98
+ case 'jserrors':
99
+ lazyImport = import('../features/jserrors/aggregate');
100
+ break;
101
+ case 'generic_events':
102
+ lazyImport = import('../features/generic_events/aggregate');
103
+ break;
104
+ case 'metrics':
105
+ lazyImport = import('../features/metrics/aggregate');
106
+ break;
107
+ case 'logging':
108
+ lazyImport = import('../features/logging/aggregate');
109
+ break;
110
+ }
111
+ lazyImport.then(({
96
112
  Aggregate
97
113
  }) => {
98
114
  this.features[f] = new Aggregate(this);
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../src/common/config/init.js"],"names":[],"mappings":"AAgJO,0CAEN;mBAvIY,OAAO,cAAc,EAAE,IAAI"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../src/common/config/init.js"],"names":[],"mappings":"AA4IO,0CAEN;mBAnIY,OAAO,cAAc,EAAE,IAAI"}
@@ -6,8 +6,6 @@ export const RAGE_CLICK_THRESHOLD_MS: 1000;
6
6
  export const FRUSTRATION_TIMEOUT_MS: 2000;
7
7
  export const RESERVED_EVENT_TYPES: string[];
8
8
  export namespace FEATURE_FLAGS {
9
- let MARKS: string;
10
- let MEASURES: string;
11
9
  let RESOURCES: string;
12
10
  }
13
11
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/logging/aggregate/index.js"],"names":[],"mappings":"AAiBA;IACE,2BAAiC;IACjC,2BAqCC;IAnCC,8BAAmG;IAY5F,iBAAmC;IAyB5C,0CAKC;IAED,4HAsCC;IAED;;YAKM,0FAA0F;;;QAoB5F,0DAA0D;;QAM7D;IAED;;MAGC;IAED,yDAAyD;IACzD,yBASC;IAED,yCAIC;CACF;8BAzJ6B,4BAA4B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/logging/aggregate/index.js"],"names":[],"mappings":"AAiBA;IACE,2BAAiC;IACjC,2BAqCC;IAnCC,8BAAmG;IAY5F,iBAAmC;IAyB5C,0CAKC;IAED,4HAsCC;IAED;;YAKM,0FAA0F;;;QAmB5F,0DAA0D;;QAM7D;IAED;;MAGC;IAED,yDAAyD;IACzD,yBASC;IAED,yCAIC;CACF;8BAxJ6B,4BAA4B"}
@@ -147,11 +147,15 @@ export class ApiBase {
147
147
  /**
148
148
  * Returns a new API object that is bound to the current SPA interaction.
149
149
  * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/interaction/}
150
+ * @param {Object} [opts] Options to configure the new or existing interaction with
151
+ * @param {boolean} [opts.waitForEnd=false] To forcibly keep the interaction open until the `.end` method is called on its handle, set to true. Defaults to false. After an interaction is earmarked with this, it cannot be undone.
150
152
  * @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.
151
153
  * - Note: Does not apply to MicroAgent
152
154
  * - Deprecation Notice: interaction.createTracer is deprecated. See https://docs.newrelic.com/eol/2024/04/eol-04-24-24-createtracer/ for more information.
153
155
  */
154
- interaction(): InteractionInstance;
156
+ interaction(opts?: {
157
+ waitForEnd?: boolean | undefined;
158
+ }): InteractionInstance;
155
159
  /**
156
160
  * Wrap a logger function to capture a log each time the function is invoked with the message and arguments passed
157
161
  * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/wraplogger/}
@@ -1 +1 @@
1
- {"version":3,"file":"api-base.d.ts","sourceRoot":"","sources":["../../../src/loaders/api-base.js"],"names":[],"mappings":"AAOA;;GAEG;AACH;IAQE;;;;;OAKG;IACH,oBAHW,MAAM,eACN,MAAM,OAIhB;IAED;;;;;;;;;;;OAWG;IACH,iBALG;QAAuB,UAAU,EAAzB,MAAM;QACS,aAAa,EAA5B,MAAM;QACU,UAAU,GAA1B,MAAM,YAAC;KACf,GAAU,MAAM,CAIlB;IAED;;;;;OAKG;IACH,6BAHW,MAAM,eACN,MAAM,OAIhB;IAED;;;;;OAKG;IACH,sBAHW,MAAM,SACN,MAAM,OAIhB;IAED;;;;;;OAMG;IACH,yBAJW,MAAM,SACN,MAAM,GAAC,MAAM,GAAC,OAAO,GAAC,IAAI,YAC1B,OAAO,OAIjB;IAED;;;;;OAKG;IACH,mBAHW,KAAK,GAAC,MAAM,qBACZ,MAAM,OAIhB;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;;;;;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;;;;;;MAME;IACF,mBAJW,MAAM,gBACN,MAAM,YACN;QAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,GAAC,OAAO,GAAC,OAAO,GAAC,MAAM,GAAC,MAAM,CAAA;KAAC,OAIpF;IAED;;;;;;OAMG;IACH,cAJW,MAAM,WACN,MAAM,OAAC,GACL;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,gBAAgB,EAAE,MAAM,CAAA;KAAC,CAIpF;;CACF;kCA9NY,OAAO,yBAAyB,EAAE,mBAAmB"}
@@ -1 +1 @@
1
- {"version":3,"file":"micro-agent.d.ts","sourceRoot":"","sources":["../../../src/loaders/micro-agent.js"],"names":[],"mappings":"AAmCA;;;;;;;;GAQG;AACH;IACE;;OAEG;IACH,qBAFW,OAAO,SAAS,EAAE,YAAY,EAsExC;IAjEC,aAAkB;IAwBlB;;;;OAIG;IACH,uBAFW,MAAM,GAAC,MAAM,EAAE,aAmCzB;IAKH;;;;;MAOC;IAED,gBAEC;CACF;+BArH8B,oBAAoB"}
1
+ {"version":3,"file":"micro-agent.d.ts","sourceRoot":"","sources":["../../../src/loaders/micro-agent.js"],"names":[],"mappings":"AAmCA;;;;;;;;GAQG;AACH;IACE;;OAEG;IACH,qBAFW,OAAO,SAAS,EAAE,YAAY,EAsFxC;IAjFC,aAAkB;IAwBlB;;;;OAIG;IACH,uBAFW,MAAM,GAAC,MAAM,EAAE,aAmDzB;IAKH;;;;;MAOC;IAED,gBAEC;CACF;+BArI8B,oBAAoB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newrelic/browser-agent",
3
- "version": "1.299.0",
3
+ "version": "1.300.0-rc.1",
4
4
  "private": false,
5
5
  "author": "New Relic Browser Agent Team <browser-agent@newrelic.com>",
6
6
  "description": "New Relic Browser Agent",
@@ -187,7 +187,7 @@
187
187
  "test": " NODE_OPTIONS=--max-old-space-size=8192 jest",
188
188
  "test:unit": "jest --selectProjects unit",
189
189
  "test:component": "jest --selectProjects component",
190
- "test:types": "tsd -f ./tests/dts/**/*.ts",
190
+ "test:types": "npm run npm:build:types && tsd -f ./tests/dts/**/*.ts",
191
191
  "wdio": "node --max-old-space-size=8192 tools/wdio/bin/cli.js",
192
192
  "wdio:smoke": "node --max-old-space-size=8192 tools/wdio/bin/cli.js -T --concurrent=30",
193
193
  "build:all": "npm run cdn:build:local && npm run build:npm && npm run tools:test-builds",
@@ -291,4 +291,4 @@
291
291
  "README.md",
292
292
  "CHANGELOG.md"
293
293
  ]
294
- }
294
+ }
@@ -21,8 +21,6 @@ const InitModelFn = () => {
21
21
  const hiddenState = {
22
22
  feature_flags: [],
23
23
  experimental: {
24
- marks: false,
25
- measures: false,
26
24
  resources: false
27
25
  },
28
26
  mask_selector: '*',
@@ -72,10 +70,8 @@ const InitModelFn = () => {
72
70
  page_view_event: { enabled: true, autoStart: true },
73
71
  page_view_timing: { enabled: true, autoStart: true },
74
72
  performance: {
75
- get capture_marks () { return hiddenState.feature_flags.includes(FEATURE_FLAGS.MARKS) || hiddenState.experimental.marks },
76
- set capture_marks (val) { hiddenState.experimental.marks = val },
77
- get capture_measures () { return hiddenState.feature_flags.includes(FEATURE_FLAGS.MEASURES) || hiddenState.experimental.measures },
78
- set capture_measures (val) { hiddenState.experimental.measures = val },
73
+ capture_marks: false,
74
+ capture_measures: false,
79
75
  capture_detail: true,
80
76
  resources: {
81
77
  get enabled () { return hiddenState.feature_flags.includes(FEATURE_FLAGS.RESOURCES) || hiddenState.experimental.resources },
@@ -266,8 +266,9 @@ function cleanPayload (payload = {}) {
266
266
  // The stuff that gets sent every time.
267
267
  function baseQueryString (agentRef, qs, endpoint, applicationID) {
268
268
  const ref = agentRef.runtime.obfuscator.obfuscateString(cleanURL('' + globalScope.location))
269
- const hr = agentRef.runtime.session?.state.sessionReplayMode === 1 && endpoint !== JSERRORS
270
- const ht = agentRef.runtime.session?.state.sessionTraceMode === 1 && ![LOGS, BLOBS].includes(endpoint)
269
+ const session = agentRef.runtime.session
270
+ const hr = !!session?.state.sessionReplaySentFirstChunk && session?.state.sessionReplayMode === 1 && endpoint !== JSERRORS
271
+ const ht = !!session?.state.traceHarvestStarted && session?.state.sessionTraceMode === 1 && ![LOGS, BLOBS].includes(endpoint)
271
272
 
272
273
  const qps = [
273
274
  'a=' + applicationID,
@@ -277,7 +278,7 @@ function baseQueryString (agentRef, qs, endpoint, applicationID) {
277
278
  param('ct', agentRef.runtime.customTransaction),
278
279
  '&rst=' + now(),
279
280
  '&ck=0', // ck param DEPRECATED - still expected by backend
280
- '&s=' + (agentRef.runtime.session?.state.value || '0'), // the 0 id encaps all untrackable and default traffic
281
+ '&s=' + (session?.state.value || '0'), // the 0 id encaps all untrackable and default traffic
281
282
  param('ref', ref),
282
283
  param('ptid', (agentRef.runtime.ptid ? '' + agentRef.runtime.ptid : ''))
283
284
  ]
@@ -17,7 +17,5 @@ export const FRUSTRATION_TIMEOUT_MS = 2000
17
17
  export const RESERVED_EVENT_TYPES = ['PageAction', 'UserAction', 'BrowserPerformance']
18
18
 
19
19
  export const FEATURE_FLAGS = {
20
- MARKS: 'experimental.marks',
21
- MEASURES: 'experimental.measures',
22
20
  RESOURCES: 'experimental.resources'
23
21
  }
@@ -110,6 +110,7 @@ export class Aggregate extends AggregateBase {
110
110
  common: {
111
111
  /** Attributes in the `common` section are added to `all` logs generated in the payload */
112
112
  attributes: {
113
+ ...this.agentRef.info.jsAttributes, // user-provided custom attributes
113
114
  'entity.guid': target.entityGuid, // browser entity guid as provided API target OR the default from RUM response if not supplied
114
115
  ...(sessionEntity && {
115
116
  session: sessionEntity.state.value || '0', // The session ID that we generate and keep across page loads
@@ -123,9 +124,7 @@ export class Aggregate extends AggregateBase {
123
124
  // The following 3 attributes are evaluated and dropped at ingest processing time and do not get stored on NRDB:
124
125
  'instrumentation.provider': 'browser',
125
126
  'instrumentation.version': this.agentRef.runtime.version,
126
- 'instrumentation.name': this.agentRef.runtime.loaderType,
127
- // Custom attributes
128
- ...this.agentRef.info.jsAttributes
127
+ 'instrumentation.name': this.agentRef.runtime.loaderType
129
128
  }
130
129
  },
131
130
  /** logs section contains individual unique log entries */
@@ -197,12 +197,14 @@ export class ApiBase {
197
197
  /**
198
198
  * Returns a new API object that is bound to the current SPA interaction.
199
199
  * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/interaction/}
200
+ * @param {Object} [opts] Options to configure the new or existing interaction with
201
+ * @param {boolean} [opts.waitForEnd=false] To forcibly keep the interaction open until the `.end` method is called on its handle, set to true. Defaults to false. After an interaction is earmarked with this, it cannot be undone.
200
202
  * @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.
201
203
  * - Note: Does not apply to MicroAgent
202
204
  * - Deprecation Notice: interaction.createTracer is deprecated. See https://docs.newrelic.com/eol/2024/04/eol-04-24-24-createtracer/ for more information.
203
205
  */
204
- interaction () {
205
- return this.#callMethod(INTERACTION)
206
+ interaction (opts) {
207
+ return this.#callMethod(INTERACTION, opts)
206
208
  }
207
209
 
208
210
  /**
@@ -99,7 +99,23 @@ export class MicroAgent extends MicroAgentBase {
99
99
  so as to avoid the race condition of things like session and sharedAggregator not being ready by features that uses them right away. */
100
100
  nonAutoFeatures.forEach(f => {
101
101
  if (enabledFeatures[f] && featureNames.includes(f)) {
102
- import(`../features/${f}/aggregate`).then(({ Aggregate }) => {
102
+ let lazyImport
103
+ /** Define these imports with static strings to not break tools like roll-up */
104
+ switch (f) {
105
+ case 'jserrors':
106
+ lazyImport = import('../features/jserrors/aggregate')
107
+ break
108
+ case 'generic_events':
109
+ lazyImport = import('../features/generic_events/aggregate')
110
+ break
111
+ case 'metrics':
112
+ lazyImport = import('../features/metrics/aggregate')
113
+ break
114
+ case 'logging':
115
+ lazyImport = import('../features/logging/aggregate')
116
+ break
117
+ }
118
+ lazyImport.then(({ Aggregate }) => {
103
119
  this.features[f] = new Aggregate(this)
104
120
  this.runtime.harvester.initializedAggregates.push(this.features[f]) // so that harvester will poll this feature agg on interval
105
121
  }).catch(err => warn(25, err))