@newrelic/browser-agent 1.303.0-rc.7 → 1.303.0-rc.9

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 (55) hide show
  1. package/dist/cjs/common/constants/env.cdn.js +1 -1
  2. package/dist/cjs/common/constants/env.npm.js +1 -1
  3. package/dist/cjs/common/util/monkey-patched.js +5 -3
  4. package/dist/cjs/common/window/page-visibility.js +4 -0
  5. package/dist/cjs/common/wrap/wrap-websocket.js +262 -32
  6. package/dist/cjs/features/generic_events/aggregate/index.js +24 -8
  7. package/dist/cjs/features/generic_events/instrument/index.js +13 -3
  8. package/dist/cjs/features/jserrors/aggregate/index.js +4 -1
  9. package/dist/cjs/features/metrics/aggregate/index.js +0 -6
  10. package/dist/cjs/features/metrics/constants.js +2 -4
  11. package/dist/cjs/features/metrics/instrument/index.js +0 -11
  12. package/dist/cjs/features/page_view_timing/instrument/index.js +1 -2
  13. package/dist/esm/common/constants/env.cdn.js +1 -1
  14. package/dist/esm/common/constants/env.npm.js +1 -1
  15. package/dist/esm/common/util/monkey-patched.js +5 -3
  16. package/dist/esm/common/window/page-visibility.js +4 -1
  17. package/dist/esm/common/wrap/wrap-websocket.js +262 -31
  18. package/dist/esm/features/generic_events/aggregate/index.js +24 -8
  19. package/dist/esm/features/generic_events/instrument/index.js +13 -3
  20. package/dist/esm/features/jserrors/aggregate/index.js +4 -1
  21. package/dist/esm/features/metrics/aggregate/index.js +0 -6
  22. package/dist/esm/features/metrics/constants.js +1 -4
  23. package/dist/esm/features/metrics/instrument/index.js +1 -14
  24. package/dist/esm/features/page_view_timing/instrument/index.js +2 -3
  25. package/dist/tsconfig.tsbuildinfo +1 -1
  26. package/dist/types/common/util/monkey-patched.d.ts.map +1 -1
  27. package/dist/types/common/window/page-visibility.d.ts +1 -0
  28. package/dist/types/common/window/page-visibility.d.ts.map +1 -1
  29. package/dist/types/common/wrap/wrap-websocket.d.ts +0 -2
  30. package/dist/types/common/wrap/wrap-websocket.d.ts.map +1 -1
  31. package/dist/types/features/generic_events/aggregate/index.d.ts +0 -1
  32. package/dist/types/features/generic_events/aggregate/index.d.ts.map +1 -1
  33. package/dist/types/features/generic_events/instrument/index.d.ts.map +1 -1
  34. package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
  35. package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
  36. package/dist/types/features/metrics/constants.d.ts +0 -1
  37. package/dist/types/features/metrics/constants.d.ts.map +1 -1
  38. package/dist/types/features/metrics/instrument/index.d.ts.map +1 -1
  39. package/dist/types/features/page_view_timing/instrument/index.d.ts.map +1 -1
  40. package/package.json +1 -1
  41. package/src/common/util/monkey-patched.js +5 -3
  42. package/src/common/window/page-visibility.js +5 -1
  43. package/src/common/wrap/wrap-websocket.js +248 -30
  44. package/src/features/generic_events/aggregate/index.js +26 -8
  45. package/src/features/generic_events/instrument/index.js +13 -3
  46. package/src/features/jserrors/aggregate/index.js +4 -1
  47. package/src/features/metrics/aggregate/index.js +0 -6
  48. package/src/features/metrics/constants.js +0 -4
  49. package/src/features/metrics/instrument/index.js +0 -10
  50. package/src/features/page_view_timing/instrument/index.js +2 -3
  51. package/dist/cjs/features/metrics/aggregate/websocket-detection.js +0 -39
  52. package/dist/esm/features/metrics/aggregate/websocket-detection.js +0 -33
  53. package/dist/types/features/metrics/aggregate/websocket-detection.d.ts +0 -12
  54. package/dist/types/features/metrics/aggregate/websocket-detection.d.ts.map +0 -1
  55. package/src/features/metrics/aggregate/websocket-detection.js +0 -35
