@newrelic/browser-agent 1.261.1 → 1.261.2

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 CHANGED
@@ -3,6 +3,13 @@
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.261.2](https://github.com/newrelic/newrelic-browser-agent/compare/v1.261.1...v1.261.2) (2024-07-01)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * recordReplay will restart replays on same session page loads ([#1093](https://github.com/newrelic/newrelic-browser-agent/issues/1093)) ([cecddbe](https://github.com/newrelic/newrelic-browser-agent/commit/cecddbebc445dabcf3ce48c1fc88311198be6d0a))
12
+
6
13
  ## [1.261.1](https://github.com/newrelic/newrelic-browser-agent/compare/v1.261.0...v1.261.1) (2024-06-26)
7
14
 
8
15
 
@@ -12,7 +12,7 @@ exports.VERSION = exports.RRWEB_VERSION = exports.DIST_METHOD = exports.BUILD_EN
12
12
  /**
13
13
  * Exposes the version of the agent
14
14
  */
15
- const VERSION = exports.VERSION = "1.261.1";
15
+ const VERSION = exports.VERSION = "1.261.2";
16
16
 
17
17
  /**
18
18
  * Exposes the build type of the agent
@@ -12,7 +12,7 @@ exports.VERSION = exports.RRWEB_VERSION = exports.DIST_METHOD = exports.BUILD_EN
12
12
  /**
13
13
  * Exposes the version of the agent
14
14
  */
15
- const VERSION = exports.VERSION = "1.261.1";
15
+ const VERSION = exports.VERSION = "1.261.2";
16
16
 
17
17
  /**
18
18
  * Exposes the build type of the agent
@@ -32,7 +32,7 @@ class Instrument extends _instrumentBase.InstrumentBase {
32
32
  session = JSON.parse(localStorage.getItem("".concat(_constants.PREFIX, "_").concat(_constants.DEFAULT_KEY)));
33
33
  } catch (err) {}
34
34
  if ((0, _utils.hasReplayPrerequisite)(agentIdentifier)) {
35
- this.ee.on('recordReplay', () => this.#apiStartOrRestartReplay());
35
+ this.ee.on(_constants2.SR_EVENT_EMITTER_TYPES.RECORD, () => this.#apiStartOrRestartReplay());
36
36
  }
37
37
  if (this.#canPreloadRecorder(session)) {
38
38
  this.#mode = session?.sessionReplayMode;
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.buildNRMetaNode = buildNRMetaNode;
7
- exports.canImportReplayAgg = canImportReplayAgg;
8
7
  exports.hasReplayPrerequisite = hasReplayPrerequisite;
9
8
  exports.isPreloadAllowed = isPreloadAllowed;
10
9
  var _config = require("../../../common/config/config");
@@ -20,10 +19,6 @@ function hasReplayPrerequisite(agentId) {
20
19
  function isPreloadAllowed(agentId) {
21
20
  return (0, _config.getConfigurationValue)(agentId, 'session_replay.preload') === true && hasReplayPrerequisite(agentId);
22
21
  }
23
- function canImportReplayAgg(agentId, sessionMgr) {
24
- if (!hasReplayPrerequisite(agentId)) return false;
25
- return !!sessionMgr?.isNew || !!sessionMgr?.state.sessionReplayMode; // Session Replay should only try to run if already running from a previous page, or at the beginning of a session
26
- }
27
22
  function buildNRMetaNode(timestamp, timeKeeper) {
28
23
  const correctedTimestamp = timeKeeper.correctAbsoluteTimestamp(timestamp);
29
24
  return {
@@ -137,8 +137,15 @@ class InstrumentBase extends _featureBase.FeatureBase {
137
137
  * @returns
138
138
  */
139
139
  #shouldImportAgg(featureName, session) {
140
- if (featureName === _features.FEATURE_NAMES.sessionReplay) return (0, _utils.canImportReplayAgg)(this.agentIdentifier, session);
141
- return !(featureName === _features.FEATURE_NAMES.sessionTrace && !session);
140
+ switch (featureName) {
141
+ case _features.FEATURE_NAMES.sessionReplay:
142
+ // the session manager must be initialized successfully for Replay & Trace features
143
+ return (0, _utils.hasReplayPrerequisite)(this.agentIdentifier) && !!session;
144
+ case _features.FEATURE_NAMES.sessionTrace:
145
+ return !!session;
146
+ default:
147
+ return true;
148
+ }
142
149
  }
143
150
  }
144
151
  exports.InstrumentBase = InstrumentBase;
