@newrelic/browser-agent 1.320.1-rc.0 → 1.320.1-rc.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/dist/cjs/common/config/runtime.js +3 -0
- package/dist/cjs/common/constants/env.cdn.js +1 -1
- package/dist/cjs/common/constants/env.npm.js +1 -1
- package/dist/cjs/common/dom/selector-path.js +1 -1
- package/dist/cjs/common/event-listener/event-listener-opts.js +1 -1
- package/dist/cjs/common/harvest/connector.js +200 -0
- package/dist/cjs/common/harvest/harvester.js +5 -8
- package/dist/cjs/common/harvest/send.js +8 -7
- package/dist/cjs/common/session/session-entity.js +1 -1
- package/dist/cjs/common/timer/interaction-timer.js +2 -2
- package/dist/cjs/common/unload/eol.js +3 -3
- package/dist/cjs/common/util/console.js +2 -1
- package/dist/cjs/common/util/feature-flags.js +2 -1
- package/dist/cjs/common/v2/constants.js +21 -0
- package/dist/cjs/common/v2/utils.js +25 -23
- package/dist/cjs/common/window/page-visibility.js +1 -1
- package/dist/cjs/common/wrap/wrap-events.js +4 -3
- package/dist/cjs/common/wrap/wrap-fetch.js +2 -2
- package/dist/cjs/common/wrap/wrap-function.js +1 -1
- package/dist/cjs/common/wrap/wrap-history.js +3 -2
- package/dist/cjs/common/wrap/wrap-xhr.js +2 -2
- package/dist/cjs/features/ajax/aggregate/index.js +1 -1
- package/dist/cjs/features/generic_events/aggregate/index.js +1 -1
- package/dist/cjs/features/generic_events/instrument/index.js +1 -1
- package/dist/cjs/features/jserrors/aggregate/index.js +5 -5
- package/dist/cjs/features/logging/instrument/index.js +1 -1
- package/dist/cjs/features/page_view_event/aggregate/index.js +2 -6
- package/dist/cjs/features/page_view_event/aggregate_v2/index.js +109 -0
- package/dist/cjs/features/page_view_event/instrument/index.js +6 -1
- package/dist/cjs/features/page_view_timing/aggregate/index.js +5 -1
- package/dist/cjs/features/session_replay/instrument/index.js +9 -0
- package/dist/cjs/features/session_replay/shared/recorder.js +2 -1
- package/dist/cjs/features/session_trace/instrument/index.js +3 -3
- package/dist/cjs/features/soft_navigations/instrument/index.js +2 -2
- package/dist/cjs/features/utils/aggregate-base.js +0 -12
- package/dist/cjs/features/utils/instrument-base.js +72 -29
- package/dist/cjs/loaders/agent.js +2 -1
- package/dist/cjs/loaders/api/consent.js +2 -2
- package/dist/cjs/loaders/api/register.js +8 -8
- package/dist/cjs/loaders/configure/configure.js +14 -0
- package/dist/cjs/loaders/features/features.js +2 -1
- package/dist/esm/common/config/runtime.js +3 -0
- package/dist/esm/common/constants/env.cdn.js +1 -1
- package/dist/esm/common/constants/env.npm.js +1 -1
- package/dist/esm/common/dom/selector-path.js +1 -1
- package/dist/esm/common/event-listener/event-listener-opts.js +1 -1
- package/dist/esm/common/harvest/connector.js +193 -0
- package/dist/esm/common/harvest/harvester.js +5 -8
- package/dist/esm/common/harvest/send.js +10 -9
- package/dist/esm/common/session/session-entity.js +1 -1
- package/dist/esm/common/timer/interaction-timer.js +2 -2
- package/dist/esm/common/unload/eol.js +3 -3
- package/dist/esm/common/util/console.js +2 -1
- package/dist/esm/common/util/feature-flags.js +2 -1
- package/dist/esm/common/v2/constants.js +15 -0
- package/dist/esm/common/v2/utils.js +24 -22
- package/dist/esm/common/window/page-visibility.js +1 -1
- package/dist/esm/common/wrap/wrap-events.js +4 -3
- package/dist/esm/common/wrap/wrap-fetch.js +2 -2
- package/dist/esm/common/wrap/wrap-function.js +1 -1
- package/dist/esm/common/wrap/wrap-history.js +3 -2
- package/dist/esm/common/wrap/wrap-xhr.js +2 -2
- package/dist/esm/features/ajax/aggregate/index.js +2 -2
- package/dist/esm/features/generic_events/aggregate/index.js +1 -1
- package/dist/esm/features/generic_events/instrument/index.js +1 -1
- package/dist/esm/features/jserrors/aggregate/index.js +6 -6
- package/dist/esm/features/logging/instrument/index.js +1 -1
- package/dist/esm/features/page_view_event/aggregate/index.js +2 -6
- package/dist/esm/features/page_view_event/aggregate_v2/index.js +100 -0
- package/dist/esm/features/page_view_event/instrument/index.js +6 -1
- package/dist/esm/features/page_view_timing/aggregate/index.js +5 -1
- package/dist/esm/features/session_replay/instrument/index.js +9 -0
- package/dist/esm/features/session_replay/shared/recorder.js +2 -1
- package/dist/esm/features/session_trace/instrument/index.js +3 -3
- package/dist/esm/features/soft_navigations/instrument/index.js +2 -2
- package/dist/esm/features/utils/aggregate-base.js +0 -12
- package/dist/esm/features/utils/instrument-base.js +71 -28
- package/dist/esm/loaders/agent.js +2 -1
- package/dist/esm/loaders/api/consent.js +2 -2
- package/dist/esm/loaders/api/register.js +1 -1
- package/dist/esm/loaders/configure/configure.js +14 -0
- package/dist/esm/loaders/features/features.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/common/config/runtime.d.ts.map +1 -1
- package/dist/types/common/event-listener/event-listener-opts.d.ts +1 -1
- package/dist/types/common/harvest/connector.d.ts +6 -0
- package/dist/types/common/harvest/connector.d.ts.map +1 -0
- package/dist/types/common/harvest/harvester.d.ts.map +1 -1
- package/dist/types/common/harvest/send.d.ts.map +1 -1
- package/dist/types/common/unload/eol.d.ts +1 -1
- package/dist/types/common/unload/eol.d.ts.map +1 -1
- package/dist/types/common/util/console.d.ts +2 -1
- package/dist/types/common/util/console.d.ts.map +1 -1
- package/dist/types/common/v2/constants.d.ts +9 -0
- package/dist/types/common/v2/constants.d.ts.map +1 -0
- package/dist/types/common/v2/utils.d.ts +36 -11
- package/dist/types/common/v2/utils.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-events.d.ts +2 -1
- package/dist/types/common/wrap/wrap-events.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-history.d.ts +2 -1
- package/dist/types/common/wrap/wrap-history.d.ts.map +1 -1
- package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/page_view_event/aggregate_v2/index.d.ts +20 -0
- package/dist/types/features/page_view_event/aggregate_v2/index.d.ts.map +1 -0
- package/dist/types/features/page_view_event/instrument/index.d.ts.map +1 -1
- package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/instrument/index.d.ts +1 -0
- package/dist/types/features/session_replay/instrument/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/shared/recorder.d.ts.map +1 -1
- package/dist/types/features/session_trace/instrument/index.d.ts.map +1 -1
- package/dist/types/features/utils/aggregate-base.d.ts +0 -5
- package/dist/types/features/utils/aggregate-base.d.ts.map +1 -1
- package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
- package/dist/types/loaders/agent.d.ts.map +1 -1
- package/dist/types/loaders/configure/configure.d.ts.map +1 -1
- package/dist/types/loaders/features/features.d.ts +1 -0
- package/dist/types/loaders/features/features.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/common/config/runtime.js +3 -0
- package/src/common/dom/selector-path.js +1 -1
- package/src/common/event-listener/event-listener-opts.js +1 -1
- package/src/common/harvest/connector.js +168 -0
- package/src/common/harvest/harvester.js +7 -9
- package/src/common/harvest/send.js +9 -7
- package/src/common/session/session-entity.js +1 -1
- package/src/common/timer/interaction-timer.js +2 -2
- package/src/common/unload/eol.js +3 -3
- package/src/common/util/console.js +2 -1
- package/src/common/util/feature-flags.js +1 -1
- package/src/common/v2/constants.js +15 -0
- package/src/common/v2/utils.js +23 -21
- package/src/common/window/page-visibility.js +1 -1
- package/src/common/wrap/wrap-events.js +4 -3
- package/src/common/wrap/wrap-fetch.js +2 -2
- package/src/common/wrap/wrap-function.js +1 -1
- package/src/common/wrap/wrap-history.js +3 -2
- package/src/common/wrap/wrap-xhr.js +2 -2
- package/src/features/ajax/aggregate/index.js +2 -2
- package/src/features/generic_events/aggregate/index.js +1 -1
- package/src/features/generic_events/instrument/index.js +1 -1
- package/src/features/jserrors/aggregate/index.js +6 -6
- package/src/features/logging/instrument/index.js +1 -1
- package/src/features/page_view_event/aggregate/index.js +2 -6
- package/src/features/page_view_event/aggregate_v2/index.js +97 -0
- package/src/features/page_view_event/instrument/index.js +6 -1
- package/src/features/page_view_timing/aggregate/index.js +5 -1
- package/src/features/session_replay/instrument/index.js +9 -0
- package/src/features/session_replay/shared/recorder.js +2 -1
- package/src/features/session_trace/instrument/index.js +3 -3
- package/src/features/soft_navigations/instrument/index.js +2 -2
- package/src/features/utils/aggregate-base.js +0 -12
- package/src/features/utils/instrument-base.js +71 -25
- package/src/loaders/agent.js +2 -1
- package/src/loaders/api/consent.js +2 -2
- package/src/loaders/api/register.js +1 -1
- package/src/loaders/configure/configure.js +12 -0
- package/src/loaders/features/features.js +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"harvester.d.ts","sourceRoot":"","sources":["../../../../src/common/harvest/harvester.js"],"names":[],"mappings":"AAiBA;IAIE,
|
|
1
|
+
{"version":3,"file":"harvester.d.ts","sourceRoot":"","sources":["../../../../src/common/harvest/harvester.js"],"names":[],"mappings":"AAiBA;IAIE,2BAKC;IAPD,6BAA0B;IAGxB,cAAwB;IAGxB,uBAA0C;IAG5C,wCAgBC;IAED;;;;;OAKG;IACH,iCAJW,MAAM,cACN,MAAM,GACJ,OAAO,CA+CnB;;CACF;2BAxF0B,mBAAmB"}
|
|
@@ -1 +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,
|
|
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,CAyHnB;8BAlIY,OAAO,YAAY,EAAE,eAAe"}
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* This is used, for example, to submit a final harvest and send all remaining data on best-effort.
|
|
4
4
|
* @param {function} cb - func to run before or during the last reliable event or time of an env's life span
|
|
5
5
|
*/
|
|
6
|
-
export function subscribeToEOL(cb: Function
|
|
6
|
+
export function subscribeToEOL(cb: Function): void;
|
|
7
7
|
//# sourceMappingURL=eol.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eol.d.ts","sourceRoot":"","sources":["../../../../src/common/unload/eol.js"],"names":[],"mappings":"AAmBA;;;;GAIG;AACH,
|
|
1
|
+
{"version":3,"file":"eol.d.ts","sourceRoot":"","sources":["../../../../src/common/unload/eol.js"],"names":[],"mappings":"AAmBA;;;;GAIG;AACH,mDAOC"}
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
* | 50 | Failed to connect. Cannot allow registered API. |
|
|
59
59
|
* | 51 | Container agent is not available to register with. Can not connect. |
|
|
60
60
|
* | 52 | Unexpected problem encountered. There should be at least one app for harvest! |
|
|
61
|
-
* | 53 |
|
|
61
|
+
* | 53 | Failed to parse connect response. |
|
|
62
62
|
* | 54 | An experimental feature is being used. Support can not be offered for issues. |
|
|
63
63
|
* | 55 | Register API has been disabled on the container agent. |
|
|
64
64
|
* | 56 | Could not find a matching entity to store data. |
|
|
@@ -84,6 +84,7 @@
|
|
|
84
84
|
* | 76 | Agent rejected post message, could not match with existing entity. |
|
|
85
85
|
* | 77 | Agent rejected post message, could not validate origin. |
|
|
86
86
|
* | 78 | RegisteredIframeEntity could not determine parent origin and will not register, to avoid trusting messages from any origin. |
|
|
87
|
+
* | 79 | Unable to initialize Connector and/or Harvester. |
|
|
87
88
|
*
|
|
88
89
|
* @param {number} code The warning code to emit, which will be used to link to the warning code documentation
|
|
89
90
|
* @param {*} [secondary] Secondary data to include, usually an extra message, error or object
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"console.d.ts","sourceRoot":"","sources":["../../../../src/common/util/console.js"],"names":[],"mappings":"AAUA
|
|
1
|
+
{"version":3,"file":"console.d.ts","sourceRoot":"","sources":["../../../../src/common/util/console.js"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2FG;AAEH,2BALW,MAAM,cACN,GAAC,QAiBX"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/common/v2/constants.js"],"names":[],"mappings":";;;uBAMU,MAAM"}
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} V2Target
|
|
3
|
+
* @property {'BA'} type always V2_TYPES.BA -- identifies this as the container (main) agent, not a registered MFE
|
|
4
|
+
* @property {string} instance the container agent's agentIdentifier
|
|
5
|
+
* @property {string} [id] the container agent's entity guid, once known (getter, resolved asynchronously)
|
|
6
|
+
* @property {{[key:string]: any}} attributes the V2 payload attributes for the container agent (getter)
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Determines if a given target represents a registered MFE (as opposed to the container agent).
|
|
10
|
+
* @param {*} target the target to check
|
|
11
|
+
* @returns {boolean} true if the target is a registered MFE target
|
|
12
|
+
*/
|
|
13
|
+
export function isMfeTarget(target: any): boolean;
|
|
1
14
|
/**
|
|
2
15
|
* Returns a single registered entity associated with a given iframe interface ID. Returns undefined if no entity is found.
|
|
3
16
|
* @param {string} iframeInterfaceId
|
|
@@ -69,24 +82,36 @@ export function shouldDuplicate(target: import("../../interfaces/registered-enti
|
|
|
69
82
|
/**
|
|
70
83
|
* Finds the registered targets from the stack trace for a given agent reference.
|
|
71
84
|
* @param {*} agentRef The agent reference to use for finding targets.
|
|
72
|
-
* @returns {Array} An array of targets found from the stack trace. If no targets are found or allowed, returns an array
|
|
85
|
+
* @returns {Array} An array of targets found from the stack trace. If no targets are found or allowed, returns an array containing the container target.
|
|
73
86
|
*/
|
|
74
87
|
export function findTargetsFromStackTrace(agentRef: any): any[];
|
|
75
88
|
/**
|
|
76
89
|
* Removes duplicate targets from an array, keyed by `target.instance`. This guards against the same canonical
|
|
77
90
|
* target re-entering the array via multiple matched stack-frame URLs (e.g. a recursive call whose stack contains the
|
|
78
|
-
* same file at multiple depths).
|
|
79
|
-
* naturally collapse to a single entry too, which is the desired behavior.
|
|
91
|
+
* same file at multiple depths). Multiple container-target entries (whose `instance` is the container agent's stable
|
|
92
|
+
* `agentIdentifier`) naturally collapse to a single entry too, which is the desired behavior.
|
|
80
93
|
* @param {Array} targets
|
|
81
94
|
* @returns {Array} deduped list of targets, preserving relative order of first occurrence
|
|
82
95
|
*/
|
|
83
96
|
export function dedupeTargetsByInstance(targets: any[]): any[];
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
97
|
+
export type V2Target = {
|
|
98
|
+
/**
|
|
99
|
+
* always V2_TYPES.BA -- identifies this as the container (main) agent, not a registered MFE
|
|
100
|
+
*/
|
|
101
|
+
type: "BA";
|
|
102
|
+
/**
|
|
103
|
+
* the container agent's agentIdentifier
|
|
104
|
+
*/
|
|
105
|
+
instance: string;
|
|
106
|
+
/**
|
|
107
|
+
* the container agent's entity guid, once known (getter, resolved asynchronously)
|
|
108
|
+
*/
|
|
109
|
+
id?: string | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* the V2 payload attributes for the container agent (getter)
|
|
112
|
+
*/
|
|
113
|
+
attributes: {
|
|
114
|
+
[key: string]: any;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
92
117
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/common/v2/utils.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/common/v2/utils.js"],"names":[],"mappings":"AAQA;;;;;;GAMG;AAEH;;;;GAIG;AACH,oCAHW,GAAC,GACC,OAAO,CAInB;AAED;;;;;GAKG;AACH,0EAJW,MAAM,YACN,GAAC,GACC,OAAO,sCAAsC,EAAE,WAAW,GAAC,SAAS,CAMhF;AAED;;;;;GAKG;AACH,+CAJW,MAAM,GAAC,MAAM,YACb,GAAC,GACC,OAAO,oCAAoC,EAAE,yBAAyB,EAAE,CAMpF;AAED;;;;;;;;;;;;GAYG;AACH,2DAJW,MAAM,YACN,GAAC,GACC,OAAO,oCAAoC,EAAE,yBAAyB,EAAE,CAOpF;AAED;;;;;;;;;;;;GAYG;AACH,wEA6BC;AAED;;;;;;;GAOG;AACH,+CAJW,MAAM,sBACN,iBAAiB,GACf,MAAM,CAQlB;AAED;;;;;;;GAOG;AACH,yDAJW,OAAO,oCAAoC,EAAE,yBAAyB,qBACtE,GAAC,GACC,MAAM,CAKlB;AAED;;;;;;GAMG;AACH,wCAJW,OAAO,oCAAoC,EAAE,yBAAyB,qBACtE,GAAC,GACC,OAAO,CAInB;AAED;;;;GAIG;AACH,oDAHW,GAAC,SAqBX;AAED;;;;;;;GAOG;AACH,+DAUC;;;;;UA1La,IAAI;;;;cACJ,MAAM;;;;;;;;gBAEN;QAAC,CAAC,GAAG,EAAC,MAAM,GAAG,GAAG,CAAA;KAAC"}
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
* `document` (if in a browser scope). Adds custom events in context of a new emitter scoped only to these methods.
|
|
4
4
|
* @param {Object} sharedEE - The shared event emitter on which a new scoped
|
|
5
5
|
* event emitter will be based.
|
|
6
|
+
* @param {*} [agentRef] - The agent reference, used to attribute wrapped calls to the correct v2 target.
|
|
6
7
|
* @returns {Object} Scoped event emitter with a debug ID of `events`.
|
|
7
8
|
*/
|
|
8
|
-
export function wrapEvents(sharedEE: Object): Object;
|
|
9
|
+
export function wrapEvents(sharedEE: Object, agentRef?: any): Object;
|
|
9
10
|
/**
|
|
10
11
|
* Returns an event emitter scoped specifically for the `events` context. This scoping is a remnant from when all the
|
|
11
12
|
* features shared the same group in the event, to isolate events between features. It will likely be revisited.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrap-events.d.ts","sourceRoot":"","sources":["../../../../src/common/wrap/wrap-events.js"],"names":[],"mappings":"AAqBA
|
|
1
|
+
{"version":3,"file":"wrap-events.d.ts","sourceRoot":"","sources":["../../../../src/common/wrap/wrap-events.js"],"names":[],"mappings":"AAqBA;;;;;;;GAOG;AACH,qCALW,MAAM,aAEN,GAAC,GACC,MAAM,CA0DlB;AAeD;;;;;;GAMG;AACH,mCAJW,MAAM,GAEJ,MAAM,CAIlB"}
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
* Wraps the `pushState` and `replaceState` methods of `window.history` and returns a corresponding event emitter
|
|
3
3
|
* scoped to the history object.
|
|
4
4
|
* @param {Object} sharedEE - The shared event emitter on which a new scoped event emitter will be based.
|
|
5
|
+
* @param {*} [agentRef] - The agent reference, used to attribute wrapped calls to the correct v2 target.
|
|
5
6
|
* @returns {Object} Scoped event emitter with a debug ID of `history`.
|
|
6
7
|
*/
|
|
7
|
-
export function wrapHistory(sharedEE: Object): Object;
|
|
8
|
+
export function wrapHistory(sharedEE: Object, agentRef?: any): Object;
|
|
8
9
|
/**
|
|
9
10
|
* Returns an event emitter scoped specifically for the `history` context. This scoping is a remnant from when all the
|
|
10
11
|
* features shared the same group in the event, to isolate events between features. It will likely be revisited.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrap-history.d.ts","sourceRoot":"","sources":["../../../../src/common/wrap/wrap-history.js"],"names":[],"mappings":"AAgBA
|
|
1
|
+
{"version":3,"file":"wrap-history.d.ts","sourceRoot":"","sources":["../../../../src/common/wrap/wrap-history.js"],"names":[],"mappings":"AAgBA;;;;;;GAMG;AACH,sCAJW,MAAM,aACN,GAAC,GACC,MAAM,CAoBlB;AAED;;;;;;GAMG;AACH,mCAJW,MAAM,GAEJ,MAAM,CAIlB"}
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,QA+DX;IAXC;;;;;;;;;;;;;;mBAOC;IANC,iCAAyB;IAY7B,kCAEC;IAED;;;;;;aA2GC;CACF;8BA9O6B,4BAA4B;2BAQ/B,gCAAgC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export class Aggregate extends AggregateBase {
|
|
2
|
+
static featureName: string;
|
|
3
|
+
constructor(agentRef: any);
|
|
4
|
+
queryStringsBuilder(): {
|
|
5
|
+
fp: any;
|
|
6
|
+
fcp: any;
|
|
7
|
+
qt: any;
|
|
8
|
+
ap: any;
|
|
9
|
+
be: number;
|
|
10
|
+
fe: number;
|
|
11
|
+
dc: number;
|
|
12
|
+
at: any;
|
|
13
|
+
af: string;
|
|
14
|
+
igp: any;
|
|
15
|
+
};
|
|
16
|
+
serializer(eventBuffer: any): any;
|
|
17
|
+
#private;
|
|
18
|
+
}
|
|
19
|
+
import { AggregateBase } from '../../utils/aggregate-base';
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/page_view_event/aggregate_v2/index.js"],"names":[],"mappings":"AAiBA;IACE,2BAA2C;IAO3C,2BAkBC;IAED;;;;;;;;;;;MA0CC;IAMD,kCAEC;;CACF;8BAvF6B,4BAA4B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/page_view_event/instrument/index.js"],"names":[],"mappings":"AAWA;IACE,2BAA2C;IAC3C,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/page_view_event/instrument/index.js"],"names":[],"mappings":"AAWA;IACE,2BAA2C;IAC3C,2BAeC;IAED,8BA+BC;CACF;AAED,8CAAuC;+BA3DR,6BAA6B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/page_view_timing/aggregate/index.js"],"names":[],"mappings":"AA2BA;IACE,2BAAiC;IAMjC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/page_view_timing/aggregate/index.js"],"names":[],"mappings":"AA2BA;IACE,2BAAiC;IAMjC,2BAmCC;IAjCC,4BAA+B;IAC/B,0BAA6B;IAK7B,uBAA2D;IA6B7D;;;OAGG;IACH,6BAFW,MAAM,QAOhB;IAED;;;;MAiCC;IAED;;;OAGG;IACH,4BAFa,IAAI,CAahB;IAWD,4BAGC;IAGD,qCA8BC;;CACF;8BA1K6B,4BAA4B;2BAC/B,gCAAgC"}
|
|
@@ -3,6 +3,7 @@ export class Instrument extends InstrumentBase {
|
|
|
3
3
|
constructor(agentRef: any);
|
|
4
4
|
/** The RRWEB recorder instance, if imported */
|
|
5
5
|
recorder: any;
|
|
6
|
+
abortHandler: () => void;
|
|
6
7
|
errorNoticed: boolean;
|
|
7
8
|
/**
|
|
8
9
|
* Returns a promise that imports the recorder module. Only lets the recorder module be imported and instantiated once. Rejects if failed to import/instantiate.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/session_replay/instrument/index.js"],"names":[],"mappings":"AAkBA;IACE,2BAAiC;IAMjC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/session_replay/instrument/index.js"],"names":[],"mappings":"AAkBA;IACE,2BAAiC;IAMjC,2BAqCC;IAxCD,+CAA+C;IAC/C,cAAQ;IA2BN,yBAA+B;IAQ3B,sBAAwB;IAmB9B;;;OAGG;IACH,+BAkBC;;CAqBF;AAED,8CAAuC;+BA/GR,6BAA6B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recorder.d.ts","sourceRoot":"","sources":["../../../../../src/features/session_replay/shared/recorder.js"],"names":[],"mappings":"AAqBA;IAUE,+BAoCC;IAtCD,sBAAmB;IAGjB,iDAAiD;IACjD,kBAAgC;IAEhC,QAAyB;IACzB,mBAA6C;IAC7C,cAAqC;IAErC,qBAAwB;IACxB,0FAA0F;IAC1F,eAAkE;IAElE,iHAAiH;IACjH,uBAAgD;IAChD,mFAAmF;IACnF,iCAA0D;IAC1D,+DAA+D;IAC/D,kBAA6B;IAC7B,uIAAuI;IACvI,yBAA4B;IAC5B,qBAAwB;IACxB,kIAAkI;IAClI,kBAAqB;IACrB,uIAAuI;IACvI,0BAAwE;IAc1E,mBAEC;IAED;;;;;;;;;MAWC;IAED,kFAAkF;IAClF,oBAGC;IAED,qDAAqD;IACrD,8CA0CC;IAED;;;;;OAKG;IACH,aAHW,GAAC,cACD,GAAC,QAiCX;IAED,yHAAyH;IACzH,
|
|
1
|
+
{"version":3,"file":"recorder.d.ts","sourceRoot":"","sources":["../../../../../src/features/session_replay/shared/recorder.js"],"names":[],"mappings":"AAqBA;IAUE,+BAoCC;IAtCD,sBAAmB;IAGjB,iDAAiD;IACjD,kBAAgC;IAEhC,QAAyB;IACzB,mBAA6C;IAC7C,cAAqC;IAErC,qBAAwB;IACxB,0FAA0F;IAC1F,eAAkE;IAElE,iHAAiH;IACjH,uBAAgD;IAChD,mFAAmF;IACnF,iCAA0D;IAC1D,+DAA+D;IAC/D,kBAA6B;IAC7B,uIAAuI;IACvI,yBAA4B;IAC5B,qBAAwB;IACxB,kIAAkI;IAClI,kBAAqB;IACrB,uIAAuI;IACvI,0BAAwE;IAc1E,mBAEC;IAED;;;;;;;;;MAWC;IAED,kFAAkF;IAClF,oBAGC;IAED,qDAAqD;IACrD,8CA0CC;IAED;;;;;OAKG;IACH,aAHW,GAAC,cACD,GAAC,QAiCX;IAED,yHAAyH;IACzH,yCAkCC;IAED,0HAA0H;IAC1H,yBAOC;IAED,wBAEC;IAED,gCAAgC;IAChC,uCAGC;IAED;;;SAGK;IACL,oCAGC;;CACF;+BA1O8B,mBAAmB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/session_trace/instrument/index.js"],"names":[],"mappings":"AAmBA;IACE,2BAAiC;IACjC,2BA+CC;IAhCC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/session_trace/instrument/index.js"],"names":[],"mappings":"AAmBA;IACE,2BAAiC;IACjC,2BA+CC;IAhCC,6BAAsD;CAiCzD;AAED,6CAAsC;+BAhEP,6BAA6B"}
|
|
@@ -58,11 +58,6 @@ export class AggregateBase extends FeatureBase {
|
|
|
58
58
|
sent?: boolean | undefined;
|
|
59
59
|
retry?: boolean | undefined;
|
|
60
60
|
}): void;
|
|
61
|
-
/**
|
|
62
|
-
* These are actions related to shared resources that should be initialized once by whichever feature Aggregate subclass loads first.
|
|
63
|
-
* This method should run after checkConfiguration, which may reset the agent's info/runtime object that is used here.
|
|
64
|
-
*/
|
|
65
|
-
doOnceForAllAggregate(agentRef: any): void;
|
|
66
61
|
/**
|
|
67
62
|
* Report a supportability metric
|
|
68
63
|
* @param {*} metricName The tag of the name matching the Angler aggregation tag
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aggregate-base.d.ts","sourceRoot":"","sources":["../../../../src/features/utils/aggregate-base.js"],"names":[],"mappings":"
|
|
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,EAiBhB;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;;;;OAIG;IACH,uCAHW,GAAC,UACD,GAAC,QAIX;;CACF;4BAtL2B,gBAAgB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrument-base.d.ts","sourceRoot":"","sources":["../../../../src/features/utils/instrument-base.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"instrument-base.d.ts","sourceRoot":"","sources":["../../../../src/features/utils/instrument-base.js"],"names":[],"mappings":"AA6BA;;;GAGG;AACH;IACE;;;;OAIG;IACH,sBAHW,MAAM,eACN,MAAM,EA0ChB;IArCC,8IAA8I;IAC9I,cADW,WAAW,SAAS,CACF;IAE7B;;;MAGE;IACF,eAHU,OAAO,kBAAkB,EAAE,aAAa,CAGpB;IAE9B;;;MAGE;IACF,iCAAmC;IACnC,kCAEE;IAEF;;;MAGE;IACF,uBAAiC;IAiBnC;;;;;;;OAOG;IACH,2BALW,MAAM,qDAEN,MAAM,QA2DhB;;CAiDF;4BAtL2B,gBAAgB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../../src/loaders/agent.js"],"names":[],"mappings":"AA2BA;;;;;;;;;GASG;AAEH;;;GAGG;AACH;IACE;;OAEG;IACH,qBAFW,YAAY,EA+BtB;IAnBC,yBAAkB;IAGlB,yCAAsD;IAkBxD;;;;;MAOC;IAED,gBAEC;IAED,
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../../src/loaders/agent.js"],"names":[],"mappings":"AA2BA;;;;;;;;;GASG;AAEH;;;GAGG;AACH;IACE;;OAEG;IACH,qBAFW,YAAY,EA+BtB;IAnBC,yBAAkB;IAGlB,yCAAsD;IAkBxD;;;;;MAOC;IAED,gBAEC;IAED,yBAoCC;CACF;;;;;UAlGa,OAAO,uBAAuB,EAAE,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;0BApBxB,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../../../../src/loaders/configure/configure.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../../../../src/loaders/configure/configure.js"],"names":[],"mappings":"AAkBA;;;GAGG;AACH,oGAyFC"}
|
|
@@ -6,6 +6,7 @@ export const EVENTS: "events";
|
|
|
6
6
|
export const JSERRORS: "jserrors";
|
|
7
7
|
export const BLOBS: "browser/blobs";
|
|
8
8
|
export const RUM: "rum";
|
|
9
|
+
export const CONNECT: "connect";
|
|
9
10
|
export const LOGS: "browser/logs";
|
|
10
11
|
export namespace FEATURE_NAMES {
|
|
11
12
|
export let ajax: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../../../../src/loaders/features/features.js"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,qBAAsB,QAAQ,CAAA;AAC9B,uBAAwB,UAAU,CAAA;AAClC,oBAAqB,eAAe,CAAA;AACpC,kBAAmB,KAAK,CAAA;AACxB,mBAAoB,cAAc,CAAA;;;;;;;;;;;;;;AAmBlC;;;GAGG;AACH;IACE,CAAC,aAAa,CAAC,aAAa,CAAC,SAAG;IAChC,CAAC,aAAa,CAAC,cAAc,CAAC,SAAG;IACjC,CAAC,aAAa,CAAC,OAAO,CAAC,SAAG;IAC1B,CAAC,aAAa,CAAC,QAAQ,CAAC,SAAG;IAC3B,CAAC,aAAa,CAAC,OAAO,CAAC,SAAG;IAC1B,CAAC,aAAa,CAAC,IAAI,CAAC,SAAG;IACvB,CAAC,aAAa,CAAC,YAAY,CAAC,SAAG;IAC/B,CAAC,aAAa,CAAC,aAAa,CAAC,SAAG;IAChC,CAAC,aAAa,CAAC,OAAO,CAAC,SAAG;IAC1B,CAAC,aAAa,CAAC,aAAa,CAAC,SAAI;EAClC;AAED;IACE,CAAC,aAAa,CAAC,aAAa,CAAC,SAAK;IAClC,CAAC,aAAa,CAAC,cAAc,CAAC,SAAQ;IACtC,CAAC,aAAa,CAAC,IAAI,CAAC,SAAQ;IAC5B,CAAC,aAAa,CAAC,OAAO,CAAC,SAAQ;IAC/B,CAAC,aAAa,CAAC,OAAO,CAAC,SAAU;IACjC,CAAC,aAAa,CAAC,QAAQ,CAAC,SAAU;IAClC,CAAC,aAAa,CAAC,YAAY,CAAC,SAAO;IACnC,CAAC,aAAa,CAAC,aAAa,CAAC,SAAO;IACpC,CAAC,aAAa,CAAC,OAAO,CAAC,SAAM;IAC7B,CAAC,aAAa,CAAC,aAAa,CAAC,SAAO;EACrC"}
|
|
1
|
+
{"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../../../../src/loaders/features/features.js"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,qBAAsB,QAAQ,CAAA;AAC9B,uBAAwB,UAAU,CAAA;AAClC,oBAAqB,eAAe,CAAA;AACpC,kBAAmB,KAAK,CAAA;AACxB,sBAAuB,SAAS,CAAA;AAChC,mBAAoB,cAAc,CAAA;;;;;;;;;;;;;;AAmBlC;;;GAGG;AACH;IACE,CAAC,aAAa,CAAC,aAAa,CAAC,SAAG;IAChC,CAAC,aAAa,CAAC,cAAc,CAAC,SAAG;IACjC,CAAC,aAAa,CAAC,OAAO,CAAC,SAAG;IAC1B,CAAC,aAAa,CAAC,QAAQ,CAAC,SAAG;IAC3B,CAAC,aAAa,CAAC,OAAO,CAAC,SAAG;IAC1B,CAAC,aAAa,CAAC,IAAI,CAAC,SAAG;IACvB,CAAC,aAAa,CAAC,YAAY,CAAC,SAAG;IAC/B,CAAC,aAAa,CAAC,aAAa,CAAC,SAAG;IAChC,CAAC,aAAa,CAAC,OAAO,CAAC,SAAG;IAC1B,CAAC,aAAa,CAAC,aAAa,CAAC,SAAI;EAClC;AAED;IACE,CAAC,aAAa,CAAC,aAAa,CAAC,SAAK;IAClC,CAAC,aAAa,CAAC,cAAc,CAAC,SAAQ;IACtC,CAAC,aAAa,CAAC,IAAI,CAAC,SAAQ;IAC5B,CAAC,aAAa,CAAC,OAAO,CAAC,SAAQ;IAC/B,CAAC,aAAa,CAAC,OAAO,CAAC,SAAU;IACjC,CAAC,aAAa,CAAC,QAAQ,CAAC,SAAU;IAClC,CAAC,aAAa,CAAC,YAAY,CAAC,SAAO;IACnC,CAAC,aAAa,CAAC,aAAa,CAAC,SAAO;IACpC,CAAC,aAAa,CAAC,OAAO,CAAC,SAAM;IAC7B,CAAC,aAAa,CAAC,aAAa,CAAC,SAAO;EACrC"}
|
package/package.json
CHANGED
|
@@ -41,7 +41,10 @@ const RuntimeModel = {
|
|
|
41
41
|
disabled: false,
|
|
42
42
|
/** @type {Map<string, {staged: boolean, priority: number}>} */
|
|
43
43
|
drainRegistry: new Map(),
|
|
44
|
+
connector: undefined,
|
|
44
45
|
harvester: undefined,
|
|
46
|
+
/** eagerly-created in configure() -- the v2 target representing the container (main) agent, see common/v2/utils#V2Target */
|
|
47
|
+
v2Target: undefined,
|
|
45
48
|
isolatedBacklog: false,
|
|
46
49
|
isRecording: false, // true when actively recording, false when paused or stopped
|
|
47
50
|
loaderType: undefined,
|
|
@@ -18,7 +18,7 @@ import { getRegisteredTargetsFromId } from '../v2/utils'
|
|
|
18
18
|
*/
|
|
19
19
|
export const analyzeElemPath = (elem, targetFields = [], agentRef) => {
|
|
20
20
|
const targets = []
|
|
21
|
-
const result = { path: undefined, nearestFields: {}, get targets () { return targets.length ? targets : [
|
|
21
|
+
const result = { path: undefined, nearestFields: {}, get targets () { return targets.length ? targets : [agentRef.runtime.v2Target] }, hasButton: false, hasLink: false }
|
|
22
22
|
if (!elem) return result
|
|
23
23
|
if (elem === window) { result.path = 'window'; return result }
|
|
24
24
|
if (elem === document) { result.path = 'document'; return result }
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2020-2026 New Relic, Inc. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { isBrowserScope } from '../constants/runtime'
|
|
7
|
+
import { send } from './send'
|
|
8
|
+
import { TimeKeeper } from '../timing/time-keeper'
|
|
9
|
+
import { activateFeatures } from '../util/feature-flags'
|
|
10
|
+
import { now } from '../timing/now'
|
|
11
|
+
import { warn } from '../util/console'
|
|
12
|
+
import { VERSION } from '../constants/env'
|
|
13
|
+
import { CONNECT, FEATURE_NAMES, FEATURE_TO_ENDPOINT } from '../../loaders/features/features'
|
|
14
|
+
import { handle } from '../event-emitter/handle'
|
|
15
|
+
import { SUPPORTABILITY_METRIC_CHANNEL } from '../../features/metrics/constants'
|
|
16
|
+
|
|
17
|
+
const MAX_CONNECT_ATTEMPTS = 3
|
|
18
|
+
const CONNECT_RETRY_BASE_MS = 3000 // affects each retry window proportionally (attempt 2: 0-3s, 3: 0-6s, 4: 0-12s, etc)
|
|
19
|
+
|
|
20
|
+
export class Connector {
|
|
21
|
+
#agentRef
|
|
22
|
+
#connectStartTime
|
|
23
|
+
#numOfAttempts = 0
|
|
24
|
+
|
|
25
|
+
constructor (agentRef) {
|
|
26
|
+
if (!agentRef.init.feature_flags.includes('rum_v2')) return // the Connector does not run in v1; legacy PVE has its own BCS handling
|
|
27
|
+
this.#agentRef = agentRef
|
|
28
|
+
agentRef.runtime.timeKeeper = new TimeKeeper(agentRef.runtime.session)
|
|
29
|
+
|
|
30
|
+
if (isBrowserScope) {
|
|
31
|
+
const cached = agentRef.runtime.session && agentRef.runtime.session.state.cachedRumResponse
|
|
32
|
+
if (cached) {
|
|
33
|
+
// `cachedRumResponse` is stored flat (`{ app, ...flags }`, matching the old v1 RUM response), so re-nest it before applying.
|
|
34
|
+
const { app, ...config } = cached
|
|
35
|
+
this.#applyConnectResponse({ app, config })
|
|
36
|
+
return
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
this.makeConnectRequest()
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
makeConnectRequest (retryHeaders) {
|
|
43
|
+
this.#connectStartTime = now()
|
|
44
|
+
return send(this.#agentRef, {
|
|
45
|
+
endpoint: `browser/connect/2/${this.#agentRef.info.licenseKey}`,
|
|
46
|
+
payload: {
|
|
47
|
+
body: {},
|
|
48
|
+
qs: {
|
|
49
|
+
a: this.#agentRef.info.applicationID,
|
|
50
|
+
v: VERSION,
|
|
51
|
+
s: this.#agentRef.runtime.session?.state.value || '0'
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
localOpts: { sendEmptyBody: true, headers: retryHeaders },
|
|
55
|
+
raw: true,
|
|
56
|
+
featureName: CONNECT,
|
|
57
|
+
cbFinished: this.#processConnectResponse.bind(this)
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
#applyConnectResponse ({ app, config }) {
|
|
62
|
+
if (!Object.keys(this.#agentRef.runtime.appMetadata).length) this.#agentRef.runtime.appMetadata = app
|
|
63
|
+
activateFeatures(config, this.#agentRef)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
#processConnectResponse ({ sent, status, retry, xhr, responseText }) {
|
|
67
|
+
const connectEndTime = now()
|
|
68
|
+
const session = this.#agentRef.runtime.session
|
|
69
|
+
|
|
70
|
+
if (session) {
|
|
71
|
+
// Double check that there isn't a response saved (e.g. from another agent/browser tab) btwn the async time of the request and now in a race-condition.
|
|
72
|
+
const cachedResp = session.state.cachedRumResponse
|
|
73
|
+
if (cachedResp) {
|
|
74
|
+
// `cachedRumResponse` is stored flat (`{ app, ...flags }`, matching the old v1 RUM response), so re-nest it before applying.
|
|
75
|
+
const { app, ...config } = cachedResp
|
|
76
|
+
this.#applyConnectResponse({ app, config })
|
|
77
|
+
return
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const shouldRetry = sent && retry // important to note: no retry if HTTP status is 0
|
|
82
|
+
if (shouldRetry && ++this.#numOfAttempts < MAX_CONNECT_ATTEMPTS) {
|
|
83
|
+
// We use an exponential backoff calculation for the retry to avoid thundering herd, skipping any further processing.
|
|
84
|
+
const delay = Math.floor(Math.random() * CONNECT_RETRY_BASE_MS * (2 ** (this.#numOfAttempts - 1)))
|
|
85
|
+
const retryHeaders = [
|
|
86
|
+
{ key: 'X-Retry-Count', value: this.#numOfAttempts },
|
|
87
|
+
{ key: 'X-Previous-Status', value: status }
|
|
88
|
+
]
|
|
89
|
+
setTimeout(() => this.makeConnectRequest(retryHeaders), delay)
|
|
90
|
+
return
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (status >= 400 || status === 0) {
|
|
94
|
+
warn(18, status)
|
|
95
|
+
|
|
96
|
+
// Get estimated payload size of our backlog.
|
|
97
|
+
const textEncoder = new TextEncoder()
|
|
98
|
+
const payloadSize = Object.values(newrelic.ee.backlog).reduce((acc, value) => {
|
|
99
|
+
if (!value) return acc
|
|
100
|
+
const encoded = textEncoder.encode(value)
|
|
101
|
+
return acc + encoded.byteLength
|
|
102
|
+
}, 0)
|
|
103
|
+
|
|
104
|
+
// Send SMs about the (last) failed connect request, then abort agent.
|
|
105
|
+
const BCSError = 'BCS/Error/'
|
|
106
|
+
const sm = [{
|
|
107
|
+
params: {
|
|
108
|
+
name: BCSError + status
|
|
109
|
+
},
|
|
110
|
+
stats: {
|
|
111
|
+
c: 1
|
|
112
|
+
}
|
|
113
|
+
}, {
|
|
114
|
+
params: {
|
|
115
|
+
name: BCSError + 'Duration/Ms'
|
|
116
|
+
},
|
|
117
|
+
stats: {
|
|
118
|
+
c: 1,
|
|
119
|
+
t: connectEndTime - this.#connectStartTime
|
|
120
|
+
}
|
|
121
|
+
}, {
|
|
122
|
+
params: {
|
|
123
|
+
name: BCSError + 'Dropped/Bytes'
|
|
124
|
+
},
|
|
125
|
+
stats: {
|
|
126
|
+
c: 1,
|
|
127
|
+
t: payloadSize
|
|
128
|
+
}
|
|
129
|
+
}]
|
|
130
|
+
send(this.#agentRef, { // note we have to send it this way because the Metrics feature will never be harvested under this branch of code (BCS failure)
|
|
131
|
+
endpoint: FEATURE_TO_ENDPOINT[FEATURE_NAMES.metrics],
|
|
132
|
+
payload: { body: { sm } },
|
|
133
|
+
featureName: FEATURE_NAMES.metrics
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
this.#agentRef.ee.abort()
|
|
137
|
+
return
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
let resp
|
|
141
|
+
try {
|
|
142
|
+
resp = JSON.parse(responseText)
|
|
143
|
+
} catch (error) {
|
|
144
|
+
warn(53, error)
|
|
145
|
+
this.#agentRef.ee.abort()
|
|
146
|
+
return
|
|
147
|
+
}
|
|
148
|
+
// store the response for other pages later in same session or in parallel tabs; flatten `.config` into the old v1 RUM response shape
|
|
149
|
+
if (session) session.write({ cachedRumResponse: { app: resp.app, ...resp.config } })
|
|
150
|
+
try {
|
|
151
|
+
const wasReady = this.#agentRef.runtime.timeKeeper.ready
|
|
152
|
+
this.#agentRef.runtime.timeKeeper.processRumRequest(xhr, this.#connectStartTime, connectEndTime, resp.app.nrServerTime)
|
|
153
|
+
if (!this.#agentRef.runtime.timeKeeper.ready) throw new Error('TimeKeeper not ready')
|
|
154
|
+
|
|
155
|
+
// If timeKeeper's origin time is ahead of nrServerTime, then the timestamp is invalid. Report a supportability metric.
|
|
156
|
+
const timeDiff = this.#agentRef.runtime.timeKeeper.correctedOriginTime - resp.app.nrServerTime
|
|
157
|
+
if (wasReady && timeDiff > 0) {
|
|
158
|
+
handle(SUPPORTABILITY_METRIC_CHANNEL, ['Generic/TimeKeeper/InvalidTimestamp/Seen', timeDiff], undefined, FEATURE_NAMES.metrics, this.#agentRef.ee)
|
|
159
|
+
}
|
|
160
|
+
} catch (error) {
|
|
161
|
+
warn(17, error)
|
|
162
|
+
this.#agentRef.ee.abort()
|
|
163
|
+
return
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
this.#applyConnectResponse(resp)
|
|
167
|
+
}
|
|
168
|
+
}
|
|
@@ -22,23 +22,21 @@ export class Harvester {
|
|
|
22
22
|
constructor (agentRef) {
|
|
23
23
|
this.agentRef = agentRef
|
|
24
24
|
|
|
25
|
-
// Create obfuscator for harvest metadata (referrer URL, etc.)
|
|
26
25
|
// No event type specified - applies to all harvests regardless of feature
|
|
27
26
|
this.obfuscator = new Obfuscator(agentRef)
|
|
28
|
-
|
|
29
|
-
subscribeToEOL(() => { // do one last harvest round or check
|
|
30
|
-
this.initializedAggregates.forEach(aggregateInst => { // let all features wrap up things needed to do before ANY harvest in case there's last minute cross-feature data dependencies
|
|
31
|
-
if (typeof aggregateInst.harvestOpts.beforeUnload === 'function') aggregateInst.harvestOpts.beforeUnload()
|
|
32
|
-
})
|
|
33
|
-
this.initializedAggregates.forEach(aggregateInst => this.triggerHarvestFor(aggregateInst, { isFinalHarvest: true }))
|
|
34
|
-
/* This callback should run in bubble phase, so that CWV api, like "onLCP", is called before the final harvest so that emitted timings are part of last outgoing. */
|
|
35
|
-
}, false)
|
|
36
27
|
}
|
|
37
28
|
|
|
38
29
|
startTimer (harvestInterval = this.agentRef.init.harvest.interval) {
|
|
39
30
|
if (this.#started) return
|
|
40
31
|
this.#started = true
|
|
41
32
|
|
|
33
|
+
subscribeToEOL(() => {
|
|
34
|
+
this.initializedAggregates.forEach(aggregateInst => { // let all features wrap up things needed to do before ANY harvest in case there's last minute cross-feature data dependencies
|
|
35
|
+
if (typeof aggregateInst.harvestOpts.beforeUnload === 'function') aggregateInst.harvestOpts.beforeUnload()
|
|
36
|
+
})
|
|
37
|
+
this.initializedAggregates.forEach(aggregateInst => this.triggerHarvestFor(aggregateInst, { isFinalHarvest: true }))
|
|
38
|
+
})
|
|
39
|
+
|
|
42
40
|
const onHarvestInterval = () => {
|
|
43
41
|
this.initializedAggregates.forEach(aggregateInst => this.triggerHarvestFor(aggregateInst))
|
|
44
42
|
setTimeout(onHarvestInterval, harvestInterval * 1000) // repeat in X seconds
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright 2020-2026 New Relic, Inc. All rights reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
|
-
import { JSERRORS, RUM, EVENTS, FEATURE_NAMES, BLOBS, LOGS } from '../../loaders/features/features'
|
|
5
|
+
import { JSERRORS, RUM, EVENTS, FEATURE_NAMES, BLOBS, LOGS, CONNECT } from '../../loaders/features/features'
|
|
6
6
|
import { VERSION } from '../constants/env'
|
|
7
7
|
import { globalScope, isWorkerScope } from '../constants/runtime'
|
|
8
8
|
import { handle } from '../event-emitter/handle'
|
|
@@ -12,7 +12,7 @@ import { cleanURL } from '../url/clean-url'
|
|
|
12
12
|
import { obj, param } from '../url/encode'
|
|
13
13
|
import { warn } from '../util/console'
|
|
14
14
|
import { stringify } from '../util/stringify'
|
|
15
|
-
import { xhr as xhrMethod, xhrFetch as fetchMethod } from '../util/submit-data'
|
|
15
|
+
import { xhr as xhrMethod, xhrFetch as fetchMethod, getSubmitMethod } from '../util/submit-data'
|
|
16
16
|
import { dispatchGlobalEvent } from '../dispatch/global-event'
|
|
17
17
|
|
|
18
18
|
/**
|
|
@@ -27,7 +27,7 @@ const warnings = {}
|
|
|
27
27
|
* @param {NetworkSendSpec} spec Specification for sending data
|
|
28
28
|
* @returns {boolean} True if a network call was made. Note that this does not mean or guarantee that it was successful.
|
|
29
29
|
*/
|
|
30
|
-
export function send (agentRef, { endpoint, payload, localOpts = {}, submitMethod, cbFinished, raw, featureName, endpointVersion = 1, harvesterObfuscator }) {
|
|
30
|
+
export function send (agentRef, { endpoint, payload, localOpts = {}, submitMethod = getSubmitMethod(), cbFinished, raw, featureName, endpointVersion = 1, harvesterObfuscator }) {
|
|
31
31
|
if (!agentRef.info.errorBeacon) return false
|
|
32
32
|
|
|
33
33
|
let { body, qs } = cleanPayload(payload)
|
|
@@ -39,16 +39,18 @@ export function send (agentRef, { endpoint, payload, localOpts = {}, submitMetho
|
|
|
39
39
|
|
|
40
40
|
const protocol = agentRef.init.ssl === false ? 'http' : 'https'
|
|
41
41
|
const perceivedBeacon = agentRef.init.proxy.beacon || agentRef.info.errorBeacon
|
|
42
|
+
const includeEndpointName = endpoint !== RUM || endpointVersion !== 1
|
|
42
43
|
const url = raw
|
|
43
44
|
? `${protocol}://${perceivedBeacon}/${endpoint}`
|
|
44
|
-
: `${protocol}://${perceivedBeacon}${
|
|
45
|
+
: `${protocol}://${perceivedBeacon}${includeEndpointName ? '/' + endpoint : ''}/${endpointVersion}/${agentRef.info.licenseKey}`
|
|
45
46
|
const baseParams = !raw ? baseQueryString(agentRef, qs, endpoint, harvesterObfuscator) : ''
|
|
46
47
|
let payloadParams = obj(qs, agentRef.runtime.maxBytes)
|
|
47
48
|
if (baseParams === '' && payloadParams.startsWith('&')) {
|
|
48
49
|
payloadParams = payloadParams.substring(1)
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
const
|
|
52
|
+
const queryString = `${baseParams}${payloadParams}`
|
|
53
|
+
const fullUrl = queryString ? `${url}?${queryString}` : url // omit the '?' if there are no query params
|
|
52
54
|
const gzip = !!qs?.attributes?.includes('gzip')
|
|
53
55
|
|
|
54
56
|
// all gzipped data is already in the correct format and needs no transformation
|
|
@@ -61,7 +63,7 @@ export function send (agentRef, { endpoint, payload, localOpts = {}, submitMetho
|
|
|
61
63
|
// Warn--once per endpoint--if the agent tries to send large payloads
|
|
62
64
|
if (endpoint !== BLOBS && stringBody.length > 750000 && (warnings[endpoint] = (warnings[endpoint] || 0) + 1) === 1) warn(28, endpoint)
|
|
63
65
|
|
|
64
|
-
const headers = [{ key: 'content-type', value: 'text/plain' }]
|
|
66
|
+
const headers = [{ key: 'content-type', value: 'text/plain' }, ...(localOpts.headers || [])]
|
|
65
67
|
|
|
66
68
|
/* Since workers don't support sendBeacon right now, they can only use XHR method.
|
|
67
69
|
Because they still do permit synch XHR, the idea is that at final harvest time (worker is closing),
|
|
@@ -92,6 +94,7 @@ export function send (agentRef, { endpoint, payload, localOpts = {}, submitMetho
|
|
|
92
94
|
|
|
93
95
|
function trackHarvestMetadata () {
|
|
94
96
|
try {
|
|
97
|
+
if (featureName === CONNECT) return
|
|
95
98
|
if (featureName === FEATURE_NAMES.jserrors && !body?.err) return
|
|
96
99
|
|
|
97
100
|
const hasReplay = baseParams.includes('hr=1')
|
|
@@ -189,7 +192,6 @@ function baseQueryString (agentRef, qs, endpoint, harvesterObfuscator) {
|
|
|
189
192
|
transactionNameParam(),
|
|
190
193
|
param('ct', agentRef.runtime.customTransaction),
|
|
191
194
|
'&rst=' + now(),
|
|
192
|
-
'&ck=0', // ck param DEPRECATED - still expected by backend
|
|
193
195
|
'&s=' + (session?.state.value || '0'), // the 0 id encaps all untrackable and default traffic
|
|
194
196
|
param('ref', ref),
|
|
195
197
|
param('ptid', (agentRef.runtime.ptid ? '' + agentRef.runtime.ptid : ''))
|