@newrelic/browser-agent 1.302.0-rc.1 → 1.302.0-rc.11
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/init-types.js +2 -0
- package/dist/cjs/common/config/init.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/harvest/harvester.js +13 -9
- package/dist/cjs/common/harvest/types.js +0 -1
- package/dist/cjs/common/session/session-entity.js +4 -2
- package/dist/cjs/common/util/mfe.js +8 -5
- package/dist/cjs/common/wrap/wrap-promise.js +10 -5
- package/dist/cjs/features/generic_events/aggregate/index.js +4 -4
- package/dist/cjs/features/logging/aggregate/index.js +1 -2
- package/dist/cjs/features/page_view_event/aggregate/index.js +84 -22
- package/dist/cjs/features/page_view_event/instrument/index.js +0 -4
- package/dist/cjs/features/session_replay/aggregate/index.js +3 -2
- package/dist/cjs/features/session_replay/constants.js +2 -6
- package/dist/cjs/features/session_replay/instrument/index.js +3 -2
- package/dist/cjs/features/utils/agent-session.js +13 -0
- package/dist/cjs/features/utils/instrument-base.js +7 -8
- package/dist/cjs/interfaces/registered-entity.js +21 -0
- package/dist/cjs/loaders/agent.js +2 -0
- package/dist/cjs/loaders/api/consent.js +24 -0
- package/dist/cjs/loaders/api/constants.js +3 -2
- package/dist/cjs/loaders/api/measure.js +36 -35
- package/dist/cjs/loaders/api/recordCustomEvent.js +5 -3
- package/dist/cjs/loaders/api/register-api-types.js +14 -10
- package/dist/cjs/loaders/api/register.js +25 -10
- package/dist/cjs/loaders/api-base.js +14 -7
- package/dist/esm/common/config/init-types.js +2 -0
- package/dist/esm/common/config/init.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/harvest/harvester.js +13 -9
- package/dist/esm/common/harvest/types.js +0 -1
- package/dist/esm/common/session/session-entity.js +4 -2
- package/dist/esm/common/util/mfe.js +7 -5
- package/dist/esm/common/wrap/wrap-promise.js +10 -5
- package/dist/esm/features/generic_events/aggregate/index.js +4 -4
- package/dist/esm/features/logging/aggregate/index.js +1 -2
- package/dist/esm/features/page_view_event/aggregate/index.js +84 -22
- package/dist/esm/features/page_view_event/instrument/index.js +0 -4
- package/dist/esm/features/session_replay/aggregate/index.js +4 -3
- package/dist/esm/features/session_replay/constants.js +1 -5
- package/dist/esm/features/session_replay/instrument/index.js +4 -3
- package/dist/esm/features/utils/agent-session.js +13 -0
- package/dist/esm/features/utils/instrument-base.js +7 -8
- package/dist/esm/interfaces/registered-entity.js +21 -0
- package/dist/esm/loaders/agent.js +2 -0
- package/dist/esm/loaders/api/consent.js +17 -0
- package/dist/esm/loaders/api/constants.js +2 -1
- package/dist/esm/loaders/api/measure.js +35 -35
- package/dist/esm/loaders/api/recordCustomEvent.js +4 -3
- package/dist/esm/loaders/api/register-api-types.js +14 -10
- package/dist/esm/loaders/api/register.js +26 -10
- package/dist/esm/loaders/api-base.js +15 -8
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/common/config/init-types.d.ts +6 -0
- package/dist/types/common/config/init.d.ts.map +1 -1
- package/dist/types/common/harvest/harvester.d.ts.map +1 -1
- package/dist/types/common/harvest/types.d.ts +0 -2
- package/dist/types/common/harvest/types.d.ts.map +1 -1
- package/dist/types/common/session/session-entity.d.ts.map +1 -1
- package/dist/types/common/util/mfe.d.ts +3 -0
- package/dist/types/common/util/mfe.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-promise.d.ts.map +1 -1
- package/dist/types/features/page_view_event/aggregate/index.d.ts +22 -3
- package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/page_view_event/instrument/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/constants.d.ts +1 -5
- package/dist/types/features/session_replay/constants.d.ts.map +1 -1
- package/dist/types/features/session_replay/instrument/index.d.ts.map +1 -1
- package/dist/types/features/utils/agent-session.d.ts.map +1 -1
- package/dist/types/features/utils/instrument-base.d.ts +1 -0
- package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
- package/dist/types/interfaces/registered-entity.d.ts +25 -0
- package/dist/types/interfaces/registered-entity.d.ts.map +1 -1
- package/dist/types/loaders/agent.d.ts.map +1 -1
- package/dist/types/loaders/api/consent.d.ts +2 -0
- package/dist/types/loaders/api/consent.d.ts.map +1 -0
- package/dist/types/loaders/api/constants.d.ts +1 -0
- package/dist/types/loaders/api/constants.d.ts.map +1 -1
- package/dist/types/loaders/api/measure.d.ts +3 -0
- package/dist/types/loaders/api/measure.d.ts.map +1 -1
- package/dist/types/loaders/api/recordCustomEvent.d.ts +1 -0
- package/dist/types/loaders/api/recordCustomEvent.d.ts.map +1 -1
- package/dist/types/loaders/api/register-api-types.d.ts +43 -12
- package/dist/types/loaders/api/register-api-types.d.ts.map +1 -1
- package/dist/types/loaders/api/register.d.ts +0 -16
- package/dist/types/loaders/api/register.d.ts.map +1 -1
- package/dist/types/loaders/api-base.d.ts +20 -15
- package/dist/types/loaders/api-base.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/common/config/init-types.js +2 -0
- package/src/common/config/init.js +1 -0
- package/src/common/harvest/harvester.js +11 -8
- package/src/common/harvest/types.js +0 -1
- package/src/common/session/session-entity.js +6 -2
- package/src/common/util/mfe.js +10 -4
- package/src/common/wrap/wrap-promise.js +16 -6
- package/src/features/generic_events/aggregate/index.js +4 -4
- package/src/features/logging/aggregate/index.js +1 -1
- package/src/features/page_view_event/aggregate/index.js +79 -15
- package/src/features/page_view_event/instrument/index.js +0 -4
- package/src/features/session_replay/aggregate/index.js +4 -3
- package/src/features/session_replay/constants.js +1 -5
- package/src/features/session_replay/instrument/index.js +4 -3
- package/src/features/utils/agent-session.js +12 -0
- package/src/features/utils/instrument-base.js +7 -9
- package/src/interfaces/registered-entity.js +21 -0
- package/src/loaders/agent.js +2 -0
- package/src/loaders/api/consent.js +18 -0
- package/src/loaders/api/constants.js +1 -0
- package/src/loaders/api/measure.js +34 -33
- package/src/loaders/api/recordCustomEvent.js +5 -3
- package/src/loaders/api/register-api-types.js +14 -10
- package/src/loaders/api/register.js +17 -10
- package/src/loaders/api-base.js +15 -8
|
@@ -10,44 +10,45 @@ import { prefix, MEASURE } from './constants'
|
|
|
10
10
|
import { setupAPI } from './sharedHandlers'
|
|
11
11
|
|
|
12
12
|
export function setupMeasureAPI (agent) {
|
|
13
|
-
setupAPI(MEASURE,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
setupAPI(MEASURE, (name, options) => measure(name, options, agent), agent)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function measure (name, options, agentRef, target, timestamp = now()) {
|
|
17
|
+
const { start, end, customAttributes } = options || {}
|
|
18
|
+
const returnObj = { customAttributes: customAttributes || {} }
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
if (typeof returnObj.customAttributes !== 'object' || typeof name !== 'string' || name.length === 0) {
|
|
21
|
+
warn(57)
|
|
22
|
+
return
|
|
23
|
+
}
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
/**
|
|
24
26
|
* getValueFromTiming - Helper function to extract a numeric value from a supplied option.
|
|
25
27
|
* @param {Number|PerformanceMark} [timing] The timing value
|
|
26
28
|
* @param {Number} [d] The default value to return if timing is invalid
|
|
27
29
|
* @returns {Number} The timing value or the default value
|
|
28
30
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}, agent)
|
|
31
|
+
const getValueFromTiming = (timing, d) => {
|
|
32
|
+
if (timing == null) return d
|
|
33
|
+
if (typeof timing === 'number') return timing
|
|
34
|
+
if (timing instanceof PerformanceMark) return timing.startTime
|
|
35
|
+
return Number.NaN
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
returnObj.start = getValueFromTiming(start, 0)
|
|
39
|
+
returnObj.end = getValueFromTiming(end, timestamp)
|
|
40
|
+
if (Number.isNaN(returnObj.start) || Number.isNaN(returnObj.end)) {
|
|
41
|
+
warn(57)
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
returnObj.duration = returnObj.end - returnObj.start
|
|
46
|
+
if (returnObj.duration < 0) {
|
|
47
|
+
warn(58)
|
|
48
|
+
return
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
handle(prefix + MEASURE, [returnObj, name, target], undefined, FEATURE_NAMES.genericEvents, agentRef.ee)
|
|
52
|
+
|
|
53
|
+
return returnObj
|
|
53
54
|
}
|
|
@@ -9,7 +9,9 @@ import { prefix, RECORD_CUSTOM_EVENT } from './constants'
|
|
|
9
9
|
import { setupAPI } from './sharedHandlers'
|
|
10
10
|
|
|
11
11
|
export function setupRecordCustomEventAPI (agent) {
|
|
12
|
-
setupAPI(RECORD_CUSTOM_EVENT,
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
setupAPI(RECORD_CUSTOM_EVENT, (eventType, attributes) => recordCustomEvent(eventType, attributes, agent), agent)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function recordCustomEvent (eventType, attributes = {}, agentRef, target, timestamp = now()) {
|
|
16
|
+
handle(prefix + RECORD_CUSTOM_EVENT, [timestamp, eventType, attributes, target], undefined, FEATURE_NAMES.genericEvents, agentRef.ee)
|
|
15
17
|
}
|
|
@@ -5,29 +5,33 @@
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @typedef {Object} RegisterAPI
|
|
8
|
-
* @property {
|
|
9
|
-
* @property {
|
|
10
|
-
* @property {
|
|
11
|
-
* @property {
|
|
12
|
-
* @property {
|
|
13
|
-
* @property {
|
|
8
|
+
* @property {(name: string, attributes?: object) => void} addPageAction - Add a page action for the registered entity.
|
|
9
|
+
* @property {(message: string, options?: { customAttributes?: object, level?: 'ERROR' | 'TRACE' | 'DEBUG' | 'INFO' | 'WARN'}) => void} log - Capture a log for the registered entity.
|
|
10
|
+
* @property {(error: Error | string, customAttributes?: object) => void} noticeError - Notice an error for the registered entity.
|
|
11
|
+
* @property {(target: RegisterAPIConstructor) => RegisterAPI} register - Record a custom event for the registered entity.
|
|
12
|
+
* @property {(eventType: string, attributes?: Object) => void} recordCustomEvent - Record a custom event for the registered entity.
|
|
13
|
+
* @property {(eventType: string, options?: {start: number, end: number, duration: number, customAttributes: object}) => ({start: number, end: number, duration: number, customAttributes: object})} measure - Measures a task that is recorded as a BrowserPerformance event.
|
|
14
|
+
* @property {(value: string | null) => void} setApplicationVersion - Add an application.version attribute to all outgoing data for the registered entity.
|
|
15
|
+
* @property {(name: string, value: string | number | boolean | null, persist?: boolean) => void} setCustomAttribute - Add a custom attribute to outgoing data for the registered entity.
|
|
16
|
+
* @property {(value: string | null) => void} setUserId - Add an enduser.id attribute to all outgoing API data for the registered entity.
|
|
14
17
|
* @property {RegisterAPIMetadata} metadata - The metadata object containing the custom attributes and target information for the registered entity.
|
|
15
18
|
*/
|
|
16
19
|
|
|
17
20
|
/**
|
|
18
21
|
* @typedef {Object} RegisterAPIConstructor
|
|
19
|
-
* @property {
|
|
20
|
-
* @property {string}
|
|
21
|
-
* @property {string}
|
|
22
|
+
* @property {string|number} id - The unique id for the registered entity. This will be assigned to any synthesized entities.
|
|
23
|
+
* @property {string} name - The readable name for the registered entity. This will be assigned to any synthesized entities.
|
|
24
|
+
* @property {string} [parentId] - The parentId for the registered entity. If none was supplied, it will assume the entity guid from the main agent.
|
|
22
25
|
*/
|
|
23
26
|
|
|
24
27
|
/**
|
|
25
28
|
* @typedef {Object} RegisterAPIMetadata
|
|
26
29
|
* @property {Object} customAttributes - The custom attributes for the registered entity.
|
|
27
30
|
* @property {Object} target - The options for the registered entity.
|
|
28
|
-
* @property {string} target.licenseKey - The license key for the registered entity. If none was supplied, it will assume the license key from the main agent.
|
|
31
|
+
* @property {string} [target.licenseKey] - The license key for the registered entity. If none was supplied, it will assume the license key from the main agent.
|
|
29
32
|
* @property {string} target.id - The ID for the registered entity.
|
|
30
33
|
* @property {string} target.name - The name returned for the registered entity.
|
|
34
|
+
* @property {string} [target.parentId] - The parentId for the registered entity. If none was supplied, it will assume the entity guid from the main agent.
|
|
31
35
|
*/
|
|
32
36
|
|
|
33
37
|
export default {}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { handle } from '../../common/event-emitter/handle'
|
|
6
6
|
import { warn } from '../../common/util/console'
|
|
7
|
-
import { isValidMFETarget } from '../../common/util/mfe'
|
|
7
|
+
import { hasValidValue, isValidMFETarget } from '../../common/util/mfe'
|
|
8
8
|
import { FEATURE_NAMES } from '../features/features'
|
|
9
9
|
import { now } from '../../common/timing/now'
|
|
10
10
|
import { SUPPORTABILITY_METRIC_CHANNEL } from '../../features/metrics/constants'
|
|
@@ -14,6 +14,8 @@ import { log } from './log'
|
|
|
14
14
|
import { addPageAction } from './addPageAction'
|
|
15
15
|
import { noticeError } from './noticeError'
|
|
16
16
|
import { single } from '../../common/util/invoke'
|
|
17
|
+
import { measure } from './measure'
|
|
18
|
+
import { recordCustomEvent } from './recordCustomEvent'
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
21
|
* @typedef {import('./register-api-types').RegisterAPI} RegisterAPI
|
|
@@ -26,7 +28,7 @@ import { single } from '../../common/util/invoke'
|
|
|
26
28
|
*/
|
|
27
29
|
export function setupRegisterAPI (agent) {
|
|
28
30
|
setupAPI(REGISTER, function (target) {
|
|
29
|
-
return
|
|
31
|
+
return register(agent, target)
|
|
30
32
|
}, agent)
|
|
31
33
|
}
|
|
32
34
|
|
|
@@ -34,20 +36,19 @@ export function setupRegisterAPI (agent) {
|
|
|
34
36
|
* Builds the api object that will be returned from the register api method.
|
|
35
37
|
* Also conducts certain side-effects, such as harvesting a PageView event when triggered and gathering metadata for the registered entity.
|
|
36
38
|
* @param {Object} agentRef the reference to the base agent instance
|
|
37
|
-
* @param {
|
|
38
|
-
* @param {
|
|
39
|
-
* @param {string} [target.licenseKey] the license key of the target to report data to
|
|
40
|
-
* @param {string} target.id the entity ID of the target to report data to
|
|
41
|
-
* @param {string} target.name the entity name of the target to report data to
|
|
39
|
+
* @param {import('./register-api-types').RegisterAPIConstructor} target
|
|
40
|
+
* @param {import('./register-api-types').RegisterAPIConstructor} [parent]
|
|
42
41
|
* @returns {RegisterAPI} the api object to be returned from the register api method
|
|
43
42
|
*/
|
|
44
|
-
|
|
43
|
+
function register (agentRef, target, parent) {
|
|
45
44
|
const attrs = {}
|
|
46
45
|
warn(54, 'newrelic.register')
|
|
47
46
|
|
|
48
47
|
target ||= {}
|
|
48
|
+
target.eventSource = 'MicroFrontendBrowserAgent'
|
|
49
49
|
target.licenseKey ||= agentRef.info.licenseKey // will inherit the license key from the container agent if not provided for brevity. A future state may dictate that we need different license keys to do different things.
|
|
50
50
|
target.blocked = false
|
|
51
|
+
target.parent = parent || {}
|
|
51
52
|
|
|
52
53
|
/** @type {Function} a function that is set and reports when APIs are triggered -- warns the customer of the invalid state */
|
|
53
54
|
let invalidApiResponse = () => {}
|
|
@@ -73,12 +74,18 @@ export function buildRegisterApi (agentRef, target) {
|
|
|
73
74
|
/** primary cases that can block the register API from working at init time */
|
|
74
75
|
if (!agentRef.init.api.allow_registered_children) block(single(() => warn(55)))
|
|
75
76
|
if (!isValidMFETarget(target)) block(single(() => warn(48, target)))
|
|
77
|
+
if (!hasValidValue(target.id) || !hasValidValue(target.name)) {
|
|
78
|
+
block(single(() => warn(48, target)))
|
|
79
|
+
}
|
|
76
80
|
|
|
77
81
|
/** @type {RegisterAPI} */
|
|
78
82
|
const api = {
|
|
79
83
|
addPageAction: (name, attributes = {}) => report(addPageAction, [name, { ...attrs, ...attributes }, agentRef], target),
|
|
80
84
|
log: (message, options = {}) => report(log, [message, { ...options, customAttributes: { ...attrs, ...(options.customAttributes || {}) } }, agentRef], target),
|
|
85
|
+
measure: (name, options = {}) => report(measure, [name, { ...options, customAttributes: { ...attrs, ...(options.customAttributes || {}) } }, agentRef], target),
|
|
81
86
|
noticeError: (error, attributes = {}) => report(noticeError, [error, { ...attrs, ...attributes }, agentRef], target),
|
|
87
|
+
register: (target = {}) => report(register, [agentRef, target], api.metadata.target),
|
|
88
|
+
recordCustomEvent: (eventType, attributes = {}) => report(recordCustomEvent, [eventType, { ...attrs, ...attributes }, agentRef], target),
|
|
82
89
|
setApplicationVersion: (value) => setLocalValue('application.version', value),
|
|
83
90
|
setCustomAttribute: (key, value) => setLocalValue(key, value),
|
|
84
91
|
setUserId: (value) => setLocalValue('enduser.id', value),
|
|
@@ -126,8 +133,8 @@ export function buildRegisterApi (agentRef, target) {
|
|
|
126
133
|
const timestamp = now()
|
|
127
134
|
handle(SUPPORTABILITY_METRIC_CHANNEL, [`API/register/${methodToCall.name}/called`], undefined, FEATURE_NAMES.metrics, agentRef.ee)
|
|
128
135
|
try {
|
|
129
|
-
const shouldDuplicate = agentRef.init.api.duplicate_registered_data
|
|
130
|
-
if (shouldDuplicate
|
|
136
|
+
const shouldDuplicate = agentRef.init.api.duplicate_registered_data && methodToCall.name !== 'register'
|
|
137
|
+
if (shouldDuplicate) {
|
|
131
138
|
// also report to container by providing undefined target
|
|
132
139
|
methodToCall(...args, undefined, timestamp)
|
|
133
140
|
}
|
package/src/loaders/api-base.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
import { warn } from '../common/util/console'
|
|
6
|
-
import { ADD_PAGE_ACTION, ADD_RELEASE, ADD_TO_TRACE, FINISHED, INTERACTION, LOG, NOTICE_ERROR, PAUSE_REPLAY, RECORD_CUSTOM_EVENT, RECORD_REPLAY, REGISTER, SET_APPLICATION_VERSION, SET_CURRENT_ROUTE_NAME, SET_CUSTOM_ATTRIBUTE, SET_ERROR_HANDLER, SET_PAGE_VIEW_NAME, SET_USER_ID, START, WRAP_LOGGER, MEASURE } from './api/constants'
|
|
6
|
+
import { ADD_PAGE_ACTION, ADD_RELEASE, ADD_TO_TRACE, CONSENT, FINISHED, INTERACTION, LOG, NOTICE_ERROR, PAUSE_REPLAY, RECORD_CUSTOM_EVENT, RECORD_REPLAY, REGISTER, SET_APPLICATION_VERSION, SET_CURRENT_ROUTE_NAME, SET_CUSTOM_ATTRIBUTE, SET_ERROR_HANDLER, SET_PAGE_VIEW_NAME, SET_USER_ID, START, WRAP_LOGGER, MEASURE } from './api/constants'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @typedef {import('./api/interaction-types').InteractionInstance} InteractionInstance
|
|
@@ -32,11 +32,8 @@ export class ApiBase {
|
|
|
32
32
|
* It is not recommended for use in production environments and will not receive support for issues.
|
|
33
33
|
*
|
|
34
34
|
* Registers an external caller to report through the base agent to a different target than the base agent.
|
|
35
|
-
* @param {
|
|
36
|
-
|
|
37
|
-
* @param {string} target.applicationID The applicationID to report data to
|
|
38
|
-
* @param {string=} target.entityGuid The entityGuid to report data to
|
|
39
|
-
* @returns {object} Returns an object that contains the available API methods and configurations to use with the external caller. See loaders/api/api.js for more information.
|
|
35
|
+
* @param {import('./api/register-api-types').RegisterAPIConstructor} target the target object to report data to
|
|
36
|
+
@returns {import('./api/register-api-types').RegisterAPI} Returns an object that contains the available API methods and configurations to use with the external caller. See loaders/api/api.js for more information.
|
|
40
37
|
*/
|
|
41
38
|
register (target) {
|
|
42
39
|
return this.#callMethod(REGISTER, target)
|
|
@@ -46,7 +43,7 @@ export class ApiBase {
|
|
|
46
43
|
* Records a custom event with a specified eventType and attributes.
|
|
47
44
|
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/recordCustomEvent/}
|
|
48
45
|
* @param {string} eventType The eventType to store the event as.
|
|
49
|
-
* @param {
|
|
46
|
+
* @param {Object} [attributes] JSON object with one or more key/value pairs. For example: {key:"value"}.
|
|
50
47
|
*/
|
|
51
48
|
recordCustomEvent (eventType, attributes) {
|
|
52
49
|
return this.#callMethod(RECORD_CUSTOM_EVENT, eventType, attributes)
|
|
@@ -222,10 +219,20 @@ export class ApiBase {
|
|
|
222
219
|
* Measures a task that is recorded as a BrowserPerformance event.
|
|
223
220
|
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/measure/}
|
|
224
221
|
* @param {string} name The name of the task
|
|
225
|
-
* @param {object
|
|
222
|
+
* @param {{start: number, end: number, duration: number, customAttributes: object}} [options] An object used to control the way the measure API operates
|
|
226
223
|
* @returns {{start: number, end: number, duration: number, customAttributes: object}} Measurement details
|
|
227
224
|
*/
|
|
228
225
|
measure (name, options) {
|
|
229
226
|
return this.#callMethod(MEASURE, name, options)
|
|
230
227
|
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Accepts or rejects consent when the agent is configured to require consent before harvesting.
|
|
231
|
+
* The consent state is stored in session storage inside the NRBA_SESSION object.
|
|
232
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/consent/}
|
|
233
|
+
* @param {boolean?} accept Whether to accept or reject consent. Defaults to true (accept) if left undefined.
|
|
234
|
+
*/
|
|
235
|
+
consent (accept) {
|
|
236
|
+
return this.#callMethod(CONSENT, accept)
|
|
237
|
+
}
|
|
231
238
|
}
|