@newrelic/browser-agent 1.303.0-rc.8 → 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.
- package/dist/cjs/common/constants/env.cdn.js +1 -1
- package/dist/cjs/common/constants/env.npm.js +1 -1
- package/dist/cjs/common/window/page-visibility.js +4 -0
- package/dist/cjs/common/wrap/wrap-websocket.js +262 -32
- package/dist/cjs/features/generic_events/aggregate/index.js +24 -8
- package/dist/cjs/features/generic_events/instrument/index.js +13 -3
- package/dist/cjs/features/jserrors/aggregate/index.js +4 -1
- package/dist/cjs/features/metrics/aggregate/index.js +0 -6
- package/dist/cjs/features/metrics/constants.js +2 -4
- package/dist/cjs/features/metrics/instrument/index.js +0 -11
- package/dist/cjs/features/page_view_timing/instrument/index.js +1 -2
- package/dist/esm/common/constants/env.cdn.js +1 -1
- package/dist/esm/common/constants/env.npm.js +1 -1
- package/dist/esm/common/window/page-visibility.js +4 -1
- package/dist/esm/common/wrap/wrap-websocket.js +262 -31
- package/dist/esm/features/generic_events/aggregate/index.js +24 -8
- package/dist/esm/features/generic_events/instrument/index.js +13 -3
- package/dist/esm/features/jserrors/aggregate/index.js +4 -1
- package/dist/esm/features/metrics/aggregate/index.js +0 -6
- package/dist/esm/features/metrics/constants.js +1 -4
- package/dist/esm/features/metrics/instrument/index.js +1 -14
- package/dist/esm/features/page_view_timing/instrument/index.js +2 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/common/window/page-visibility.d.ts +1 -0
- package/dist/types/common/window/page-visibility.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-websocket.d.ts +0 -2
- package/dist/types/common/wrap/wrap-websocket.d.ts.map +1 -1
- package/dist/types/features/generic_events/aggregate/index.d.ts +0 -1
- package/dist/types/features/generic_events/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/generic_events/instrument/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/metrics/constants.d.ts +0 -1
- package/dist/types/features/metrics/constants.d.ts.map +1 -1
- package/dist/types/features/metrics/instrument/index.d.ts.map +1 -1
- package/dist/types/features/page_view_timing/instrument/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/common/window/page-visibility.js +5 -1
- package/src/common/wrap/wrap-websocket.js +248 -30
- package/src/features/generic_events/aggregate/index.js +26 -8
- package/src/features/generic_events/instrument/index.js +13 -3
- package/src/features/jserrors/aggregate/index.js +4 -1
- package/src/features/metrics/aggregate/index.js +0 -6
- package/src/features/metrics/constants.js +0 -4
- package/src/features/metrics/instrument/index.js +0 -10
- package/src/features/page_view_timing/instrument/index.js +2 -3
- package/dist/cjs/features/metrics/aggregate/websocket-detection.js +0 -39
- package/dist/esm/features/metrics/aggregate/websocket-detection.js +0 -33
- package/dist/types/features/metrics/aggregate/websocket-detection.d.ts +0 -12
- package/dist/types/features/metrics/aggregate/websocket-detection.d.ts.map +0 -1
- package/src/features/metrics/aggregate/websocket-detection.js +0 -35
|
@@ -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
|
-
}
|