@newrelic/browser-agent 1.317.0 → 1.318.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 (78) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/cjs/common/config/configurable.js +1 -1
  3. package/dist/cjs/common/config/init-types.js +2 -0
  4. package/dist/cjs/common/config/init.js +3 -0
  5. package/dist/cjs/common/constants/env.cdn.js +1 -1
  6. package/dist/cjs/common/constants/env.npm.js +1 -1
  7. package/dist/cjs/common/harvest/harvester.js +3 -219
  8. package/dist/cjs/common/harvest/send.js +232 -0
  9. package/dist/cjs/common/harvest/types.js +9 -5
  10. package/dist/cjs/common/session/session-entity.js +8 -8
  11. package/dist/cjs/common/v2/mfe-vitals.js +303 -0
  12. package/dist/cjs/features/generic_events/aggregate/index.js +1 -1
  13. package/dist/cjs/features/generic_events/instrument/index.js +1 -1
  14. package/dist/cjs/features/logging/aggregate/index.js +5 -5
  15. package/dist/cjs/features/page_view_event/aggregate/index.js +65 -30
  16. package/dist/cjs/features/session_replay/aggregate/index.js +32 -28
  17. package/dist/cjs/features/session_trace/aggregate/index.js +29 -27
  18. package/dist/cjs/features/session_trace/constants.js +17 -3
  19. package/dist/cjs/features/utils/aggregate-base.js +2 -0
  20. package/dist/cjs/loaders/api/register.js +27 -4
  21. package/dist/esm/common/config/configurable.js +1 -1
  22. package/dist/esm/common/config/init-types.js +2 -0
  23. package/dist/esm/common/config/init.js +3 -0
  24. package/dist/esm/common/constants/env.cdn.js +1 -1
  25. package/dist/esm/common/constants/env.npm.js +1 -1
  26. package/dist/esm/common/harvest/harvester.js +3 -219
  27. package/dist/esm/common/harvest/send.js +226 -0
  28. package/dist/esm/common/harvest/types.js +9 -5
  29. package/dist/esm/common/session/session-entity.js +9 -9
  30. package/dist/esm/common/v2/mfe-vitals.js +298 -0
  31. package/dist/esm/features/generic_events/aggregate/index.js +1 -1
  32. package/dist/esm/features/generic_events/instrument/index.js +1 -1
  33. package/dist/esm/features/logging/aggregate/index.js +5 -5
  34. package/dist/esm/features/page_view_event/aggregate/index.js +64 -29
  35. package/dist/esm/features/session_replay/aggregate/index.js +32 -28
  36. package/dist/esm/features/session_trace/aggregate/index.js +30 -28
  37. package/dist/esm/features/session_trace/constants.js +16 -2
  38. package/dist/esm/features/utils/aggregate-base.js +2 -0
  39. package/dist/esm/loaders/api/register.js +27 -4
  40. package/dist/tsconfig.tsbuildinfo +1 -1
  41. package/dist/types/common/config/init-types.d.ts +6 -0
  42. package/dist/types/common/config/init.d.ts.map +1 -1
  43. package/dist/types/common/harvest/harvester.d.ts +0 -17
  44. package/dist/types/common/harvest/harvester.d.ts.map +1 -1
  45. package/dist/types/common/harvest/send.d.ts +9 -0
  46. package/dist/types/common/harvest/send.d.ts.map +1 -0
  47. package/dist/types/common/harvest/types.d.ts +39 -10
  48. package/dist/types/common/harvest/types.d.ts.map +1 -1
  49. package/dist/types/common/session/session-entity.d.ts.map +1 -1
  50. package/dist/types/common/v2/mfe-vitals.d.ts +14 -0
  51. package/dist/types/common/v2/mfe-vitals.d.ts.map +1 -0
  52. package/dist/types/features/page_view_event/aggregate/index.d.ts +1 -0
  53. package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
  54. package/dist/types/features/session_replay/aggregate/index.d.ts +2 -2
  55. package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
  56. package/dist/types/features/session_trace/aggregate/index.d.ts +1 -1
  57. package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
  58. package/dist/types/features/session_trace/constants.d.ts +17 -0
  59. package/dist/types/features/utils/aggregate-base.d.ts.map +1 -1
  60. package/dist/types/loaders/api/register.d.ts.map +1 -1
  61. package/package.json +2 -2
  62. package/src/common/config/configurable.js +1 -1
  63. package/src/common/config/init-types.js +2 -0
  64. package/src/common/config/init.js +2 -1
  65. package/src/common/harvest/harvester.js +3 -202
  66. package/src/common/harvest/send.js +209 -0
  67. package/src/common/harvest/types.js +9 -5
  68. package/src/common/session/session-entity.js +8 -9
  69. package/src/common/v2/mfe-vitals.js +285 -0
  70. package/src/features/generic_events/aggregate/index.js +1 -1
  71. package/src/features/generic_events/instrument/index.js +1 -1
  72. package/src/features/logging/aggregate/index.js +5 -5
  73. package/src/features/page_view_event/aggregate/index.js +52 -27
  74. package/src/features/session_replay/aggregate/index.js +30 -27
  75. package/src/features/session_trace/aggregate/index.js +31 -28
  76. package/src/features/session_trace/constants.js +7 -1
  77. package/src/features/utils/aggregate-base.js +2 -0
  78. package/src/loaders/api/register.js +25 -4
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Initiate a harvest call.
3
+ * @param {object} agentRef The initialized agent reference
4
+ * @param {NetworkSendSpec} spec Specification for sending data
5
+ * @returns {boolean} True if a network call was made. Note that this does not mean or guarantee that it was successful.
6
+ */
7
+ export function send(agentRef: object, { endpoint, payload, localOpts, submitMethod, cbFinished, raw, featureName, endpointVersion, harvesterObfuscator }: NetworkSendSpec): boolean;
8
+ export type NetworkSendSpec = import("./types.js").NetworkSendSpec;
9
+ //# sourceMappingURL=send.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../../../../src/common/harvest/send.js"],"names":[],"mappings":"AAuBA;;;;;GAKG;AACH,+BAJW,MAAM,sHACN,eAAe,GACb,OAAO,CAsHnB;8BA/HY,OAAO,YAAY,EAAE,eAAe"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2020-2025 New Relic, Inc. All rights reserved.
2
+ * Copyright 2020-2026 New Relic, Inc. All rights reserved.
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
  /**
@@ -19,11 +19,15 @@
19
19
  * @typedef {object} NetworkSendSpec
20
20
  * @property {HarvestEndpointIdentifier} endpoint The endpoint to use (jserrors, events, resources etc.)
21
21
  * @property {HarvestPayload} payload Object representing payload.
22
- * @property {object} localOpts Additional options for sending data
23
- * @property {boolean} localOpts.isFinalHarvest Specify whether the call is a final harvest during page unload.
24
- * @property {boolean} localOpts.sendEmptyBody Specify whether the call should be made even if the body is empty. Useful for rum calls.
25
- * @property {boolean} localOpts.forceNoRetry Don't save the buffered data in the case of a need to retry the transmission.
22
+ * @property {object} [localOpts] Additional options for sending data
23
+ * @property {boolean} [localOpts.isFinalHarvest] Specify whether the call is a final harvest during page unload.
24
+ * @property {boolean} [localOpts.sendEmptyBody] Specify whether the call should be made even if the body is empty. Useful for rum calls.
25
+ * @property {boolean} [localOpts.forceNoRetry] Don't save the buffered data in the case of a need to retry the transmission.
26
26
  * @property {import('../util/submit-data.js').NetworkMethods} submitMethod The network method to use {@link ../util/submit-data.js}
27
+ * @property {function(object): void} [cbFinished] Callback invoked with the result once the network request completes. Receives an object with sent, status, retry, fullUrl, responseText, and either xhr or fetchResponse.
28
+ * @property {boolean} [raw] If true, skips standard versioned URL path construction and uses a bare endpoint URL.
29
+ * @property {string} [featureName] The feature name associated with this harvest, used for metadata tracking and the global harvest event.
30
+ * @property {number} [endpointVersion] The endpoint version included in the URL path. Defaults to 1.
27
31
  */
