@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.
Files changed (76) hide show
  1. package/libEs5/components/ActivityCollector/attachClickActivityCollector.js +4 -0
  2. package/libEs5/components/ActivityCollector/configValidators.js +17 -2
  3. package/libEs5/components/ActivityCollector/createClickActivityStorage.js +35 -0
  4. package/libEs5/components/ActivityCollector/createClickedElementProperties.js +215 -0
  5. package/libEs5/components/ActivityCollector/createGetClickedElementProperties.js +64 -0
  6. package/libEs5/components/ActivityCollector/createInjectClickedElementProperties.js +70 -0
  7. package/libEs5/components/ActivityCollector/createRecallAndInjectClickedElementProperties.js +46 -0
  8. package/libEs5/components/ActivityCollector/{createLinkClick.js → createStorePageViewProperties.js} +6 -21
  9. package/libEs5/components/ActivityCollector/getLinkName.js +9 -24
  10. package/libEs5/components/ActivityCollector/getLinkRegion.js +2 -2
  11. package/libEs5/components/ActivityCollector/index.js +54 -19
  12. package/libEs5/components/ActivityCollector/utils/activityMapExtensionEnabled.js +20 -0
  13. package/libEs5/components/ActivityCollector/utils/createTransientStorage.js +28 -0
  14. package/libEs5/components/ActivityCollector/utils/determineLinkType.js +28 -0
  15. package/libEs5/components/ActivityCollector/utils/dom/elementHasClickHandler.js +17 -0
  16. package/libEs5/components/ActivityCollector/utils/dom/extractDomain.js +22 -0
  17. package/libEs5/components/ActivityCollector/utils/dom/findClickableElement.js +28 -0
  18. package/libEs5/components/ActivityCollector/utils/dom/getAbsoluteUrlFromAnchorElement.js +42 -0
  19. package/libEs5/components/ActivityCollector/utils/dom/isButtonSubmitElement.js +17 -0
  20. package/libEs5/components/ActivityCollector/utils/dom/isDownloadLink.js +28 -0
  21. package/libEs5/components/ActivityCollector/utils/dom/isExitLink.js +25 -0
  22. package/libEs5/components/ActivityCollector/utils/dom/isInputSubmitElement.js +28 -0
  23. package/libEs5/components/ActivityCollector/utils/dom/isSupportedAnchorElement.js +20 -0
  24. package/libEs5/components/ActivityCollector/utils/dom/isSupportedTextNode.js +30 -0
  25. package/libEs5/components/ActivityCollector/utils/hasPageName.js +21 -0
  26. package/libEs5/components/ActivityCollector/utils/isDifferentDomains.js +20 -0
  27. package/libEs5/components/ActivityCollector/utils/trimQueryFromUrl.js +25 -0
  28. package/libEs5/components/ActivityCollector/utils/truncateWhiteSpace.js +24 -0
  29. package/libEs5/components/ActivityCollector/utils/urlStartsWithScheme.js +17 -0
  30. package/libEs5/constants/libraryVersion.js +1 -1
  31. package/libEs5/constants/sessionDataKeys.js +15 -0
  32. package/libEs5/core/config/createCoreConfigs.js +1 -1
  33. package/libEs5/utils/validation/createDeprecatedValidator.js +8 -23
  34. package/libEs5/utils/validation/createRenamedValidator.js +44 -0
  35. package/libEs5/utils/validation/index.js +7 -3
  36. package/libEs6/components/ActivityCollector/attachClickActivityCollector.js +4 -0
  37. package/libEs6/components/ActivityCollector/configValidators.js +17 -2
  38. package/libEs6/components/ActivityCollector/createClickActivityStorage.js +34 -0
  39. package/libEs6/components/ActivityCollector/createClickedElementProperties.js +218 -0
  40. package/libEs6/components/ActivityCollector/createGetClickedElementProperties.js +69 -0
  41. package/libEs6/components/ActivityCollector/createInjectClickedElementProperties.js +69 -0
  42. package/libEs6/components/ActivityCollector/createRecallAndInjectClickedElementProperties.js +45 -0
  43. package/libEs6/components/ActivityCollector/{createLinkClick.js → createStorePageViewProperties.js} +7 -22
  44. package/libEs6/components/ActivityCollector/getLinkName.js +2 -16
  45. package/libEs6/components/ActivityCollector/getLinkRegion.js +1 -1
  46. package/libEs6/components/ActivityCollector/index.js +50 -14
  47. package/libEs6/components/ActivityCollector/utils/activityMapExtensionEnabled.js +14 -0
  48. package/libEs6/components/ActivityCollector/utils/createTransientStorage.js +26 -0
  49. package/libEs6/components/ActivityCollector/utils/determineLinkType.js +26 -0
  50. package/libEs6/components/ActivityCollector/utils/dom/elementHasClickHandler.js +15 -0
  51. package/libEs6/components/ActivityCollector/utils/dom/extractDomain.js +20 -0
  52. package/libEs6/components/ActivityCollector/utils/dom/findClickableElement.js +26 -0
  53. package/libEs6/components/ActivityCollector/utils/dom/getAbsoluteUrlFromAnchorElement.js +42 -0
  54. package/libEs6/components/ActivityCollector/utils/dom/isButtonSubmitElement.js +15 -0
  55. package/libEs6/components/ActivityCollector/utils/dom/isDownloadLink.js +26 -0
  56. package/libEs6/components/ActivityCollector/utils/dom/isExitLink.js +23 -0
  57. package/libEs6/components/ActivityCollector/utils/dom/isInputSubmitElement.js +26 -0
  58. package/libEs6/components/ActivityCollector/utils/dom/isSupportedAnchorElement.js +18 -0
  59. package/libEs6/components/ActivityCollector/utils/dom/isSupportedTextNode.js +27 -0
  60. package/libEs6/components/ActivityCollector/utils/hasPageName.js +19 -0
  61. package/libEs6/components/ActivityCollector/utils/isDifferentDomains.js +18 -0
  62. package/libEs6/components/ActivityCollector/utils/trimQueryFromUrl.js +23 -0
  63. package/libEs6/components/ActivityCollector/utils/truncateWhiteSpace.js +22 -0
  64. package/libEs6/components/ActivityCollector/utils/urlStartsWithScheme.js +15 -0
  65. package/libEs6/constants/libraryVersion.js +1 -1
  66. package/libEs6/constants/sessionDataKeys.js +12 -0
  67. package/libEs6/core/config/createCoreConfigs.js +1 -1
  68. package/libEs6/utils/validation/createDeprecatedValidator.js +7 -20
  69. package/libEs6/utils/validation/createRenamedValidator.js +37 -0
  70. package/libEs6/utils/validation/index.js +7 -3
  71. package/package.json +15 -16
  72. package/scripts/alloyBuilder.js +3 -1
  73. package/libEs5/components/ActivityCollector/createGetLinkDetails.js +0 -68
  74. package/libEs5/components/ActivityCollector/utils.js +0 -104
  75. package/libEs6/components/ActivityCollector/createGetLinkDetails.js +0 -70
  76. package/libEs6/components/ActivityCollector/utils.js +0 -104
