@newrelic/browser-agent 1.323.0-rc.4 → 1.323.0-rc.6

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.
@@ -17,7 +17,7 @@ exports.VERSION = exports.RRWEB_VERSION = exports.RRWEB_PACKAGE_NAME = exports.D
17
17
  /**
18
18
  * Exposes the version of the agent
19
19
  */
20
- const VERSION = exports.VERSION = "1.323.0-rc.4";
20
+ const VERSION = exports.VERSION = "1.323.0-rc.6";
21
21
 
22
22
  /**
23
23
  * Exposes the build type of the agent
@@ -17,7 +17,7 @@ exports.VERSION = exports.RRWEB_VERSION = exports.RRWEB_PACKAGE_NAME = exports.D
17
17
  /**
18
18
  * Exposes the version of the agent
19
19
  */
20
- const VERSION = exports.VERSION = "1.323.0-rc.4";
20
+ const VERSION = exports.VERSION = "1.323.0-rc.6";
21
21
 
22
22
  /**
23
23
  * Exposes the build type of the agent
@@ -133,10 +133,23 @@ class Aggregate extends _aggregateBase.AggregateBase {
133
133
  ...event,
134
134
  targetAttributes: (0, _utils.getVersion2Attributes)(target, this)
135
135
  });
136
- if ((0, _utils.shouldDuplicate)(target, this)) this.reportContainerEvent({
137
- ...event,
138
- targetAttributes: (0, _utils.getVersion2DuplicationAttributes)(target, this)
139
- }, ctx);
136
+ if ((0, _utils.shouldDuplicate)(target, this)) {
137
+ const duplicateEvent = {
138
+ ...event,
139
+ targetAttributes: (0, _utils.getVersion2DuplicationAttributes)(target, this)
140
+ };
141
+ /** the container-duplicate copy represents the same single real HTTP call as the MFE event above, so it
142
+ * needs its own independent trace/span identity -- otherwise the two would collide on the same
143
+ * spanId/traceId, and BELC could not create two separate Spans/Traces from them. Only the id namespace is
144
+ * independent; spanTimestamp is intentionally left as-is (event.spanTimestamp), since it still reflects the
145
+ * real call's actual timing. When `event.spanId` was never set (e.g. distributed tracing is disabled), there
146
+ * is no span identity to duplicate either -- both copies correctly end up with no spanId/traceId. */
147
+ if (event.spanId) {
148
+ duplicateEvent.spanId = (0, _uniqueId.generateSpanId)();
149
+ duplicateEvent.traceId = (0, _uniqueId.generateTraceId)();
150
+ }
151
+ this.reportContainerEvent(duplicateEvent, ctx);
152
+ }
140
153
  } else {
141
154
  this.reportContainerEvent(event, ctx);
142
155
  }
@@ -11,7 +11,7 @@
11
11
  /**
12
12
  * Exposes the version of the agent
13
13
  */
14
- export const VERSION = "1.323.0-rc.4";
14
+ export const VERSION = "1.323.0-rc.6";
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.323.0-rc.4";
14
+ export const VERSION = "1.323.0-rc.6";
15
15
 