28
32
  export const unused: {};
29
33
  export type HarvestEndpointIdentifier = "rum" | "jserrors" | "events" | "ins" | "resources" | "blob";
@@ -49,14 +53,39 @@ export type NetworkSendSpec = {
49
53
  /**
50
54
  * Additional options for sending data
51
55
  */
52
- localOpts: {
53
- isFinalHarvest: boolean;
54
- sendEmptyBody: boolean;
55
- forceNoRetry: boolean;
56
- };
56
+ localOpts?: {
57
+ /**
58
+ * Specify whether the call is a final harvest during page unload.
59
+ */
60
+ isFinalHarvest?: boolean | undefined;
61
+ /**
62
+ * Specify whether the call should be made even if the body is empty. Useful for rum calls.
63
+ */
64
+ sendEmptyBody?: boolean | undefined;
65
+ /**
66
+ * Don't save the buffered data in the case of a need to retry the transmission.
67
+ */
68
+ forceNoRetry?: boolean | undefined;
69
+ } | undefined;
57
70
  /**
58
71
  * The network method to use {@link ../util/submit-data.js}
59
72
  */
60
73
  submitMethod: import("../util/submit-data.js").NetworkMethods;
74
+ /**
75
+ * Callback invoked with the result once the network request completes. Receives an object with sent, status, retry, fullUrl, responseText, and either xhr or fetchResponse.
76
+ */
77
+ cbFinished?: ((arg0: object) => void) | undefined;
78
+ /**
79
+ * If true, skips standard versioned URL path construction and uses a bare endpoint URL.
80
+ */
81
+ raw?: boolean | undefined;
82
+ /**
83
+ * The feature name associated with this harvest, used for metadata tracking and the global harvest event.
84
+ */
85
+ featureName?: string | undefined;
86
+ /**
87
+ * The endpoint version included in the URL path. Defaults to 1.
88
+ */
89
+ endpointVersion?: number | undefined;
61
90
  };
