@adobe/alloy 2.14.0-beta.1 → 2.15.0-alpha.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.
@@ -48,11 +48,9 @@ var _default = function _default(_ref) {
48
48
  return Promise.all(urlDestinations.map(function (urlDestination) {
49
49
  return fireReferrerHideableImage(urlDestination.spec).then(function () {
50
50
  logger.info(createResultLogMessage(urlDestination, true));
51
- }).catch(function () {
52
- // We intentionally do not throw an error if destinations fail. We
51
+ }).catch(function () {// We intentionally do not throw an error if destinations fail. We
53
52
  // consider it a non-critical failure and therefore do not want it to
54
53
  // reject the promise handed back to the customer.
55
- logger.error(createResultLogMessage(urlDestination, false));
56
54
  });
57
55
  })).then(_utils.noop);
58
56
  };
@@ -18,7 +18,8 @@ var metasToArray = function metasToArray(metas) {
18
18
  return {
19
19
  id: key,
20
20
  scope: metas[key].scope,
21
- scopeDetails: metas[key].scopeDetails
21
+ scopeDetails: metas[key].scopeDetails,
22
+ trackingLabel: metas[key].trackingLabel
22
23
  };
23
24
  });
24
25
  };
@@ -33,7 +34,8 @@ var _default = function _default() {
33
34
 
34
35
  clickStorage[value.selector][value.meta.id] = {
35
36
  scope: value.meta.scope,
36
- scopeDetails: value.meta.scopeDetails
37
+ scopeDetails: value.meta.scopeDetails,
38
+ trackingLabel: value.meta.trackingLabel
37
39
  };
38
40
  };
39
41
 
@@ -21,8 +21,14 @@ var identity = function identity(item) {
21
21
  return item;
22
22
  };
23
23
 