16
16
  /**
17
17
  * Exposes the build type of the agent
@@ -16,7 +16,7 @@ import { canCapturePayload, isLikelyHumanReadable, parseQueryString, createStrin
16
16
  import { Obfuscator } from '../../../common/util/obfuscate';
17
17
  import { getVersion2Attributes, getVersion2DuplicationAttributes, shouldDuplicate, isMfeTarget } from '../../../common/v2/utils';
18
18
  import { EVENT_TYPES } from '../../../common/constants/events';
19
- import { generateUuid } from '../../../common/ids/unique-id';
19
+ import { generateSpanId, generateTraceId, generateUuid } from '../../../common/ids/unique-id';
20
20
  export class Aggregate extends AggregateBase {
21
21
  static featureName = FEATURE_NAME;
22
22
  constructor(agentRef) {
@@ -126,10 +126,23 @@ export class Aggregate extends AggregateBase {
126
126
  ...event,
127
127
  targetAttributes: getVersion2Attributes(target, this)
128
128
  });
129
- if (shouldDuplicate(target, this)) this.reportContainerEvent({
130
- ...event,
131
- targetAttributes: getVersion2DuplicationAttributes(target, this)
132
- }, ctx);
129
+ if (shouldDuplicate(target, this)) {
130
+ const duplicateEvent = {
131
+ ...event,
132
+ targetAttributes: getVersion2DuplicationAttributes(target, this)
133
+ };
134
+ /** the container-duplicate copy represents the same single real HTTP call as the MFE event above, so it
135
+ * needs its own independent trace/span identity -- otherwise the two would collide on the same
136
+ * spanId/traceId, and BELC could not create two separate Spans/Traces from them. Only the id namespace is
137
+ * independent; spanTimestamp is intentionally left as-is (event.spanTimestamp), since it still reflects the
138
+ * real call's actual timing. When `event.spanId` was never set (e.g. distributed tracing is disabled), there
139
+ * is no span identity to duplicate either -- both copies correctly end up with no spanId/traceId. */
140
+ if (event.spanId) {
141
+ duplicateEvent.spanId = generateSpanId();
142
+ duplicateEvent.traceId = generateTraceId();
143
+ }
144
+ this.reportContainerEvent(duplicateEvent, ctx);
145
+ }
133
146
  } else {
134
147
  this.reportContainerEvent(event, ctx);
135
148
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/ajax/aggregate/index.js"],"names":[],"mappings":"AAoBA;IACE,2BAAiC;IAEjC,2BA6BC;IAvBC,uBAA4D;IAyB9D,0GA2FC;IAED,+CAOC;IAED,iDA2EC;CACF;8BA9N6B,4BAA4B;2BAK/B,gCAAgC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/ajax/aggregate/index.js"],"names":[],"mappings":"AAoBA;IACE,2BAAiC;IAEjC,2BA6BC;IAvBC,uBAA4D;IAyB9D,0GAwGC;IAED,+CAOC;IAED,iDA2EC;CACF;8BA3O6B,4BAA4B;2BAK/B,gCAAgC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newrelic/browser-agent",
3
- "version": "1.323.0-rc.4",
3
+ "version": "1.323.0-rc.6",
4
4
  "private": false,
5
5
  "author": "New Relic Browser Agent Team <browser-agent@newrelic.com>",
6
6
  "description": "New Relic Browser Agent",
@@ -16,7 +16,7 @@ import { canCapturePayload, isLikelyHumanReadable, parseQueryString, createStrin
16
16
  import { Obfuscator } from '../../../common/util/obfuscate'
17
17
  import { getVersion2Attributes, getVersion2DuplicationAttributes, shouldDuplicate, isMfeTarget } from '../../../common/v2/utils'
18
18
  import { EVENT_TYPES } from '../../../common/constants/events'
19
- import { generateUuid } from '../../../common/ids/unique-id'
19
+ import { generateSpanId, generateTraceId, generateUuid } from '../../../common/ids/unique-id'
20
20
 
21
21
  export class Aggregate extends AggregateBase {
22
22
  static featureName = FEATURE_NAME
@@ -139,7 +139,20 @@ export class Aggregate extends AggregateBase {
139
139
  /** make a copy of the event for the MFE target if it exists */
140
140
  if (isMfeTarget(target)) {
141
141
  this.events.add({ ...event, targetAttributes: getVersion2Attributes(target, this) })
142
- if (shouldDuplicate(target, this)) this.reportContainerEvent({ ...event, targetAttributes: getVersion2DuplicationAttributes(target, this) }, ctx)
142
+ if (shouldDuplicate(target, this)) {
143
+ const duplicateEvent = { ...event, targetAttributes: getVersion2DuplicationAttributes(target, this) }
144
+ /** the container-duplicate copy represents the same single real HTTP call as the MFE event above, so it
145
+ * needs its own independent trace/span identity -- otherwise the two would collide on the same
146
+ * spanId/traceId, and BELC could not create two separate Spans/Traces from them. Only the id namespace is
147
+ * independent; spanTimestamp is intentionally left as-is (event.spanTimestamp), since it still reflects the
148
+ * real call's actual timing. When `event.spanId` was never set (e.g. distributed tracing is disabled), there
149
+ * is no span identity to duplicate either -- both copies correctly end up with no spanId/traceId. */
150
+ if (event.spanId) {
151
+ duplicateEvent.spanId = generateSpanId()
152
+ duplicateEvent.traceId = generateTraceId()
153
+ }
154
+ this.reportContainerEvent(duplicateEvent, ctx)
155
+ }
143
156
  } else {
144
157
  this.reportContainerEvent(event, ctx)
145
158
  }