62
91
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/common/harvest/types.js"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH;;GAEG;AAEH;;;;GAIG;AAEH;;;;;;;;;GASG;AAEH,wBAAwB;wCApBX,KAAK,GAAC,UAAU,GAAC,QAAQ,GAAC,KAAK,GAAC,WAAW,GAAC,MAAM;;;;;QAKjD,MAAM;;;;UACN,MAAM;;;;;;cAKN,yBAAyB;;;;aACzB,cAAc;;;;eAEzB;QAA8B,cAAc,EAAjC,OAAO;QACY,aAAa,EAAhC,OAAO;QACY,YAAY,EAA/B,OAAO;KAClB;;;;kBAAW,OAAO,wBAAwB,EAAE,cAAc"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/common/harvest/types.js"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH;;GAEG;AAEH;;;;GAIG;AAEH;;;;;;;;;;;;;GAaG;AAEH,wBAAwB;wCAxBX,KAAK,GAAC,UAAU,GAAC,QAAQ,GAAC,KAAK,GAAC,WAAW,GAAC,MAAM;;;;;QAKjD,MAAM;;;;UACN,MAAM;;;;;;cAKN,yBAAyB;;;;aACzB,cAAc;;;;;;;;;;;;;;;;;;;;;kBAKd,OAAO,wBAAwB,EAAE,cAAc;;;;yBACtC,MAAM,KAAG,IAAI"}
@@ -1 +1 @@
1
- {"version":3,"file":"session-entity.d.ts","sourceRoot":"","sources":["../../../../src/common/session/session-entity.js"],"names":[],"mappings":"AAsCA;IACE;;;;;OAKG;IACH,uBA+BC;IAzBC,cAAwB;IACxB,aAAsB;IACtB,UAAe;IAGf,SAAc;IAEd,QAAqB;IAoBvB;;;;;aAgFC;IApEC,8BAA0B;IAC1B,+BAA4B;IAe1B,gCAOqC;IAUrC,4CAkBsC;IAexC,iCAAuB;IAKzB,wBAEC;IAED,sBAEC;IAED;;;OAGG;IACH,QAFa,MAAM,CA6BlB;IAED;;;;;;OAMG;IACH,YAHW,MAAM,GACJ,MAAM,CAkBlB;IAED,gBA4BC;IAED;;OAEG;IACH,gBAIC;IAED;;;OAGG;IACH,qBAHW,MAAM,GACJ,OAAO,CAInB;IAED;;;OAGG;IACH,gBAHW,MAAM,GACJ,OAAO,CAKnB;IAED,yDAUC;IAED,6DAIC;IAED;;;OAGG;IACH,6BAHW,MAAM,GACJ,MAAM,CAIlB;IAED,gDAaC;IAHG,YAAuD;CAI5D;sBA5TqB,gBAAgB;iCAGL,4BAA4B"}
1
+ {"version":3,"file":"session-entity.d.ts","sourceRoot":"","sources":["../../../../src/common/session/session-entity.js"],"names":[],"mappings":"AAsCA;IACE;;;;;OAKG;IACH,uBA+BC;IAzBC,cAAwB;IACxB,aAAsB;IACtB,UAAe;IAGf,SAAc;IAEd,QAAqB;IAoBvB;;;;;aAgFC;IApEC,8BAA0B;IAC1B,+BAA4B;IAe1B,gCAOqC;IAUrC,4CAkBsC;IAexC,iCAAuB;IAKzB,wBAEC;IAED,sBAEC;IAED;;;OAGG;IACH,QAFa,MAAM,CA6BlB;IAED;;;;;;OAMG;IACH,YAHW,MAAM,GACJ,MAAM,CAkBlB;IAED,gBA2BC;IAED;;OAEG;IACH,gBAIC;IAED;;;OAGG;IACH,qBAHW,MAAM,GACJ,OAAO,CAInB;IAED;;;OAGG;IACH,gBAHW,MAAM,GACJ,OAAO,CAKnB;IAED,yDAUC;IAED,6DAIC;IAED;;;OAGG;IACH,6BAHW,MAAM,GACJ,MAAM,CAIlB;IAED,gDAaC;IAHG,YAAuD;CAI5D;sBA3TqB,gBAAgB;iCAGL,4BAA4B"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Tracks all Core Web Vitals for a specific MFE.
3
+ * @param {string} id - The MFE ID to track
4
+ * @returns {{fcp: object|null, lcp: object|null, cls: object|null, inp: object|null, disconnect: Function}}
5
+ */
6
+ export function trackMFEVitals(id: string, timings: any): {
7
+ fcp: object | null;
8
+ lcp: object | null;
9
+ cls: object | null;
10
+ inp: object | null;
11
+ disconnect: Function;
12
+ };
13
+ export type RegisterAPITimings = any;
14
+ //# sourceMappingURL=mfe-vitals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mfe-vitals.d.ts","sourceRoot":"","sources":["../../../../src/common/v2/mfe-vitals.js"],"names":[],"mappings":"AA+FA;;;;GAIG;AACH,mCAHW,MAAM,iBACJ;IAAC,GAAG,EAAE,MAAM,GAAC,IAAI,CAAC;IAAC,GAAG,EAAE,MAAM,GAAC,IAAI,CAAC;IAAC,GAAG,EAAE,MAAM,GAAC,IAAI,CAAC;IAAC,GAAG,EAAE,MAAM,GAAC,IAAI,CAAC;IAAC,UAAU,WAAU;CAAC,CA0L1G"}
@@ -1,6 +1,7 @@
1
1
  export class Aggregate extends AggregateBase {
2
2
  static featureName: string;
3
3
  constructor(agentRef: any);
4
+ isSessionTrackingEnabled: boolean;
4
5
  sentRum: boolean;
5
6
  timeToFirstByte: number;
6
7
  firstByteToWindowLoad: number;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/page_view_event/aggregate/index.js"],"names":[],"mappings":"AAwBA;IACE,2BAA2C;IAE3C,2BA2BC;IAxBC,iBAAoB;IAEpB,wBAAwB;IACxB,8BAA8B;IAC9B,8BAA8B;IAC9B,gBAAgB;IAGhB,uBAA2D;IAkB7D;;;;OAIG;IACH,2BAFW,GAAC,QAiEX;IAbC;;;;;;;;;;;;;;mBAOC;IANC,iCAAyB;IAc7B,kCAEC;IAED;;;;;;aAiGC;CACF;8BAzN6B,4BAA4B;2BAM/B,gCAAgC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/page_view_event/aggregate/index.js"],"names":[],"mappings":"AAyBA;IACE,2BAA2C;IAE3C,2BAuCC;IApCC,kCAAqG;IACrG,iBAAoB;IAEpB,wBAAwB;IACxB,8BAA8B;IAC9B,8BAA8B;IAC9B,gBAAgB;IAGhB,uBAA2D;IA6B7D;;;;OAIG;IACH,2BAFW,GAAC,QAiEX;IAbC;;;;;;;;;;;;;;mBAOC;IANC,iCAAyB;IAc7B,kCAEC;IAED;;;;;;aA6GC;CACF;8BAlP6B,4BAA4B;2BAQ/B,gCAAgC"}
@@ -1,7 +1,7 @@
1
1
  export class Aggregate extends AggregateBase {
2
2
  static featureName: string;
3
3
  constructor(agentRef: any, args: any);
4
- mode: number;
4
+ mode: null;
5
5
  obfuscator: Obfuscator;
6
6
  /** Set once the recorder has fully initialized after flag checks and sampling */
7
7
  initialized: boolean;
@@ -66,7 +66,7 @@ export class Aggregate extends AggregateBase {
66
66
  forceStop(forceHarvest: any): void;
67
67
  /** Abort the feature, once aborted it will not resume */
68
68
  abort(reason: {} | undefined, data: any): void;
69
- syncWithSessionManager(state?: {}): void;
69
+ #private;
70
70
  }
71
71
  import { AggregateBase } from '../../utils/aggregate-base';
72
72
  import { Obfuscator } from '../../../common/util/obfuscate';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/session_replay/aggregate/index.js"],"names":[],"mappings":"AA2BA;IACE,2BAAiC;IAIjC,sCA6FC;IAhGD,aAAe;IAOb,uBAA0D;IAE1D,iFAAiF;IACjF,qBAAwB;IAGxB,2CAA2C;IAC3C,sDAAwB;IACxB,6CAA6C;IAC7C,gDAAmB;IACnB,+DAA+D;IAC/D,wBAA0B;IAE1B,0BAA0B;IAC1B,kBAAqB;IACrB,6CAA6C;IAC7C,gBAA2B;IAE3B,qBAA2B;IAE3B,cAA8C;IAI9C,kCAAqG;IAmEvG,0BAEC;IAED,0BAMC;IAED,qBAUC;IAED;;;;;;OAMG;IACH,4BALW,OAAO,iBACP,OAAO;;;;;;QAEL,IAAI,CA8ChB;IAED,2BAUC;IAED,0BA0CC;IAED;;;;OAIG;IACH,6BAHW,MAAM,EAAE,GACN;QAAE,UAAU,EAAE,MAAM,GAAC,SAAS,CAAC;QAAC,SAAS,EAAE,MAAM,GAAC,SAAS,CAAA;KAAE,CAUzE;IAED;;;;;;;;;;MAsEC;IAED,sCAcC;IAED;;;;OAIG;IACH,mCAKC;IAED,yDAAyD;IACzD,+CASC;IAED,yCAIC;CACF;8BA9X6B,4BAA4B;2BAe/B,gCAAgC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/session_replay/aggregate/index.js"],"names":[],"mappings":"AA2BA;IACE,2BAAiC;IAIjC,sCA+FC;IAlGD,WAAW;IAOT,uBAA0D;IAE1D,iFAAiF;IACjF,qBAAwB;IAGxB,2CAA2C;IAC3C,sDAAwB;IACxB,6CAA6C;IAC7C,gDAAmB;IACnB,+DAA+D;IAC/D,wBAA0B;IAE1B,0BAA0B;IAC1B,kBAAqB;IACrB,6CAA6C;IAC7C,gBAA2B;IAE3B,qBAA2B;IAE3B,cAA8C;IAI9C,kCAAqG;IAqEvG,0BAEC;IAED,0BAMC;IAED,qBAUC;IAED;;;;;;OAMG;IACH,4BALW,OAAO,iBACP,OAAO;;;;;;QAEL,IAAI,CA+ChB;IAED,2BAUC;IAED,0BA0CC;IAED;;;;OAIG;IACH,6BAHW,MAAM,EAAE,GACN;QAAE,UAAU,EAAE,MAAM,GAAC,SAAS,CAAC;QAAC,SAAS,EAAE,MAAM,GAAC,SAAS,CAAA;KAAE,CAUzE;IAED;;;;;;;;;;MAsEC;IAED,sCAcC;IAED;;;;OAIG;IACH,mCAKC;IAED,yDAAyD;IACzD,+CASC;;CAOF;8BAjY6B,4BAA4B;2BAe/B,gCAAgC"}
@@ -30,7 +30,7 @@ export class Aggregate extends AggregateBase {
30
30
  /** Switch from "off" or "error" to full mode (if entitled) */
31
31
  switchToFull(): void;
32
32
  /** Stop running for the remainder of the page lifecycle */
33
- abort(code: any): void;
33
+ abort(reason?: {}): void;
34
34
  postHarvestCleanup(result: any): void;
35
35
  }
36
36
  import { AggregateBase } from '../../utils/aggregate-base';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/session_trace/aggregate/index.js"],"names":[],"mappings":"AAkBA;IACE,2BAAiC;IAEjC,2BAmBC;IAdC,uBAA0D;IAE1D,0GAA0G;IAC1G,cAAyB;IACzB,mIAAmI;IACnI,uBAA0B;IAC1B,0CAA0C;IAC1C,oBAAuB;IACvB,0GAA0G;IAC1G,2BAA0C;IAO5C,gLAAgL;IAChL,mEA2DC;IApDG,iCAAuB;IACvB,yJAAyJ;IACzJ,UAAsC;IACtC,eAA2D;IAyBD,UAAgE;IA0B9H,qCAWC;IAED,0CAIC;IAED;;;;;;;MAgDC;IAED,8DAA8D;IAC9D,qBAUC;IAED,2DAA2D;IAC3D,uBAMC;IAED,sCAGC;CACF;8BAjM6B,4BAA4B;2BAK/B,gCAAgC;6BAJ9B,iBAAiB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/session_trace/aggregate/index.js"],"names":[],"mappings":"AAkBA;IACE,2BAAiC;IAEjC,2BAmBC;IAdC,uBAA0D;IAE1D,0GAA0G;IAC1G,cAAyB;IACzB,mIAAmI;IACnI,uBAA0B;IAC1B,0CAA0C;IAC1C,oBAAuB;IACvB,0GAA0G;IAC1G,2BAA0C;IAO5C,gLAAgL;IAChL,mEA8DC;IArDG,iCAAuB;IACvB,yJAAyJ;IACzJ,UAAsC;IACtC,eAA2D;IAyBwB,UAAgE;IA2BvJ,qCAWC;IAED,0CAIC;IAED;;;;;;;MAgDC;IAED,8DAA8D;IAC9D,qBAUC;IAED,2DAA2D;IAC3D,yBAMC;IAED,sCAGC;CACF;8BApM6B,4BAA4B;2BAK/B,gCAAgC;6BAJ9B,iBAAiB"}
@@ -8,4 +8,21 @@ export const FN_END: string;
8
8
  export const PUSH_STATE: "pushState";
9
9
  export const MAX_NODES_PER_HARVEST: 1000;
10
10
  export const ERROR_MODE_SECONDS_WINDOW: number;
11
+ export namespace ABORT_REASONS {
12
+ namespace CROSS_TAB {
13
+ let message: string;
14
+ }
15
+ namespace ENTITLEMENTS {
16
+ let message_1: string;
17
+ export { message_1 as message };
18
+ }
19
+ namespace RESET {
20
+ let message_2: string;
21
+ export { message_2 as message };
22
+ }
23
+ namespace SESSION_CHANGED {
24
+ let message_3: string;
25
+ export { message_3 as message };
26
+ }
27
+ }
11
28
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"aggregate-base.d.ts","sourceRoot":"","sources":["../../../../src/features/utils/aggregate-base.js"],"names":[],"mappings":"AAcA;IACE;;;;OAIG;IACH,sBAHW,MAAM,eACN,MAAM,EAkBhB;IAZC,uOAAuO;IACvO,qCAAwC;IACxC,gLAAgL;IAChL,yBAA2B;IAC3B,sFAAsF;IACtF,oBAAuB;IAEvB,gBAAqB;IAqBjB,YAAsE;IAW5E,iNAAiN;IACjN,0CAEC;IAED;;;;OAIG;IACH,8BAHU,MAAM,CAKf;IAED,qBAOC;IAFG,6BAAmB;IAIvB;;;;OAIG;IACH,2BAOC;IAED;;;;OAIG;IACH,yBAHW,MAAM,EAAE,gBAwBlB;IAED;;OAEG;IACH,cAEC;IAED,qCAEC;IAED;;;;;;OAMG;IACH,uDAJW,MAAM,GAAC,SAAS,SAsB1B;IAED;;;;;OAKG;IACH,4BAHG;QAAyB,IAAI,GAArB,OAAO,YAAC;QACS,KAAK,GAAtB,OAAO,YAAC;KAClB,QAKA;IAED;;;OAGG;IACH,2CAIC;IAED;;;;OAIG;IACH,uCAHW,GAAC,UACD,GAAC,QAIX;;CACF;4BAhM2B,gBAAgB"}
1
+ {"version":3,"file":"aggregate-base.d.ts","sourceRoot":"","sources":["../../../../src/features/utils/aggregate-base.js"],"names":[],"mappings":"AAeA;IACE;;;;OAIG;IACH,sBAHW,MAAM,eACN,MAAM,EAkBhB;IAZC,uOAAuO;IACvO,qCAAwC;IACxC,gLAAgL;IAChL,yBAA2B;IAC3B,sFAAsF;IACtF,oBAAuB;IAEvB,gBAAqB;IAqBjB,YAAsE;IAW5E,iNAAiN;IACjN,0CAEC;IAED;;;;OAIG;IACH,8BAHU,MAAM,CAKf;IAED,qBAOC;IAFG,6BAAmB;IAIvB;;;;OAIG;IACH,2BAOC;IAED;;;;OAIG;IACH,yBAHW,MAAM,EAAE,gBAyBlB;IAED;;OAEG;IACH,cAEC;IAED,qCAEC;IAED;;;;;;OAMG;IACH,uDAJW,MAAM,GAAC,SAAS,SAsB1B;IAED;;;;;OAKG;IACH,4BAHG;QAAyB,IAAI,GAArB,OAAO,YAAC;QACS,KAAK,GAAtB,OAAO,YAAC;KAClB,QAKA;IAED;;;OAGG;IACH,2CAIC;IAED;;;;OAIG;IACH,uCAHW,GAAC,UACD,GAAC,QAIX;;CACF;4BAlM2B,gBAAgB"}
@@ -1 +1 @@
1
- {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../../src/loaders/api/register.js"],"names":[],"mappings":"AAmDA;;;;GAIG;AACH,mDAIC;;;;;;;0BArCY,OAAO,sBAAsB,EAAE,WAAW"}
1
+ {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../../src/loaders/api/register.js"],"names":[],"mappings":"AAoDA;;;;GAIG;AACH,mDAIC;;;;;;;0BArCY,OAAO,sBAAsB,EAAE,WAAW"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newrelic/browser-agent",
3
- "version": "1.317.0",
3
+ "version": "1.318.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",
@@ -284,4 +284,4 @@
284
284
  "README.md",
285
285
  "CHANGELOG.md"
286
286
  ]
287
- }
287
+ }
@@ -21,7 +21,7 @@ export function getModeledObject (obj, model) {
21
21
 
22
22
  if (Array.isArray(obj[key]) && Array.isArray(model[key])) output[key] = Array.from(new Set([...obj[key], ...model[key]]))
23
23
  else if (obj[key] instanceof Map || obj[key] instanceof Set || obj[key] instanceof Date || obj[key] instanceof RegExp) output[key] = obj[key]
24
- else if (typeof obj[key] === 'object' && typeof model[key] === 'object') output[key] = getModeledObject(obj[key], model[key])
24
+ else if (typeof obj[key] === 'object' && model[key] !== null && typeof model[key] === 'object') output[key] = getModeledObject(obj[key], model[key])
25
25
  else output[key] = obj[key]
26
26
  } catch (e) {
27
27
  if (!output[key]) warn(1, e)
@@ -88,6 +88,8 @@
88
88
  * @property {Object} [user_actions]
89
89
  * @property {boolean} [user_actions.enabled] - Must be true to allow UserAction events to be captured.
90
90
  * @property {Array<string>} [user_actions.elementAttributes] - List of HTML Element properties to be captured with UserAction events' target elements. This may help to identify the source element being interacted with in the UI.
91
+ * @property {Object} [web_sockets]
92
+ * @property {boolean} [web_sockets.enabled] - Turn on/off the web sockets feature (off by default).
91
93
  */
92
94
 
93
95
  export default {}
@@ -138,7 +138,8 @@ const InitModelFn = () => {
138
138
  session_trace: { enabled: true, autoStart: true },
139
139
  soft_navigations: { enabled: true, autoStart: true },
140
140
  ssl: undefined,
141
- user_actions: { enabled: true, elementAttributes: ['id', 'className', 'tagName', 'type'] }
141
+ user_actions: { enabled: true, elementAttributes: ['id', 'className', 'tagName', 'type'] },
142
+ web_sockets: { enabled: false }
142
143
  }
143
144
  }
144
145
 
@@ -3,19 +3,11 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
  import { SUPPORTABILITY_METRIC_CHANNEL } from '../../features/metrics/constants'
6
- import { FEATURE_TO_ENDPOINT, JSERRORS, RUM, EVENTS, FEATURE_NAMES, BLOBS, LOGS } from '../../loaders/features/features'
7
- import { VERSION } from '../constants/env'
8
- import { globalScope, isWorkerScope } from '../constants/runtime'
6
+ import { FEATURE_TO_ENDPOINT, FEATURE_NAMES } from '../../loaders/features/features'
9
7
  import { handle } from '../event-emitter/handle'
10
- import { eventListenerOpts } from '../event-listener/event-listener-opts'
11
- import { now } from '../timing/now'
12
8
  import { subscribeToEOL } from '../unload/eol'
13
- import { cleanURL } from '../url/clean-url'
14
- import { obj, param } from '../url/encode'
15
- import { warn } from '../util/console'
16
- import { stringify } from '../util/stringify'
17
- import { getSubmitMethod, xhr as xhrMethod, xhrFetch as fetchMethod } from '../util/submit-data'
18
- import { dispatchGlobalEvent } from '../dispatch/global-event'
9
+ import { getSubmitMethod, xhr as xhrMethod } from '../util/submit-data'
10
+ import { send } from './send'
19
11
  import { Obfuscator } from '../util/obfuscate'
20
12
 
21
13
  const RETRY = 'Harvester/Retry/'
@@ -107,194 +99,3 @@ export class Harvester {
107
99
  }
108
100
  }
