@adobe/alloy 2.21.0-beta.1 → 2.21.0-beta.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.
Files changed (87) hide show
  1. package/LICENSE_BANNER +9 -0
  2. package/babel.config.cjs +93 -0
  3. package/libEs5/components/ActivityCollector/attachClickActivityCollector.js +4 -0
  4. package/libEs5/components/ActivityCollector/configValidators.js +17 -2
  5. package/libEs5/components/ActivityCollector/createClickActivityStorage.js +35 -0
  6. package/libEs5/components/ActivityCollector/createClickedElementProperties.js +215 -0
  7. package/libEs5/components/ActivityCollector/createGetClickedElementProperties.js +64 -0
  8. package/libEs5/components/ActivityCollector/createInjectClickedElementProperties.js +70 -0
  9. package/libEs5/components/ActivityCollector/createRecallAndInjectClickedElementProperties.js +46 -0
  10. package/libEs5/components/ActivityCollector/{createLinkClick.js → createStorePageViewProperties.js} +6 -21
  11. package/libEs5/components/ActivityCollector/getLinkName.js +9 -24
  12. package/libEs5/components/ActivityCollector/getLinkRegion.js +2 -2
  13. package/libEs5/components/ActivityCollector/index.js +54 -19
  14. package/libEs5/components/ActivityCollector/utils/activityMapExtensionEnabled.js +20 -0
  15. package/libEs5/components/ActivityCollector/utils/createTransientStorage.js +28 -0
  16. package/libEs5/components/ActivityCollector/utils/determineLinkType.js +28 -0
  17. package/libEs5/components/ActivityCollector/utils/dom/elementHasClickHandler.js +17 -0
  18. package/libEs5/components/ActivityCollector/utils/dom/extractDomain.js +22 -0
  19. package/libEs5/components/ActivityCollector/utils/dom/findClickableElement.js +28 -0
  20. package/libEs5/components/ActivityCollector/utils/dom/getAbsoluteUrlFromAnchorElement.js +42 -0
  21. package/libEs5/components/ActivityCollector/utils/dom/isButtonSubmitElement.js +17 -0
  22. package/libEs5/components/ActivityCollector/utils/dom/isDownloadLink.js +28 -0
  23. package/libEs5/components/ActivityCollector/utils/dom/isExitLink.js +25 -0
  24. package/libEs5/components/ActivityCollector/utils/dom/isInputSubmitElement.js +28 -0
  25. package/libEs5/components/ActivityCollector/utils/dom/isSupportedAnchorElement.js +20 -0
  26. package/libEs5/components/ActivityCollector/utils/dom/isSupportedTextNode.js +30 -0
  27. package/libEs5/components/ActivityCollector/utils/hasPageName.js +21 -0
  28. package/libEs5/components/ActivityCollector/utils/isDifferentDomains.js +20 -0
  29. package/libEs5/components/ActivityCollector/utils/trimQueryFromUrl.js +25 -0
  30. package/libEs5/components/ActivityCollector/utils/truncateWhiteSpace.js +24 -0
  31. package/libEs5/components/ActivityCollector/utils/urlStartsWithScheme.js +17 -0
  32. package/libEs5/constants/libraryVersion.js +1 -1
  33. package/libEs5/constants/sessionDataKeys.js +15 -0
  34. package/libEs5/core/componentCreators.js +4 -0
  35. package/libEs5/core/config/createCoreConfigs.js +1 -1
  36. package/libEs5/standalone.js +18 -0
  37. package/libEs5/utils/validation/createDeprecatedValidator.js +8 -23
  38. package/libEs5/utils/validation/createRenamedValidator.js +44 -0
  39. package/libEs5/utils/validation/index.js +7 -3
  40. package/libEs6/components/ActivityCollector/attachClickActivityCollector.js +4 -0
  41. package/libEs6/components/ActivityCollector/configValidators.js +17 -2
  42. package/libEs6/components/ActivityCollector/createClickActivityStorage.js +34 -0
  43. package/libEs6/components/ActivityCollector/createClickedElementProperties.js +218 -0
  44. package/libEs6/components/ActivityCollector/createGetClickedElementProperties.js +69 -0
  45. package/libEs6/components/ActivityCollector/createInjectClickedElementProperties.js +69 -0
  46. package/libEs6/components/ActivityCollector/createRecallAndInjectClickedElementProperties.js +45 -0
  47. package/libEs6/components/ActivityCollector/{createLinkClick.js → createStorePageViewProperties.js} +7 -22
  48. package/libEs6/components/ActivityCollector/getLinkName.js +2 -16
  49. package/libEs6/components/ActivityCollector/getLinkRegion.js +1 -1
  50. package/libEs6/components/ActivityCollector/index.js +50 -14
  51. package/libEs6/components/ActivityCollector/utils/activityMapExtensionEnabled.js +14 -0
  52. package/libEs6/components/ActivityCollector/utils/createTransientStorage.js +26 -0
  53. package/libEs6/components/ActivityCollector/utils/determineLinkType.js +26 -0
  54. package/libEs6/components/ActivityCollector/utils/dom/elementHasClickHandler.js +15 -0
  55. package/libEs6/components/ActivityCollector/utils/dom/extractDomain.js +20 -0
  56. package/libEs6/components/ActivityCollector/utils/dom/findClickableElement.js +26 -0
  57. package/libEs6/components/ActivityCollector/utils/dom/getAbsoluteUrlFromAnchorElement.js +42 -0
  58. package/libEs6/components/ActivityCollector/utils/dom/isButtonSubmitElement.js +15 -0
  59. package/libEs6/components/ActivityCollector/utils/dom/isDownloadLink.js +26 -0
  60. package/libEs6/components/ActivityCollector/utils/dom/isExitLink.js +23 -0
  61. package/libEs6/components/ActivityCollector/utils/dom/isInputSubmitElement.js +26 -0
  62. package/libEs6/components/ActivityCollector/utils/dom/isSupportedAnchorElement.js +18 -0
  63. package/libEs6/components/ActivityCollector/utils/dom/isSupportedTextNode.js +27 -0
  64. package/libEs6/components/ActivityCollector/utils/hasPageName.js +19 -0
  65. package/libEs6/components/ActivityCollector/utils/isDifferentDomains.js +18 -0
  66. package/libEs6/components/ActivityCollector/utils/trimQueryFromUrl.js +23 -0
  67. package/libEs6/components/ActivityCollector/utils/truncateWhiteSpace.js +22 -0
  68. package/libEs6/components/ActivityCollector/utils/urlStartsWithScheme.js +15 -0
  69. package/libEs6/constants/libraryVersion.js +1 -1
  70. package/libEs6/constants/sessionDataKeys.js +12 -0
  71. package/libEs6/core/componentCreators.js +8 -0
  72. package/libEs6/core/config/createCoreConfigs.js +1 -1
  73. package/libEs6/standalone.js +16 -0
  74. package/libEs6/utils/validation/createDeprecatedValidator.js +7 -20
  75. package/libEs6/utils/validation/createRenamedValidator.js +37 -0
  76. package/libEs6/utils/validation/index.js +7 -3
  77. package/package.json +35 -29
  78. package/rollup.config.js +164 -0
  79. package/scripts/alloyBuilder.js +215 -0
  80. package/scripts/helpers/alloyComponents.js +63 -0
  81. package/scripts/helpers/conditionalBuildBabelPlugin.js +57 -0
  82. package/scripts/helpers/versionBabelPlugin.js +43 -0
  83. package/libEs5/components/ActivityCollector/createGetLinkDetails.js +0 -68
  84. package/libEs5/components/ActivityCollector/utils.js +0 -104
  85. package/libEs6/components/ActivityCollector/createGetLinkDetails.js +0 -70
  86. package/libEs6/components/ActivityCollector/utils.js +0 -104
  87. package/scripts/build-alloy.js +0 -125
