@adobe/alloy 2.21.0-beta.6 → 2.21.0
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 +4 -0
- package/libEs5/components/ActivityCollector/configValidators.js +17 -2
- package/libEs5/components/ActivityCollector/createClickActivityStorage.js +35 -0
- package/libEs5/components/ActivityCollector/createClickedElementProperties.js +215 -0
- package/libEs5/components/ActivityCollector/createGetClickedElementProperties.js +64 -0
- package/libEs5/components/ActivityCollector/createInjectClickedElementProperties.js +70 -0
- package/libEs5/components/ActivityCollector/createRecallAndInjectClickedElementProperties.js +46 -0
- package/libEs5/components/ActivityCollector/{createLinkClick.js → createStorePageViewProperties.js} +6 -21
- package/libEs5/components/ActivityCollector/getLinkName.js +9 -24
- package/libEs5/components/ActivityCollector/getLinkRegion.js +2 -2
- package/libEs5/components/ActivityCollector/index.js +54 -19
- package/libEs5/components/ActivityCollector/utils/activityMapExtensionEnabled.js +20 -0
- package/libEs5/components/ActivityCollector/utils/createTransientStorage.js +28 -0
- package/libEs5/components/ActivityCollector/utils/determineLinkType.js +28 -0
- package/libEs5/components/ActivityCollector/utils/dom/elementHasClickHandler.js +17 -0
- package/libEs5/components/ActivityCollector/utils/dom/extractDomain.js +22 -0
- package/libEs5/components/ActivityCollector/utils/dom/findClickableElement.js +28 -0
- package/libEs5/components/ActivityCollector/utils/dom/getAbsoluteUrlFromAnchorElement.js +42 -0
- package/libEs5/components/ActivityCollector/utils/dom/isButtonSubmitElement.js +17 -0
- package/libEs5/components/ActivityCollector/utils/dom/isDownloadLink.js +28 -0
- package/libEs5/components/ActivityCollector/utils/dom/isExitLink.js +25 -0
- package/libEs5/components/ActivityCollector/utils/dom/isInputSubmitElement.js +28 -0
- package/libEs5/components/ActivityCollector/utils/dom/isSupportedAnchorElement.js +20 -0
- package/libEs5/components/ActivityCollector/utils/dom/isSupportedTextNode.js +30 -0
- package/libEs5/components/ActivityCollector/utils/hasPageName.js +21 -0
- package/libEs5/components/ActivityCollector/utils/isDifferentDomains.js +20 -0
- package/libEs5/components/ActivityCollector/utils/trimQueryFromUrl.js +25 -0
- package/libEs5/components/ActivityCollector/utils/truncateWhiteSpace.js +24 -0
- package/libEs5/components/ActivityCollector/utils/urlStartsWithScheme.js +17 -0
- package/libEs5/constants/libraryVersion.js +1 -1
- package/libEs5/constants/sessionDataKeys.js +15 -0
- package/libEs5/core/config/createCoreConfigs.js +1 -1
- package/libEs5/utils/validation/createDeprecatedValidator.js +8 -23
- package/libEs5/utils/validation/createRenamedValidator.js +44 -0
- package/libEs5/utils/validation/index.js +7 -3
- package/libEs6/components/ActivityCollector/attachClickActivityCollector.js +4 -0
- package/libEs6/components/ActivityCollector/configValidators.js +17 -2
- package/libEs6/components/ActivityCollector/createClickActivityStorage.js +34 -0
- package/libEs6/components/ActivityCollector/createClickedElementProperties.js +218 -0
- package/libEs6/components/ActivityCollector/createGetClickedElementProperties.js +69 -0
- package/libEs6/components/ActivityCollector/createInjectClickedElementProperties.js +69 -0
- package/libEs6/components/ActivityCollector/createRecallAndInjectClickedElementProperties.js +45 -0
- package/libEs6/components/ActivityCollector/{createLinkClick.js → createStorePageViewProperties.js} +7 -22
- package/libEs6/components/ActivityCollector/getLinkName.js +2 -16
- package/libEs6/components/ActivityCollector/getLinkRegion.js +1 -1
- package/libEs6/components/ActivityCollector/index.js +50 -14
- package/libEs6/components/ActivityCollector/utils/activityMapExtensionEnabled.js +14 -0
- package/libEs6/components/ActivityCollector/utils/createTransientStorage.js +26 -0
- package/libEs6/components/ActivityCollector/utils/determineLinkType.js +26 -0
- package/libEs6/components/ActivityCollector/utils/dom/elementHasClickHandler.js +15 -0
- package/libEs6/components/ActivityCollector/utils/dom/extractDomain.js +20 -0
- package/libEs6/components/ActivityCollector/utils/dom/findClickableElement.js +26 -0
- package/libEs6/components/ActivityCollector/utils/dom/getAbsoluteUrlFromAnchorElement.js +42 -0
- package/libEs6/components/ActivityCollector/utils/dom/isButtonSubmitElement.js +15 -0
- package/libEs6/components/ActivityCollector/utils/dom/isDownloadLink.js +26 -0
- package/libEs6/components/ActivityCollector/utils/dom/isExitLink.js +23 -0
- package/libEs6/components/ActivityCollector/utils/dom/isInputSubmitElement.js +26 -0
- package/libEs6/components/ActivityCollector/utils/dom/isSupportedAnchorElement.js +18 -0
- package/libEs6/components/ActivityCollector/utils/dom/isSupportedTextNode.js +27 -0
- package/libEs6/components/ActivityCollector/utils/hasPageName.js +19 -0
- package/libEs6/components/ActivityCollector/utils/isDifferentDomains.js +18 -0
- package/libEs6/components/ActivityCollector/utils/trimQueryFromUrl.js +23 -0
- package/libEs6/components/ActivityCollector/utils/truncateWhiteSpace.js +22 -0
- package/libEs6/components/ActivityCollector/utils/urlStartsWithScheme.js +15 -0
- package/libEs6/constants/libraryVersion.js +1 -1
- package/libEs6/constants/sessionDataKeys.js +12 -0
- package/libEs6/core/config/createCoreConfigs.js +1 -1
- package/libEs6/utils/validation/createDeprecatedValidator.js +7 -20
- package/libEs6/utils/validation/createRenamedValidator.js +37 -0
- package/libEs6/utils/validation/index.js +7 -3
- package/package.json +15 -16
- package/scripts/alloyBuilder.js +3 -1
- package/libEs5/components/ActivityCollector/createGetLinkDetails.js +0 -68
- package/libEs5/components/ActivityCollector/utils.js +0 -104
- package/libEs6/components/ActivityCollector/createGetLinkDetails.js +0 -70
- package/libEs6/components/ActivityCollector/utils.js +0 -104
|
@@ -19,6 +19,10 @@ var createClickHandler = function createClickHandler(_ref) {
|
|
|
19
19
|
lifecycle = _ref.lifecycle,
|
|
20
20
|
handleError = _ref.handleError;
|
|
21
21
|
return function (clickEvent) {
|
|
22
|
+
// Ignore repropagated clicks from AppMeasurement
|
|
23
|
+
if (clickEvent.s_fe) {
|
|
24
|
+
return Promise.resolve();
|
|
25
|
+
}
|
|
22
26
|
// TODO: Consider safeguarding from the same object being clicked multiple times in rapid succession?
|
|
23
27
|
var clickedElement = clickEvent.target;
|
|
24
28
|
var event = eventManager.createEvent();
|
|
@@ -17,6 +17,21 @@ governing permissions and limitations under the License.
|
|
|
17
17
|
var downloadLinkQualifier = exports.downloadLinkQualifier = (0, _index.string)().regexp().default("\\.(exe|zip|wav|mp3|mov|mpg|avi|wmv|pdf|doc|docx|xls|xlsx|ppt|pptx)$");
|
|
18
18
|
var _default = exports.default = (0, _index.objectOf)({
|
|
19
19
|
clickCollectionEnabled: (0, _index.boolean)().default(true),
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
clickCollection: (0, _index.objectOf)({
|
|
21
|
+
internalLinkEnabled: (0, _index.boolean)().default(true),
|
|
22
|
+
externalLinkEnabled: (0, _index.boolean)().default(true),
|
|
23
|
+
downloadLinkEnabled: (0, _index.boolean)().default(true),
|
|
24
|
+
// TODO: Consider moving downloadLinkQualifier here.
|
|
25
|
+
sessionStorageEnabled: (0, _index.boolean)().default(false),
|
|
26
|
+
eventGroupingEnabled: (0, _index.boolean)().default(false),
|
|
27
|
+
filterClickProperties: (0, _index.callback)()
|
|
28
|
+
}).default({
|
|
29
|
+
internalLinkEnabled: true,
|
|
30
|
+
externalLinkEnabled: true,
|
|
31
|
+
downloadLinkEnabled: true,
|
|
32
|
+
sessionStorageEnabled: false,
|
|
33
|
+
eventGroupingEnabled: false
|
|
34
|
+
}),
|
|
35
|
+
downloadLinkQualifier: downloadLinkQualifier,
|
|
36
|
+
onBeforeLinkClickSend: (0, _index.callback)().deprecated('The field "onBeforeLinkClickSend" has been deprecated. Use "clickCollection.filterClickDetails" instead.')
|
|
22
37
|
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
var _sessionDataKeys = require("../../constants/sessionDataKeys.js");
|
|
5
|
+
/*
|
|
6
|
+
Copyright 2024 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 = exports.default = function _default(_ref) {
|
|
17
|
+
var storage = _ref.storage;
|
|
18
|
+
return {
|
|
19
|
+
save: function save(data) {
|
|
20
|
+
var jsonData = JSON.stringify(data);
|
|
21
|
+
storage.setItem(_sessionDataKeys.CLICK_ACTIVITY_DATA, jsonData);
|
|
22
|
+
},
|
|
23
|
+
load: function load() {
|
|
24
|
+
var jsonData = null;
|
|
25
|
+
var data = storage.getItem(_sessionDataKeys.CLICK_ACTIVITY_DATA);
|
|
26
|
+
if (data) {
|
|
27
|
+
jsonData = JSON.parse(data);
|
|
28
|
+
}
|
|
29
|
+
return jsonData;
|
|
30
|
+
},
|
|
31
|
+
remove: function remove() {
|
|
32
|
+
storage.removeItem(_sessionDataKeys.CLICK_ACTIVITY_DATA);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
};
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
/*
|
|
5
|
+
Copyright 2022 Adobe. All rights reserved.
|
|
6
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
+
governing permissions and limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
var buildXdmFromClickedElementProperties = function buildXdmFromClickedElementProperties(props) {
|
|
17
|
+
return {
|
|
18
|
+
eventType: "web.webinteraction.linkClicks",
|
|
19
|
+
web: {
|
|
20
|
+
webInteraction: {
|
|
21
|
+
name: props.linkName,
|
|
22
|
+
region: props.linkRegion,
|
|
23
|
+
type: props.linkType,
|
|
24
|
+
URL: props.linkUrl,
|
|
25
|
+
linkClicks: {
|
|
26
|
+
value: 1
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
var buildDataFromClickedElementProperties = function buildDataFromClickedElementProperties(props) {
|
|
33
|
+
return {
|
|
34
|
+
__adobe: {
|
|
35
|
+
analytics: {
|
|
36
|
+
contextData: {
|
|
37
|
+
a: {
|
|
38
|
+
activitymap: {
|
|
39
|
+
page: props.pageName,
|
|
40
|
+
link: props.linkName,
|
|
41
|
+
region: props.linkRegion,
|
|
42
|
+
pageIDType: props.pageIDType
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
var populateClickedElementPropertiesFromOptions = function populateClickedElementPropertiesFromOptions(options, props) {
|
|
51
|
+
var xdm = options.xdm,
|
|
52
|
+
data = options.data,
|
|
53
|
+
clickedElement = options.clickedElement;
|
|
54
|
+
props.clickedElement = clickedElement;
|
|
55
|
+
if (xdm && xdm.web && xdm.web.webInteraction) {
|
|
56
|
+
var _xdm$web$webInteracti = xdm.web.webInteraction,
|
|
57
|
+
name = _xdm$web$webInteracti.name,
|
|
58
|
+
region = _xdm$web$webInteracti.region,
|
|
59
|
+
type = _xdm$web$webInteracti.type,
|
|
60
|
+
URL = _xdm$web$webInteracti.URL;
|
|
61
|
+
props.linkName = name;
|
|
62
|
+
props.linkRegion = region;
|
|
63
|
+
props.linkType = type;
|
|
64
|
+
props.linkUrl = URL;
|
|
65
|
+
}
|
|
66
|
+
// DATA has priority over XDM
|
|
67
|
+
/* eslint no-underscore-dangle: 0 */
|
|
68
|
+
if (data && data.__adobe && data.__adobe.analytics) {
|
|
69
|
+
var contextData = data.__adobe.analytics.contextData;
|
|
70
|
+
if (contextData && contextData.a && contextData.a.activitymap) {
|
|
71
|
+
// Set the properties if they exists
|
|
72
|
+
var _contextData$a$activi = contextData.a.activitymap,
|
|
73
|
+
page = _contextData$a$activi.page,
|
|
74
|
+
link = _contextData$a$activi.link,
|
|
75
|
+
_region = _contextData$a$activi.region,
|
|
76
|
+
pageIDType = _contextData$a$activi.pageIDType;
|
|
77
|
+
props.pageName = page || props.pageName;
|
|
78
|
+
props.linkName = link || props.linkName;
|
|
79
|
+
props.linkRegion = _region || props.linkRegion;
|
|
80
|
+
if (pageIDType !== undefined) {
|
|
81
|
+
props.pageIDType = pageIDType;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
var _default = exports.default = function _default() {
|
|
87
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
88
|
+
properties = _ref.properties,
|
|
89
|
+
logger = _ref.logger;
|
|
90
|
+
var props = properties || {};
|
|
91
|
+
var clickedElementProperties = {
|
|
92
|
+
get pageName() {
|
|
93
|
+
return props.pageName;
|
|
94
|
+
},
|
|
95
|
+
set pageName(value) {
|
|
96
|
+
props.pageName = value;
|
|
97
|
+
},
|
|
98
|
+
get linkName() {
|
|
99
|
+
return props.linkName;
|
|
100
|
+
},
|
|
101
|
+
set linkName(value) {
|
|
102
|
+
props.linkName = value;
|
|
103
|
+
},
|
|
104
|
+
get linkRegion() {
|
|
105
|
+
return props.linkRegion;
|
|
106
|
+
},
|
|
107
|
+
set linkRegion(value) {
|
|
108
|
+
props.linkRegion = value;
|
|
109
|
+
},
|
|
110
|
+
get linkType() {
|
|
111
|
+
return props.linkType;
|
|
112
|
+
},
|
|
113
|
+
set linkType(value) {
|
|
114
|
+
props.linkType = value;
|
|
115
|
+
},
|
|
116
|
+
get linkUrl() {
|
|
117
|
+
return props.linkUrl;
|
|
118
|
+
},
|
|
119
|
+
set linkUrl(value) {
|
|
120
|
+
props.linkUrl = value;
|
|
121
|
+
},
|
|
122
|
+
get pageIDType() {
|
|
123
|
+
return props.pageIDType;
|
|
124
|
+
},
|
|
125
|
+
set pageIDType(value) {
|
|
126
|
+
props.pageIDType = value;
|
|
127
|
+
},
|
|
128
|
+
get clickedElement() {
|
|
129
|
+
return props.clickedElement;
|
|
130
|
+
},
|
|
131
|
+
set clickedElement(value) {
|
|
132
|
+
props.clickedElement = value;
|
|
133
|
+
},
|
|
134
|
+
get properties() {
|
|
135
|
+
return {
|
|
136
|
+
pageName: props.pageName,
|
|
137
|
+
linkName: props.linkName,
|
|
138
|
+
linkRegion: props.linkRegion,
|
|
139
|
+
linkType: props.linkType,
|
|
140
|
+
linkUrl: props.linkUrl,
|
|
141
|
+
pageIDType: props.pageIDType
|
|
142
|
+
};
|
|
143
|
+
},
|
|
144
|
+
isValidLink: function isValidLink() {
|
|
145
|
+
return !!props.linkUrl && !!props.linkType && !!props.linkName && !!props.linkRegion;
|
|
146
|
+
},
|
|
147
|
+
isInternalLink: function isInternalLink() {
|
|
148
|
+
return this.isValidLink() && props.linkType === "other";
|
|
149
|
+
},
|
|
150
|
+
isValidActivityMapData: function isValidActivityMapData() {
|
|
151
|
+
return !!props.pageName && !!props.linkName && !!props.linkRegion && props.pageIDType !== undefined;
|
|
152
|
+
},
|
|
153
|
+
get xdm() {
|
|
154
|
+
if (props.filteredXdm) {
|
|
155
|
+
return props.filteredXdm;
|
|
156
|
+
}
|
|
157
|
+
return buildXdmFromClickedElementProperties(this);
|
|
158
|
+
},
|
|
159
|
+
get data() {
|
|
160
|
+
if (props.filteredData) {
|
|
161
|
+
return props.filteredData;
|
|
162
|
+
}
|
|
163
|
+
return buildDataFromClickedElementProperties(this);
|
|
164
|
+
},
|
|
165
|
+
applyPropertyFilter: function applyPropertyFilter(filter) {
|
|
166
|
+
if (filter && filter(props) === false) {
|
|
167
|
+
if (logger) {
|
|
168
|
+
logger.info("Clicked element properties were rejected by filter function: " + JSON.stringify(this.properties, null, 2));
|
|
169
|
+
}
|
|
170
|
+
props = {};
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
applyOptionsFilter: function applyOptionsFilter(filter) {
|
|
174
|
+
var opts = this.options;
|
|
175
|
+
if (opts && opts.clickedElement && (opts.xdm || opts.data)) {
|
|
176
|
+
// Properties are rejected if filter is explicitly false.
|
|
177
|
+
if (filter && filter(opts) === false) {
|
|
178
|
+
if (logger) {
|
|
179
|
+
logger.info("Clicked element properties were rejected by filter function: " + JSON.stringify(this.properties, null, 2));
|
|
180
|
+
}
|
|
181
|
+
this.options = undefined;
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
this.options = opts;
|
|
185
|
+
// This is just to ensure that any fields outside clicked element properties
|
|
186
|
+
// set by the user filter persists.
|
|
187
|
+
props.filteredXdm = opts.xdm;
|
|
188
|
+
props.filteredData = opts.data;
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
get options() {
|
|
192
|
+
var opts = {};
|
|
193
|
+
if (this.isValidLink()) {
|
|
194
|
+
opts.xdm = this.xdm;
|
|
195
|
+
}
|
|
196
|
+
if (this.isValidActivityMapData()) {
|
|
197
|
+
opts.data = this.data;
|
|
198
|
+
}
|
|
199
|
+
if (this.clickedElement) {
|
|
200
|
+
opts.clickedElement = this.clickedElement;
|
|
201
|
+
}
|
|
202
|
+
if (!opts.xdm && !opts.data) {
|
|
203
|
+
return undefined;
|
|
204
|
+
}
|
|
205
|
+
return opts;
|
|
206
|
+
},
|
|
207
|
+
set options(value) {
|
|
208
|
+
props = {};
|
|
209
|
+
if (value) {
|
|
210
|
+
populateClickedElementPropertiesFromOptions(value, props);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
return clickedElementProperties;
|
|
215
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
var _createClickedElementProperties = require("./createClickedElementProperties.js");
|
|
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 = exports.default = function _default(_ref) {
|
|
17
|
+
var window = _ref.window,
|
|
18
|
+
getLinkName = _ref.getLinkName,
|
|
19
|
+
getLinkRegion = _ref.getLinkRegion,
|
|
20
|
+
getAbsoluteUrlFromAnchorElement = _ref.getAbsoluteUrlFromAnchorElement,
|
|
21
|
+
findClickableElement = _ref.findClickableElement,
|
|
22
|
+
determineLinkType = _ref.determineLinkType;
|
|
23
|
+
return function (_ref2) {
|
|
24
|
+
var clickedElement = _ref2.clickedElement,
|
|
25
|
+
config = _ref2.config,
|
|
26
|
+
logger = _ref2.logger,
|
|
27
|
+
clickActivityStorage = _ref2.clickActivityStorage;
|
|
28
|
+
var optionsFilter = config.onBeforeLinkClickSend,
|
|
29
|
+
clickCollection = config.clickCollection;
|
|
30
|
+
var propertyFilter = clickCollection.filterClickDetails;
|
|
31
|
+
var elementProperties = (0, _createClickedElementProperties.default)({
|
|
32
|
+
logger: logger
|
|
33
|
+
});
|
|
34
|
+
if (clickedElement) {
|
|
35
|
+
var clickableElement = findClickableElement(clickedElement);
|
|
36
|
+
if (clickableElement) {
|
|
37
|
+
elementProperties.clickedElement = clickedElement;
|
|
38
|
+
elementProperties.linkUrl = getAbsoluteUrlFromAnchorElement(window, clickableElement);
|
|
39
|
+
elementProperties.linkType = determineLinkType(window, config, elementProperties.linkUrl, clickableElement);
|
|
40
|
+
elementProperties.linkRegion = getLinkRegion(clickableElement);
|
|
41
|
+
elementProperties.linkName = getLinkName(clickableElement);
|
|
42
|
+
elementProperties.pageIDType = 0;
|
|
43
|
+
elementProperties.pageName = window.location.href;
|
|
44
|
+
// Check if we have a page-name stored from an earlier page view event
|
|
45
|
+
var storedLinkData = clickActivityStorage.load();
|
|
46
|
+
if (storedLinkData && storedLinkData.pageName) {
|
|
47
|
+
elementProperties.pageName = storedLinkData.pageName;
|
|
48
|
+
// Perhaps pageIDType should be established after customer filter is applied
|
|
49
|
+
// Like if pageName starts with "http" then pageIDType = 0
|
|
50
|
+
elementProperties.pageIDType = 1;
|
|
51
|
+
}
|
|
52
|
+
// If defined, run user provided filter function
|
|
53
|
+
if (propertyFilter) {
|
|
54
|
+
// clickCollection.filterClickDetails
|
|
55
|
+
elementProperties.applyPropertyFilter(propertyFilter);
|
|
56
|
+
} else if (optionsFilter) {
|
|
57
|
+
// onBeforeLinkClickSend
|
|
58
|
+
elementProperties.applyOptionsFilter(optionsFilter);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return elementProperties;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
var _activityMapExtensionEnabled = require("./utils/activityMapExtensionEnabled.js");
|
|
5
|
+
var _isDifferentDomains = require("./utils/isDifferentDomains.js");
|
|
6
|
+
/*
|
|
7
|
+
Copyright 2022 Adobe. All rights reserved.
|
|
8
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
10
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
|
|
12
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
13
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
14
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
15
|
+
governing permissions and limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
var isDissallowedLinkType = function isDissallowedLinkType(clickCollection, linkType) {
|
|
19
|
+
return linkType && (linkType === "download" && !clickCollection.downloadLinkEnabled || linkType === "exit" && !clickCollection.externalLinkEnabled || linkType === "other" && !clickCollection.internalLinkEnabled);
|
|
20
|
+
};
|
|
21
|
+
var _default = exports.default = function _default(_ref) {
|
|
22
|
+
var config = _ref.config,
|
|
23
|
+
logger = _ref.logger,
|
|
24
|
+
getClickedElementProperties = _ref.getClickedElementProperties,
|
|
25
|
+
clickActivityStorage = _ref.clickActivityStorage;
|
|
26
|
+
var clickCollectionEnabled = config.clickCollectionEnabled,
|
|
27
|
+
clickCollection = config.clickCollection;
|
|
28
|
+
if (!clickCollectionEnabled) {
|
|
29
|
+
return function () {
|
|
30
|
+
return undefined;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return function (_ref2) {
|
|
34
|
+
var event = _ref2.event,
|
|
35
|
+
clickedElement = _ref2.clickedElement;
|
|
36
|
+
var elementProperties = getClickedElementProperties({
|
|
37
|
+
clickActivityStorage: clickActivityStorage,
|
|
38
|
+
clickedElement: clickedElement,
|
|
39
|
+
config: config,
|
|
40
|
+
logger: logger
|
|
41
|
+
});
|
|
42
|
+
var linkType = elementProperties.linkType;
|
|
43
|
+
// Avoid clicks to be collected for the ActivityMap interface
|
|
44
|
+
if ((0, _activityMapExtensionEnabled.default)()) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (elementProperties.isValidLink() && isDissallowedLinkType(clickCollection, linkType)) {
|
|
48
|
+
logger.info("Cancelling link click event due to clickCollection." + linkType + "LinkEnabled = false.");
|
|
49
|
+
} else if (
|
|
50
|
+
// Determine if element properties should be sent with event now, or be saved
|
|
51
|
+
// and grouped with a future page view event.
|
|
52
|
+
// Event grouping is not supported for the deprecated onBeforeLinkClickSend callback
|
|
53
|
+
// because only click properties is saved and not XDM and DATA (which could have been modified).
|
|
54
|
+
// However, if the filterClickDetails callback is available we group events because it takes
|
|
55
|
+
// priority over onBeforeLinkClickSend and only supports processing click properties.
|
|
56
|
+
elementProperties.isInternalLink() && clickCollection.eventGroupingEnabled && (!config.onBeforeLinkClickSend || clickCollection.filterClickDetails) && !(0, _isDifferentDomains.default)(window.location.hostname, elementProperties.linkUrl)) {
|
|
57
|
+
clickActivityStorage.save(elementProperties.properties);
|
|
58
|
+
} else if (elementProperties.isValidLink()) {
|
|
59
|
+
// Event will be sent
|
|
60
|
+
event.mergeXdm(elementProperties.xdm);
|
|
61
|
+
event.mergeData(elementProperties.data);
|
|
62
|
+
clickActivityStorage.save({
|
|
63
|
+
pageName: elementProperties.pageName,
|
|
64
|
+
pageIDType: elementProperties.pageIDType
|
|
65
|
+
});
|
|
66
|
+
} else if (elementProperties.isValidActivityMapData()) {
|
|
67
|
+
clickActivityStorage.save(elementProperties.properties);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
var _createClickedElementProperties = require("./createClickedElementProperties.js");
|
|
5
|
+
var _activityMapExtensionEnabled = require("./utils/activityMapExtensionEnabled.js");
|
|
6
|
+
/*
|
|
7
|
+
Copyright 2024 Adobe. All rights reserved.
|
|
8
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
10
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
|
|
12
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
13
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
14
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
15
|
+
governing permissions and limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
var _default = exports.default = function _default(_ref) {
|
|
18
|
+
var clickActivityStorage = _ref.clickActivityStorage;
|
|
19
|
+
return function (event) {
|
|
20
|
+
// Avoid clicks to be collected for the ActivityMap interface
|
|
21
|
+
if ((0, _activityMapExtensionEnabled.default)()) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
var properties = clickActivityStorage.load();
|
|
25
|
+
var elementProperties = (0, _createClickedElementProperties.default)({
|
|
26
|
+
properties: properties
|
|
27
|
+
});
|
|
28
|
+
if (elementProperties.isValidLink() || elementProperties.isValidActivityMapData()) {
|
|
29
|
+
if (elementProperties.isValidLink()) {
|
|
30
|
+
var xdm = elementProperties.xdm;
|
|
31
|
+
// Have to delete the eventType not to override the page view
|
|
32
|
+
delete xdm.eventType;
|
|
33
|
+
event.mergeXdm(xdm);
|
|
34
|
+
}
|
|
35
|
+
if (elementProperties.isValidActivityMapData()) {
|
|
36
|
+
event.mergeData(elementProperties.data);
|
|
37
|
+
}
|
|
38
|
+
// NOTE: We can't clear out all the storage here because we might still need to
|
|
39
|
+
// keep a page-name for multiple link-clicks (e.g. downloads) on the same page.
|
|
40
|
+
clickActivityStorage.save({
|
|
41
|
+
pageName: elementProperties.pageName,
|
|
42
|
+
pageIDType: elementProperties.pageIDType
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
};
|
package/libEs5/components/ActivityCollector/{createLinkClick.js → createStorePageViewProperties.js}
RENAMED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports.default = void 0;
|
|
4
4
|
/*
|
|
5
|
-
Copyright
|
|
5
|
+
Copyright 2024 Adobe. All rights reserved.
|
|
6
6
|
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
7
7
|
you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
8
|
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
@@ -13,26 +13,11 @@ OF ANY KIND, either express or implied. See the License for the specific languag
|
|
|
13
13
|
governing permissions and limitations under the License.
|
|
14
14
|
*/
|
|
15
15
|
var _default = exports.default = function _default(_ref) {
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return function () {
|
|
22
|
-
return undefined;
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
return function (_ref2) {
|
|
26
|
-
var targetElement = _ref2.targetElement,
|
|
27
|
-
event = _ref2.event;
|
|
28
|
-
var linkDetails = getLinkDetails({
|
|
29
|
-
targetElement: targetElement,
|
|
30
|
-
config: config,
|
|
31
|
-
logger: logger
|
|
16
|
+
var clickActivityStorage = _ref.clickActivityStorage;
|
|
17
|
+
return function (event) {
|
|
18
|
+
clickActivityStorage.save({
|
|
19
|
+
pageName: event.getContent().xdm.web.webPageDetails.name,
|
|
20
|
+
pageIDType: 1 // 1 = name, 0 = URL
|
|
32
21
|
});
|
|
33
|
-
if (linkDetails) {
|
|
34
|
-
event.mergeXdm(linkDetails.xdm);
|
|
35
|
-
event.setUserData(linkDetails.data);
|
|
36
|
-
}
|
|
37
22
|
};
|
|
38
23
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.default = void 0;
|
|
4
|
-
var
|
|
4
|
+
var _truncateWhiteSpace = require("./utils/truncateWhiteSpace.js");
|
|
5
|
+
var _isSupportedTextNode = require("./utils/dom/isSupportedTextNode.js");
|
|
5
6
|
/*
|
|
6
7
|
Copyright 2022 Adobe. All rights reserved.
|
|
7
8
|
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -14,22 +15,6 @@ OF ANY KIND, either express or implied. See the License for the specific languag
|
|
|
14
15
|
governing permissions and limitations under the License.
|
|
15
16
|
*/
|
|
16
17
|
|
|
17
|
-
var unsupportedNodeNames = /^(SCRIPT|STYLE|LINK|CANVAS|NOSCRIPT|#COMMENT)$/i;
|
|
18
|
-
|
|
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
|
-
var isSupportedTextNode = function isSupportedTextNode(node) {
|
|
25
|
-
if (node && node.nodeName) {
|
|
26
|
-
if (node.nodeName.match(unsupportedNodeNames)) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return true;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
18
|
/**
|
|
34
19
|
* Orders and returns specified node and its child nodes in arrays of supported
|
|
35
20
|
* and unsupported nodes.
|
|
@@ -39,7 +24,7 @@ var isSupportedTextNode = function isSupportedTextNode(node) {
|
|
|
39
24
|
var extractSupportedNodes = function extractSupportedNodes(node) {
|
|
40
25
|
var supportedNodes = [];
|
|
41
26
|
var includesUnsupportedNodes = false;
|
|
42
|
-
if (
|
|
27
|
+
if ((0, _isSupportedTextNode.default)(node)) {
|
|
43
28
|
supportedNodes.push(node);
|
|
44
29
|
if (node.childNodes) {
|
|
45
30
|
var childNodes = Array.prototype.slice.call(node.childNodes);
|
|
@@ -85,16 +70,16 @@ var getChildrenAttributes = function getChildrenAttributes(nodes) {
|
|
|
85
70
|
nodes.supportedNodes.forEach(function (supportedNode) {
|
|
86
71
|
if (supportedNode.getAttribute) {
|
|
87
72
|
if (!attributes.alt) {
|
|
88
|
-
attributes.alt = (0,
|
|
73
|
+
attributes.alt = (0, _truncateWhiteSpace.default)(supportedNode.getAttribute("alt"));
|
|
89
74
|
}
|
|
90
75
|
if (!attributes.title) {
|
|
91
|
-
attributes.title = (0,
|
|
76
|
+
attributes.title = (0, _truncateWhiteSpace.default)(supportedNode.getAttribute("title"));
|
|
92
77
|
}
|
|
93
78
|
if (!attributes.inputValue) {
|
|
94
|
-
attributes.inputValue = (0,
|
|
79
|
+
attributes.inputValue = (0, _truncateWhiteSpace.default)(getNodeAttributeValue(supportedNode, "value", "INPUT"));
|
|
95
80
|
}
|
|
96
81
|
if (!attributes.imgSrc) {
|
|
97
|
-
attributes.imgSrc = (0,
|
|
82
|
+
attributes.imgSrc = (0, _truncateWhiteSpace.default)(getNodeAttributeValue(supportedNode, "src", "IMG"));
|
|
98
83
|
}
|
|
99
84
|
}
|
|
100
85
|
if (supportedNode.nodeValue) {
|
|
@@ -125,12 +110,12 @@ var getChildrenAttributes = function getChildrenAttributes(nodes) {
|
|
|
125
110
|
* @returns {string} link-name or an empty string if not link-name is found.
|
|
126
111
|
*/
|
|
127
112
|
var _default = exports.default = function _default(node) {
|
|
128
|
-
var nodeText = (0,
|
|
113
|
+
var nodeText = (0, _truncateWhiteSpace.default)(node.innerText || node.textContent);
|
|
129
114
|
var nodes = extractSupportedNodes(node);
|
|
130
115
|
// if contains unsupported nodes we want children node attributes
|
|
131
116
|
if (!nodeText || nodes.includesUnsupportedNodes) {
|
|
132
117
|
var attributesMap = getChildrenAttributes(nodes);
|
|
133
|
-
nodeText = (0,
|
|
118
|
+
nodeText = (0, _truncateWhiteSpace.default)(attributesMap.texts.join(""));
|
|
134
119
|
if (!nodeText) {
|
|
135
120
|
nodeText = attributesMap.alt || attributesMap.title || attributesMap.inputValue || attributesMap.imgSrc;
|
|
136
121
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.default = void 0;
|
|
4
|
-
var
|
|
4
|
+
var _truncateWhiteSpace = require("./utils/truncateWhiteSpace.js");
|
|
5
5
|
var _index = require("../../utils/index.js");
|
|
6
6
|
/*
|
|
7
7
|
Copyright 2022 Adobe. All rights reserved.
|
|
@@ -51,7 +51,7 @@ var _default = exports.default = function _default(node) {
|
|
|
51
51
|
var linkParentNode = node.parentNode;
|
|
52
52
|
var regionName;
|
|
53
53
|
while (linkParentNode) {
|
|
54
|
-
regionName = (0,
|
|
54
|
+
regionName = (0, _truncateWhiteSpace.default)(linkParentNode.id || getAriaRegionLabel(linkParentNode) || getSectionNodeName(linkParentNode));
|
|
55
55
|
if (regionName) {
|
|
56
56
|
return regionName;
|
|
57
57
|
}
|