@adobe/alloy 2.14.0 → 2.15.0-alpha.1
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/libEs5/components/ActivityCollector/attachClickActivityCollector.js +1 -1
- package/libEs5/components/ActivityCollector/configValidators.js +2 -1
- package/libEs5/components/ActivityCollector/createGetLinkDetails.js +79 -0
- package/libEs5/components/ActivityCollector/createLinkClick.js +22 -64
- package/libEs5/components/ActivityCollector/getLinkName.js +158 -0
- package/libEs5/components/ActivityCollector/getLinkRegion.js +76 -0
- package/libEs5/components/ActivityCollector/index.js +43 -4
- package/libEs5/components/ActivityCollector/utils.js +52 -2
- package/libEs5/components/Audiences/injectProcessDestinations.js +1 -3
- package/libEs5/components/Personalization/createClickStorage.js +4 -2
- package/libEs5/components/Personalization/createExecuteDecisions.js +8 -2
- package/libEs5/components/Personalization/createOnClickHandler.js +4 -2
- package/libEs5/components/Personalization/dom-actions/clicks/collectClicks.js +57 -6
- package/libEs5/components/Personalization/event.js +12 -2
- package/libEs5/constants/libraryVersion.js +1 -1
- package/libEs5/core/buildAndValidateConfig.js +33 -21
- package/libEs5/core/componentCreators.js +4 -0
- package/libEs6/components/ActivityCollector/attachClickActivityCollector.js +1 -1
- package/libEs6/components/ActivityCollector/configValidators.js +3 -2
- package/libEs6/components/ActivityCollector/createGetLinkDetails.js +77 -0
- package/libEs6/components/ActivityCollector/createLinkClick.js +24 -64
- package/libEs6/components/ActivityCollector/getLinkName.js +151 -0
- package/libEs6/components/ActivityCollector/getLinkRegion.js +68 -0
- package/libEs6/components/ActivityCollector/index.js +39 -4
- package/libEs6/components/ActivityCollector/utils.js +43 -1
- package/libEs6/components/Audiences/injectProcessDestinations.js +1 -3
- package/libEs6/components/Personalization/createClickStorage.js +4 -2
- package/libEs6/components/Personalization/createExecuteDecisions.js +6 -2
- package/libEs6/components/Personalization/createOnClickHandler.js +5 -2
- package/libEs6/components/Personalization/dom-actions/clicks/collectClicks.js +50 -6
- package/libEs6/components/Personalization/event.js +13 -3
- package/libEs6/constants/libraryVersion.js +1 -1
- package/libEs6/core/buildAndValidateConfig.js +19 -2
- package/libEs6/core/componentCreators.js +4 -0
- package/package.json +3 -3
|
@@ -5,7 +5,7 @@ exports.default = void 0;
|
|
|
5
5
|
var _utils = require("../../utils");
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
|
-
Copyright
|
|
8
|
+
Copyright 2022 Adobe. All rights reserved.
|
|
9
9
|
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
10
10
|
you may not use this file except in compliance with the License. You may obtain a copy
|
|
11
11
|
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
@@ -17,6 +17,7 @@ governing permissions and limitations under the License.
|
|
|
17
17
|
*/
|
|
18
18
|
var _default = {
|
|
19
19
|
clickCollectionEnabled: (0, _validation.boolean)().default(true),
|
|
20
|
-
downloadLinkQualifier: (0, _validation.string)().regexp().default("\\.(exe|zip|wav|mp3|mov|mpg|avi|wmv|pdf|doc|docx|xls|xlsx|ppt|pptx)$")
|
|
20
|
+
downloadLinkQualifier: (0, _validation.string)().regexp().default("\\.(exe|zip|wav|mp3|mov|mpg|avi|wmv|pdf|doc|docx|xls|xlsx|ppt|pptx)$"),
|
|
21
|
+
onBeforeLinkClickSend: (0, _validation.callback)()
|
|
21
22
|
};
|
|
22
23
|
exports.default = _default;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
Copyright 2022 Adobe. All rights reserved.
|
|
7
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
governing permissions and limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
var _default = function _default(_ref) {
|
|
17
|
+
var window = _ref.window,
|
|
18
|
+
getLinkName = _ref.getLinkName,
|
|
19
|
+
getLinkRegion = _ref.getLinkRegion,
|
|
20
|
+
getAbsoluteUrlFromAnchorElement = _ref.getAbsoluteUrlFromAnchorElement,
|
|
21
|
+
findSupportedAnchorElement = _ref.findSupportedAnchorElement,
|
|
22
|
+
determineLinkType = _ref.determineLinkType;
|
|
23
|
+
return function (_ref2) {
|
|
24
|
+
var targetElement = _ref2.targetElement,
|
|
25
|
+
config = _ref2.config,
|
|
26
|
+
logger = _ref2.logger;
|
|
27
|
+
var anchorElement = findSupportedAnchorElement(targetElement);
|
|
28
|
+
|
|
29
|
+
if (!anchorElement) {
|
|
30
|
+
logger.info("This link click event is not triggered because the HTML element is not an anchor.");
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
var linkUrl = getAbsoluteUrlFromAnchorElement(window, anchorElement);
|
|
35
|
+
|
|
36
|
+
if (!linkUrl) {
|
|
37
|
+
logger.info("This link click event is not triggered because the HTML element doesn't have an URL.");
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
var linkType = determineLinkType(window, config, linkUrl, anchorElement);
|
|
42
|
+
var linkRegion = getLinkRegion(anchorElement);
|
|
43
|
+
var linkName = getLinkName(anchorElement);
|
|
44
|
+
var onBeforeLinkClickSend = config.onBeforeLinkClickSend;
|
|
45
|
+
var options = {
|
|
46
|
+
xdm: {
|
|
47
|
+
eventType: "web.webinteraction.linkClicks",
|
|
48
|
+
web: {
|
|
49
|
+
webInteraction: {
|
|
50
|
+
name: linkName,
|
|
51
|
+
region: linkRegion,
|
|
52
|
+
type: linkType,
|
|
53
|
+
URL: linkUrl,
|
|
54
|
+
linkClicks: {
|
|
55
|
+
value: 1
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
data: {},
|
|
61
|
+
clickedElement: targetElement
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
if (!onBeforeLinkClickSend) {
|
|
65
|
+
return options;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
var shouldEventBeTracked = onBeforeLinkClickSend(options);
|
|
69
|
+
|
|
70
|
+
if (shouldEventBeTracked !== false) {
|
|
71
|
+
return options;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
logger.info("This link click event is not triggered because it was canceled in onBeforeLinkClickSend.");
|
|
75
|
+
return undefined;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
exports.default = _default;
|
|
@@ -2,10 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
exports.default = void 0;
|
|
4
4
|
|
|
5
|
-
var _utils = require("./utils");
|
|
6
|
-
|
|
7
5
|
/*
|
|
8
|
-
Copyright
|
|
6
|
+
Copyright 2022 Adobe. All rights reserved.
|
|
9
7
|
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
10
8
|
you may not use this file except in compliance with the License. You may obtain a copy
|
|
11
9
|
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
@@ -15,71 +13,31 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
|
|
|
15
13
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
16
14
|
governing permissions and limitations under the License.
|
|
17
15
|
*/
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
var _default = function _default(_ref) {
|
|
17
|
+
var getLinkDetails = _ref.getLinkDetails,
|
|
18
|
+
config = _ref.config,
|
|
19
|
+
logger = _ref.logger;
|
|
20
|
+
var clickCollectionEnabled = config.clickCollectionEnabled;
|
|
21
|
+
|
|
22
|
+
if (!clickCollectionEnabled) {
|
|
23
|
+
return function () {
|
|
24
|
+
return undefined;
|
|
25
|
+
};
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
return
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return node;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
node = node.parentNode;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return null;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
var _default = function _default(window, config) {
|
|
45
|
-
return function (event, targetElement) {
|
|
46
|
-
var clickCollectionEnabled = config.clickCollectionEnabled;
|
|
47
|
-
|
|
48
|
-
if (!clickCollectionEnabled) {
|
|
49
|
-
return;
|
|
50
|
-
} // Search parent elements for an anchor element
|
|
51
|
-
// TODO: Replace with generic DOM tool that can fetch configured properties
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
var anchorElement = findSupportedAnchorElement(targetElement);
|
|
55
|
-
|
|
56
|
-
if (!anchorElement) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
var linkUrl = (0, _utils.getAbsoluteUrlFromAnchorElement)(window, anchorElement);
|
|
28
|
+
return function (_ref2) {
|
|
29
|
+
var targetElement = _ref2.targetElement,
|
|
30
|
+
event = _ref2.event;
|
|
31
|
+
var linkDetails = getLinkDetails({
|
|
32
|
+
targetElement: targetElement,
|
|
33
|
+
config: config,
|
|
34
|
+
logger: logger
|
|
35
|
+
});
|
|
61
36
|
|
|
62
|
-
if (
|
|
63
|
-
|
|
37
|
+
if (linkDetails) {
|
|
38
|
+
event.mergeXdm(linkDetails.xdm);
|
|
39
|
+
event.setUserData(linkDetails.data);
|
|
64
40
|
}
|
|
65
|
-
|
|
66
|
-
var linkType = determineLinkType(window, config, linkUrl, anchorElement); // TODO: Update link name from the clicked element context
|
|
67
|
-
|
|
68
|
-
var linkName = "Link Click";
|
|
69
|
-
event.documentMayUnload();
|
|
70
|
-
event.mergeXdm({
|
|
71
|
-
eventType: "web.webinteraction.linkClicks",
|
|
72
|
-
web: {
|
|
73
|
-
webInteraction: {
|
|
74
|
-
name: linkName,
|
|
75
|
-
type: linkType,
|
|
76
|
-
URL: linkUrl,
|
|
77
|
-
linkClicks: {
|
|
78
|
-
value: 1
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
41
|
};
|
|
84
42
|
};
|
|
85
43
|
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
|
|
5
|
+
var _utils = require("./utils");
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
Copyright 2022 Adobe. All rights reserved.
|
|
9
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
11
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
14
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
15
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
16
|
+
governing permissions and limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
var unsupportedNodeNames = /^(SCRIPT|STYLE|LINK|CANVAS|NOSCRIPT|#COMMENT)$/i;
|
|
19
|
+
/**
|
|
20
|
+
* Determines if a node qualifies as a supported link text node.
|
|
21
|
+
* @param {*} node Node to determine support for.
|
|
22
|
+
* @returns {boolean}
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
var isSupportedTextNode = function isSupportedTextNode(node) {
|
|
26
|
+
if (node && node.nodeName) {
|
|
27
|
+
if (node.nodeName.match(unsupportedNodeNames)) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return true;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Orders and returns specified node and its child nodes in arrays of supported
|
|
36
|
+
* and unsupported nodes.
|
|
37
|
+
* @param {*} node The node to extract supported and unsupported nodes from.
|
|
38
|
+
* @returns {{supportedNodes: Array, includesUnsupportedNodes: boolean}} Node support object.
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
var extractSupportedNodes = function extractSupportedNodes(node) {
|
|
43
|
+
var supportedNodes = [];
|
|
44
|
+
var includesUnsupportedNodes = false;
|
|
45
|
+
|
|
46
|
+
if (isSupportedTextNode(node)) {
|
|
47
|
+
supportedNodes.push(node);
|
|
48
|
+
|
|
49
|
+
if (node.childNodes) {
|
|
50
|
+
var childNodes = Array.prototype.slice.call(node.childNodes);
|
|
51
|
+
childNodes.forEach(function (childNode) {
|
|
52
|
+
var nodes = extractSupportedNodes(childNode);
|
|
53
|
+
supportedNodes = supportedNodes.concat(nodes.supportedNodes);
|
|
54
|
+
includesUnsupportedNodes = includesUnsupportedNodes || nodes.includesUnsupportedNodes;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
includesUnsupportedNodes = true;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
supportedNodes: supportedNodes,
|
|
63
|
+
includesUnsupportedNodes: includesUnsupportedNodes
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Returns the value of a node attribute.
|
|
68
|
+
* @param {*} node The node holding the attribute.
|
|
69
|
+
* @param {string} attributeName The name of the attribute.
|
|
70
|
+
* @param {string} nodeName Optional node name constraint.
|
|
71
|
+
* @returns {string} Attribute value or undefined.
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
var getNodeAttributeValue = function getNodeAttributeValue(node, attributeName, nodeName) {
|
|
76
|
+
var attributeValue;
|
|
77
|
+
|
|
78
|
+
if (!nodeName || nodeName === node.nodeName.toUpperCase()) {
|
|
79
|
+
attributeValue = node.getAttribute(attributeName);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return attributeValue;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Extracts the children supported nodes attributes map
|
|
86
|
+
* @param {*} nodes The nodes array holding the children nodes.
|
|
87
|
+
* The returned map contains the supported not empty children attributes values.
|
|
88
|
+
* */
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
var getChildrenAttributes = function getChildrenAttributes(nodes) {
|
|
92
|
+
var attributes = {
|
|
93
|
+
texts: []
|
|
94
|
+
};
|
|
95
|
+
nodes.supportedNodes.forEach(function (supportedNode) {
|
|
96
|
+
if (supportedNode.getAttribute) {
|
|
97
|
+
if (!attributes.alt) {
|
|
98
|
+
attributes.alt = (0, _utils.truncateWhiteSpace)(supportedNode.getAttribute("alt"));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (!attributes.title) {
|
|
102
|
+
attributes.title = (0, _utils.truncateWhiteSpace)(supportedNode.getAttribute("title"));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (!attributes.inputValue) {
|
|
106
|
+
attributes.inputValue = (0, _utils.truncateWhiteSpace)(getNodeAttributeValue(supportedNode, "value", "INPUT"));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (!attributes.imgSrc) {
|
|
110
|
+
attributes.imgSrc = (0, _utils.truncateWhiteSpace)(getNodeAttributeValue(supportedNode, "src", "IMG"));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (supportedNode.nodeValue) {
|
|
115
|
+
attributes.texts.push(supportedNode.nodeValue);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
return attributes;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Extracts a link-name from a given node.
|
|
122
|
+
*
|
|
123
|
+
* The returned link-name is set to one of the following (in order of priority):
|
|
124
|
+
*
|
|
125
|
+
* 1. Clicked node innerText
|
|
126
|
+
* 2. Clicked node textContent
|
|
127
|
+
* 3. Clicked node and its child nodes nodeValue appended together.
|
|
128
|
+
* 4. Clicked node alt attribute or node descendant alt attribute.
|
|
129
|
+
* Whichever is found first.
|
|
130
|
+
* 5. Clicked node text attribute or node descendant text attribute.
|
|
131
|
+
* Whichever is found first.
|
|
132
|
+
* 6. Clicked node INPUT descendant value attribute.
|
|
133
|
+
* Whichever is found first.
|
|
134
|
+
* 7. Clicked node IMG descendant src attribute.
|
|
135
|
+
* Whichever is found first.
|
|
136
|
+
*
|
|
137
|
+
* @param {*} node The node to find link text for.
|
|
138
|
+
* @returns {string} link-name or an empty string if not link-name is found.
|
|
139
|
+
*/
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
var _default = function _default(node) {
|
|
143
|
+
var nodeText = (0, _utils.truncateWhiteSpace)(node.innerText || node.textContent);
|
|
144
|
+
var nodes = extractSupportedNodes(node); // if contains unsupported nodes we want children node attributes
|
|
145
|
+
|
|
146
|
+
if (!nodeText || nodes.includesUnsupportedNodes) {
|
|
147
|
+
var attributesMap = getChildrenAttributes(nodes);
|
|
148
|
+
nodeText = (0, _utils.truncateWhiteSpace)(attributesMap.texts.join(""));
|
|
149
|
+
|
|
150
|
+
if (!nodeText) {
|
|
151
|
+
nodeText = attributesMap.alt || attributesMap.title || attributesMap.inputValue || attributesMap.imgSrc;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return nodeText || "";
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
exports.default = _default;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
|
|
5
|
+
var _utils = require("./utils");
|
|
6
|
+
|
|
7
|
+
var _utils2 = require("../../utils");
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
Copyright 2022 Adobe. All rights reserved.
|
|
11
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
13
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
|
|
15
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
16
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
17
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
18
|
+
governing permissions and limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
var semanticElements = /^(HEADER|MAIN|FOOTER|NAV)$/i;
|
|
21
|
+
|
|
22
|
+
var getAriaRegionLabel = function getAriaRegionLabel(node) {
|
|
23
|
+
var regionLabel;
|
|
24
|
+
|
|
25
|
+
if (node.role === "region" && (0, _utils2.isNonEmptyString)(node["aria-label"])) {
|
|
26
|
+
regionLabel = node["aria-label"];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return regionLabel;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
var getSectionNodeName = function getSectionNodeName(node) {
|
|
33
|
+
var nodeName;
|
|
34
|
+
|
|
35
|
+
if (node && node.nodeName) {
|
|
36
|
+
if (node.nodeName.match(semanticElements)) {
|
|
37
|
+
nodeName = node.nodeName;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return nodeName;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Extracts a node link-region.
|
|
45
|
+
*
|
|
46
|
+
* The link-region is determined by traversing up the DOM
|
|
47
|
+
* looking for a region that is determined in order of priority:
|
|
48
|
+
*
|
|
49
|
+
* 1. element.id
|
|
50
|
+
* 2. Aria region label
|
|
51
|
+
* 3. Semantic element name
|
|
52
|
+
* 4. BODY (if no other link-region is found).
|
|
53
|
+
*
|
|
54
|
+
* @param {*} node The node to find link region for.
|
|
55
|
+
* @returns {string} link-region.
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
var _default = function _default(node) {
|
|
60
|
+
var linkParentNode = node.parentNode;
|
|
61
|
+
var regionName;
|
|
62
|
+
|
|
63
|
+
while (linkParentNode) {
|
|
64
|
+
regionName = (0, _utils.truncateWhiteSpace)(linkParentNode.id || getAriaRegionLabel(linkParentNode) || getSectionNodeName(linkParentNode));
|
|
65
|
+
|
|
66
|
+
if (regionName) {
|
|
67
|
+
return regionName;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
linkParentNode = linkParentNode.parentNode;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return "BODY";
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
exports.default = _default;
|
|
@@ -8,6 +8,14 @@ var _configValidators = require("./configValidators");
|
|
|
8
8
|
|
|
9
9
|
var _createLinkClick = require("./createLinkClick");
|
|
10
10
|
|
|
11
|
+
var _createGetLinkDetails = require("./createGetLinkDetails");
|
|
12
|
+
|
|
13
|
+
var _getLinkName = require("./getLinkName");
|
|
14
|
+
|
|
15
|
+
var _getLinkRegion = require("./getLinkRegion");
|
|
16
|
+
|
|
17
|
+
var _utils = require("./utils");
|
|
18
|
+
|
|
11
19
|
/*
|
|
12
20
|
Copyright 2019 Adobe. All rights reserved.
|
|
13
21
|
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -19,17 +27,30 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
|
|
|
19
27
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
20
28
|
governing permissions and limitations under the License.
|
|
21
29
|
*/
|
|
30
|
+
var _getLinkDetails = (0, _createGetLinkDetails.default)({
|
|
31
|
+
window: window,
|
|
32
|
+
getLinkName: _getLinkName.default,
|
|
33
|
+
getLinkRegion: _getLinkRegion.default,
|
|
34
|
+
getAbsoluteUrlFromAnchorElement: _utils.getAbsoluteUrlFromAnchorElement,
|
|
35
|
+
findSupportedAnchorElement: _utils.findSupportedAnchorElement,
|
|
36
|
+
determineLinkType: _utils.determineLinkType
|
|
37
|
+
});
|
|
38
|
+
|
|
22
39
|
var createActivityCollector = function createActivityCollector(_ref) {
|
|
23
40
|
var config = _ref.config,
|
|
24
41
|
eventManager = _ref.eventManager,
|
|
25
|
-
handleError = _ref.handleError
|
|
26
|
-
|
|
42
|
+
handleError = _ref.handleError,
|
|
43
|
+
logger = _ref.logger;
|
|
44
|
+
var linkClick = (0, _createLinkClick.default)({
|
|
45
|
+
getLinkDetails: _getLinkDetails,
|
|
46
|
+
config: config,
|
|
47
|
+
logger: logger
|
|
48
|
+
});
|
|
27
49
|
return {
|
|
28
50
|
lifecycle: {
|
|
29
51
|
onComponentsRegistered: function onComponentsRegistered(tools) {
|
|
30
52
|
var lifecycle = tools.lifecycle;
|
|
31
53
|
(0, _attachClickActivityCollector.default)({
|
|
32
|
-
config: config,
|
|
33
54
|
eventManager: eventManager,
|
|
34
55
|
lifecycle: lifecycle,
|
|
35
56
|
handleError: handleError
|
|
@@ -38,7 +59,10 @@ var createActivityCollector = function createActivityCollector(_ref) {
|
|
|
38
59
|
onClick: function onClick(_ref2) {
|
|
39
60
|
var event = _ref2.event,
|
|
40
61
|
clickedElement = _ref2.clickedElement;
|
|
41
|
-
linkClick(
|
|
62
|
+
linkClick({
|
|
63
|
+
targetElement: clickedElement,
|
|
64
|
+
event: event
|
|
65
|
+
});
|
|
42
66
|
}
|
|
43
67
|
}
|
|
44
68
|
};
|
|
@@ -46,5 +70,20 @@ var createActivityCollector = function createActivityCollector(_ref) {
|
|
|
46
70
|
|
|
47
71
|
createActivityCollector.namespace = "ActivityCollector";
|
|
48
72
|
createActivityCollector.configValidators = _configValidators.default;
|
|
73
|
+
|
|
74
|
+
createActivityCollector.buildOnInstanceConfiguredExtraParams = function (_ref3) {
|
|
75
|
+
var config = _ref3.config,
|
|
76
|
+
logger = _ref3.logger;
|
|
77
|
+
return {
|
|
78
|
+
getLinkDetails: function getLinkDetails(targetElement) {
|
|
79
|
+
return _getLinkDetails({
|
|
80
|
+
targetElement: targetElement,
|
|
81
|
+
config: config,
|
|
82
|
+
logger: logger
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
|
|
49
88
|
var _default = createActivityCollector;
|
|
50
89
|
exports.default = _default;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
exports.urlStartsWithScheme = exports.isSupportedAnchorElement = exports.isExitLink = exports.isDownloadLink = exports.getAbsoluteUrlFromAnchorElement = void 0;
|
|
3
|
+
exports.urlStartsWithScheme = exports.truncateWhiteSpace = exports.isSupportedAnchorElement = exports.isExitLink = exports.isEmptyString = exports.isDownloadLink = exports.getAbsoluteUrlFromAnchorElement = exports.findSupportedAnchorElement = exports.determineLinkType = void 0;
|
|
4
4
|
|
|
5
5
|
/*
|
|
6
6
|
Copyright 2019 Adobe. All rights reserved.
|
|
@@ -78,5 +78,55 @@ var isExitLink = function isExitLink(window, linkUrl) {
|
|
|
78
78
|
|
|
79
79
|
return true;
|
|
80
80
|
};
|
|
81
|
+
/**
|
|
82
|
+
* Reduces repeated whitespace within a string. Whitespace surrounding the string
|
|
83
|
+
* is trimmed and any occurrence of whitespace within the string is replaced with
|
|
84
|
+
* a single space.
|
|
85
|
+
* @param {string} str String to be formatted.
|
|
86
|
+
* @returns {string} Formatted string.
|
|
87
|
+
*/
|
|
81
88
|
|
|
82
|
-
|
|
89
|
+
|
|
90
|
+
exports.isExitLink = isExitLink;
|
|
91
|
+
|
|
92
|
+
var truncateWhiteSpace = function truncateWhiteSpace(str) {
|
|
93
|
+
return str && str.replace(/\s+/g, " ").trim();
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
exports.truncateWhiteSpace = truncateWhiteSpace;
|
|
97
|
+
|
|
98
|
+
var isEmptyString = function isEmptyString(str) {
|
|
99
|
+
return !str || str.length === 0;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
exports.isEmptyString = isEmptyString;
|
|
103
|
+
|
|
104
|
+
var determineLinkType = function determineLinkType(window, config, linkUrl, clickedObj) {
|
|
105
|
+
var linkType = "other";
|
|
106
|
+
|
|
107
|
+
if (isDownloadLink(config.downloadLinkQualifier, linkUrl, clickedObj)) {
|
|
108
|
+
linkType = "download";
|
|
109
|
+
} else if (isExitLink(window, linkUrl)) {
|
|
110
|
+
linkType = "exit";
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return linkType;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
exports.determineLinkType = determineLinkType;
|
|
117
|
+
|
|
118
|
+
var findSupportedAnchorElement = function findSupportedAnchorElement(targetElement) {
|
|
119
|
+
var node = targetElement;
|
|
120
|
+
|
|
121
|
+
while (node) {
|
|
122
|
+
if (isSupportedAnchorElement(node)) {
|
|
123
|
+
return node;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
node = node.parentNode;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return null;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
exports.findSupportedAnchorElement = findSupportedAnchorElement;
|
|
@@ -48,11 +48,9 @@ var _default = function _default(_ref) {
|
|
|
48
48
|
return Promise.all(urlDestinations.map(function (urlDestination) {
|
|
49
49
|
return fireReferrerHideableImage(urlDestination.spec).then(function () {
|
|
50
50
|
logger.info(createResultLogMessage(urlDestination, true));
|
|
51
|
-
}).catch(function () {
|
|
52
|
-
// We intentionally do not throw an error if destinations fail. We
|
|
51
|
+
}).catch(function () {// We intentionally do not throw an error if destinations fail. We
|
|
53
52
|
// consider it a non-critical failure and therefore do not want it to
|
|
54
53
|
// reject the promise handed back to the customer.
|
|
55
|
-
logger.error(createResultLogMessage(urlDestination, false));
|
|
56
54
|
});
|
|
57
55
|
})).then(_utils.noop);
|
|
58
56
|
};
|
|
@@ -18,7 +18,8 @@ var metasToArray = function metasToArray(metas) {
|
|
|
18
18
|
return {
|
|
19
19
|
id: key,
|
|
20
20
|
scope: metas[key].scope,
|
|
21
|
-
scopeDetails: metas[key].scopeDetails
|
|
21
|
+
scopeDetails: metas[key].scopeDetails,
|
|
22
|
+
trackingLabel: metas[key].trackingLabel
|
|
22
23
|
};
|
|
23
24
|
});
|
|
24
25
|
};
|
|
@@ -33,7 +34,8 @@ var _default = function _default() {
|
|
|
33
34
|
|
|
34
35
|
clickStorage[value.selector][value.meta.id] = {
|
|
35
36
|
scope: value.meta.scope,
|
|
36
|
-
scopeDetails: value.meta.scopeDetails
|
|
37
|
+
scopeDetails: value.meta.scopeDetails,
|
|
38
|
+
trackingLabel: value.meta.trackingLabel
|
|
37
39
|
};
|
|
38
40
|
};
|
|
39
41
|
|
|
@@ -21,8 +21,14 @@ var identity = function identity(item) {
|
|
|
21
21
|
return item;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
+
var getItemMeta = function getItemMeta(item, decisionMeta) {
|
|
25
|
+
return item.characteristics && item.characteristics.trackingLabel ? (0, _utils.assign)({
|
|
26
|
+
trackingLabel: item.characteristics.trackingLabel
|
|
27
|
+
}, decisionMeta) : decisionMeta;
|
|
28
|
+
};
|
|
29
|
+
|
|
24
30
|
var buildActions = function buildActions(decision) {
|
|
25
|
-
var
|
|
31
|
+
var decisionMeta = {
|
|
26
32
|
id: decision.id,
|
|
27
33
|
scope: decision.scope,
|
|
28
34
|
scopeDetails: decision.scopeDetails
|
|
@@ -31,7 +37,7 @@ var buildActions = function buildActions(decision) {
|
|
|
31
37
|
return (0, _utils.assign)({
|
|
32
38
|
type: DEFAULT_ACTION_TYPE
|
|
33
39
|
}, item.data, {
|
|
34
|
-
meta:
|
|
40
|
+
meta: getItemMeta(item, decisionMeta)
|
|
35
41
|
});
|
|
36
42
|
});
|
|
37
43
|
};
|
|
@@ -33,7 +33,9 @@ var _default = function _default(_ref) {
|
|
|
33
33
|
var selectors = getClickSelectors();
|
|
34
34
|
|
|
35
35
|
if ((0, _utils.isNonEmptyArray)(selectors)) {
|
|
36
|
-
var
|
|
36
|
+
var _collectClicks = collectClicks(clickedElement, selectors, getClickMetasBySelector),
|
|
37
|
+
decisionsMeta = _collectClicks.decisionsMeta,
|
|
38
|
+
eventLabel = _collectClicks.eventLabel;
|
|
37
39
|
|
|
38
40
|
if ((0, _utils.isNonEmptyArray)(decisionsMeta)) {
|
|
39
41
|
var xdm = {
|
|
@@ -50,7 +52,7 @@ var _default = function _default(_ref) {
|
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
event.mergeXdm(xdm);
|
|
53
|
-
mergeDecisionsMeta(event, decisionsMeta, _propositionEventType.PropositionEventType.INTERACT);
|
|
55
|
+
mergeDecisionsMeta(event, decisionsMeta, _propositionEventType.PropositionEventType.INTERACT, eventLabel);
|
|
54
56
|
}
|
|
55
57
|
}
|
|
56
58
|
};
|