24
+ var getItemMeta = function getItemMeta(item, decisionMeta) {
25
+ return item.characteristics && item.characteristics.trackingLabel ? (0, _utils.assign)({
26
+ trackingLabel: item.characteristics.trackingLabel
27
+ }, decisionMeta) : decisionMeta;
28
+ };
29
+
24
30
  var buildActions = function buildActions(decision) {
25
- var meta = {
31
+ var decisionMeta = {
26
32
  id: decision.id,
27
33
  scope: decision.scope,
28
34
  scopeDetails: decision.scopeDetails
@@ -31,7 +37,7 @@ var buildActions = function buildActions(decision) {
31
37
  return (0, _utils.assign)({
32
38
  type: DEFAULT_ACTION_TYPE
33
39
  }, item.data, {
34
- meta: meta
40
+ meta: getItemMeta(item, decisionMeta)
35
41
  });
36
42
  });
37
43
  };
@@ -33,7 +33,9 @@ var _default = function _default(_ref) {
33
33
  var selectors = getClickSelectors();
34
34
 
35
35
  if ((0, _utils.isNonEmptyArray)(selectors)) {
36
- var decisionsMeta = collectClicks(clickedElement, selectors, getClickMetasBySelector);
36
+ var _collectClicks = collectClicks(clickedElement, selectors, getClickMetasBySelector),
37
+ decisionsMeta = _collectClicks.decisionsMeta,
38
+ eventLabel = _collectClicks.eventLabel;
37
39
 
38
40
  if ((0, _utils.isNonEmptyArray)(decisionsMeta)) {
39
41
  var xdm = {
@@ -50,7 +52,7 @@ var _default = function _default(_ref) {
50
52
  }
51
53
 
52
54
  event.mergeXdm(xdm);
53
- mergeDecisionsMeta(event, decisionsMeta, _propositionEventType.PropositionEventType.INTERACT);
55
+ mergeDecisionsMeta(event, decisionsMeta, _propositionEventType.PropositionEventType.INTERACT, eventLabel);
54
56
  }
55
57
  }
56
58
  };
@@ -20,30 +20,81 @@ var getMetasIfMatches = function getMetasIfMatches(clickedElement, selector, get
20
20
  var _document = document,
21
21
  documentElement = _document.documentElement;
22
22
  var element = clickedElement;
23
+ var i = 0;
23
24
 
24
25
  while (element && element !== documentElement) {
25
26
  if ((0, _matchesSelectorWithEq.default)(selector, element)) {
26
- return getClickMetasBySelector(selector);
27
+ var matchedMetas = getClickMetasBySelector(selector);
28
+ var foundMetaWithLabel = matchedMetas.find(function (meta) {
29
+ return meta.trackingLabel;
30
+ });
31
+
32
+ if (foundMetaWithLabel) {
33
+ return {
34
+ metas: matchedMetas,
35
+ label: foundMetaWithLabel.trackingLabel,
36
+ weight: i
37
+ };
38
+ }
39
+
40
+ return {
41
+ metas: matchedMetas
42
+ };
27
43
  }
28
44
 
29
45
  element = element.parentNode;
46
+ i += 1;
30
47
  }
31
48
 
32
- return null;
49
+ return {
50
+ metas: null
51
+ };
52
+ };
53
+
54
+ var cleanMetas = function cleanMetas(metas) {
55
+ return metas.map(function (meta) {
56
+ delete meta.trackingLabel;
57
+ return meta;
58
+ });
59
+ };
60
+
61
+ var dedupMetas = function dedupMetas(metas) {
62
+ return metas.filter(function (meta, index) {
63
+ var stringifiedMeta = JSON.stringify(meta);
64
+ return index === metas.findIndex(function (innerMeta) {
65
+ return JSON.stringify(innerMeta) === stringifiedMeta;
66
+ });
67
+ });
33
68
  };
34
69
 
35
70
  var _default = function _default(clickedElement, selectors, getClickMetasBySelector) {
36
71
  var result = [];
72
+ var resultLabel = "";
73
+ var resultLabelWeight = Number.MAX_SAFE_INTEGER;
74
+ /* eslint-disable no-continue */
37
75
 
38
76
  for (var i = 0; i < selectors.length; i += 1) {
39
- var metas = getMetasIfMatches(clickedElement, selectors[i], getClickMetasBySelector);
77
+ var _getMetasIfMatches = getMetasIfMatches(clickedElement, selectors[i], getClickMetasBySelector),
78
+ metas = _getMetasIfMatches.metas,
79
+ label = _getMetasIfMatches.label,
80
+ weight = _getMetasIfMatches.weight;
40
81
 
41
- if (metas) {
42
- result.push.apply(result, _toConsumableArray(metas));
82
+ if (!metas) {
83
+ continue;
43
84
  }
85
+
86
+ if (label && weight <= resultLabelWeight) {
87
+ resultLabel = label;
88
+ resultLabelWeight = weight;
89
+ }
90
+
91
+ result.push.apply(result, _toConsumableArray(cleanMetas(metas)));
44
92
  }
45
93
 
46
- return result;
94
+ return {
95
+ decisionsMeta: dedupMetas(result),
96
+ eventLabel: resultLabel
97
+ };
47
98
  };
48
99
 
49
100
  exports.default = _default;
@@ -20,16 +20,26 @@ OF ANY KIND, either express or implied. See the License for the specific languag
20
20
  governing permissions and limitations under the License.
21
21
  */
22
22
  var EVENT_TYPE_TRUE = 1;
23
+ /* eslint-disable no-underscore-dangle */
23
24
 
24
25
  var mergeDecisionsMeta = function mergeDecisionsMeta(event, decisionsMeta, eventType) {
25
- event.mergeXdm({
26
+ var eventLabel = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "";
27
+ var xdm = {
26
28
  _experience: {
27
29
  decisioning: {
28
30
  propositions: decisionsMeta,
29
31
  propositionEventType: _defineProperty({}, eventType, EVENT_TYPE_TRUE)
30
32
  }
31
33
  }
32
- });
34
+ };
35
+
36
+ if (eventLabel) {
37
+ xdm._experience.decisioning.propositionAction = {
38
+ label: eventLabel
39
+ };
40
+ }
41
+
42
+ event.mergeXdm(xdm);
33
43
  };
34
44
 
35
45
  exports.mergeDecisionsMeta = mergeDecisionsMeta;
@@ -15,5 +15,5 @@ governing permissions and limitations under the License.
15
15
  */
16
16
  // The __VERSION__ keyword will be replace at alloy build time with the package.json version.
17
17
  // see babel-plugin-version
18
- var _default = "2.14.0-beta.1";
18
+ var _default = "2.15.0-alpha.0";
19
19
  exports.default = _default;
@@ -49,11 +49,9 @@ export default (({
49
49
  return Promise.all(urlDestinations.map(urlDestination => {
50
50
  return fireReferrerHideableImage(urlDestination.spec).then(() => {
51
51
  logger.info(createResultLogMessage(urlDestination, true));
52
- }).catch(() => {
53
- // We intentionally do not throw an error if destinations fail. We
52
+ }).catch(() => {// We intentionally do not throw an error if destinations fail. We
54
53
  // consider it a non-critical failure and therefore do not want it to
55
54
  // reject the promise handed back to the customer.
56
- logger.error(createResultLogMessage(urlDestination, false));
57
55
  });
58
56
  })).then(noop);
59
57
  };
@@ -14,7 +14,8 @@ const metasToArray = metas => {
14
14
  return {
15
15
  id: key,
16
16
  scope: metas[key].scope,
17
- scopeDetails: metas[key].scopeDetails
17
+ scopeDetails: metas[key].scopeDetails,
18
+ trackingLabel: metas[key].trackingLabel
18
19
  };
19
20
  });
20
21
  };
@@ -29,7 +30,8 @@ export default (() => {
29
30
 
30
31
  clickStorage[value.selector][value.meta.id] = {
31
32
  scope: value.meta.scope,
32
- scopeDetails: value.meta.scopeDetails
33
+ scopeDetails: value.meta.scopeDetails,
34
+ trackingLabel: value.meta.trackingLabel
33
35
  };
34
36
  };
35
37
 
@@ -14,8 +14,12 @@ const DEFAULT_ACTION_TYPE = "defaultContent";
14
14
 
15
15
  const identity = item => item;
16
16
 
17
+ const getItemMeta = (item, decisionMeta) => item.characteristics && item.characteristics.trackingLabel ? assign({
18
+ trackingLabel: item.characteristics.trackingLabel
19
+ }, decisionMeta) : decisionMeta;
20
+
17
21
  const buildActions = decision => {
18
- const meta = {
22
+ const decisionMeta = {
19
23
  id: decision.id,
20
24
  scope: decision.scope,
21
25
  scopeDetails: decision.scopeDetails
@@ -23,7 +27,7 @@ const buildActions = decision => {
23
27
  return decision.items.map(item => assign({
24
28
  type: DEFAULT_ACTION_TYPE
25
29
  }, item.data, {
26
- meta
30
+ meta: getItemMeta(item, decisionMeta)
27
31
  }));
28
32
  };
29
33
 
@@ -27,7 +27,10 @@ export default (({
27
27
  const selectors = getClickSelectors();
28
28
 
29
29
  if (isNonEmptyArray(selectors)) {
30
- const decisionsMeta = collectClicks(clickedElement, selectors, getClickMetasBySelector);
30
+ const {
31
+ decisionsMeta,
32
+ eventLabel
33
+ } = collectClicks(clickedElement, selectors, getClickMetasBySelector);
31
34
 
32
35
  if (isNonEmptyArray(decisionsMeta)) {
33
36
  const xdm = {
@@ -44,7 +47,7 @@ export default (({
44
47
  }
45
48
 
46
49
  event.mergeXdm(xdm);
47
- mergeDecisionsMeta(event, decisionsMeta, PropositionEventType.INTERACT);
50
+ mergeDecisionsMeta(event, decisionsMeta, PropositionEventType.INTERACT, eventLabel);
48
51
  }
49
52
  }
50
53
  };
@@ -16,28 +16,72 @@ const getMetasIfMatches = (clickedElement, selector, getClickMetasBySelector) =>
16
16
  documentElement
17
17
  } = document;
18
18
  let element = clickedElement;
19
+ let i = 0;
19
20
 
20
21
  while (element && element !== documentElement) {
21
22
  if (matchesSelectorWithEq(selector, element)) {
22
- return getClickMetasBySelector(selector);
23
+ const matchedMetas = getClickMetasBySelector(selector);
24
+ const foundMetaWithLabel = matchedMetas.find(meta => meta.trackingLabel);
25
+
26
+ if (foundMetaWithLabel) {
27
+ return {
28
+ metas: matchedMetas,
29
+ label: foundMetaWithLabel.trackingLabel,
30
+ weight: i
31
+ };
32
+ }
33
+
34
+ return {
35
+ metas: matchedMetas
36
+ };
23
37
  }
24
38
 
25
39
  element = element.parentNode;
40
+ i += 1;
26
41
  }
27
42
 
28
- return null;
43
+ return {
44
+ metas: null
45
+ };
29
46
  };
30
47
 
48
+ const cleanMetas = metas => metas.map(meta => {
49
+ delete meta.trackingLabel;
50
+ return meta;
51
+ });
52
+
53
+ const dedupMetas = metas => metas.filter((meta, index) => {
54
+ const stringifiedMeta = JSON.stringify(meta);
55
+ return index === metas.findIndex(innerMeta => JSON.stringify(innerMeta) === stringifiedMeta);
56
+ });
57
+
31
58
  export default ((clickedElement, selectors, getClickMetasBySelector) => {
32
59
  const result = [];
60
+ let resultLabel = "";
61
+ let resultLabelWeight = Number.MAX_SAFE_INTEGER;
62
+ /* eslint-disable no-continue */
33
63
 
34
64
  for (let i = 0; i < selectors.length; i += 1) {
35
- const metas = getMetasIfMatches(clickedElement, selectors[i], getClickMetasBySelector);
65
+ const {
66
+ metas,
67
+ label,
68
+ weight
69
+ } = getMetasIfMatches(clickedElement, selectors[i], getClickMetasBySelector);
36
70
 
37
- if (metas) {
38
- result.push(...metas);
71
+ if (!metas) {
72
+ continue;
39
73
  }
74
+
75
+ if (label && weight <= resultLabelWeight) {
76
+ resultLabel = label;
77
+ resultLabelWeight = weight;
78
+ }
79
+
80
+ result.push(...cleanMetas(metas));
40
81
  }
41
82
 
42
- return result;
83
+ return {
84
+ decisionsMeta: dedupMetas(result),
85
+ eventLabel: resultLabel
86
+ };
43
87
  });
@@ -10,8 +10,10 @@ OF ANY KIND, either express or implied. See the License for the specific languag
10
10
  governing permissions and limitations under the License.
11
11
  */
12
12
  const EVENT_TYPE_TRUE = 1;
13
- export const mergeDecisionsMeta = (event, decisionsMeta, eventType) => {
14
- event.mergeXdm({
13
+ /* eslint-disable no-underscore-dangle */
14
+
15
+ export const mergeDecisionsMeta = (event, decisionsMeta, eventType, eventLabel = "") => {
16
+ const xdm = {
15
17
  _experience: {
16
18
  decisioning: {
17
19
  propositions: decisionsMeta,
@@ -20,7 +22,15 @@ export const mergeDecisionsMeta = (event, decisionsMeta, eventType) => {
20
22
  }
21
23
  }
22
24
  }
23
- });
25
+ };
26
+
27
+ if (eventLabel) {
28
+ xdm._experience.decisioning.propositionAction = {
29
+ label: eventLabel
30
+ };
31
+ }
32
+
33
+ event.mergeXdm(xdm);
24
34
  };
25
35
  export const mergeQuery = (event, details) => {
26
36
  event.mergeQuery({
@@ -11,4 +11,4 @@ governing permissions and limitations under the License.
11
11
  */
12
12
  // The __VERSION__ keyword will be replace at alloy build time with the package.json version.
13
13
  // see babel-plugin-version
14
- export default "2.14.0-beta.1";
14
+ export default "2.15.0-alpha.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/alloy",
3
- "version": "2.14.0-beta.1",
3
+ "version": "2.15.0-alpha.0",
4
4
  "description": "Adobe Experience Platform Web SDK",
5
5
  "main": "libEs5/index.js",
6
6
  "module": "libEs6/index.js",
@@ -64,7 +64,7 @@
64
64
  "uuid": "^3.3.2"
65
65
  },
66
66
  "devDependencies": {
67
- "@adobe/alloy": "^2.14.0-beta.0",
67
+ "@adobe/alloy": "^2.14.0",
68
68
  "@babel/cli": "^7.12.8",
69
69
  "@babel/core": "^7.2.2",
70
70
  "@babel/plugin-proposal-object-rest-spread": "^7.3.2",
@@ -118,7 +118,7 @@
118
118
  "rollup-plugin-terser": "^7.0.2",
119
119
  "semver": "^7.3.7",
120
120
  "start-server-and-test": "^1.10.6",
121
- "testcafe": "^2.2.0",
121
+ "testcafe": "^2.3.1",
122
122
  "testcafe-browser-provider-saucelabs": "^1.9.0",
123
123
  "testcafe-reporter-junit": "^3.0.2",
124
124
  "url-exists-nodejs": "^0.1.0",