package/LICENSE_BANNER ADDED
@@ -0,0 +1,9 @@
1
+ Copyright 2019 Adobe. All rights reserved.
2
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
3
+ you may not use this file except in compliance with the License. You may obtain a copy
4
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
5
+
6
+ Unless required by applicable law or agreed to in writing, software distributed under
7
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
8
+ OF ANY KIND, either express or implied. See the License for the specific language
9
+ governing permissions and limitations under the License.
@@ -0,0 +1,93 @@
1
+ /*
2
+ Copyright 2021 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+
13
+ /*
14
+ * This file is used in 4 scenarios:
15
+ * 1. Building files specified in rollup.config.js
16
+ * 2. Building libEs5/ files when publishing to NPM
17
+ * 3. Building libEs6/ files when publishing to NPM
18
+ * 4. Testcafe compiling clientFunctions. Unfortunately, there is no configuration I've found
19
+ * to tell Testcafe not to use this file.
20
+ *
21
+ * Environments:
22
+ * "rollup" - Used for rollup.config.js
23
+ * "npmEs5" - Used for building libEs5 files when publishing to NPM
24
+ * "npmEs6" - Used for building libEs6 files when publishing to NPM
25
+ */
26
+
27
+ const targets = {
28
+ browsers: [
29
+ "last 2 Chrome versions",
30
+ "last 2 Firefox versions",
31
+ "last 2 Safari versions",
32
+ "last 2 Edge versions",
33
+ "Explorer >= 10",
34
+ ],
35
+ };
36
+
37
+ const transformTemplateLiteralsPlugin = [
38
+ "@babel/plugin-transform-template-literals",
39
+ {
40
+ loose: true,
41
+ },
42
+ ];
43
+ const versionPlugin = [
44
+ "./scripts/helpers/versionBabelPlugin",
45
+ { cwd: __dirname },
46
+ ];
47
+
48
+ const transformModulesCommonjsPlugin = [
49
+ "@babel/plugin-transform-modules-commonjs",
50
+ {
51
+ strict: true,
52
+ noInterop: true,
53
+ },
54
+ ];
55
+
56
+ const npmIgnoreFiles = ["src/baseCode.js"];
57
+
58
+ module.exports = {
59
+ env: {
60
+ rollup: {
61
+ presets: [
62
+ [
63
+ "@babel/preset-env",
64
+ {
65
+ modules: false,
66
+ targets,
67
+ },
68
+ ],
69
+ ],
70
+ plugins: [transformTemplateLiteralsPlugin, versionPlugin],
71
+ },
72
+ npmEs5: {
73
+ presets: [
74
+ [
75
+ "@babel/preset-env",
76
+ {
77
+ targets,
78
+ },
79
+ ],
80
+ ],
81
+ ignore: npmIgnoreFiles,
82
+ plugins: [
83
+ transformTemplateLiteralsPlugin,
84
+ versionPlugin,
85
+ transformModulesCommonjsPlugin,
86
+ ],
87
+ },
88
+ npmEs6: {
89
+ ignore: npmIgnoreFiles,
90
+ plugins: [versionPlugin],
91
+ },
92
+ },
93
+ };
@@ -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
- onBeforeLinkClickSend: (0, _index.callback)(),
21
- downloadLinkQualifier: downloadLinkQualifier
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
+ c: {
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 c = data.__adobe.analytics.c;
70
+ if (c && c.a && c.a.activitymap) {
71
+ // Set the properties if they exists
72
+ var _c$a$activitymap = c.a.activitymap,
73
+ page = _c$a$activitymap.page,
74
+ link = _c$a$activitymap.link,
75
+ _region = _c$a$activitymap.region,
76
+ pageIDType = _c$a$activitymap.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.setUserData(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.setUserData(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
+ };
@@ -2,7 +2,7 @@
2
2
 
3
3
  exports.default = void 0;
4
4
  /*
5
- Copyright 2022 Adobe. All rights reserved.
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 getLinkDetails = _ref.getLinkDetails,
17
- config = _ref.config,
18
- logger = _ref.logger;
19
- var clickCollectionEnabled = config.clickCollectionEnabled;
20
- if (!clickCollectionEnabled) {
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
  };