You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/common/util/mfe.js
+6-4Lines changed: 6 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,8 @@ export function hasValidValue (val) {
17
17
18
18
/**
19
19
* When given a valid target, returns an object with the MFE payload attributes. Returns an empty object otherwise.
20
+
* @note Field names may change as the schema is finalized
21
+
*
20
22
* @param {Object} [target] the registered target
21
23
* @param {AggregateInstance} [aggregateInstance] the aggregate instance calling the method
22
24
* @returns {{'mfe.id': *, 'mfe.name': String}|{}} returns an empty object if args are not supplied or the aggregate instance is not supporting version 2
@@ -31,9 +33,9 @@ export function getVersion2Attributes (target, aggregateInstance) {
31
33
}
32
34
}
33
35
return{
34
-
'mfe.id': target.id,// these field names may change as the schema is finalized
35
-
'mfe.name': target.name,// these field names may change as the schema is finalized
36
-
eventSource: 'MicroFrontendBrowserAgent',// these field names may change as the schema is finalized
Copy file name to clipboardExpand all lines: src/loaders/api/register-api-types.js
+5-2Lines changed: 5 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -8,8 +8,9 @@
8
8
* @property {(name: string, attributes?: object) => void} addPageAction - Add a page action for the registered entity.
9
9
* @property {(message: string, options?: { customAttributes?: object, level?: 'ERROR' | 'TRACE' | 'DEBUG' | 'INFO' | 'WARN'}) => void} log - Capture a log for the registered entity.
10
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.
11
12
* @property {(eventType: string, attributes?: Object) => void} recordCustomEvent - Record a custom event for the registered entity.
12
-
* @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.
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.
13
14
* @property {(value: string | null) => void} setApplicationVersion - Add an application.version attribute to all outgoing data for the registered entity.
14
15
* @property {(name: string, value: string | number | boolean | null, persist?: boolean) => void} setCustomAttribute - Add a custom attribute to outgoing data for the registered entity.
15
16
* @property {(value: string | null) => void} setUserId - Add an enduser.id attribute to all outgoing API data for the registered entity.
@@ -20,15 +21,17 @@
20
21
* @typedef {Object} RegisterAPIConstructor
21
22
* @property {string|number} id - The unique id for the registered entity. This will be assigned to any synthesized entities.
22
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.
23
25
*/
24
26
25
27
/**
26
28
* @typedef {Object} RegisterAPIMetadata
27
29
* @property {Object} customAttributes - The custom attributes for the registered entity.
28
30
* @property {Object} target - The options for the registered entity.
29
-
* @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.
30
32
* @property {string} target.id - The ID for the registered entity.
31
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.
* @returns {RegisterAPI} the api object to be returned from the register api method
45
42
*/
46
-
exportfunctionbuildRegisterApi(agentRef,target){
43
+
functionregister(agentRef,target,parent){
47
44
constattrs={}
48
45
warn(54,'newrelic.register')
49
46
50
47
target||={}
48
+
target.eventSource='MicroFrontendBrowserAgent'
51
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.
52
50
target.blocked=false
51
+
target.parent=parent||{}
53
52
54
53
/** @type {Function} a function that is set and reports when APIs are triggered -- warns the customer of the invalid state */
55
54
letinvalidApiResponse=()=>{}
@@ -85,6 +84,7 @@ export function buildRegisterApi (agentRef, target) {
0 commit comments