@@ -6,7 +6,7 @@
6
6
  /**
7
7
  * Exposes the version of the agent
8
8
  */
9
- export const VERSION = "1.261.1";
9
+ export const VERSION = "1.261.2";
10
10
 
11
11
  /**
12
12
  * Exposes the build type of the agent
@@ -6,7 +6,7 @@
6
6
  /**
7
7
  * Exposes the version of the agent
8
8
  */
9
- export const VERSION = "1.261.1";
9
+ export const VERSION = "1.261.2";
10
10
 
11
11
  /**
12
12
  * Exposes the build type of the agent
@@ -26,7 +26,7 @@ export class Instrument extends InstrumentBase {
26
26
  session = JSON.parse(localStorage.getItem("".concat(PREFIX, "_").concat(DEFAULT_KEY)));
27
27
  } catch (err) {}
28
28
  if (hasReplayPrerequisite(agentIdentifier)) {
29
- this.ee.on('recordReplay', () => this.#apiStartOrRestartReplay());
29
+ this.ee.on(SR_EVENT_EMITTER_TYPES.RECORD, () => this.#apiStartOrRestartReplay());
30
30
  }
31
31
  if (this.#canPreloadRecorder(session)) {
32
32
  this.#mode = session?.sessionReplayMode;
@@ -11,10 +11,6 @@ export function hasReplayPrerequisite(agentId) {
11
11
  export function isPreloadAllowed(agentId) {
12
12
  return getConfigurationValue(agentId, 'session_replay.preload') === true && hasReplayPrerequisite(agentId);
13
13
  }
14
- export function canImportReplayAgg(agentId, sessionMgr) {
15
- if (!hasReplayPrerequisite(agentId)) return false;
16
- return !!sessionMgr?.isNew || !!sessionMgr?.state.sessionReplayMode; // Session Replay should only try to run if already running from a previous page, or at the beginning of a session
17
- }
18
14
  export function buildNRMetaNode(timestamp, timeKeeper) {
19
15
  const correctedTimestamp = timeKeeper.correctAbsoluteTimestamp(timestamp);
20
16
  return {
@@ -11,7 +11,7 @@ import { isBrowserScope } from '../../common/constants/runtime';
11
11
  import { warn } from '../../common/util/console';
12
12
  import { FEATURE_NAMES } from '../../loaders/features/features';
13
13
  import { getConfigurationValue } from '../../common/config/config';
14
- import { canImportReplayAgg } from '../session_replay/shared/utils';
14
+ import { hasReplayPrerequisite } from '../session_replay/shared/utils';
15
15
  import { canEnableSessionTracking } from './feature-gates';
16
16
  import { single } from '../../common/util/invoke';
17
17
 
@@ -132,7 +132,14 @@ export class InstrumentBase extends FeatureBase {
132
132
  * @returns
133
133
  */
134
134
  #shouldImportAgg(featureName, session) {
135
- if (featureName === FEATURE_NAMES.sessionReplay) return canImportReplayAgg(this.agentIdentifier, session);
136
- return !(featureName === FEATURE_NAMES.sessionTrace && !session);
135
+ switch (featureName) {
136
+ case FEATURE_NAMES.sessionReplay:
137
+ // the session manager must be initialized successfully for Replay & Trace features
138
+ return hasReplayPrerequisite(this.agentIdentifier) && !!session;
139
+ case FEATURE_NAMES.sessionTrace:
140
+ return !!session;
141
+ default:
142
+ return true;
143
+ }
137
144
  }
138
145
  }
@@ -1,6 +1,5 @@
1
1
  export function hasReplayPrerequisite(agentId: any): boolean;
2
2
  export function isPreloadAllowed(agentId: any): boolean;