@@ -1,17 +1,8 @@
1
1
  "use strict";
2
2
 
3
3
  exports.default = void 0;
4
- var _isObject = require("../isObject.js");
5
- var _utils = require("./utils.js");
6
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
7
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
8
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
9
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
10
- function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
11
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
12
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
13
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
14
- Copyright 2023 Adobe. All rights reserved.
4
+ /*
5
+ Copyright 2024 Adobe. All rights reserved.
15
6
  This file is licensed to you under the Apache License, Version 2.0 (the "License");
16
7
  you may not use this file except in compliance with the License. You may obtain a copy
17
8
  of the License at http://www.apache.org/licenses/LICENSE-2.0
@@ -21,24 +12,18 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
21
12
  OF ANY KIND, either express or implied. See the License for the specific language
22
13
  governing permissions and limitations under the License.
23
14
  */
24
- var _default = exports.default = function _default(oldField, oldSchema, newField) {
15
+ var _default = exports.default = function _default() {
16
+ var warning = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "This field has been deprecated";
25
17
  return function deprecated(value, path) {
26
- (0, _utils.assertValid)((0, _isObject.default)(value), value, path, "an object");
27
- var oldValue = value[oldField],
28
- newValue = value[newField],
29
- otherValues = _objectWithoutProperties(value, [oldField, newField].map(_toPropertyKey));
30
- var validatedOldValue = oldSchema(oldValue, path);
31
- if (validatedOldValue !== undefined) {
32
- var message = "The field '" + oldField + "' is deprecated. Use '" + newField + "' instead.";
18
+ var message = warning;
19
+ if (value !== undefined) {
33
20
  if (path) {
34
21
  message = "'" + path + "': " + message;
35
22
  }
36
- if (newValue !== undefined && newValue !== validatedOldValue) {
37
- throw new Error(message);
38
- } else if (this && this.logger) {
23
+ if (this && this.logger) {
39
24
  this.logger.warn(message);
40
25
  }
41
26
  }
42
- return _objectSpread(_defineProperty({}, newField, newValue || validatedOldValue), otherValues);
27
+ return value;
43
28
  };
44
29
  };
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ exports.default = void 0;
4
+ var _isObject = require("../isObject.js");
5
+ var _utils = require("./utils.js");
6
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
7
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
8
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
9
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
10
+ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
11
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
12
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
13
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
14
+ Copyright 2023 Adobe. All rights reserved.
15
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
16
+ you may not use this file except in compliance with the License. You may obtain a copy
17
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
18
+
19
+ Unless required by applicable law or agreed to in writing, software distributed under
20
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
21
+ OF ANY KIND, either express or implied. See the License for the specific language
22
+ governing permissions and limitations under the License.
23
+ */
24
+ var _default = exports.default = function _default(oldField, oldSchema, newField) {
25
+ return function deprecated(value, path) {
26
+ (0, _utils.assertValid)((0, _isObject.default)(value), value, path, "an object");
27
+ var oldValue = value[oldField],
28
+ newValue = value[newField],
29
+ otherValues = _objectWithoutProperties(value, [oldField, newField].map(_toPropertyKey));
30
+ var validatedOldValue = oldSchema(oldValue, path);
31
+ if (validatedOldValue !== undefined) {
32
+ var message = "The field '" + oldField + "' is deprecated. Use '" + newField + "' instead.";
33
+ if (path) {
34
+ message = "'" + path + "': " + message;
35
+ }
36
+ if (newValue !== undefined && newValue !== validatedOldValue) {
37
+ throw new Error(message);
38
+ } else if (this && this.logger) {
39
+ this.logger.warn(message);
40
+ }
41
+ }
42
+ return _objectSpread(_defineProperty({}, newField, newValue || validatedOldValue), otherValues);
43
+ };
44
+ };
@@ -4,6 +4,7 @@ exports.string = exports.objectOf = exports.number = exports.mapOfValues = expor
4
4
  var _utils = require("./utils.js");
5
5
  var _booleanValidator = require("./booleanValidator.js");
6
6
  var _callbackValidator = require("./callbackValidator.js");
7
+ var _createAnyOfValidator = require("./createAnyOfValidator.js");
7
8
  var _createArrayOfValidator = require("./createArrayOfValidator.js");
8
9
  var _createDefaultValidator = require("./createDefaultValidator.js");
9
10
  var _createDeprecatedValidator = require("./createDeprecatedValidator.js");
@@ -14,7 +15,7 @@ var _createMaximumValidator = require("./createMaximumValidator.js");
14
15
  var _createNoUnknownFieldsValidator = require("./createNoUnknownFieldsValidator.js");
15
16
  var _createNonEmptyValidator = require("./createNonEmptyValidator.js");
16
17
  var _createObjectOfValidator = require("./createObjectOfValidator.js");
17
- var _createAnyOfValidator = require("./createAnyOfValidator.js");
18
+ var _createRenamedValidator = require("./createRenamedValidator.js");
18
19
  var _createUniqueValidator = require("./createUniqueValidator.js");
19
20
  var _createUniqueItemsValidator = require("./createUniqueItemsValidator.js");
20
21
  var _domainValidator = require("./domainValidator.js");
@@ -110,6 +111,9 @@ base.default = function _default(defaultValue) {
110
111
  base.required = function required() {
111
112
  return (0, _utils.chain)(this, _requiredValidator.default);
112
113
  };
114
+ base.deprecated = function deprecated(message) {
115
+ return (0, _utils.chain)(this, (0, _createDeprecatedValidator.default)(message));
116
+ };
113
117
 
114
118
  // helper validators
115
119
  var domain = function domain() {
@@ -199,10 +203,10 @@ var createObjectOfAdditionalProperties = function createObjectOfAdditionalProper
199
203
  var newSchema = _objectSpread(_objectSpread({}, schema), otherObjectOfValidator.schema);
200
204
  return (0, _utils.nullSafeChain)(this, otherObjectOfValidator, createObjectOfAdditionalProperties(newSchema));
201
205
  },
202
- deprecated: function deprecated(oldField, oldSchema, newField) {
206
+ renamed: function renamed(oldField, oldSchema, newField) {
203
207
  // Run the deprecated validator first so that the deprecated field is removed
204
208
  // before the objectOf validator runs.
205
- return (0, _utils.reverseNullSafeChainJoinErrors)(this, (0, _createDeprecatedValidator.default)(oldField, oldSchema, newField));
209
+ return (0, _utils.reverseNullSafeChainJoinErrors)(this, (0, _createRenamedValidator.default)(oldField, oldSchema, newField));
206
210
  },
207
211
  schema: schema
208
212
  };
@@ -17,6 +17,10 @@ const createClickHandler = ({
17
17
  handleError
18
18
  }) => {
19
19
  return clickEvent => {
20
+ // Ignore repropagated clicks from AppMeasurement
21
+ if (clickEvent.s_fe) {
22
+ return Promise.resolve();
23
+ }
20
24
  // TODO: Consider safeguarding from the same object being clicked multiple times in rapid succession?
21
25
  const clickedElement = clickEvent.target;
22
26
  const event = eventManager.createEvent();
@@ -14,6 +14,21 @@ import { boolean, callback, objectOf, string } from "../../utils/validation/inde
14
14
  export const downloadLinkQualifier = string().regexp().default("\\.(exe|zip|wav|mp3|mov|mpg|avi|wmv|pdf|doc|docx|xls|xlsx|ppt|pptx)$");
15
15
  export default objectOf({
16
16
  clickCollectionEnabled: boolean().default(true),
17
- onBeforeLinkClickSend: callback(),
18
- downloadLinkQualifier
17
+ clickCollection: objectOf({
18
+ internalLinkEnabled: boolean().default(true),
19
+ externalLinkEnabled: boolean().default(true),
20
+ downloadLinkEnabled: boolean().default(true),
21
+ // TODO: Consider moving downloadLinkQualifier here.
22
+ sessionStorageEnabled: boolean().default(false),
23
+ eventGroupingEnabled: boolean().default(false),
24
+ filterClickProperties: callback()
25
+ }).default({
26
+ internalLinkEnabled: true,
27
+ externalLinkEnabled: true,
28
+ downloadLinkEnabled: true,
29
+ sessionStorageEnabled: false,
30
+ eventGroupingEnabled: false
31
+ }),
32
+ downloadLinkQualifier,
33
+ onBeforeLinkClickSend: callback().deprecated('The field "onBeforeLinkClickSend" has been deprecated. Use "clickCollection.filterClickDetails" instead.')
19
34
  });
@@ -0,0 +1,34 @@
1
+ /*
2
+ Copyright 2024 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
+ import { CLICK_ACTIVITY_DATA } from "../../constants/sessionDataKeys.js";
14
+ export default (({
15
+ storage
16
+ }) => {
17
+ return {
18
+ save: data => {
19
+ const jsonData = JSON.stringify(data);
20
+ storage.setItem(CLICK_ACTIVITY_DATA, jsonData);
21
+ },
22
+ load: () => {
23
+ let jsonData = null;
24
+ const data = storage.getItem(CLICK_ACTIVITY_DATA);
25
+ if (data) {
26
+ jsonData = JSON.parse(data);
27
+ }
28
+ return jsonData;
29
+ },
30
+ remove: () => {
31
+ storage.removeItem(CLICK_ACTIVITY_DATA);
32
+ }
33
+ };
34
+ });
@@ -0,0 +1,218 @@
1
+ /*
2
+ Copyright 2022 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
+ const buildXdmFromClickedElementProperties = props => {
14
+ return {
15
+ eventType: "web.webinteraction.linkClicks",
16
+ web: {
17
+ webInteraction: {
18
+ name: props.linkName,
19
+ region: props.linkRegion,
20
+ type: props.linkType,
21
+ URL: props.linkUrl,
22
+ linkClicks: {
23
+ value: 1
24
+ }
25
+ }
26
+ }
27
+ };
28
+ };
29
+ const buildDataFromClickedElementProperties = props => {
30
+ return {
31
+ __adobe: {
32
+ analytics: {
33
+ contextData: {
34
+ a: {
35
+ activitymap: {
36
+ page: props.pageName,
37
+ link: props.linkName,
38
+ region: props.linkRegion,
39
+ pageIDType: props.pageIDType
40
+ }
41
+ }
42
+ }
43
+ }
44
+ }
45
+ };
46
+ };
47
+ const populateClickedElementPropertiesFromOptions = (options, props) => {
48
+ const {
49
+ xdm,
50
+ data,
51
+ clickedElement
52
+ } = options;
53
+ props.clickedElement = clickedElement;
54
+ if (xdm && xdm.web && xdm.web.webInteraction) {
55
+ const {
56
+ name,
57
+ region,
58
+ type,
59
+ URL
60
+ } = xdm.web.webInteraction;
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
+ const {
70
+ contextData
71
+ } = data.__adobe.analytics;
72
+ if (contextData && contextData.a && contextData.a.activitymap) {
73
+ // Set the properties if they exists
74
+ const {
75
+ page,
76
+ link,
77
+ region,
78
+ pageIDType
79
+ } = contextData.a.activitymap;
80
+ props.pageName = page || props.pageName;
81
+ props.linkName = link || props.linkName;
82
+ props.linkRegion = region || props.linkRegion;
83
+ if (pageIDType !== undefined) {
84
+ props.pageIDType = pageIDType;
85
+ }
86
+ }
87
+ }
88
+ };
89
+ export default (({
90
+ properties,
91
+ logger
92
+ } = {}) => {
93
+ let props = properties || {};
94
+ const clickedElementProperties = {
95
+ get pageName() {
96
+ return props.pageName;
97
+ },
98
+ set pageName(value) {
99
+ props.pageName = value;
100
+ },
101
+ get linkName() {
102
+ return props.linkName;
103
+ },
104
+ set linkName(value) {
105
+ props.linkName = value;
106
+ },
107
+ get linkRegion() {
108
+ return props.linkRegion;
109
+ },
110
+ set linkRegion(value) {
111
+ props.linkRegion = value;
112
+ },
113
+ get linkType() {
114
+ return props.linkType;
115
+ },
116
+ set linkType(value) {
117
+ props.linkType = value;
118
+ },
119
+ get linkUrl() {
120
+ return props.linkUrl;
121
+ },
122
+ set linkUrl(value) {
123
+ props.linkUrl = value;
124
+ },
125
+ get pageIDType() {
126
+ return props.pageIDType;
127
+ },
128
+ set pageIDType(value) {
129
+ props.pageIDType = value;
130
+ },
131
+ get clickedElement() {
132
+ return props.clickedElement;
133
+ },
134
+ set clickedElement(value) {
135
+ props.clickedElement = value;
136
+ },
137
+ get properties() {
138
+ return {
139
+ pageName: props.pageName,
140
+ linkName: props.linkName,
141
+ linkRegion: props.linkRegion,
142
+ linkType: props.linkType,
143
+ linkUrl: props.linkUrl,
144
+ pageIDType: props.pageIDType
145
+ };
146
+ },
147
+ isValidLink() {
148
+ return !!props.linkUrl && !!props.linkType && !!props.linkName && !!props.linkRegion;
149
+ },
150
+ isInternalLink() {
151
+ return this.isValidLink() && props.linkType === "other";
152
+ },
153
+ isValidActivityMapData() {
154
+ return !!props.pageName && !!props.linkName && !!props.linkRegion && props.pageIDType !== undefined;
155
+ },
156
+ get xdm() {
157
+ if (props.filteredXdm) {
158
+ return props.filteredXdm;
159
+ }
160
+ return buildXdmFromClickedElementProperties(this);
161
+ },
162
+ get data() {
163
+ if (props.filteredData) {
164
+ return props.filteredData;
165
+ }
166
+ return buildDataFromClickedElementProperties(this);
167
+ },
168
+ applyPropertyFilter(filter) {
169
+ if (filter && filter(props) === false) {
170
+ if (logger) {
171
+ logger.info(`Clicked element properties were rejected by filter function: ${JSON.stringify(this.properties, null, 2)}`);
172
+ }
173
+ props = {};
174
+ }
175
+ },
176
+ applyOptionsFilter(filter) {
177
+ const opts = this.options;
178
+ if (opts && opts.clickedElement && (opts.xdm || opts.data)) {
179
+ // Properties are rejected if filter is explicitly false.
180
+ if (filter && filter(opts) === false) {
181
+ if (logger) {
182
+ logger.info(`Clicked element properties were rejected by filter function: ${JSON.stringify(this.properties, null, 2)}`);
183
+ }
184
+ this.options = undefined;
185
+ return;
186
+ }
187
+ this.options = opts;
188
+ // This is just to ensure that any fields outside clicked element properties
189
+ // set by the user filter persists.
190
+ props.filteredXdm = opts.xdm;
191
+ props.filteredData = opts.data;
192
+ }
193
+ },
194
+ get options() {
195
+ const opts = {};
196
+ if (this.isValidLink()) {
197
+ opts.xdm = this.xdm;
198
+ }
199
+ if (this.isValidActivityMapData()) {
200
+ opts.data = this.data;
201
+ }
202
+ if (this.clickedElement) {
203
+ opts.clickedElement = this.clickedElement;
204
+ }
205
+ if (!opts.xdm && !opts.data) {
206
+ return undefined;
207
+ }
208
+ return opts;
209
+ },
210
+ set options(value) {
211
+ props = {};
212
+ if (value) {
213
+ populateClickedElementPropertiesFromOptions(value, props);
214
+ }
215
+ }
216
+ };
217
+ return clickedElementProperties;
218
+ });
@@ -0,0 +1,69 @@
1
+ /*
2
+ Copyright 2022 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
+ import createClickedElementProperties from "./createClickedElementProperties.js";
14
+ export default (({
15
+ window,
16
+ getLinkName,
17
+ getLinkRegion,
18
+ getAbsoluteUrlFromAnchorElement,
19
+ findClickableElement,
20
+ determineLinkType
21
+ }) => {
22
+ return ({
23
+ clickedElement,
24
+ config,
25
+ logger,
26
+ clickActivityStorage
27
+ }) => {
28
+ const {
29
+ onBeforeLinkClickSend: optionsFilter,
30
+ // Deprecated
31
+ clickCollection
32
+ } = config;
33
+ const {
34
+ filterClickDetails: propertyFilter
35
+ } = clickCollection;
36
+ const elementProperties = createClickedElementProperties({
37
+ logger
38
+ });
39
+ if (clickedElement) {
40
+ const clickableElement = findClickableElement(clickedElement);
41
+ if (clickableElement) {
42
+ elementProperties.clickedElement = clickedElement;
43
+ elementProperties.linkUrl = getAbsoluteUrlFromAnchorElement(window, clickableElement);
44
+ elementProperties.linkType = determineLinkType(window, config, elementProperties.linkUrl, clickableElement);
45
+ elementProperties.linkRegion = getLinkRegion(clickableElement);
46
+ elementProperties.linkName = getLinkName(clickableElement);
47
+ elementProperties.pageIDType = 0;
48
+ elementProperties.pageName = window.location.href;
49
+ // Check if we have a page-name stored from an earlier page view event
50
+ const storedLinkData = clickActivityStorage.load();
51
+ if (storedLinkData && storedLinkData.pageName) {
52
+ elementProperties.pageName = storedLinkData.pageName;
53
+ // Perhaps pageIDType should be established after customer filter is applied
54
+ // Like if pageName starts with "http" then pageIDType = 0
55
+ elementProperties.pageIDType = 1;
56
+ }
57
+ // If defined, run user provided filter function
58
+ if (propertyFilter) {
59
+ // clickCollection.filterClickDetails
60
+ elementProperties.applyPropertyFilter(propertyFilter);
61
+ } else if (optionsFilter) {
62
+ // onBeforeLinkClickSend
63
+ elementProperties.applyOptionsFilter(optionsFilter);
64
+ }
65
+ }
66
+ }
67
+ return elementProperties;
68
+ };
69
+ });
@@ -0,0 +1,69 @@
1
+ /*
2
+ Copyright 2022 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
+ import activityMapExtensionEnabled from "./utils/activityMapExtensionEnabled.js";
14
+ import isDifferentDomains from "./utils/isDifferentDomains.js";
15
+ const isDissallowedLinkType = (clickCollection, linkType) => {
16
+ return linkType && (linkType === "download" && !clickCollection.downloadLinkEnabled || linkType === "exit" && !clickCollection.externalLinkEnabled || linkType === "other" && !clickCollection.internalLinkEnabled);
17
+ };
18
+ export default (({
19
+ config,
20
+ logger,
21
+ getClickedElementProperties,
22
+ clickActivityStorage
23
+ }) => {
24
+ const {
25
+ clickCollectionEnabled,
26
+ clickCollection
27
+ } = config;
28
+ if (!clickCollectionEnabled) {
29
+ return () => undefined;
30
+ }
31
+ return ({
32
+ event,
33
+ clickedElement
34
+ }) => {
35
+ const elementProperties = getClickedElementProperties({
36
+ clickActivityStorage,
37
+ clickedElement,
38
+ config,
39
+ logger
40
+ });
41
+ const linkType = elementProperties.linkType;
42
+ // Avoid clicks to be collected for the ActivityMap interface
43
+ if (activityMapExtensionEnabled()) {
44
+ return;
45
+ }
46
+ if (elementProperties.isValidLink() && isDissallowedLinkType(clickCollection, linkType)) {
47
+ logger.info(`Cancelling link click event due to clickCollection.${linkType}LinkEnabled = false.`);
48
+ } else if (
49
+ // Determine if element properties should be sent with event now, or be saved
50
+ // and grouped with a future page view event.
51
+ // Event grouping is not supported for the deprecated onBeforeLinkClickSend callback
52
+ // because only click properties is saved and not XDM and DATA (which could have been modified).
53
+ // However, if the filterClickDetails callback is available we group events because it takes
54
+ // priority over onBeforeLinkClickSend and only supports processing click properties.
55
+ elementProperties.isInternalLink() && clickCollection.eventGroupingEnabled && (!config.onBeforeLinkClickSend || clickCollection.filterClickDetails) && !isDifferentDomains(window.location.hostname, elementProperties.linkUrl)) {
56
+ clickActivityStorage.save(elementProperties.properties);
57
+ } else if (elementProperties.isValidLink()) {
58
+ // Event will be sent
59
+ event.mergeXdm(elementProperties.xdm);
60
+ event.mergeData(elementProperties.data);
61
+ clickActivityStorage.save({
62
+ pageName: elementProperties.pageName,
63
+ pageIDType: elementProperties.pageIDType
64
+ });
65
+ } else if (elementProperties.isValidActivityMapData()) {
66
+ clickActivityStorage.save(elementProperties.properties);
67
+ }
68
+ };
69
+ });
@@ -0,0 +1,45 @@
1
+ /*
2
+ Copyright 2024 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
+ import createClickedElementProperties from "./createClickedElementProperties.js";
14
+ import activityMapExtensionEnabled from "./utils/activityMapExtensionEnabled.js";
15
+ export default (({
16
+ clickActivityStorage
17
+ }) => {
18
+ return event => {
19
+ // Avoid clicks to be collected for the ActivityMap interface
20
+ if (activityMapExtensionEnabled()) {
21
+ return;
22
+ }
23
+ const properties = clickActivityStorage.load();
24
+ const elementProperties = createClickedElementProperties({
25
+ properties
26
+ });
27
+ if (elementProperties.isValidLink() || elementProperties.isValidActivityMapData()) {
28
+ if (elementProperties.isValidLink()) {
29
+ const xdm = elementProperties.xdm;
30
+ // Have to delete the eventType not to override the page view
31
+ delete xdm.eventType;
32
+ event.mergeXdm(xdm);
33
+ }
34
+ if (elementProperties.isValidActivityMapData()) {
35
+ event.mergeData(elementProperties.data);
36
+ }
37
+ // NOTE: We can't clear out all the storage here because we might still need to
38
+ // keep a page-name for multiple link-clicks (e.g. downloads) on the same page.
39
+ clickActivityStorage.save({
40
+ pageName: elementProperties.pageName,
41
+ pageIDType: elementProperties.pageIDType
42
+ });
43
+ }
44
+ };
45
+ });
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2022 Adobe. All rights reserved.
2
+ Copyright 2024 Adobe. All rights reserved.
3
3
  This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License. You may obtain a copy
5
5
  of the License at http://www.apache.org/licenses/LICENSE-2.0
@@ -9,29 +9,14 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
9
9
  OF ANY KIND, either express or implied. See the License for the specific language
10
10
  governing permissions and limitations under the License.
11
11
  */
12
+
12
13
  export default (({
13
- getLinkDetails,
14
- config,
15
- logger
14
+ clickActivityStorage
16
15
  }) => {
17
- const {
18
- clickCollectionEnabled
19
- } = config;
20
- if (!clickCollectionEnabled) {
21
- return () => undefined;
22
- }
23
- return ({
24
- targetElement,
25
- event
26
- }) => {
27
- const linkDetails = getLinkDetails({
28
- targetElement,
29
- config,
30
- logger
16
+ return event => {
17
+ clickActivityStorage.save({
18
+ pageName: event.getContent().xdm.web.webPageDetails.name,
19
+ pageIDType: 1 // 1 = name, 0 = URL
31
20
  });
32
- if (linkDetails) {
33
- event.mergeXdm(linkDetails.xdm);
34
- event.setUserData(linkDetails.data);
35
- }
36
21
  };
37
22
  });