@newrelic/browser-agent 1.318.0-rc.5 → 1.318.0-rc.7

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.318.0-rc.5";
20
+ const VERSION = exports.VERSION = "1.318.0-rc.7";
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.318.0-rc.5";
20
+ const VERSION = exports.VERSION = "1.318.0-rc.7";
21
21
 
22
22
  /**
23
23
  * Exposes the build type of the agent
@@ -17,13 +17,31 @@ var _constants = require("../../features/ajax/constants");
17
17
 
18
18
  /**
19
19
  * Determines whether payload data should be captured based on the capture mode setting,
20
- * HTTP status code, and GraphQL error status.
20
+ * HTTP status code, and GraphQL error status. Will never capture agent's own payloads.
21
21
  * @param {string} captureMode - The capture mode setting ('none', 'all', or 'failures')
22
- * @param {number} statusCode - The HTTP status code
23
- * @param {boolean} hasGQLErrors - Whether the response contains GraphQL errors
22
+ * @param {Object} event - An object representing the AJAX event
23
+ * @param {number} event.statusCode - The HTTP status code
24
+ * @param {boolean} event.hasGQLErrors - Whether the response contains GraphQL errors
25
+ * @param {string} event.payloadHost - The host of the AJAX payload (includes port)
26
+ * @param {string} event.payloadHostname - The hostname of the AJAX payload
27
+ * @param {string} [event.payloadPathname=''] - The pathname of the AJAX payload
28
+ * @param {string[]} [beacons=[]] - Array of beacon hostnames to avoid capturing
24
29
  * @returns {boolean} True if payload should be captured
25
30
  */