3
- export function canImportReplayAgg(agentId: any, sessionMgr: any): boolean;
4
3
  export function buildNRMetaNode(timestamp: any, timeKeeper: any): {
5
4
  originalTimestamp: any;
6
5
  correctedTimestamp: any;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/features/session_replay/shared/utils.js"],"names":[],"mappings":"AAIA,6DAIC;AAED,wDAEC;AAED,2EAGC;AAED;;;;;;;EAUC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/features/session_replay/shared/utils.js"],"names":[],"mappings":"AAIA,6DAIC;AAED,wDAEC;AAED;;;;;;;EAUC"}
@@ -1 +1 @@
1
- {"version":3,"file":"instrument-base.d.ts","sourceRoot":"","sources":["../../../../src/features/utils/instrument-base.js"],"names":[],"mappings":"AAiBA;;;GAGG;AACH;IACE;;;;;;;;OAQG;IACH,6BAPW,MAAM,cACN,OAAO,mCAAmC,EAAE,UAAU,eACtD,MAAM,8BAqChB;IA9BC,cAAgB;IAEhB,8IAA8I;IAC9I,cADW,WAAW,SAAS,CACF;IAE7B;;;MAGE;IACF,eAHU,OAAO,kBAAkB,EAAE,aAAa,CAGpB;IAE9B;;;MAGE;IACF,kCAAoC;IAiBtC;;;;;OAKG;IACH,mEAiDC;;CAYF;4BA7H2B,gBAAgB"}
1
+ {"version":3,"file":"instrument-base.d.ts","sourceRoot":"","sources":["../../../../src/features/utils/instrument-base.js"],"names":[],"mappings":"AAiBA;;;GAGG;AACH;IACE;;;;;;;;OAQG;IACH,6BAPW,MAAM,cACN,OAAO,mCAAmC,EAAE,UAAU,eACtD,MAAM,8BAqChB;IA9BC,cAAgB;IAEhB,8IAA8I;IAC9I,cADW,WAAW,SAAS,CACF;IAE7B;;;MAGE;IACF,eAHU,OAAO,kBAAkB,EAAE,aAAa,CAGpB;IAE9B;;;MAGE;IACF,kCAAoC;IAiBtC;;;;;OAKG;IACH,mEAiDC;;CAkBF;4BAnI2B,gBAAgB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newrelic/browser-agent",
3
- "version": "1.261.1",
3
+ "version": "1.261.2",
4
4
  "private": false,
5
5
  "author": "New Relic Browser Agent Team <browser-agent@newrelic.com>",
6
6
  "description": "New Relic Browser Agent",
@@ -28,7 +28,7 @@ export class Instrument extends InstrumentBase {
28
28
  } catch (err) { }
29
29
 
30
30
  if (hasReplayPrerequisite(agentIdentifier)) {
31
- this.ee.on('recordReplay', () => this.#apiStartOrRestartReplay())
31
+ this.ee.on(SR_EVENT_EMITTER_TYPES.RECORD, () => this.#apiStartOrRestartReplay())
32
32
  }
33
33
 
34
34
  if (this.#canPreloadRecorder(session)) {
@@ -12,11 +12,6 @@ export function isPreloadAllowed (agentId) {
12
12
  return getConfigurationValue(agentId, 'session_replay.preload') === true && hasReplayPrerequisite(agentId)
13
13
  }
14
14
 
15
- export function canImportReplayAgg (agentId, sessionMgr) {
16
- if (!hasReplayPrerequisite(agentId)) return false
17
- return !!sessionMgr?.isNew || !!sessionMgr?.state.sessionReplayMode // Session Replay should only try to run if already running from a previous page, or at the beginning of a session
18
- }
19
-
20
15
  export function buildNRMetaNode (timestamp, timeKeeper) {
21
16
  const correctedTimestamp = timeKeeper.correctAbsoluteTimestamp(timestamp)
22
17
  return {
@@ -11,7 +11,7 @@ import { isBrowserScope } from '../../common/constants/runtime'
11
11
  import { warn } from '../../common/util/console'
12
12
  import { FEATURE_NAMES } from '../../loaders/features/features'
13
13
  import { getConfigurationValue } from '../../common/config/config'
14
- import { canImportReplayAgg } from '../session_replay/shared/utils'
14
+ import { hasReplayPrerequisite } from '../session_replay/shared/utils'
15
15
  import { canEnableSessionTracking } from './feature-gates'
16
16
  import { single } from '../../common/util/invoke'
17
17
 
@@ -127,7 +127,13 @@ export class InstrumentBase extends FeatureBase {
127
127
  * @returns
128
128
  */
129
129
  #shouldImportAgg (featureName, session) {
130
- if (featureName === FEATURE_NAMES.sessionReplay) return canImportReplayAgg(this.agentIdentifier, session)
131
- return !(featureName === FEATURE_NAMES.sessionTrace && !session)
130
+ switch (featureName) {
131
+ case FEATURE_NAMES.sessionReplay: // the session manager must be initialized successfully for Replay & Trace features
132
+ return hasReplayPrerequisite(this.agentIdentifier) && !!session
133
+ case FEATURE_NAMES.sessionTrace:
134
+ return !!session
135
+ default:
136
+ return true
137
+ }
132
138
  }
133
139
  }
@@ -1 +0,0 @@
1
- export const canImportReplayAgg = jest.fn()