@newrelic/browser-agent 1.252.0 → 1.253.0

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 (217) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +6 -6
  3. package/dist/cjs/cdn/experimental.js +6 -2
  4. package/dist/cjs/cdn/spa.js +5 -3
  5. package/dist/cjs/common/aggregate/aggregator.js +1 -8
  6. package/dist/cjs/common/config/state/init.js +7 -0
  7. package/dist/cjs/common/constants/env.cdn.js +1 -1
  8. package/dist/cjs/common/constants/env.npm.js +1 -1
  9. package/dist/cjs/common/context/observation-context-manager.js +56 -0
  10. package/dist/cjs/common/event-emitter/contextual-ee.js +12 -9
  11. package/dist/cjs/common/session/constants.js +2 -1
  12. package/dist/cjs/common/session/session-entity.js +3 -1
  13. package/dist/cjs/common/timing/nav-timing.js +8 -3
  14. package/dist/cjs/common/timing/now.js +1 -1
  15. package/dist/cjs/common/util/feature-flags.js +1 -1
  16. package/dist/cjs/common/wrap/index.js +0 -7
  17. package/dist/cjs/common/wrap/wrap-events.js +2 -2
  18. package/dist/cjs/common/wrap/wrap-fetch.js +2 -1
  19. package/dist/cjs/common/wrap/wrap-function.js +5 -7
  20. package/dist/cjs/common/wrap/wrap-promise.js +2 -1
  21. package/dist/cjs/features/ajax/aggregate/index.js +34 -16
  22. package/dist/cjs/features/jserrors/aggregate/index.js +77 -66
  23. package/dist/cjs/features/page_view_event/aggregate/index.js +1 -1
  24. package/dist/cjs/features/page_view_event/aggregate/initialized-features.js +1 -0
  25. package/dist/cjs/features/session_replay/aggregate/index.js +96 -94
  26. package/dist/cjs/features/session_replay/constants.js +5 -1
  27. package/dist/cjs/features/session_replay/instrument/index.js +24 -8
  28. package/dist/cjs/features/session_replay/shared/recorder.js +5 -4
  29. package/dist/cjs/features/session_replay/shared/stylesheet-evaluator.js +8 -7
  30. package/dist/cjs/features/session_replay/shared/utils.js +26 -0
  31. package/dist/cjs/features/soft_navigations/aggregate/ajax-node.js +50 -0
  32. package/dist/cjs/features/soft_navigations/aggregate/bel-node.js +29 -0
  33. package/dist/cjs/features/soft_navigations/aggregate/index.js +263 -0
  34. package/dist/cjs/features/soft_navigations/aggregate/initial-page-load-interaction.js +62 -0
  35. package/dist/cjs/features/soft_navigations/aggregate/interaction.js +146 -0
  36. package/dist/cjs/features/soft_navigations/constants.js +31 -0
  37. package/dist/cjs/features/soft_navigations/index.js +12 -0
  38. package/dist/cjs/features/soft_navigations/instrument/index.js +79 -0
  39. package/dist/cjs/features/spa/aggregate/index.js +4 -4
  40. package/dist/cjs/features/utils/agent-session.js +2 -1
  41. package/dist/cjs/features/utils/instrument-base.js +6 -9
  42. package/dist/cjs/features/utils/lazy-feature-loader.js +2 -0
  43. package/dist/cjs/loaders/agent-base.js +18 -3
  44. package/dist/cjs/loaders/agent.js +15 -18
  45. package/dist/cjs/loaders/api/api-methods.js +9 -0
  46. package/dist/cjs/loaders/api/api.js +17 -18
  47. package/dist/cjs/loaders/configure/configure.js +5 -2
  48. package/dist/cjs/loaders/features/enabled-features.js +1 -1
  49. package/dist/cjs/loaders/features/features.js +3 -1
  50. package/dist/esm/cdn/experimental.js +5 -2
  51. package/dist/esm/cdn/spa.js +3 -1
  52. package/dist/esm/common/aggregate/aggregator.js +1 -8
  53. package/dist/esm/common/config/state/init.js +7 -0
  54. package/dist/esm/common/constants/env.cdn.js +1 -1
  55. package/dist/esm/common/constants/env.npm.js +1 -1
  56. package/dist/esm/common/context/observation-context-manager.js +49 -0
  57. package/dist/esm/common/event-emitter/contextual-ee.js +12 -9
  58. package/dist/esm/common/session/constants.js +1 -0
  59. package/dist/esm/common/session/session-entity.js +3 -1
  60. package/dist/esm/common/timing/nav-timing.js +8 -3
  61. package/dist/esm/common/timing/now.js +1 -1
  62. package/dist/esm/common/util/feature-flags.js +1 -1
  63. package/dist/esm/common/wrap/index.js +1 -2
  64. package/dist/esm/common/wrap/wrap-events.js +3 -3
  65. package/dist/esm/common/wrap/wrap-fetch.js +3 -2
  66. package/dist/esm/common/wrap/wrap-function.js +4 -5
  67. package/dist/esm/common/wrap/wrap-promise.js +3 -2
  68. package/dist/esm/features/ajax/aggregate/index.js +36 -18
  69. package/dist/esm/features/jserrors/aggregate/index.js +77 -66
  70. package/dist/esm/features/page_view_event/aggregate/index.js +1 -1
  71. package/dist/esm/features/page_view_event/aggregate/initialized-features.js +1 -0
  72. package/dist/esm/features/session_replay/aggregate/index.js +97 -95
  73. package/dist/esm/features/session_replay/constants.js +4 -0
  74. package/dist/esm/features/session_replay/instrument/index.js +25 -9
  75. package/dist/esm/features/session_replay/shared/recorder.js +5 -4
  76. package/dist/esm/features/session_replay/shared/stylesheet-evaluator.js +8 -7
  77. package/dist/esm/features/session_replay/shared/utils.js +17 -0
  78. package/dist/esm/features/soft_navigations/aggregate/ajax-node.js +43 -0
  79. package/dist/esm/features/soft_navigations/aggregate/bel-node.js +22 -0
  80. package/dist/esm/features/soft_navigations/aggregate/index.js +256 -0
  81. package/dist/esm/features/soft_navigations/aggregate/initial-page-load-interaction.js +55 -0
  82. package/dist/esm/features/soft_navigations/aggregate/interaction.js +140 -0
  83. package/dist/esm/features/soft_navigations/constants.js +25 -0
  84. package/dist/esm/features/soft_navigations/index.js +1 -0
  85. package/dist/esm/features/soft_navigations/instrument/index.js +73 -0
  86. package/dist/esm/features/spa/aggregate/index.js +4 -4
  87. package/dist/esm/features/utils/agent-session.js +2 -1
  88. package/dist/esm/features/utils/instrument-base.js +7 -10
  89. package/dist/esm/features/utils/lazy-feature-loader.js +2 -0
  90. package/dist/esm/loaders/agent-base.js +18 -3
  91. package/dist/esm/loaders/agent.js +15 -18
  92. package/dist/esm/loaders/api/api-methods.js +3 -0
  93. package/dist/esm/loaders/api/api.js +17 -17
  94. package/dist/esm/loaders/configure/configure.js +5 -2
  95. package/dist/esm/loaders/features/enabled-features.js +1 -1
  96. package/dist/esm/loaders/features/features.js +3 -1
  97. package/dist/types/common/aggregate/aggregator.d.ts.map +1 -1
  98. package/dist/types/common/config/state/init.d.ts.map +1 -1
  99. package/dist/types/common/context/event-context.d.ts.map +1 -0
  100. package/dist/types/common/context/observation-context-manager.d.ts +28 -0
  101. package/dist/types/common/context/observation-context-manager.d.ts.map +1 -0
  102. package/dist/types/common/event-emitter/contextual-ee.d.ts +2 -2
  103. package/dist/types/common/event-emitter/contextual-ee.d.ts.map +1 -1
  104. package/dist/types/common/session/constants.d.ts +1 -0
  105. package/dist/types/common/session/constants.d.ts.map +1 -1
  106. package/dist/types/common/session/session-entity.d.ts +0 -1
  107. package/dist/types/common/session/session-entity.d.ts.map +1 -1
  108. package/dist/types/common/timing/nav-timing.d.ts.map +1 -1
  109. package/dist/types/common/wrap/index.d.ts +1 -2
  110. package/dist/types/common/wrap/index.d.ts.map +1 -1
  111. package/dist/types/common/wrap/wrap-fetch.d.ts.map +1 -1
  112. package/dist/types/common/wrap/wrap-function.d.ts +0 -1
  113. package/dist/types/common/wrap/wrap-function.d.ts.map +1 -1
  114. package/dist/types/common/wrap/wrap-promise.d.ts.map +1 -1
  115. package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
  116. package/dist/types/features/jserrors/aggregate/index.d.ts +4 -3
  117. package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
  118. package/dist/types/features/page_view_event/aggregate/initialized-features.d.ts.map +1 -1
  119. package/dist/types/features/session_replay/aggregate/index.d.ts +1 -1
  120. package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
  121. package/dist/types/features/session_replay/constants.d.ts +4 -0
  122. package/dist/types/features/session_replay/constants.d.ts.map +1 -1
  123. package/dist/types/features/session_replay/instrument/index.d.ts.map +1 -1
  124. package/dist/types/features/session_replay/shared/recorder.d.ts.map +1 -1
  125. package/dist/types/features/session_replay/shared/stylesheet-evaluator.d.ts.map +1 -1
  126. package/dist/types/features/session_replay/shared/utils.d.ts +4 -0
  127. package/dist/types/features/session_replay/shared/utils.d.ts.map +1 -0
  128. package/dist/types/features/soft_navigations/aggregate/ajax-node.d.ts +19 -0
  129. package/dist/types/features/soft_navigations/aggregate/ajax-node.d.ts.map +1 -0
  130. package/dist/types/features/soft_navigations/aggregate/bel-node.d.ts +16 -0
  131. package/dist/types/features/soft_navigations/aggregate/bel-node.d.ts.map +1 -0
  132. package/dist/types/features/soft_navigations/aggregate/index.d.ts +36 -0
  133. package/dist/types/features/soft_navigations/aggregate/index.d.ts.map +1 -0
  134. package/dist/types/features/soft_navigations/aggregate/initial-page-load-interaction.d.ts +12 -0
  135. package/dist/types/features/soft_navigations/aggregate/initial-page-load-interaction.d.ts.map +1 -0
  136. package/dist/types/features/soft_navigations/aggregate/interaction.d.ts +50 -0
  137. package/dist/types/features/soft_navigations/aggregate/interaction.d.ts.map +1 -0
  138. package/dist/types/features/soft_navigations/constants.d.ts +20 -0
  139. package/dist/types/features/soft_navigations/constants.d.ts.map +1 -0
  140. package/dist/types/features/soft_navigations/index.d.ts +2 -0
  141. package/dist/types/features/soft_navigations/index.d.ts.map +1 -0
  142. package/dist/types/features/soft_navigations/instrument/index.d.ts +7 -0
  143. package/dist/types/features/soft_navigations/instrument/index.d.ts.map +1 -0
  144. package/dist/types/features/spa/aggregate/index.d.ts.map +1 -1
  145. package/dist/types/features/utils/agent-session.d.ts.map +1 -1
  146. package/dist/types/features/utils/instrument-base.d.ts +1 -7
  147. package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
  148. package/dist/types/features/utils/lazy-feature-loader.d.ts.map +1 -1
  149. package/dist/types/loaders/agent-base.d.ts +5 -1
  150. package/dist/types/loaders/agent-base.d.ts.map +1 -1
  151. package/dist/types/loaders/agent.d.ts +2 -2
  152. package/dist/types/loaders/agent.d.ts.map +1 -1
  153. package/dist/types/loaders/api/api-methods.d.ts +3 -0
  154. package/dist/types/loaders/api/api-methods.d.ts.map +1 -0
  155. package/dist/types/loaders/api/api.d.ts +3 -6
  156. package/dist/types/loaders/api/api.d.ts.map +1 -1
  157. package/dist/types/loaders/configure/configure.d.ts.map +1 -1
  158. package/dist/types/loaders/features/features.d.ts +1 -0
  159. package/dist/types/loaders/features/features.d.ts.map +1 -1
  160. package/dist/types/loaders/micro-agent.d.ts +0 -1
  161. package/dist/types/loaders/micro-agent.d.ts.map +1 -1
  162. package/package.json +1 -1
  163. package/src/cdn/experimental.js +4 -2
  164. package/src/cdn/spa.js +3 -1
  165. package/src/common/aggregate/aggregator.js +2 -11
  166. package/src/common/config/state/init.js +3 -1
  167. package/src/common/context/observation-context-manager.js +55 -0
  168. package/src/common/event-emitter/contextual-ee.js +20 -10
  169. package/src/common/session/constants.js +1 -0
  170. package/src/common/session/session-entity.js +3 -1
  171. package/src/common/timing/nav-timing.js +7 -3
  172. package/src/common/timing/now.js +1 -1
  173. package/src/common/util/feature-flags.js +1 -1
  174. package/src/common/wrap/index.js +1 -2
  175. package/src/common/wrap/wrap-events.js +3 -3
  176. package/src/common/wrap/wrap-fetch.js +3 -2
  177. package/src/common/wrap/wrap-function.js +4 -6
  178. package/src/common/wrap/wrap-promise.js +3 -2
  179. package/src/features/ajax/aggregate/index.js +36 -18
  180. package/src/features/jserrors/aggregate/index.js +70 -73
  181. package/src/features/page_view_event/aggregate/index.js +1 -1
  182. package/src/features/page_view_event/aggregate/initialized-features.js +1 -0
  183. package/src/features/session_replay/aggregate/index.js +92 -95
  184. package/src/features/session_replay/constants.js +5 -0
  185. package/src/features/session_replay/instrument/index.js +24 -9
  186. package/src/features/session_replay/shared/recorder.js +5 -4
  187. package/src/features/session_replay/shared/stylesheet-evaluator.js +8 -7
  188. package/src/features/session_replay/shared/utils.js +19 -0
  189. package/src/features/soft_navigations/aggregate/ajax-node.js +57 -0
  190. package/src/features/soft_navigations/aggregate/bel-node.js +26 -0
  191. package/src/features/soft_navigations/aggregate/index.js +254 -0
  192. package/src/features/soft_navigations/aggregate/initial-page-load-interaction.js +53 -0
  193. package/src/features/soft_navigations/aggregate/interaction.js +159 -0
  194. package/src/features/soft_navigations/constants.js +29 -0
  195. package/src/features/soft_navigations/index.js +1 -0
  196. package/src/features/soft_navigations/instrument/index.js +67 -0
  197. package/src/features/spa/aggregate/index.js +5 -4
  198. package/src/features/utils/agent-session.js +2 -1
  199. package/src/features/utils/instrument-base.js +7 -10
  200. package/src/features/utils/lazy-feature-loader.js +2 -0
  201. package/src/loaders/agent-base.js +18 -3
  202. package/src/loaders/agent.js +18 -17
  203. package/src/loaders/api/api-methods.js +12 -0
  204. package/src/loaders/api/api.js +17 -28
  205. package/src/loaders/configure/configure.js +4 -1
  206. package/src/loaders/features/enabled-features.js +1 -1
  207. package/src/loaders/features/features.js +3 -1
  208. package/dist/cjs/common/wrap/wrap-raf.js +0 -55
  209. package/dist/esm/common/wrap/wrap-raf.js +0 -48
  210. package/dist/types/common/event-emitter/event-context.d.ts.map +0 -1
  211. package/dist/types/common/wrap/wrap-raf.d.ts +0 -16
  212. package/dist/types/common/wrap/wrap-raf.d.ts.map +0 -1
  213. package/src/common/wrap/wrap-raf.js +0 -52
  214. /package/dist/cjs/common/{event-emitter → context}/event-context.js +0 -0
  215. /package/dist/esm/common/{event-emitter → context}/event-context.js +0 -0
  216. /package/dist/types/common/{event-emitter → context}/event-context.d.ts +0 -0
  217. /package/src/common/{event-emitter → context}/event-context.js +0 -0