26
- function canCapturePayload(captureMode, statusCode, hasGQLErrors) {
31
+ function canCapturePayload(captureMode, {
32
+ statusCode,
33
+ hasGQLErrors,
34
+ payloadHost,
35
+ payloadHostname,
36
+ payloadPathname = ''
37
+ }, beacons = []) {
38
+ if (payloadHostname) {
39
+ const payloadUrl = payloadHostname + payloadPathname;
40
+ const payloadUrlWithPort = payloadHost + payloadPathname;
41
+ if (beacons.some(b => {
42
+ return b === payloadUrl || payloadUrl.startsWith(b + '/') || b === payloadUrlWithPort || payloadUrlWithPort.startsWith(b + '/');
43
+ })) return false;
44
+ }
27
45
  if (captureMode === _constants.CAPTURE_PAYLOAD_SETTINGS.ALL) return true;
28
46
  if (!captureMode || captureMode === _constants.CAPTURE_PAYLOAD_SETTINGS.NONE) return false;
29
47
 
@@ -103,7 +103,13 @@ class Aggregate extends _aggregateBase.AggregateBase {
103
103
  });
104
104
  if (event.gql) event.gql.operationHasErrors = (0, _gql.hasGQLErrors)(ctx.responseBody);
105
105
  const capturePayloadSetting = this.agentRef.init.ajax.capture_payloads;
106
- const shouldCapturePayload = (0, _payloads.canCapturePayload)(capturePayloadSetting, params.status, event.gql?.operationHasErrors);
106
+ const shouldCapturePayload = (0, _payloads.canCapturePayload)(capturePayloadSetting, {
107
+ statusCode: event.status,
108
+ hasGQLErrors: event.gql?.operationHasErrors,
109
+ payloadHostname: params.hostname,
110
+ payloadHost: params.host,
111
+ payloadPathname: params.pathname
112
+ }, this.agentRef.beacons);
107
113
  if (shouldCapturePayload) {
108
114
  // Store raw data; obfuscation and truncation will happen in the serializer
109
115
  event.requestQuery = (0, _payloads.parseQueryString)(ctx.parsedOrigin?.search);
@@ -11,7 +11,7 @@
11
11
  /**
12
12
  * Exposes the version of the agent
13
13
  */
14
- export const VERSION = "1.318.0-rc.5";
14
+ export const VERSION = "1.318.0-rc.7";
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.318.0-rc.5";
14
+ export const VERSION = "1.318.0-rc.7";
15
15
 
16
16
  /**
17
17
  * Exposes the build type of the agent
@@ -8,13 +8,31 @@ import { CAPTURE_PAYLOAD_SETTINGS } from '../../features/ajax/constants';
8
8
 
9
9
  /**
10
10
  * Determines whether payload data should be captured based on the capture mode setting,
11
- * HTTP status code, and GraphQL error status.
11
+ * HTTP status code, and GraphQL error status. Will never capture agent's own payloads.
12
12
  * @param {string} captureMode - The capture mode setting ('none', 'all', or 'failures')
13
- * @param {number} statusCode - The HTTP status code
14
- * @param {boolean} hasGQLErrors - Whether the response contains GraphQL errors
13
+ * @param {Object} event - An object representing the AJAX event
14
+ * @param {number} event.statusCode - The HTTP status code
15
+ * @param {boolean} event.hasGQLErrors - Whether the response contains GraphQL errors
16
+ * @param {string} event.payloadHost - The host of the AJAX payload (includes port)
17
+ * @param {string} event.payloadHostname - The hostname of the AJAX payload
18
+ * @param {string} [event.payloadPathname=''] - The pathname of the AJAX payload
19
+ * @param {string[]} [beacons=[]] - Array of beacon hostnames to avoid capturing
15
20
  * @returns {boolean} True if payload should be captured
16
21
  */
17
- export function canCapturePayload(captureMode, statusCode, hasGQLErrors) {
22
+ export function canCapturePayload(captureMode, {
23
+ statusCode,
24
+ hasGQLErrors,
25
+ payloadHost,
26
+ payloadHostname,
27
+ payloadPathname = ''
28
+ }, beacons = []) {
29
+ if (payloadHostname) {
30
+ const payloadUrl = payloadHostname + payloadPathname;
31
+ const payloadUrlWithPort = payloadHost + payloadPathname;
32
+ if (beacons.some(b => {
33
+ return b === payloadUrl || payloadUrl.startsWith(b + '/') || b === payloadUrlWithPort || payloadUrlWithPort.startsWith(b + '/');
34
+ })) return false;
35
+ }
18
36
  if (captureMode === CAPTURE_PAYLOAD_SETTINGS.ALL) return true;
19
37
  if (!captureMode || captureMode === CAPTURE_PAYLOAD_SETTINGS.NONE) return false;
20
38
 
@@ -96,7 +96,13 @@ export class Aggregate extends AggregateBase {
96
96
  });
97
97
  if (event.gql) event.gql.operationHasErrors = hasGQLErrors(ctx.responseBody);
98
98
  const capturePayloadSetting = this.agentRef.init.ajax.capture_payloads;
99
- const shouldCapturePayload = canCapturePayload(capturePayloadSetting, params.status, event.gql?.operationHasErrors);
99
+ const shouldCapturePayload = canCapturePayload(capturePayloadSetting, {
100
+ statusCode: event.status,
101
+ hasGQLErrors: event.gql?.operationHasErrors,
102
+ payloadHostname: params.hostname,
103
+ payloadHost: params.host,
104
+ payloadPathname: params.pathname
105
+ }, this.agentRef.beacons);
100
106
  if (shouldCapturePayload) {
101
107
  // Store raw data; obfuscation and truncation will happen in the serializer
102
108
  event.requestQuery = parseQueryString(ctx.parsedOrigin?.search);
@@ -1,12 +1,23 @@
1
1
  /**
2
2
  * Determines whether payload data should be captured based on the capture mode setting,
3
- * HTTP status code, and GraphQL error status.
3
+ * HTTP status code, and GraphQL error status. Will never capture agent's own payloads.
4
4
  * @param {string} captureMode - The capture mode setting ('none', 'all', or 'failures')
5
- * @param {number} statusCode - The HTTP status code
6
- * @param {boolean} hasGQLErrors - Whether the response contains GraphQL errors
5
+ * @param {Object} event - An object representing the AJAX event
6
+ * @param {number} event.statusCode - The HTTP status code
7
+ * @param {boolean} event.hasGQLErrors - Whether the response contains GraphQL errors
8
+ * @param {string} event.payloadHost - The host of the AJAX payload (includes port)
9
+ * @param {string} event.payloadHostname - The hostname of the AJAX payload
10
+ * @param {string} [event.payloadPathname=''] - The pathname of the AJAX payload
11
+ * @param {string[]} [beacons=[]] - Array of beacon hostnames to avoid capturing
7
12
  * @returns {boolean} True if payload should be captured
8
13
  */
9
- export function canCapturePayload(captureMode: string, statusCode: number, hasGQLErrors: boolean): boolean;
14
+ export function canCapturePayload(captureMode: string, { statusCode, hasGQLErrors, payloadHost, payloadHostname, payloadPathname }: {
15
+ statusCode: number;
16
+ hasGQLErrors: boolean;
17
+ payloadHost: string;
18
+ payloadHostname: string;
19
+ payloadPathname?: string | undefined;
20
+ }, beacons?: string[]): boolean;
10
21
  /**
11
22
  * Parses a query string into an object of key-value pairs.
12
23
  * @param {string} search a query string starting with "?" or without (ex. new URL(...).search)
@@ -1 +1 @@
1
- {"version":3,"file":"payloads.d.ts","sourceRoot":"","sources":["../../../../src/common/payloads/payloads.js"],"names":[],"mappings":"AAQA;;;;;;;GAOG;AACH,+CALW,MAAM,cACN,MAAM,gBACN,OAAO,GACL,OAAO,CAQnB;AAED;;;;GAIG;AACH,yCAHW,MAAM,GACJ,MAAM,GAAC,SAAS,CAgB5B;AAED;;;;;GAKG;AACH,+CAJW,MAAM,QACN,GAAC,GACC,OAAO,CA2BnB;AAED;;;;;;GAMG;AACH,uCAHW,GAAC,GACC,MAAM,CA2BlB;AAED;;;;;;GAMG;AACH,8EAHW,MAAM,GACJ;IAAC,SAAS,WAAW;IAAC,uBAAuB,WAAU;CAAC,CAiBpE"}
1
+ {"version":3,"file":"payloads.d.ts","sourceRoot":"","sources":["../../../../src/common/payloads/payloads.js"],"names":[],"mappings":"AAQA;;;;;;;;;;;;GAYG;AACH,+CAVW,MAAM,+EAEd;IAAsB,UAAU,EAAxB,MAAM;IACS,YAAY,EAA3B,OAAO;IACO,WAAW,EAAzB,MAAM;IACQ,eAAe,EAA7B,MAAM;IACS,eAAe;CACtC,YAAQ,MAAM,EAAE,GACN,OAAO,CAqBnB;AAED;;;;GAIG;AACH,yCAHW,MAAM,GACJ,MAAM,GAAC,SAAS,CAgB5B;AAED;;;;;GAKG;AACH,+CAJW,MAAM,QACN,GAAC,GACC,OAAO,CA2BnB;AAED;;;;;;GAMG;AACH,uCAHW,GAAC,GACC,MAAM,CA2BlB;AAED;;;;;;GAMG;AACH,8EAHW,MAAM,GACJ;IAAC,SAAS,WAAW;IAAC,uBAAuB,WAAU;CAAC,CAiBpE"}
@@ -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,0GAqFC;IAED,+CAOC;IAED,iDAoEC;CACF;8BAjN6B,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,0GA2FC;IAED,+CAOC;IAED,iDAoEC;CACF;8BAvN6B,4BAA4B;2BAK/B,gCAAgC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newrelic/browser-agent",
3
- "version": "1.318.0-rc.5",
3
+ "version": "1.318.0-rc.7",
4
4
  "private": false,
5
5
  "author": "New Relic Browser Agent Team <browser-agent@newrelic.com>",
6
6
  "description": "New Relic Browser Agent",
@@ -8,13 +8,31 @@ import { CAPTURE_PAYLOAD_SETTINGS } from '../../features/ajax/constants'
8
8
 
9
9
  /**
10
10
  * Determines whether payload data should be captured based on the capture mode setting,
11
- * HTTP status code, and GraphQL error status.
11
+ * HTTP status code, and GraphQL error status. Will never capture agent's own payloads.
12
12
  * @param {string} captureMode - The capture mode setting ('none', 'all', or 'failures')
13
- * @param {number} statusCode - The HTTP status code
14
- * @param {boolean} hasGQLErrors - Whether the response contains GraphQL errors
13
+ * @param {Object} event - An object representing the AJAX event
14
+ * @param {number} event.statusCode - The HTTP status code
15
+ * @param {boolean} event.hasGQLErrors - Whether the response contains GraphQL errors
16
+ * @param {string} event.payloadHost - The host of the AJAX payload (includes port)
17
+ * @param {string} event.payloadHostname - The hostname of the AJAX payload
18
+ * @param {string} [event.payloadPathname=''] - The pathname of the AJAX payload
19
+ * @param {string[]} [beacons=[]] - Array of beacon hostnames to avoid capturing
15
20
  * @returns {boolean} True if payload should be captured
16
21
  */
17
- export function canCapturePayload (captureMode, statusCode, hasGQLErrors) {
22
+ export function canCapturePayload (captureMode, {
23
+ statusCode,
24
+ hasGQLErrors,
25
+ payloadHost,
26
+ payloadHostname,
27
+ payloadPathname = ''
28
+ }, beacons = []) {
29
+ if (payloadHostname) {
30
+ const payloadUrl = payloadHostname + payloadPathname
31
+ const payloadUrlWithPort = payloadHost + payloadPathname
32
+ if (beacons.some((b) => {
33
+ return b === payloadUrl || payloadUrl.startsWith(b + '/') || b === payloadUrlWithPort || payloadUrlWithPort.startsWith(b + '/')
34
+ })) return false
35
+ }
18
36
  if (captureMode === CAPTURE_PAYLOAD_SETTINGS.ALL) return true
19
37
  if (!captureMode || captureMode === CAPTURE_PAYLOAD_SETTINGS.NONE) return false
20
38
 
@@ -109,7 +109,13 @@ export class Aggregate extends AggregateBase {
109
109
  if (event.gql) event.gql.operationHasErrors = hasGQLErrors(ctx.responseBody)
110
110
 
111
111
  const capturePayloadSetting = this.agentRef.init.ajax.capture_payloads
112
- const shouldCapturePayload = canCapturePayload(capturePayloadSetting, params.status, event.gql?.operationHasErrors)
112
+ const shouldCapturePayload = canCapturePayload(capturePayloadSetting, {
113
+ statusCode: event.status,
114
+ hasGQLErrors: event.gql?.operationHasErrors,
115
+ payloadHostname: params.hostname,
116
+ payloadHost: params.host,
117
+ payloadPathname: params.pathname
118
+ }, this.agentRef.beacons)
113
119
 
114
120
  if (shouldCapturePayload) {
115
121
  // Store raw data; obfuscation and truncation will happen in the serializer