@@ -1,39 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.handleWebsocketEvents = handleWebsocketEvents;
7
- var _dataSize = require("../../../common/util/data-size");
8
- var _text = require("../../../common/util/text");
9
- var _wrapWebsocket = require("../../../common/wrap/wrap-websocket");
10
- /**
11
- * Copyright 2020-2025 New Relic, Inc. All rights reserved.
12
- * SPDX-License-Identifier: Apache-2.0
13
- */
14
-
15
- /**
16
- * A SM handler for web socket events, which converts them to a shape suitable for SMs and reports them.
17
- * @param {Function} reporter a function that reports data as a supportability metric
18
- * @param {string} tag the unique tag to assign to the sm
19
- * @param {number} timestamp ms from page origin
20
- * @param {number} timeSinceInit ms from class init
21
- * @param {boolean} isLoaded whether the even was observed before the page load event
22
- * @param {string} socketId a unique id assigned to the observed socket
23
- * @param {*} data the data reported alongside the socket event
24
- */
25
- function handleWebsocketEvents(reporter, tag, timestamp, timeSinceInit, isLoaded, socketId, data) {
26
- // socketId is unused in the SMs
27
- const useDataType = tag === _wrapWebsocket.ADD_EVENT_LISTENER_TAG;
28
- let metricTag = (0, _text.toTitleCase)(useDataType ? data.eventType : tag);
29
- if (metricTag === 'Close') {
30
- if (data?.event.code === 1000 || data?.event.wasClean) metricTag += '-Clean';else metricTag += '-Dirty';
31
- }
32
- const bytes = metricTag === 'Message' && (0, _dataSize.dataSize)(data?.event?.data) || metricTag === 'Send' && (0, _dataSize.dataSize)(data);
33
- reporter(buildSMTag(metricTag, 'Ms'), timestamp);
34
- reporter(buildSMTag(metricTag, 'MsSinceClassInit'), timeSinceInit);
35
- if (bytes) reporter(buildSMTag(metricTag, 'Bytes'), bytes);
36
- }
37
- function buildSMTag(tag, category) {
38
- return 'WebSocket/' + tag + '/' + category;
39
- }
@@ -1,33 +0,0 @@
1
- /**
2
- * Copyright 2020-2025 New Relic, Inc. All rights reserved.
3
- * SPDX-License-Identifier: Apache-2.0
4
- */
5
- import { dataSize } from '../../../common/util/data-size';
6
- import { toTitleCase } from '../../../common/util/text';
7
- import { ADD_EVENT_LISTENER_TAG } from '../../../common/wrap/wrap-websocket';
8
-
9
- /**
10
- * A SM handler for web socket events, which converts them to a shape suitable for SMs and reports them.
11
- * @param {Function} reporter a function that reports data as a supportability metric
12
- * @param {string} tag the unique tag to assign to the sm
13
- * @param {number} timestamp ms from page origin
14
- * @param {number} timeSinceInit ms from class init
15
- * @param {boolean} isLoaded whether the even was observed before the page load event
16
- * @param {string} socketId a unique id assigned to the observed socket
17
- * @param {*} data the data reported alongside the socket event
18
- */
19
- export function handleWebsocketEvents(reporter, tag, timestamp, timeSinceInit, isLoaded, socketId, data) {
20
- // socketId is unused in the SMs
21
- const useDataType = tag === ADD_EVENT_LISTENER_TAG;
22
- let metricTag = toTitleCase(useDataType ? data.eventType : tag);
23
- if (metricTag === 'Close') {
24
- if (data?.event.code === 1000 || data?.event.wasClean) metricTag += '-Clean';else metricTag += '-Dirty';
25
- }
26
- const bytes = metricTag === 'Message' && dataSize(data?.event?.data) || metricTag === 'Send' && dataSize(data);
27
- reporter(buildSMTag(metricTag, 'Ms'), timestamp);
28
- reporter(buildSMTag(metricTag, 'MsSinceClassInit'), timeSinceInit);
29
- if (bytes) reporter(buildSMTag(metricTag, 'Bytes'), bytes);
30
- }
31
- function buildSMTag(tag, category) {
32
- return 'WebSocket/' + tag + '/' + category;
33
- }
@@ -1,12 +0,0 @@
1
- /**
2
- * A SM handler for web socket events, which converts them to a shape suitable for SMs and reports them.
3
- * @param {Function} reporter a function that reports data as a supportability metric
4
- * @param {string} tag the unique tag to assign to the sm
5
- * @param {number} timestamp ms from page origin
6
- * @param {number} timeSinceInit ms from class init
7
- * @param {boolean} isLoaded whether the even was observed before the page load event
8
- * @param {string} socketId a unique id assigned to the observed socket
9
- * @param {*} data the data reported alongside the socket event
10
- */
11
- export function handleWebsocketEvents(reporter: Function, tag: string, timestamp: number, timeSinceInit: number, isLoaded: boolean, socketId: string, data: any): void;
12
- //# sourceMappingURL=websocket-detection.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"websocket-detection.d.ts","sourceRoot":"","sources":["../../../../../src/features/metrics/aggregate/websocket-detection.js"],"names":[],"mappings":"AAQA;;;;;;;;;GASG;AACH,+DAPW,MAAM,aACN,MAAM,iBACN,MAAM,YACN,OAAO,YACP,MAAM,QACN,GAAC,QAcX"}
@@ -1,35 +0,0 @@
1
- /**
2
- * Copyright 2020-2025 New Relic, Inc. All rights reserved.
3
- * SPDX-License-Identifier: Apache-2.0
4
- */
5
- import { dataSize } from '../../../common/util/data-size'
6
- import { toTitleCase } from '../../../common/util/text'
7
- import { ADD_EVENT_LISTENER_TAG } from '../../../common/wrap/wrap-websocket'
8
-
9
- /**
10
- * A SM handler for web socket events, which converts them to a shape suitable for SMs and reports them.
11
- * @param {Function} reporter a function that reports data as a supportability metric
12
- * @param {string} tag the unique tag to assign to the sm
13
- * @param {number} timestamp ms from page origin
14
- * @param {number} timeSinceInit ms from class init
15
- * @param {boolean} isLoaded whether the even was observed before the page load event
16
- * @param {string} socketId a unique id assigned to the observed socket
17
- * @param {*} data the data reported alongside the socket event
18
- */
19
- export function handleWebsocketEvents (reporter, tag, timestamp, timeSinceInit, isLoaded, socketId, data) {
20
- // socketId is unused in the SMs
21
- const useDataType = tag === ADD_EVENT_LISTENER_TAG
22
- let metricTag = toTitleCase(useDataType ? data.eventType : tag)
23
- if (metricTag === 'Close') {
24
- if (data?.event.code === 1000 || data?.event.wasClean) metricTag += '-Clean'
25
- else metricTag += '-Dirty'
26
- }
27
- const bytes = (metricTag === 'Message' && dataSize(data?.event?.data)) || (metricTag === 'Send' && dataSize(data))
28
- reporter(buildSMTag(metricTag, 'Ms'), timestamp)
29
- reporter(buildSMTag(metricTag, 'MsSinceClassInit'), timeSinceInit)
30
- if (bytes) reporter(buildSMTag(metricTag, 'Bytes'), bytes)
31
- }
32
-
33
- function buildSMTag (tag, category) {
34
- return 'WebSocket/' + tag + '/' + category
35
- }