@@ -0,0 +1,36 @@
1
+ export class Aggregate extends AggregateBase {
2
+ static featureName: string;
3
+ constructor(agentIdentifier: any, aggregator: any, { domObserver }: {
4
+ domObserver: any;
5
+ });
6
+ interactionsToHarvest: any[];
7
+ interactionsAwaitingRetry: any[];
8
+ domObserver: any;
9
+ scheduler: HarvestScheduler;
10
+ initialPageLoadInteraction: InitialPageLoadInteraction;
11
+ latestRouteSetByApi: any;
12
+ interactionInProgress: Interaction | null;
13
+ onHarvestStarted(options: any): {
14
+ body: {
15
+ e: string;
16
+ };
17
+ } | undefined;
18
+ onHarvestFinished(result: any): void;
19
+ startUIInteraction(eventName: any, startedAt: any, sourceElem: any): void;
20
+ setClosureHandlers(): void;
21
+ /**
22
+ * Find the active interaction (current or past) for a given timestamp. Note that historic lookups mostly only go as far back as the last harvest for this feature.
23
+ * Also, the caller should check the status of the interaction returned if found via {@link Interaction.status}, if that's pertinent.
24
+ * TIP: Cancelled (status) interactions are NOT returned!
25
+ * IMPORTANT: Finished interactions are in queue for next harvest! It's highly recommended that consumer logic be synchronous for safe reference.
26
+ * @param {DOMHighResTimeStamp} timestamp
27
+ * @returns An {@link Interaction} or undefined, if no active interaction was found.
28
+ */
29
+ getInteractionFor(timestamp: DOMHighResTimeStamp): any;
30
+ #private;
31
+ }
32
+ import { AggregateBase } from '../../utils/aggregate-base';
33
+ import { HarvestScheduler } from '../../../common/harvest/harvest-scheduler';
34
+ import { InitialPageLoadInteraction } from './initial-page-load-interaction';
35
+ import { Interaction } from './interaction';
36
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/soft_navigations/aggregate/index.js"],"names":[],"mappings":"AAcA;IACE,2BAAiC;IACjC;;OAiDC;IA7CC,6BAA+B;IAC/B,iCAAmC;IACnC,iBAA8B;IAE9B,4BAIoC;IAGpC,uDAAiF;IAWjF,yBAA+B;IAC/B,0CAAiC;IAwBnC;;;;kBAiBC;IAED,qCAKC;IAED,0EAeC;IAED,2BAiBC;IAED;;;;;;;OAOG;IACH,6BAHW,mBAAmB,OAoB7B;;CA2FF;8BA7O6B,4BAA4B;iCALzB,2CAA2C;2CAQjC,iCAAiC;4BAChD,eAAe"}
@@ -0,0 +1,12 @@
1
+ export class InitialPageLoadInteraction extends Interaction {
2
+ constructor(agentIdentifier: any);
3
+ get firstPaint(): any;
4
+ get firstContentfulPaint(): any;
5
+ /**
6
+ * Build the navTiming node. This assumes the navTimingValues array in nav-timing.js has already been filled with values via the PageViewEvent feature having
7
+ * executed the addPT function first and foremost.
8
+ */
9
+ get navTiming(): string | undefined;
10
+ }
11
+ import { Interaction } from './interaction';
12
+ //# sourceMappingURL=initial-page-load-interaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initial-page-load-interaction.d.ts","sourceRoot":"","sources":["../../../../../src/features/soft_navigations/aggregate/initial-page-load-interaction.js"],"names":[],"mappings":"AAOA;IACE,kCAKC;IAED,sBAAqD;IACrD,gCAAyE;IAEzE;;;OAGG;IACH,oCA6BC;CACF;4BAnD2B,eAAe"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * link https://github.com/newrelic/nr-querypack/blob/main/schemas/bel/7.qpschema
3
+ **/
4
+ export class Interaction extends BelNode {
5
+ constructor(agentIdentifier: any, uiEvent: any, uiEventTimestamp: any, currentRouteKnown: any);
6
+ id: string;
7
+ initialPageURL: string;
8
+ oldURL: string;
9
+ newURL: string;
10
+ customName: any;
11
+ customAttributes: {};
12
+ customDataByApi: {};
13
+ queueTime: any;
14
+ appTime: any;
15
+ newRoute: any;
16
+ /** Internal state of this interaction: in-progress, finished, or cancelled. */
17
+ status: string;
18
+ domTimestamp: number;
19
+ historyTimestamp: number;
20
+ createdByApi: boolean;
21
+ keepOpenUntilEndApi: boolean;
22
+ onDone: any[];
23
+ cancellationTimer: any;
24
+ belType: number;
25
+ trigger: any;
26
+ start: any;
27
+ oldRoute: any;
28
+ eventSubscription: Map<string, never[]>;
29
+ forceSave: boolean;
30
+ forceIgnore: boolean;
31
+ updateDom(timestamp: any): void;
32
+ updateHistory(timestamp: any, newUrl: any): void;
33
+ seenHistoryAndDomChange(): boolean;
34
+ on(event: any, cb: any): void;
35
+ done(customEndTime: any): boolean;
36
+ /**
37
+ * Given a timestamp, determine if it falls within this interaction's span, i.e. if this was the active interaction during that time.
38
+ * For in-progress interactions, this only compares the time with the start of span. Cancelled interactions are not considered active at all.
39
+ * @param {DOMHighResTimeStamp} timestamp
40
+ * @returns True or false boolean.
41
+ */
42
+ isActiveDuring(timestamp: DOMHighResTimeStamp): boolean;
43
+ get firstPaint(): void;
44
+ get firstContentfulPaint(): void;
45
+ get navTiming(): void;
46
+ serialize(firstStartTimeOfPayload: any): string;
47
+ #private;
48
+ }
49
+ import { BelNode } from './bel-node';
50
+ //# sourceMappingURL=interaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interaction.d.ts","sourceRoot":"","sources":["../../../../../src/features/soft_navigations/aggregate/interaction.js"],"names":[],"mappings":"AAQA;;IAEI;AACJ;IAoBE,+FAYC;IA/BD,WAAmB;IACnB,uBAAgC;IAChC,eAAmC;IACnC,eAAmC;IACnC,gBAAU;IACV,qBAAqB;IACrB,oBAAoB;IACpB,eAAS;IACT,aAAO;IACP,cAAQ;IACR,+EAA+E;IAC/E,eAA8B;IAC9B,qBAAgB;IAChB,yBAAoB;IACpB,sBAAoB;IACpB,6BAA2B;IAC3B,cAAW;IACX,uBAAiB;IAIf,gBAAoC;IACpC,aAAsB;IACtB,WAA6B;IAC7B,cAAiC;IACjC,wCAGE;IACF,mBAAyC;IAAxB,qBAAwB;IAI3C,gCAEC;IAED,iDAGC;IAED,mCAEC;IAED,8BAIC;IAED,kCAUC;IAwBD;;;;;OAKG;IACH,0BAHW,mBAAmB,WAM7B;IAGD,uBAAoB;IACpB,iCAA8B;IAC9B,sBAAmB;IAEnB,gDA2CC;;CACF;wBAxJuB,YAAY"}
@@ -0,0 +1,20 @@
1
+ export const INTERACTION_TRIGGERS: string[];
2
+ export const API_TRIGGER_NAME: "api";
3
+ export const FEATURE_NAME: string;
4
+ export namespace INTERACTION_TYPE {
5
+ let INITIAL_PAGE_LOAD: string;
6
+ let ROUTE_CHANGE: number;
7
+ let UNSPECIFIED: number;
8
+ }
9
+ export namespace NODE_TYPE {
10
+ let INTERACTION: number;
11
+ let AJAX: number;
12
+ let CUSTOM_END: number;
13
+ let CUSTOM_TRACER: number;
14
+ }
15
+ export namespace INTERACTION_STATUS {
16
+ let IP: string;
17
+ let FIN: string;
18
+ let CAN: string;
19
+ }
20
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/features/soft_navigations/constants.js"],"names":[],"mappings":"AAEA,4CAIC;AACD,qCAAqC;AAErC,kCAAiD"}
@@ -0,0 +1,2 @@
1
+ export { Instrument as SoftNav } from "./instrument/index";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/soft_navigations/index.js"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ export class Instrument extends InstrumentBase {
2
+ static featureName: string;
3
+ constructor(agentIdentifier: any, aggregator: any, auto?: boolean);
4
+ removeOnAbort: AbortController | undefined;
5
+ }
6
+ import { InstrumentBase } from '../../utils/instrument-base';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/soft_navigations/instrument/index.js"],"names":[],"mappings":"AAgBA;IACE,2BAAiC;IACjC,mEA+CC;IAnCG,2CAA0C;CAoC/C;+BA3D8B,6BAA6B"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/spa/aggregate/index.js"],"names":[],"mappings":"AA+BA;IACE,2BAAiC;IACjC,mDAssBC;IAnsBC;;;;;;;;;;;;;;;;;MAkBC;IAED,uBAAsC;CAgrBzC;8BArtB6B,4BAA4B;2BAJ/B,cAAc"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/spa/aggregate/index.js"],"names":[],"mappings":"AA+BA;IACE,2BAAiC;IACjC,mDAusBC;IApsBC;;;;;;;;;;;;;;;;;MAkBC;IAED,uBAAsC;CAirBzC;8BAttB6B,4BAA4B;2BAJ/B,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"agent-session.d.ts","sourceRoot":"","sources":["../../../../src/features/utils/agent-session.js"],"names":[],"mappings":"AASA,6DA6CC"}
1
+ {"version":3,"file":"agent-session.d.ts","sourceRoot":"","sources":["../../../../src/features/utils/agent-session.js"],"names":[],"mappings":"AAUA,6DA6CC"}
@@ -33,13 +33,7 @@ export class InstrumentBase extends FeatureBase {
33
33
  * @returns void
34
34
  */
35
35
  importAggregator(argsObjFromInstrument?: Object | undefined): void;
36
- /**
37
- * Make a determination if an aggregate class should even be imported
38
- * @param {string} featureName
39
- * @param {import('../../common/session/session-entity').SessionEntity} session
40
- * @returns
41
- */
42
- shouldImportAgg(featureName: string, session: import('../../common/session/session-entity').SessionEntity): boolean;
36
+ #private;
43
37
  }
