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
@@ -29,7 +29,7 @@ export function getRegisteredTargetsFromId (id, agentRef) {
29
29
}
30
30
31
31
/**
32
-
* Returns the registered target(s) associated with a given filename if found in the resource timing API during registration. Returns an empty array if not found.
32
+
* Returns the registered target(s) associated with a given filename if found in the resource timing API during registration. Returns an empty array if no target is found.
/** if there's no target, but we are in v2 mode, this means the data belongs to the container agent */
55
55
if(!target){
@@ -63,22 +63,36 @@ export function getVersion2Attributes (target, aggregateInstance) {
63
63
}
64
64
65
65
/**
66
-
* Returns the attributes used for duplicating data in version 2 of the harvest endpoint. If not valid for duplication, returns an empty object.
66
+
* Returns the attributes used for duplicating data in version 2 of the harvest endpoint.
67
+
* If not valid for duplication, returns an empty object.
68
+
* @note BEST PRACTICE - Caller should call shouldDuplicate() before utilizing this method to determine if duplication attributes should be added to the event.
* Determines if an event should be duplicated for a given target and aggregate instance. This is used to determine if duplication attributes should be added to an event and if the event should be sent to the soft nav feature for evaluation.
80
+
* @note This method is intended to be used in conjunction with getVersion2DuplicationAttributes and should be called before it to determine if duplication attributes should be added to an event.
* @param {*} aggregateInstance The aggregate instance calling the method. This is needed to check if duplication is enabled and if the harvest endpoint version supports it.
83
+
* @returns {boolean} returns true if the event should be duplicated for the target, false otherwise
@@ -90,5 +104,17 @@ export function findTargetsFromStackTrace (agentRef) {
90
104
}catch(err){
91
105
// Silent catch to prevent errors from propagating
92
106
}
107
+
if(!targets.length)targets.push(undefined)// if we can't find any targets from the stack trace, return an array with undefined to signify the container agent is the target
93
108
returntargets
94
109
}
110
+
111
+
/**
112
+
* Determines if the aggregate instance supports version 2 of the harvest endpoint. Nearly all the V2 logic "depends" on
113
+
* the harvest endpoint version, so this is the main gatekeeper method for whether or not V2 logic should be executed across the
114
+
* various functions in this module.
115
+
* @param {*} aggregateInstance The aggregate instance to check.
116
+
* @returns {boolean} Returns true if the aggregate instance supports version 2, false otherwise.
@@ -55,9 +56,10 @@ export function createWrapperWithEmitter (emitter, always) {
55
56
* @param {function|object} getContext - The function or object that will serve as the 'this' context for handlers of events emitted by this wrapper.
56
57
* @param {string} methodName - The name of the method being wrapped.
57
58
* @param {boolean} bubble - If true, emitted events should also bubble up to the old emitter upon which the `emitter` in the current scope was based (if it defines one).
59
+
* @param {boolean} [evaluateStack] - If true, the wrapper will attempt to evaluate the stack of the executed wrapped function to find targets of the execution (ex. the MFE source of a console.log).
0 commit comments