109
101
  }
110
-
111
- /**
112
- * @typedef {import('./types.js').NetworkSendSpec} NetworkSendSpec
113
- */
114
-
115
- const warnings = {}
116
- /**
117
- * Initiate a harvest call.
118
- * @param {NetworkSendSpec} param0 Specification for sending data
119
- * @returns {boolean} True if a network call was made. Note that this does not mean or guarantee that it was successful.
120
- */
121
- export function send (agentRef, { endpoint, payload, localOpts = {}, submitMethod, cbFinished, raw, featureName, endpointVersion = 1, harvesterObfuscator }) {
122
- if (!agentRef.info.errorBeacon) return false
123
-
124
- let { body, qs } = cleanPayload(payload)
125
-
126
- if (Object.keys(body).length === 0 && !localOpts.sendEmptyBody) { // if there's no body to send, just run onfinish stuff and return
127
- if (cbFinished) cbFinished({ sent: false })
128
- return false
129
- }
130
-
131
- const protocol = agentRef.init.ssl === false ? 'http' : 'https'
132
- const perceivedBeacon = agentRef.init.proxy.beacon || agentRef.info.errorBeacon
133
- const url = raw
134
- ? `${protocol}://${perceivedBeacon}/${endpoint}`
135
- : `${protocol}://${perceivedBeacon}${endpoint !== RUM ? '/' + endpoint : ''}/${endpointVersion}/${agentRef.info.licenseKey}`
136
- const baseParams = !raw ? baseQueryString(agentRef, qs, endpoint, harvesterObfuscator) : ''
137
- let payloadParams = obj(qs, agentRef.runtime.maxBytes)
138
- if (baseParams === '' && payloadParams.startsWith('&')) {
139
- payloadParams = payloadParams.substring(1)
140
- }
141
-
142
- const fullUrl = `${url}?${baseParams}${payloadParams}`
143
- const gzip = !!qs?.attributes?.includes('gzip')
144
-
145
- // all gzipped data is already in the correct format and needs no transformation
146
- // all features going to 'events' endpoint should already be serialized & stringified
147
- let stringBody = gzip || endpoint === EVENTS ? body : stringify(body)
148
-
149
- // If body is null, undefined, or an empty object or array after stringifying, send an empty string instead.
150
- if (!stringBody || stringBody.length === 0 || stringBody === '{}' || stringBody === '[]') stringBody = ''
151
-
152
- // Warn--once per endpoint--if the agent tries to send large payloads
153
- if (endpoint !== BLOBS && stringBody.length > 750000 && (warnings[endpoint] = (warnings[endpoint] || 0) + 1) === 1) warn(28, endpoint)
154
-
155
- const headers = [{ key: 'content-type', value: 'text/plain' }]
156
-
157
- /* Since workers don't support sendBeacon right now, they can only use XHR method.
158
- Because they still do permit synch XHR, the idea is that at final harvest time (worker is closing),
159
- we just make a BLOCKING request--trivial impact--with the remaining data as a temp fill-in for sendBeacon.
160
- Following the removal of img-element method. */
161
- let result = submitMethod({ url: fullUrl, body: stringBody, sync: localOpts.isFinalHarvest && isWorkerScope, headers })
162
-
163
- if (!localOpts.isFinalHarvest && cbFinished) { // final harvests don't hold onto buffer data (shouldRetryOnFail is false), so cleanup isn't needed
164
- if (submitMethod === xhrMethod) {
165
- result.addEventListener('loadend', function () {
166
- // `this` here in block refers to the XHR object in this scope, do not change the anon function to an arrow function
167
- // status 0 refers to a local error, such as CORS or network failure, or a blocked request by the browser (e.g. adblocker)
168
- const cbResult = { sent: this.status !== 0, status: this.status, retry: shouldRetry(this.status), fullUrl, xhr: this, responseText: this.responseText }
169
- cbFinished(cbResult)
170
-
171
- /** temporary audit of consistency of harvest metadata flags */
172
- if (!shouldRetry(this.status)) trackHarvestMetadata()
173
- }, eventListenerOpts(false))
174
- } else if (submitMethod === fetchMethod) {
175
- result.then(async function (response) {
176
- const status = response.status
177
- const cbResult = { sent: true, status, retry: shouldRetry(status), fullUrl, fetchResponse: response, responseText: await response.text() }
178
- cbFinished(cbResult)
179
- /** temporary audit of consistency of harvest metadata flags */
180
- if (!shouldRetry(status)) trackHarvestMetadata()
181
- })
182
- }
183
-
184
- function trackHarvestMetadata () {
185
- try {
186
- if (featureName === FEATURE_NAMES.jserrors && !body?.err) return
187
-
188
- const hasReplay = baseParams.includes('hr=1')
189
- const hasTrace = baseParams.includes('ht=1')
190
- const hasError = qs?.attributes?.includes('hasError=true')
191
-
192
- handle('harvest-metadata', [{
193
- [featureName]: {
194
- ...(hasReplay && { hasReplay }),
195
- ...(hasTrace && { hasTrace }),
196
- ...(hasError && { hasError })
197
- }
198
- }], undefined, FEATURE_NAMES.metrics, agentRef.ee)
199
- } catch (err) {
200
- // do nothing
201
- }
202
- }
203
- }
204
-
205
- dispatchGlobalEvent({
206
- drained: !!agentRef.runtime?.activatedFeatures,
207
- type: 'data',
208
- name: 'harvest',
209
- feature: featureName,
210
- data: {
211
- endpoint,
212
- headers,
213
- payload,
214
- submitMethod: getSubmitMethodName(),
215
- raw,
216
- synchronousXhr: !!(localOpts.isFinalHarvest && isWorkerScope)
217
- }
218
- })
219
-
220
- return true
221
-
222
- function shouldRetry (status) {
223
- switch (status) {
224
- case 408:
225
- case 429:
226
- case 500:
227
- return true
228
- }
229
- return (status >= 502 && status <= 504) || (status >= 512 && status <= 530)
230
- }
231
-
232
- function getSubmitMethodName () {
233
- if (submitMethod === xhrMethod) return 'xhr'
234
- if (submitMethod === fetchMethod) return 'fetch'
235
- return 'beacon'
236
- }
237
- }
238
-
239
- /**
240
- * Cleans and returns a payload object containing a body and qs
241
- * object with key/value pairs. KV pairs where the value is null,
242
- * undefined, or an empty string are removed to save on transmission
243
- * size.
244
- * @param {HarvestPayload} payload Payload to be sent to the endpoint.
245
- * @returns {HarvestPayload} Cleaned payload payload to be sent to the endpoint.
246
- */
247
- function cleanPayload (payload = {}) {
248
- const clean = (input) => {
249
- if ((typeof Uint8Array !== 'undefined' && input instanceof Uint8Array) || Array.isArray(input)) return input
250
- if (typeof input === 'string') return input
251
- return Object.entries(input || {}).reduce((accumulator, [key, value]) => {
252
- if ((typeof value === 'number') ||
253
- (typeof value === 'string' && value.length > 0) ||
254
- (typeof value === 'object' && Object.keys(value || {}).length > 0)
255
- ) {
256
- accumulator[key] = value
257
- }
258
- return accumulator
259
- }, {})
260
- }
261
-
262
- return {
263
- body: clean(payload.body),
264
- qs: clean(payload.qs)
265
- }
266
- }
267
-
268
- // The stuff that gets sent every time.
269
- function baseQueryString (agentRef, qs, endpoint, harvesterObfuscator) {
270
- const cleanedURL = cleanURL('' + globalScope.location)
271
- const ref = harvesterObfuscator?.obfuscateString(cleanedURL) ?? cleanedURL
272
- const session = agentRef.runtime.session
273
- const hr = !!session?.state.sessionReplaySentFirstChunk && session?.state.sessionReplayMode === 1 && endpoint !== JSERRORS
274
- const ht = !!session?.state.traceHarvestStarted && session?.state.sessionTraceMode === 1 && ![LOGS, BLOBS].includes(endpoint)
275
-
276
- const qps = [
277
- 'a=' + agentRef.info.applicationID,
278
- param('sa', (agentRef.info.sa ? '' + agentRef.info.sa : '')),
279
- param('v', VERSION),
280
- transactionNameParam(),
281
- param('ct', agentRef.runtime.customTransaction),
282
- '&rst=' + now(),
283
- '&ck=0', // ck param DEPRECATED - still expected by backend
284
- '&s=' + (session?.state.value || '0'), // the 0 id encaps all untrackable and default traffic
285
- param('ref', ref),
286
- param('ptid', (agentRef.runtime.ptid ? '' + agentRef.runtime.ptid : ''))
287
- ]
288
- if (hr) qps.push(param('hr', '1', qs))
289
- if (ht) qps.push(param('ht', '1', qs))
290
-
291
- return qps.join('')
292
-
293
- // Constructs the transaction name param for the beacon URL.
294
- // Prefers the obfuscated transaction name over the plain text.
295
- // Falls back to making up a name.
296
- function transactionNameParam () {
297
- if (agentRef.info.transactionName) return param('to', agentRef.info.transactionName)
298
- return param('t', agentRef.info.tNamePlain || 'Unnamed Transaction')
299
- }
300
- }