44
38
  import { FeatureBase } from './feature-base';
45
39
  //# sourceMappingURL=instrument-base.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"instrument-base.d.ts","sourceRoot":"","sources":["../../../../src/features/utils/instrument-base.js"],"names":[],"mappings":"AAcA;;;GAGG;AACH;IACE;;;;;;;;OAQG;IACH,6BAPW,MAAM,cACN,OAAO,mCAAmC,EAAE,UAAU,eACtD,MAAM,8BA4BhB;IArBC,cAAgB;IAEhB,8IAA8I;IAC9I,cADW,WAAW,SAAS,CACF;IAE7B;;;MAGE;IACF,eAHU,OAAO,kBAAkB,EAAE,aAAa,CAGpB;IAE9B;;;MAGE;IACF,kCAAoC;IAQtC;;;;;OAKG;IACH,mEA4DC;IAED;;;;;KAKC;IACD,6BAJS,MAAM,WACN,OAAO,qCAAqC,EAAE,aAAa,WAUnE;CACF;4BAhI2B,gBAAgB"}
1
+ {"version":3,"file":"instrument-base.d.ts","sourceRoot":"","sources":["../../../../src/features/utils/instrument-base.js"],"names":[],"mappings":"AAeA;;;GAGG;AACH;IACE;;;;;;;;OAQG;IACH,6BAPW,MAAM,cACN,OAAO,mCAAmC,EAAE,UAAU,eACtD,MAAM,8BA4BhB;IArBC,cAAgB;IAEhB,8IAA8I;IAC9I,cADW,WAAW,SAAS,CACF;IAE7B;;;MAGE;IACF,eAHU,OAAO,kBAAkB,EAAE,aAAa,CAGpB;IAE9B;;;MAGE;IACF,kCAAoC;IAQtC;;;;;OAKG;IACH,mEA4DC;;CAYF;4BA7H2B,gBAAgB"}
@@ -1 +1 @@
1
- {"version":3,"file":"lazy-feature-loader.d.ts","sourceRoot":"","sources":["../../../../src/features/utils/lazy-feature-loader.js"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,uEAFa,QAAQ,+BAA2B,IAAI,CAAC,CA2BpD"}
1
+ {"version":3,"file":"lazy-feature-loader.d.ts","sourceRoot":"","sources":["../../../../src/features/utils/lazy-feature-loader.js"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,uEAFa,QAAQ,+BAA2B,IAAI,CAAC,CA6BpD"}
@@ -2,6 +2,9 @@
2
2
  * @typedef {import('./api/interaction-types').InteractionInstance} InteractionInstance
3
3
  */
4
4
  export class AgentBase {
5
+ constructor(agentIdentifier?: string);
6
+ agentIdentifier: string;
7
+ observationContext: ObservationContextManager;
5
8
  /**
6
9
  * Reports a browser PageAction event along with a name and optional attributes.
7
10
  * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/addpageaction/}
@@ -83,7 +86,7 @@ export class AgentBase {
83
86
  * Forces an active replay to pause recording. If a replay is already actively recording, this call will cause the recording to pause.
84
87
  * If a recording is not currently recording, this call will be ignored. This API will pause both manual and automatic replays that are in progress.
85
88
  * The only way to resume recording after manually pausing a replay is to manually record again using the recordReplay() API.
86
- * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/recordReplay/}
89
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/pauseReplay/}
87
90
  */
88
91
  pauseReplay(): any;
89
92
  /**
@@ -121,4 +124,5 @@ export class AgentBase {
121
124
  #private;
122
125
  }
123
126
  export type InteractionInstance = import('./api/interaction-types').InteractionInstance;
127
+ import { ObservationContextManager } from '../common/context/observation-context-manager';
124
128
  //# sourceMappingURL=agent-base.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent-base.d.ts","sourceRoot":"","sources":["../../../src/loaders/agent-base.js"],"names":[],"mappings":"AAIA;;GAEG;AAEH;IAWE;;;;;OAKG;IACH,oBAHW,MAAM,wCAKhB;IAED;;;;;OAKG;IACH,sBAHW,MAAM,kCAKhB;IAED;;;;;;OAMG;IACH,yBAJW,MAAM,SACN,MAAM,GAAC,MAAM,GAAC,IAAI,sCAK5B;IAED;;;;;OAKG;IACH,mBAHW,KAAK,GAAC,MAAM,8CAKtB;IAED;;;;OAIG;IACH,iBAFW,MAAM,GAAC,IAAI,OAIrB;IAED;;;;;;;OAOG;IACH,6BAJW,MAAM,GAAC,IAAI,OAMrB;IAED;;;;OAIG;IACH,kCAFmB,KAAK,GAAC,MAAM,KAAK,OAAO,GAAG;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,OAI9D;IAED;;;;OAIG;IACH,8CAEC;IAED;;;;;OAKG;IACH,iBAHW,MAAM,MACN,MAAM,OAIhB;IAED;;;;OAIG;IACH,yDAEC;IAED;;;;OAIG;IACH,oBAEC;IAED;;;;;OAKG;IACH,mBAEC;IAED;;;;;;;;;;OAUG;IACH,6BARW;QAAC,MAAM,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAC,OAUrF;IAED;;;;;OAKG;IACH,0BAHW,MAAM,OAKhB;IAED;;;;;MAKE;IACF,eAHa,mBAAmB,CAK/B;;CACF;kCAtKY,OAAO,yBAAyB,EAAE,mBAAmB"}
1
+ {"version":3,"file":"agent-base.d.ts","sourceRoot":"","sources":["../../../src/loaders/agent-base.js"],"names":[],"mappings":"AAQA;;GAEG;AAEH;IAIE,sCAMC;IATD,wBAAe;IACf,8CAAoD;IAoBpD;;;;;OAKG;IACH,oBAHW,MAAM,wCAKhB;IAED;;;;;OAKG;IACH,sBAHW,MAAM,kCAKhB;IAED;;;;;;OAMG;IACH,yBAJW,MAAM,SACN,MAAM,GAAC,MAAM,GAAC,IAAI,sCAK5B;IAED;;;;;OAKG;IACH,mBAHW,KAAK,GAAC,MAAM,8CAKtB;IAED;;;;OAIG;IACH,iBAFW,MAAM,GAAC,IAAI,OAIrB;IAED;;;;;;;OAOG;IACH,6BAJW,MAAM,GAAC,IAAI,OAMrB;IAED;;;;OAIG;IACH,kCAFmB,KAAK,GAAC,MAAM,KAAK,OAAO,GAAG;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,OAI9D;IAED;;;;OAIG;IACH,8CAEC;IAED;;;;;OAKG;IACH,iBAHW,MAAM,MACN,MAAM,OAIhB;IAED;;;;OAIG;IACH,yDAEC;IAED;;;;OAIG;IACH,oBAEC;IAED;;;;;OAKG;IACH,mBAEC;IAED;;;;;;;;;;OAUG;IACH,6BARW;QAAC,MAAM,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAC,OAUrF;IAED;;;;;OAKG;IACH,0BAHW,MAAM,OAKhB;IAED;;;;;MAKE;IACF,eAHa,mBAAmB,CAK/B;;CACF;kCAjLY,OAAO,yBAAyB,EAAE,mBAAmB;0CALxB,+CAA+C"}
@@ -3,11 +3,11 @@
3
3
  * sensitive to network load, this may result in smaller builds with slightly lower performance impact.
4
4
  */
5
5
  export class Agent extends AgentBase {
6
- constructor(options: any, agentIdentifier?: string);
7
- agentIdentifier: string | undefined;
6
+ constructor(options: any, agentIdentifier: any);
8
7
  sharedAggregator: Aggregator | undefined;
9
8
  features: {} | undefined;
10
9
  desiredFeatures: Set<any> | undefined;
10
+ runSoftNavOverSpa: boolean | undefined;
11
11
  get config(): {
12
12
  info: any;
13
13
  init: any;
@@ -1 +1 @@
1
- {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../../src/loaders/agent.js"],"names":[],"mappings":"AAoBA;;;GAGG;AACH;IACE,oDAwBC;IAdC,oCAAsC;IACtC,yCAAiF;IACjF,yBAAkB;IAGlB,sCAAsD;IAWxD;;;;;MAOC;IAED,yBA8BC;CACF;0BAvFyB,cAAc;2BAQb,gCAAgC"}
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../../src/loaders/agent.js"],"names":[],"mappings":"AAkBA;;;GAGG;AACH;IACE,gDAwBC;IAdC,yCAAiF;IACjF,yBAAkB;IAGlB,sCAAsD;IAMtD,uCAA6G;IAM/G;;;;;MAOC;IAED,yBAiCC;CACF;0BAxFyB,cAAc;2BAQb,gCAAgC"}
@@ -0,0 +1,3 @@
1
+ export const apiMethods: string[];
2
+ export const asyncApiMethods: string[];
3
+ //# sourceMappingURL=api-methods.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-methods.d.ts","sourceRoot":"","sources":["../../../../src/loaders/api/api-methods.js"],"names":[],"mappings":"AAEA,kCAKC;AAED,uCAEC"}
@@ -1,7 +1,6 @@
1
1
  export function setTopLevelCallers(): void;
2
- export function setAPI(agentIdentifier: any, forceDrain: any): {
2
+ export function setAPI(agentIdentifier: any, forceDrain: any, runSoftNavOverSpa?: boolean): {
3
3
  addPageAction: (...args: any[]) => any;
4
- setCurrentRouteName: (...args: any[]) => any;
5
4
  setPageViewName(name: any, host: any): any;
6
5
  setCustomAttribute(name: any, value: any, persistAttribute?: boolean): any;
7
6
  /**
@@ -17,10 +16,8 @@ export function setAPI(agentIdentifier: any, forceDrain: any): {
17
16
  */
18
17
  setApplicationVersion(value: string | null): any;
19
18
  start(features: any): void;
20
- recordReplay(): void;
21
- pauseReplay(): void;
22
- interaction(): any;
19
+ interaction(options: any): any;
20
+ setCurrentRouteName: (...args: any[]) => any;
23
21
  noticeError(err: any, customAttributes: any): void;
24
22
  };
25
- export const CUSTOM_ATTR_GROUP: "CUSTOM/";
26
23
  //# sourceMappingURL=api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../../src/loaders/api/api.js"],"names":[],"mappings":"AAkBA,2CAoBC;AAED;;;;;IAyDE;;;;OAIG;qBAFQ,MAAM;IAWjB;;;;OAIG;iCAFQ,MAAM,GAAC,IAAI;;;;;;EAwGvB;AAxMD,0CAA0C"}
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../../src/loaders/api/api.js"],"names":[],"mappings":"AAkBA,2CAeC;AAED;;;;IAiDE;;;;OAIG;qBAFQ,MAAM;IAWjB;;;;OAIG;iCAFQ,MAAM,GAAC,IAAI;;;;;EA0GvB"}
@@ -1 +1 @@
1
- {"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../../../../src/loaders/configure/configure.js"],"names":[],"mappings":"AASA;;GAEG;AACH,oGA4CC"}
1
+ {"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../../../../src/loaders/configure/configure.js"],"names":[],"mappings":"AASA;;GAEG;AACH,oGA+CC"}
@@ -7,6 +7,7 @@ export namespace FEATURE_NAMES {
7
7
  let pageViewTiming: string;
8
8
  let sessionReplay: string;
9
9
  let sessionTrace: string;
10
+ let softNav: string;
10
11
  let spa: string;
11
12
  }
12
13
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../../../../src/loaders/features/features.js"],"names":[],"mappings":";;;;;;;;;;;AAYA;;;GAGG;AACH;;EAUC"}
1
+ {"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../../../../src/loaders/features/features.js"],"names":[],"mappings":";;;;;;;;;;;;AAaA;;;GAGG;AACH;;EAWC"}
@@ -9,7 +9,6 @@ export class MicroAgent extends AgentBase {
9
9
  * @param {string=} agentIdentifier - The optional unique ID of the agent.
10
10
  */
11
11
  constructor(options: Object, agentIdentifier?: string | undefined);
12
- agentIdentifier: string;
13
12
  sharedAggregator: Aggregator;
14
13
  features: {};
15
14
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"micro-agent.d.ts","sourceRoot":"","sources":["../../../src/loaders/micro-agent.js"],"names":[],"mappings":"AAoBA;;;;GAIG;AACH;IACE;;;OAGG;IACH,qBAHW,MAAM,oBACN,MAAM,cAoBhB;IAfC,wBAAsC;IACtC,6BAAiF;IACjF,aAAkB;IAMlB;;;;OAIG;IACH,yCAA2C;IAI7C;;;;;MAOC;IAED,mCAyCC;CACF;0BAzFyB,cAAc;2BAPb,gCAAgC"}
1
+ {"version":3,"file":"micro-agent.d.ts","sourceRoot":"","sources":["../../../src/loaders/micro-agent.js"],"names":[],"mappings":"AAoBA;;;;GAIG;AACH;IACE;;;OAGG;IACH,qBAHW,MAAM,oBACN,MAAM,cAoBhB;IAdC,6BAAiF;IACjF,aAAkB;IAMlB;;;;OAIG;IACH,yCAA2C;IAI7C;;;;;MAOC;IAED,mCAyCC;CACF;0BAzFyB,cAAc;2BAPb,gCAAgC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newrelic/browser-agent",
3
- "version": "1.252.0",
3
+ "version": "1.253.0",
4
4
  "private": false,
5
5
  "author": "New Relic Browser Agent Team <browser-agent@newrelic.com>",
6
6
  "description": "New Relic Browser Agent",
@@ -17,7 +17,8 @@ import { Instrument as InstrumentErrors } from '../features/jserrors/instrument'
17
17
  import { Instrument as InstrumentXhr } from '../features/ajax/instrument'
18
18
  import { Instrument as InstrumentSessionTrace } from '../features/session_trace/instrument'
19
19
  import { Instrument as InstrumentSessionReplay } from '../features/session_replay/instrument'
20
- import { Instrument as InstrumentSpa } from '../features/spa/instrument'
20
+ // import { Instrument as InstrumentSpa } from '../features/spa/instrument'
21
+ import { Instrument as InstrumentSoftNav } from '../features/soft_navigations/instrument'
21
22
  import { Instrument as InstrumentPageAction } from '../features/page_action/instrument'
22
23
 
23
24
  new Agent({
@@ -30,7 +31,8 @@ new Agent({
30
31
  InstrumentMetrics,
31
32
  InstrumentPageAction,
32
33
  InstrumentErrors,
33
- InstrumentSpa
34
+ // InstrumentSpa,
35
+ InstrumentSoftNav
34
36
  ],
35
37
  loaderType: 'experimental'
36
38
  })
package/src/cdn/spa.js CHANGED
@@ -11,6 +11,7 @@ import { Instrument as InstrumentErrors } from '../features/jserrors/instrument'
11
11
  import { Instrument as InstrumentXhr } from '../features/ajax/instrument'
12
12
  import { Instrument as InstrumentSessionTrace } from '../features/session_trace/instrument'
13
13
  import { Instrument as InstrumentSessionReplay } from '../features/session_replay/instrument'
14
+ import { Instrument as InstrumentSoftNav } from '../features/soft_navigations/instrument'
14
15
  import { Instrument as InstrumentSpa } from '../features/spa/instrument'
15
16
  import { Instrument as InstrumentPageAction } from '../features/page_action/instrument'
16
17
 
@@ -24,7 +25,8 @@ new Agent({
24
25
  InstrumentMetrics,
25
26
  InstrumentPageAction,
26
27
  InstrumentErrors,
27
- InstrumentSpa
28
+ InstrumentSoftNav,
29
+ InstrumentSpa // either the softnav or the old spa will be used (not both), but we still need to pack both to avoid dynamic import for instrument files
28
30
  ],
29
31
  loaderType: 'spa'
30
32
  })
@@ -82,7 +82,8 @@ export class Aggregator extends SharedContext {
82
82
  var hasData = false
83
83
  for (var i = 0; i < types.length; i++) {
84
84
  type = types[i]
85
- results[type] = toArray(this.aggregatedData[type])
85
+ results[type] = Object.values(this.aggregatedData[type] || {})
86
+
86
87
  if (results[type].length) hasData = true
87
88
  delete this.aggregatedData[type]
88
89
  }
@@ -159,13 +160,3 @@ function createMetricObject (value) {
159
160
  c: 1
160
161
  }
161
162
  }
162
-
163
- function toArray (obj) {
164
- if (typeof obj !== 'object') return []
165
-
166
- return mapOwn(obj, getValue)
167
- }
168
-
169
- function getValue (key, value) {
170
- return value
171
- }
@@ -64,6 +64,7 @@ const model = () => {
64
64
  autoStart: true,
65
65
  enabled: false,
66
66
  harvestTimeSeconds: 60,
67
+ preload: false, // if true, enables the agent to load rrweb immediately instead of waiting to do so after the window.load event
67
68
  sampling_rate: 10, // float from 0 - 100
68
69
  error_sampling_rate: 100, // float from 0 - 100
69
70
  collect_fonts: false, // serialize fonts for collection without public asset url, this is currently broken in RRWeb -- https://github.com/rrweb-io/rrweb/issues/1304. When fixed, revisit with test cases
@@ -100,7 +101,8 @@ const model = () => {
100
101
  else warn('An invalid session_replay.mask_input_option was provided and will not be used', val)
101
102
  }
102
103
  },
103
- spa: { enabled: true, harvestTimeSeconds: 10, autoStart: true }
104
+ spa: { enabled: true, harvestTimeSeconds: 10, autoStart: true },
105
+ soft_navigations: { enabled: true, harvestTimeSeconds: 10, autoStart: true }
104
106
  }
105
107
  }
106
108
 
@@ -0,0 +1,55 @@
1
+ import { gosNREUM } from '../window/nreum'
2
+ import { bundleId } from '../ids/bundle-id'
3
+ import { EventContext } from './event-context'
4
+
5
+ export class ObservationContextManager {
6
+ // These IDs are provided for backwards compatibility until the agent is fully updated
7
+ // use the observation context class.
8
+
9
+ static contextId = `nr@context:${bundleId}`
10
+ static contextOriginalId = `nr@original:${bundleId}`
11
+ static contextWrappedId = `nr@wrapped:${ObservationContextManager.contextId}`
12
+
13
+ static getObservationContextByAgentIdentifier (agentIdentifier) {
14
+ const nr = gosNREUM()
15
+ return Object.keys(nr?.initializedAgents || {}).indexOf(agentIdentifier) > -1
16
+ ? nr.initializedAgents[agentIdentifier].observationContext
17
+ : undefined
18
+ }
19
+
20
+ /**
21
+ * @type {WeakMap<WeakKey, {[key: string]: unknown}>}
22
+ */
23
+ #observationContext = new WeakMap()
24
+
25
+ /**
26
+ * Returns the observation context tied to the supplied construct. If there has been
27
+ * no observation construct created, an empty object is created and stored as the current
28
+ * context.
29
+ * @param key {unknown} The construct being observed such as an XHR instance
30
+ * @return {EventContext} An object of key:value pairs to track as
31
+ * part of the observation
32
+ */
33
+ getCreateContext (key) {
34
+ if (!this.#observationContext.has(key)) {
35
+ this.#observationContext.set(key, new EventContext())
36
+ }
37
+
38
+ return this.#observationContext.get(key)
39
+ }
40
+
41
+ /**
42
+ * Set the observation context for an observed construct. If values of the context
43
+ * need to be updated, they should be done so directly on the context. This function
44
+ * is only for the setting of a whole context.
45
+ * @param key {unknown} The construct being observed such as an XHR instance
46
+ * @param value {EventContext} An object of key:value pairs to track as
47
+ * part of the observation
48
+ * @return {EventContext} The updated observation context
49
+ */
50
+ setContext (key, value) {
51
+ this.#observationContext.set(key, value)
52
+
53
+ return this.#observationContext.get(key)
54
+ }
55
+ }
@@ -6,11 +6,9 @@
6
6
  import { gosNREUM } from '../window/nreum'
7
7
  import { getOrSet } from '../util/get-or-set'
8
8
  import { getRuntime } from '../config/config'
9
- import { EventContext } from './event-context'
10
- import { bundleId } from '../ids/bundle-id'
9
+ import { EventContext } from '../context/event-context'
10
+ import { ObservationContextManager } from '../context/observation-context-manager'
11
11
 
12
- // create a unique id to store event context data for the current agent bundle
13
- const contextId = `nr@context:${bundleId}`
14
12
  // create global emitter instance that can be shared among bundles
15
13
  const globalInstance = ee(undefined, 'globalEE')
16
14
 
@@ -20,7 +18,7 @@ if (!nr.ee) {
20
18
  nr.ee = globalInstance
21
19
  }
22
20
 
23
- export { globalInstance as ee, contextId }
21
+ export { globalInstance as ee }
24
22
 
25
23
  function ee (old, debugId) {
26
24
  var handlers = {}
@@ -52,8 +50,8 @@ function ee (old, debugId) {
52
50
  aborted: false,
53
51
  isBuffering,
54
52
  debugId,
55
- backlog: isolatedBacklog ? {} : old && typeof old.backlog === 'object' ? old.backlog : {}
56
-
53
+ backlog: isolatedBacklog ? {} : old && typeof old.backlog === 'object' ? old.backlog : {},
54
+ observationContextManager: null
57
55
  }
58
56
 
59
57
  return emitter
@@ -62,9 +60,15 @@ function ee (old, debugId) {
62
60
  if (contextOrStore && contextOrStore instanceof EventContext) {
63
61
  return contextOrStore
64
62
  } else if (contextOrStore) {
65
- return getOrSet(contextOrStore, contextId, () => new EventContext(contextId))
63
+ return getOrSet(contextOrStore, ObservationContextManager.contextId, () =>
64
+ emitter.observationContextManager
65
+ ? emitter.observationContextManager.getCreateContext(contextOrStore)
66
+ : new EventContext(ObservationContextManager.contextId)
67
+ )
66
68
  } else {
67
- return new EventContext(contextId)
69
+ return emitter.observationContextManager
70
+ ? emitter.observationContextManager.getCreateContext({})
71
+ : new EventContext(ObservationContextManager.contextId)
68
72
  }
69
73
  }
70
74
 
@@ -112,7 +116,13 @@ function ee (old, debugId) {
112
116
  }
113
117
 
114
118
  function getOrCreate (name) {
115
- return (emitters[name] = emitters[name] || ee(emitter, name))
119
+ const newEventEmitter = (emitters[name] = emitters[name] || ee(emitter, name))
120
+
121
+ if (!newEventEmitter.observationContextManager && emitter.observationContextManager) {
122
+ newEventEmitter.observationContextManager = emitter.observationContextManager
123
+ }
124
+
125
+ return newEventEmitter
116
126
  }
117
127
 
118
128
  function bufferEventsByGroup (types, group) {
@@ -1,4 +1,5 @@
1
1
  export const PREFIX = 'NRBA'
2
+ export const DEFAULT_KEY = 'SESSION'
2
3
  export const DEFAULT_EXPIRES_MS = 14400000
3
4
  export const DEFAULT_INACTIVE_MS = 1800000
4
5
 
@@ -125,7 +125,9 @@ export class SessionEntity {
125
125
 
126
126
  // The fact that the session is "new" or pre-existing is used in some places in the agent. Session Replay and Trace
127
127
  // can use this info to inform whether to trust a new sampling decision vs continue a previous tracking effort.
128
- this.isNew = !Object.keys(initialRead).length
128
+ /* [NR-230914] 02/2024 - the logical OR assignment is used so that isNew remains 'true' if it was already set as such. This fixes the expires and inactive timestamps timing out in localStorage
129
+ while no page for a given domain is in-use and the session resetting upon user returning to the page as part of a fresh session. */
130
+ this.isNew ||= !Object.keys(initialRead).length
129
131
  // if its a "new" session, we write to storage API with the default values. These values may change over the lifespan of the agent run.
130
132
  // we can use a modeled object here to help us know and manage what values are being used. -- see "model" above
131
133
  if (this.isNew) this.write(getModeledObject(this.state, model), true)
@@ -25,7 +25,7 @@ var RESPONSE = 'response'
25
25
  var LOAD_EVENT = 'loadEvent'
26
26
  var DOM_CONTENT_LOAD_EVENT = 'domContentLoadedEvent'
27
27
 
28
- export var navTimingValues = []
28
+ export const navTimingValues = []
29
29
 
30
30
  function getPntType (type) {
31
31
  if (typeof type === 'number') return type
@@ -72,6 +72,10 @@ export function addPN (pn, v) {
72
72
  return v
73
73
  }
74
74
 
75
+ /**
76
+ * By side effect, this modifies 'obj' with a mapping of the 'prop' provided to a 'value', and invalid values are not added.
77
+ * On the other hand, the local navTimingValues array gets the value appended if valid and 'undefined' appended if invalid, regardless.
78
+ */
75
79
  function handleValue (value, obj, prop, isOldApi) {
76
80
  /*
77
81
  For L2 Timing API, the value will already be a relative-to-previous-document DOMHighResTimeStamp.
@@ -85,6 +89,6 @@ function handleValue (value, obj, prop, isOldApi) {
85
89
  }
86
90
  value = Math.round(value)
87
91
  obj[prop] = value
88
- }
89
- navTimingValues.push(value)
92
+ navTimingValues.push(value)
93
+ } else navTimingValues.push(undefined)
90
94
  }
@@ -5,5 +5,5 @@
5
5
 
6
6
  // This is our own layer around performance.now. It's not strictly necessary, but we keep it in case of future mod-ing of the value for refactor purpose.
7
7
  export function now () {
8
- return Math.round(performance.now())
8
+ return Math.floor(performance.now())
9
9
  }
@@ -11,7 +11,7 @@ const bucketMap = {
11
11
  stn: [FEATURE_NAMES.sessionTrace],
12
12
  err: [FEATURE_NAMES.jserrors, FEATURE_NAMES.metrics],
13
13
  ins: [FEATURE_NAMES.pageAction],
14
- spa: [FEATURE_NAMES.spa],
14
+ spa: [FEATURE_NAMES.spa, FEATURE_NAMES.softNav],
15
15
  sr: [FEATURE_NAMES.sessionReplay, FEATURE_NAMES.sessionTrace]
16
16
  }
17
17
 
@@ -8,10 +8,9 @@ import { wrapHistory } from './wrap-history'
8
8
  import { wrapJsonP } from './wrap-jsonp'
9
9
  import { wrapMutation } from './wrap-mutation'
10
10
  import { wrapPromise } from './wrap-promise'
11
- import { wrapRaf } from './wrap-raf'
12
11
  import { wrapTimer } from './wrap-timer'
13
12
  import { wrapXhr } from './wrap-xhr'
14
13
 
15
14
  export {
16
- wrapEvents, wrapFetch, wrapHistory, wrapJsonP, wrapMutation, wrapPromise, wrapRaf, wrapTimer, wrapXhr
15
+ wrapEvents, wrapFetch, wrapHistory, wrapJsonP, wrapMutation, wrapPromise, wrapTimer, wrapXhr
17
16
  }