@adobe/alloy 2.9.0-alpha.1 → 2.9.0-alpha.4

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 (25) hide show
  1. package/libEs5/components/Personalization/constants/schema.js +3 -1
  2. package/libEs5/components/Personalization/constants/scopeType.js +17 -0
  3. package/libEs5/components/Personalization/createComponent.js +10 -4
  4. package/libEs5/components/Personalization/createExecuteDecisions.js +5 -1
  5. package/libEs5/components/Personalization/createFetchDataHandler.js +1 -7
  6. package/libEs5/components/Personalization/createOnClickHandler.js +15 -2
  7. package/libEs5/components/Personalization/createPersonalizationDetails.js +1 -1
  8. package/libEs5/components/Personalization/createViewChangeHandler.js +2 -7
  9. package/libEs5/components/Personalization/dom-actions/initDomActionsModules.js +5 -0
  10. package/libEs5/components/Personalization/groupDecisions.js +37 -18
  11. package/libEs5/components/Personalization/index.js +3 -4
  12. package/libEs5/constants/libraryVersion.js +1 -1
  13. package/libEs6/components/Personalization/constants/schema.js +1 -0
  14. package/libEs6/components/Personalization/constants/scopeType.js +12 -0
  15. package/libEs6/components/Personalization/createComponent.js +6 -4
  16. package/libEs6/components/Personalization/createExecuteDecisions.js +4 -1
  17. package/libEs6/components/Personalization/createFetchDataHandler.js +1 -7
  18. package/libEs6/components/Personalization/createOnClickHandler.js +14 -2
  19. package/libEs6/components/Personalization/createPersonalizationDetails.js +2 -2
  20. package/libEs6/components/Personalization/createViewChangeHandler.js +2 -7
  21. package/libEs6/components/Personalization/dom-actions/initDomActionsModules.js +4 -1
  22. package/libEs6/components/Personalization/groupDecisions.js +32 -20
  23. package/libEs6/components/Personalization/index.js +3 -4
  24. package/libEs6/constants/libraryVersion.js +1 -1
  25. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- exports.REDIRECT_ITEM = exports.JSON_CONTENT_ITEM = exports.HTML_CONTENT_ITEM = exports.DOM_ACTION = void 0;
3
+ exports.REDIRECT_ITEM = exports.JSON_CONTENT_ITEM = exports.HTML_CONTENT_ITEM = exports.DOM_ACTION = exports.DEFAULT_CONTENT_ITEM = void 0;
4
4
 
5
5
  /*
6
6
  Copyright 2019 Adobe. All rights reserved.
@@ -13,6 +13,8 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
13
13
  OF ANY KIND, either express or implied. See the License for the specific language
14
14
  governing permissions and limitations under the License.
15
15
  */
16
+ var DEFAULT_CONTENT_ITEM = "https://ns.adobe.com/personalization/default-content-item";
17
+ exports.DEFAULT_CONTENT_ITEM = DEFAULT_CONTENT_ITEM;
16
18
  var DOM_ACTION = "https://ns.adobe.com/personalization/dom-action";
17
19
  exports.DOM_ACTION = DOM_ACTION;
18
20
  var HTML_CONTENT_ITEM = "https://ns.adobe.com/personalization/html-content-item";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ exports.VIEW_SCOPE_TYPE = void 0;
4
+
5
+ /*
6
+ Copyright 2022 Adobe. All rights reserved.
7
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License. You may obtain a copy
9
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software distributed under
12
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
+ OF ANY KIND, either express or implied. See the License for the specific language
14
+ governing permissions and limitations under the License.
15
+ */
16
+ var VIEW_SCOPE_TYPE = "view";
17
+ exports.VIEW_SCOPE_TYPE = VIEW_SCOPE_TYPE;
@@ -26,7 +26,8 @@ var _default = function _default(_ref) {
26
26
  onClickHandler = _ref.onClickHandler,
27
27
  isAuthoringModeEnabled = _ref.isAuthoringModeEnabled,
28
28
  mergeQuery = _ref.mergeQuery,
29
- viewCache = _ref.viewCache;
29
+ viewCache = _ref.viewCache,
30
+ showContainers = _ref.showContainers;
30
31
  return {
31
32
  lifecycle: {
32
33
  onBeforeEvent: function onBeforeEvent(_ref2) {
@@ -38,12 +39,15 @@ var _default = function _default(_ref) {
38
39
  onResponse = _ref2$onResponse === void 0 ? _utils.noop : _ref2$onResponse,
39
40
  _ref2$onRequestFailur = _ref2.onRequestFailure,
40
41
  onRequestFailure = _ref2$onRequestFailur === void 0 ? _utils.noop : _ref2$onRequestFailur;
41
- // Include proositions on all responses, overridden with data as needed
42
+ // Include propositions on all responses, overridden with data as needed
42
43
  onResponse(function () {
43
44
  return {
44
45
  propositions: []
45
46
  };
46
47
  });
48
+ onRequestFailure(function () {
49
+ return showContainers();
50
+ });
47
51
 
48
52
  if (isAuthoringModeEnabled()) {
49
53
  logger.warn(_loggerMessage.AUTHORING_ENABLED); // If we are in authoring mode we disable personalization
@@ -64,12 +68,14 @@ var _default = function _default(_ref) {
64
68
  if (personalizationDetails.shouldFetchData()) {
65
69
  var decisionsDeferred = (0, _utils.defer)();
66
70
  viewCache.storeViews(decisionsDeferred.promise);
71
+ onRequestFailure(function () {
72
+ return decisionsDeferred.reject();
73
+ });
67
74
  fetchDataHandler({
68
75
  decisionsDeferred: decisionsDeferred,
69
76
  personalizationDetails: personalizationDetails,
70
77
  event: event,
71
- onResponse: onResponse,
72
- onRequestFailure: onRequestFailure
78
+ onResponse: onResponse
73
79
  });
74
80
  return;
75
81
  }
@@ -15,6 +15,8 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
15
15
  OF ANY KIND, either express or implied. See the License for the specific language
16
16
  governing permissions and limitations under the License.
17
17
  */
18
+ var DEFAULT_ACTION_TYPE = "defaultContent";
19
+
18
20
  var identity = function identity(item) {
19
21
  return item;
20
22
  };
@@ -26,7 +28,9 @@ var buildActions = function buildActions(decision) {
26
28
  scopeDetails: decision.scopeDetails
27
29
  };
28
30
  return decision.items.map(function (item) {
29
- return (0, _utils.assign)({}, item.data, {
31
+ return (0, _utils.assign)({
32
+ type: DEFAULT_ACTION_TYPE
33
+ }, item.data, {
30
34
  meta: meta
31
35
  });
32
36
  });
@@ -16,15 +16,13 @@ governing permissions and limitations under the License.
16
16
  var _default = function _default(_ref) {
17
17
  var config = _ref.config,
18
18
  responseHandler = _ref.responseHandler,
19
- showContainers = _ref.showContainers,
20
19
  hideContainers = _ref.hideContainers,
21
20
  mergeQuery = _ref.mergeQuery;
22
21
  return function (_ref2) {
23
22
  var decisionsDeferred = _ref2.decisionsDeferred,
24
23
  personalizationDetails = _ref2.personalizationDetails,
25
24
  event = _ref2.event,
26
- onResponse = _ref2.onResponse,
27
- onRequestFailure = _ref2.onRequestFailure;
25
+ onResponse = _ref2.onResponse;
28
26
  var prehidingStyle = config.prehidingStyle;
29
27
 
30
28
  if (personalizationDetails.isRenderDecisions()) {
@@ -40,10 +38,6 @@ var _default = function _default(_ref) {
40
38
  response: response
41
39
  });
42
40
  });
43
- onRequestFailure(function () {
44
- decisionsDeferred.reject();
45
- showContainers();
46
- });
47
41
  };
48
42
  };
49
43
 
@@ -6,6 +6,8 @@ var _utils = require("../../utils");
6
6
 
7
7
  var _eventType = require("./constants/eventType");
8
8
 
9
+ var _scope = require("./constants/scope");
10
+
9
11
  /*
10
12
  Copyright 2020 Adobe. All rights reserved.
11
13
  This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -32,9 +34,20 @@ var _default = function _default(_ref) {
32
34
  var decisionsMeta = collectClicks(clickedElement, selectors, getClickMetasBySelector);
33
35
 
34
36
  if ((0, _utils.isNonEmptyArray)(decisionsMeta)) {
35
- event.mergeXdm({
37
+ var xdm = {
36
38
  eventType: _eventType.INTERACT
37
- });
39
+ };
40
+ var scope = decisionsMeta[0].scope;
41
+
42
+ if (scope !== _scope.default) {
43
+ xdm.web = {
44
+ webPageDetails: {
45
+ viewName: scope
46
+ }
47
+ };
48
+ }
49
+
50
+ event.mergeXdm(xdm);
38
51
  mergeDecisionsMeta(event, decisionsMeta);
39
52
  }
40
53
  }
@@ -48,7 +48,7 @@ var _default = function _default(_ref) {
48
48
  scopes.push(_scope.default);
49
49
  }
50
50
 
51
- var schemas = [_schema.HTML_CONTENT_ITEM, _schema.JSON_CONTENT_ITEM, _schema.REDIRECT_ITEM];
51
+ var schemas = [_schema.DEFAULT_CONTENT_ITEM, _schema.HTML_CONTENT_ITEM, _schema.JSON_CONTENT_ITEM, _schema.REDIRECT_ITEM];
52
52
 
53
53
  if ((0, _utils.includes)(scopes, _scope.default)) {
54
54
  schemas.push(_schema.DOM_ACTION);
@@ -17,12 +17,10 @@ governing permissions and limitations under the License.
17
17
  */
18
18
  var _default = function _default(_ref) {
19
19
  var executeCachedViewDecisions = _ref.executeCachedViewDecisions,
20
- viewCache = _ref.viewCache,
21
- showContainers = _ref.showContainers;
20
+ viewCache = _ref.viewCache;
22
21
  return function (_ref2) {
23
22
  var personalizationDetails = _ref2.personalizationDetails,
24
- onResponse = _ref2.onResponse,
25
- onRequestFailure = _ref2.onRequestFailure;
23
+ onResponse = _ref2.onResponse;
26
24
  var viewName = personalizationDetails.getViewName();
27
25
  return viewCache.getView(viewName).then(function (currentViewDecisions) {
28
26
  if (personalizationDetails.isRenderDecisions()) {
@@ -46,9 +44,6 @@ var _default = function _default(_ref) {
46
44
  })
47
45
  };
48
46
  });
49
- onRequestFailure(function () {
50
- showContainers();
51
- });
52
47
  });
53
48
  };
54
49
  };
@@ -36,6 +36,11 @@ var _default = function _default(store) {
36
36
  appendHtml: (0, _action.createAction)(_action.appendHtml),
37
37
  click: function click(settings) {
38
38
  return (0, _action.click)(settings, store);
39
+ },
40
+ defaultContent: function defaultContent(settings) {
41
+ return Promise.resolve({
42
+ meta: settings.meta
43
+ });
39
44
  }
40
45
  };
41
46
  };
@@ -6,6 +6,8 @@ var _utils = require("../../utils");
6
6
 
7
7
  var _schema = require("./constants/schema");
8
8
 
9
+ var _scopeType = require("./constants/scopeType");
10
+
9
11
  var _scope = require("./constants/scope");
10
12
 
11
13
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
@@ -20,11 +22,11 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
20
22
 
21
23
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
22
24
 
23
- var splitItems = function splitItems(items, schema) {
25
+ var splitItems = function splitItems(items, schemas) {
24
26
  var matched = [];
25
27
  var nonMatched = [];
26
28
  items.forEach(function (item) {
27
- if (item.schema === schema) {
29
+ if ((0, _utils.includes)(schemas, item.schema)) {
28
30
  matched.push(item);
29
31
  } else {
30
32
  nonMatched.push(item);
@@ -42,14 +44,18 @@ var createDecision = function createDecision(decision, items) {
42
44
  };
43
45
  };
44
46
 
45
- var splitDecisions = function splitDecisions(decisions, schema) {
47
+ var splitDecisions = function splitDecisions(decisions) {
48
+ for (var _len = arguments.length, schemas = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
49
+ schemas[_key - 1] = arguments[_key];
50
+ }
51
+
46
52
  var matchedDecisions = [];
47
53
  var unmatchedDecisions = [];
48
54
  decisions.forEach(function (decision) {
49
55
  var _decision$items = decision.items,
50
56
  items = _decision$items === void 0 ? [] : _decision$items;
51
57
 
52
- var _splitItems = splitItems(items, schema),
58
+ var _splitItems = splitItems(items, schemas),
53
59
  _splitItems2 = _slicedToArray(_splitItems, 2),
54
60
  matchedItems = _splitItems2[0],
55
61
  nonMatchedItems = _splitItems2[1];
@@ -68,43 +74,56 @@ var splitDecisions = function splitDecisions(decisions, schema) {
68
74
  };
69
75
  };
70
76
 
71
- var extractDecisionsByScope = function extractDecisionsByScope(decisions, scope) {
77
+ var appendScopeDecision = function appendScopeDecision(scopeDecisions, decision) {
78
+ if (!scopeDecisions[decision.scope]) {
79
+ scopeDecisions[decision.scope] = [];
80
+ }
81
+
82
+ scopeDecisions[decision.scope].push(decision);
83
+ };
84
+
85
+ var isViewScope = function isViewScope(scopeDetails) {
86
+ return scopeDetails.characteristics && scopeDetails.characteristics.scopeType && scopeDetails.characteristics.scopeType === _scopeType.VIEW_SCOPE_TYPE;
87
+ };
88
+
89
+ var extractDecisionsByScope = function extractDecisionsByScope(decisions) {
72
90
  var pageWideScopeDecisions = [];
73
- var nonPageWideScopeDecisions = {};
91
+ var nonPageWideScopeDecisions = [];
92
+ var viewScopeDecisions = {};
74
93
 
75
94
  if ((0, _utils.isNonEmptyArray)(decisions)) {
76
95
  decisions.forEach(function (decision) {
77
- if (decision.scope === scope) {
96
+ if (decision.scope === _scope.default) {
78
97
  pageWideScopeDecisions.push(decision);
98
+ } else if (isViewScope(decision.scopeDetails)) {
99
+ appendScopeDecision(viewScopeDecisions, decision);
79
100
  } else {
80
- if (!nonPageWideScopeDecisions[decision.scope]) {
81
- nonPageWideScopeDecisions[decision.scope] = [];
82
- }
83
-
84
- nonPageWideScopeDecisions[decision.scope].push(decision);
101
+ nonPageWideScopeDecisions.push(decision);
85
102
  }
86
103
  });
87
104
  }
88
105
 
89
106
  return {
90
107
  pageWideScopeDecisions: pageWideScopeDecisions,
91
- nonPageWideScopeDecisions: nonPageWideScopeDecisions
108
+ nonPageWideScopeDecisions: nonPageWideScopeDecisions,
109
+ viewScopeDecisions: viewScopeDecisions
92
110
  };
93
111
  };
94
112
 
95
113
  var groupDecisions = function groupDecisions(unprocessedDecisions) {
96
114
  var decisionsGroupedByRedirectItemSchema = splitDecisions(unprocessedDecisions, _schema.REDIRECT_ITEM);
97
- var decisionsGroupedByDomActionSchema = splitDecisions(decisionsGroupedByRedirectItemSchema.unmatchedDecisions, _schema.DOM_ACTION);
115
+ var decisionsGroupedByRenderableSchemas = splitDecisions(decisionsGroupedByRedirectItemSchema.unmatchedDecisions, _schema.DOM_ACTION, _schema.DEFAULT_CONTENT_ITEM);
98
116
 
99
- var _extractDecisionsBySc = extractDecisionsByScope(decisionsGroupedByDomActionSchema.matchedDecisions, _scope.default),
117
+ var _extractDecisionsBySc = extractDecisionsByScope(decisionsGroupedByRenderableSchemas.matchedDecisions),
100
118
  pageWideScopeDecisions = _extractDecisionsBySc.pageWideScopeDecisions,
101
- nonPageWideScopeDecisions = _extractDecisionsBySc.nonPageWideScopeDecisions;
119
+ nonPageWideScopeDecisions = _extractDecisionsBySc.nonPageWideScopeDecisions,
120
+ viewScopeDecisions = _extractDecisionsBySc.viewScopeDecisions;
102
121
 
103
122
  return {
104
123
  redirectDecisions: decisionsGroupedByRedirectItemSchema.matchedDecisions,
105
124
  pageWideScopeDecisions: pageWideScopeDecisions,
106
- viewDecisions: nonPageWideScopeDecisions,
107
- nonAutoRenderableDecisions: decisionsGroupedByDomActionSchema.unmatchedDecisions
125
+ viewDecisions: viewScopeDecisions,
126
+ nonAutoRenderableDecisions: decisionsGroupedByRenderableSchemas.unmatchedDecisions.concat(nonPageWideScopeDecisions)
108
127
  };
109
128
  };
110
129
 
@@ -117,7 +117,6 @@ var createPersonalization = function createPersonalization(_ref) {
117
117
  var fetchDataHandler = (0, _createFetchDataHandler.default)({
118
118
  config: config,
119
119
  responseHandler: responseHandler,
120
- showContainers: _flicker.showContainers,
121
120
  hideContainers: _flicker.hideContainers,
122
121
  mergeQuery: _event.mergeQuery
123
122
  });
@@ -129,8 +128,7 @@ var createPersonalization = function createPersonalization(_ref) {
129
128
  });
130
129
  var viewChangeHandler = (0, _createViewChangeHandler.default)({
131
130
  executeCachedViewDecisions: executeCachedViewDecisions,
132
- viewCache: viewCache,
133
- showContainers: _flicker.showContainers
131
+ viewCache: viewCache
134
132
  });
135
133
  return (0, _createComponent.default)({
136
134
  logger: logger,
@@ -139,7 +137,8 @@ var createPersonalization = function createPersonalization(_ref) {
139
137
  onClickHandler: onClickHandler,
140
138
  isAuthoringModeEnabled: _isAuthoringModeEnabled.default,
141
139
  mergeQuery: _event.mergeQuery,
142
- viewCache: viewCache
140
+ viewCache: viewCache,
141
+ showContainers: _flicker.showContainers
143
142
  });
144
143
  };
145
144
 
@@ -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.9.0-alpha.1";
18
+ var _default = "2.9.0-alpha.4";
19
19
  exports.default = _default;
@@ -9,6 +9,7 @@ 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
+ export const DEFAULT_CONTENT_ITEM = "https://ns.adobe.com/personalization/default-content-item";
12
13
  export const DOM_ACTION = "https://ns.adobe.com/personalization/dom-action";
13
14
  export const HTML_CONTENT_ITEM = "https://ns.adobe.com/personalization/html-content-item";
14
15
  export const JSON_CONTENT_ITEM = "https://ns.adobe.com/personalization/json-content-item";
@@ -0,0 +1,12 @@
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
+ export const VIEW_SCOPE_TYPE = "view";
@@ -19,7 +19,8 @@ export default (({
19
19
  onClickHandler,
20
20
  isAuthoringModeEnabled,
21
21
  mergeQuery,
22
- viewCache
22
+ viewCache,
23
+ showContainers
23
24
  }) => {
24
25
  return {
25
26
  lifecycle: {
@@ -30,10 +31,11 @@ export default (({
30
31
  onResponse = noop,
31
32
  onRequestFailure = noop
32
33
  }) {
33
- // Include proositions on all responses, overridden with data as needed
34
+ // Include propositions on all responses, overridden with data as needed
34
35
  onResponse(() => ({
35
36
  propositions: []
36
37
  }));
38
+ onRequestFailure(() => showContainers());
37
39
 
38
40
  if (isAuthoringModeEnabled()) {
39
41
  logger.warn(AUTHORING_ENABLED); // If we are in authoring mode we disable personalization
@@ -54,12 +56,12 @@ export default (({
54
56
  if (personalizationDetails.shouldFetchData()) {
55
57
  const decisionsDeferred = defer();
56
58
  viewCache.storeViews(decisionsDeferred.promise);
59
+ onRequestFailure(() => decisionsDeferred.reject());
57
60
  fetchDataHandler({
58
61
  decisionsDeferred,
59
62
  personalizationDetails,
60
63
  event,
61
- onResponse,
62
- onRequestFailure
64
+ onResponse
63
65
  });
64
66
  return;
65
67
  }
@@ -10,6 +10,7 @@ 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
  import { assign, flatMap, isNonEmptyArray } from "../../utils";
13
+ const DEFAULT_ACTION_TYPE = "defaultContent";
13
14
 
14
15
  const identity = item => item;
15
16
 
@@ -19,7 +20,9 @@ const buildActions = decision => {
19
20
  scope: decision.scope,
20
21
  scopeDetails: decision.scopeDetails
21
22
  };
22
- return decision.items.map(item => assign({}, item.data, {
23
+ return decision.items.map(item => assign({
24
+ type: DEFAULT_ACTION_TYPE
25
+ }, item.data, {
23
26
  meta
24
27
  }));
25
28
  };
@@ -12,7 +12,6 @@ governing permissions and limitations under the License.
12
12
  export default (({
13
13
  config,
14
14
  responseHandler,
15
- showContainers,
16
15
  hideContainers,
17
16
  mergeQuery
18
17
  }) => {
@@ -20,8 +19,7 @@ export default (({
20
19
  decisionsDeferred,
21
20
  personalizationDetails,
22
21
  event,
23
- onResponse,
24
- onRequestFailure
22
+ onResponse
25
23
  }) => {
26
24
  const {
27
25
  prehidingStyle
@@ -39,9 +37,5 @@ export default (({
39
37
  personalizationDetails,
40
38
  response
41
39
  }));
42
- onRequestFailure(() => {
43
- decisionsDeferred.reject();
44
- showContainers();
45
- });
46
40
  };
47
41
  });
@@ -11,6 +11,7 @@ governing permissions and limitations under the License.
11
11
  */
12
12
  import { isNonEmptyArray } from "../../utils";
13
13
  import { INTERACT } from "./constants/eventType";
14
+ import PAGE_WIDE_SCOPE from "./constants/scope";
14
15
  export default (({
15
16
  mergeDecisionsMeta,
16
17
  collectClicks,
@@ -28,9 +29,20 @@ export default (({
28
29
  const decisionsMeta = collectClicks(clickedElement, selectors, getClickMetasBySelector);
29
30
 
30
31
  if (isNonEmptyArray(decisionsMeta)) {
31
- event.mergeXdm({
32
+ const xdm = {
32
33
  eventType: INTERACT
33
- });
34
+ };
35
+ const scope = decisionsMeta[0].scope;
36
+
37
+ if (scope !== PAGE_WIDE_SCOPE) {
38
+ xdm.web = {
39
+ webPageDetails: {
40
+ viewName: scope
41
+ }
42
+ };
43
+ }
44
+
45
+ event.mergeXdm(xdm);
34
46
  mergeDecisionsMeta(event, decisionsMeta);
35
47
  }
36
48
  }
@@ -11,7 +11,7 @@ governing permissions and limitations under the License.
11
11
  */
12
12
  import { includes } from "../../utils";
13
13
  import PAGE_WIDE_SCOPE from "./constants/scope";
14
- import { DOM_ACTION, HTML_CONTENT_ITEM, JSON_CONTENT_ITEM, REDIRECT_ITEM } from "./constants/schema";
14
+ import { DEFAULT_CONTENT_ITEM, DOM_ACTION, HTML_CONTENT_ITEM, JSON_CONTENT_ITEM, REDIRECT_ITEM } from "./constants/schema";
15
15
  import isNonEmptyString from "../../utils/isNonEmptyString";
16
16
  export default (({
17
17
  renderDecisions,
@@ -44,7 +44,7 @@ export default (({
44
44
  scopes.push(PAGE_WIDE_SCOPE);
45
45
  }
46
46
 
47
- const schemas = [HTML_CONTENT_ITEM, JSON_CONTENT_ITEM, REDIRECT_ITEM];
47
+ const schemas = [DEFAULT_CONTENT_ITEM, HTML_CONTENT_ITEM, JSON_CONTENT_ITEM, REDIRECT_ITEM];
48
48
 
49
49
  if (includes(scopes, PAGE_WIDE_SCOPE)) {
50
50
  schemas.push(DOM_ACTION);
@@ -12,13 +12,11 @@ governing permissions and limitations under the License.
12
12
  import addRenderAttemptedToDecisions from "./utils/addRenderAttemptedToDecisions";
13
13
  export default (({
14
14
  executeCachedViewDecisions,
15
- viewCache,
16
- showContainers
15
+ viewCache
17
16
  }) => {
18
17
  return ({
19
18
  personalizationDetails,
20
- onResponse,
21
- onRequestFailure
19
+ onResponse
22
20
  }) => {
23
21
  const viewName = personalizationDetails.getViewName();
24
22
  return viewCache.getView(viewName).then(currentViewDecisions => {
@@ -43,9 +41,6 @@ export default (({
43
41
  })
44
42
  };
45
43
  });
46
- onRequestFailure(() => {
47
- showContainers();
48
- });
49
44
  });
50
45
  };
51
46
  });
@@ -28,6 +28,9 @@ export default (store => {
28
28
  replaceHtml: createAction(replaceHtml),
29
29
  prependHtml: createAction(prependHtml),
30
30
  appendHtml: createAction(appendHtml),
31
- click: settings => click(settings, store)
31
+ click: settings => click(settings, store),
32
+ defaultContent: settings => Promise.resolve({
33
+ meta: settings.meta
34
+ })
32
35
  };
33
36
  });
@@ -9,15 +9,16 @@ 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
- import { isNonEmptyArray } from "../../utils";
13
- import { DOM_ACTION, REDIRECT_ITEM } from "./constants/schema";
12
+ import { isNonEmptyArray, includes } from "../../utils";
13
+ import { DOM_ACTION, REDIRECT_ITEM, DEFAULT_CONTENT_ITEM } from "./constants/schema";
14
+ import { VIEW_SCOPE_TYPE } from "./constants/scopeType";
14
15
  import PAGE_WIDE_SCOPE from "./constants/scope";
15
16
 
16
- const splitItems = (items, schema) => {
17
+ const splitItems = (items, schemas) => {
17
18
  const matched = [];
18
19
  const nonMatched = [];
19
20
  items.forEach(item => {
20
- if (item.schema === schema) {
21
+ if (includes(schemas, item.schema)) {
21
22
  matched.push(item);
22
23
  } else {
23
24
  nonMatched.push(item);
@@ -35,14 +36,14 @@ const createDecision = (decision, items) => {
35
36
  };
36
37
  };
37
38
 
38
- const splitDecisions = (decisions, schema) => {
39
+ const splitDecisions = (decisions, ...schemas) => {
39
40
  const matchedDecisions = [];
40
41
  const unmatchedDecisions = [];
41
42
  decisions.forEach(decision => {
42
43
  const {
43
44
  items = []
44
45
  } = decision;
45
- const [matchedItems, nonMatchedItems] = splitItems(items, schema);
46
+ const [matchedItems, nonMatchedItems] = splitItems(items, schemas);
46
47
 
47
48
  if (isNonEmptyArray(matchedItems)) {
48
49
  matchedDecisions.push(createDecision(decision, matchedItems));
@@ -58,42 +59,53 @@ const splitDecisions = (decisions, schema) => {
58
59
  };
59
60
  };
60
61
 
61
- const extractDecisionsByScope = (decisions, scope) => {
62
+ const appendScopeDecision = (scopeDecisions, decision) => {
63
+ if (!scopeDecisions[decision.scope]) {
64
+ scopeDecisions[decision.scope] = [];
65
+ }
66
+
67
+ scopeDecisions[decision.scope].push(decision);
68
+ };
69
+
70
+ const isViewScope = scopeDetails => scopeDetails.characteristics && scopeDetails.characteristics.scopeType && scopeDetails.characteristics.scopeType === VIEW_SCOPE_TYPE;
71
+
72
+ const extractDecisionsByScope = decisions => {
62
73
  const pageWideScopeDecisions = [];
63
- const nonPageWideScopeDecisions = {};
74
+ const nonPageWideScopeDecisions = [];
75
+ const viewScopeDecisions = {};
64
76
 
65
77
  if (isNonEmptyArray(decisions)) {
66
78
  decisions.forEach(decision => {
67
- if (decision.scope === scope) {
79
+ if (decision.scope === PAGE_WIDE_SCOPE) {
68
80
  pageWideScopeDecisions.push(decision);
81
+ } else if (isViewScope(decision.scopeDetails)) {
82
+ appendScopeDecision(viewScopeDecisions, decision);
69
83
  } else {
70
- if (!nonPageWideScopeDecisions[decision.scope]) {
71
- nonPageWideScopeDecisions[decision.scope] = [];
72
- }
73
-
74
- nonPageWideScopeDecisions[decision.scope].push(decision);
84
+ nonPageWideScopeDecisions.push(decision);
75
85
  }
76
86
  });
77
87
  }
78
88
 
79
89
  return {
80
90
  pageWideScopeDecisions,
81
- nonPageWideScopeDecisions
91
+ nonPageWideScopeDecisions,
92
+ viewScopeDecisions
82
93
  };
83
94
  };
84
95
 
85
96
  const groupDecisions = unprocessedDecisions => {
86
97
  const decisionsGroupedByRedirectItemSchema = splitDecisions(unprocessedDecisions, REDIRECT_ITEM);
87
- const decisionsGroupedByDomActionSchema = splitDecisions(decisionsGroupedByRedirectItemSchema.unmatchedDecisions, DOM_ACTION);
98
+ const decisionsGroupedByRenderableSchemas = splitDecisions(decisionsGroupedByRedirectItemSchema.unmatchedDecisions, DOM_ACTION, DEFAULT_CONTENT_ITEM);
88
99
  const {
89
100
  pageWideScopeDecisions,
90
- nonPageWideScopeDecisions
91
- } = extractDecisionsByScope(decisionsGroupedByDomActionSchema.matchedDecisions, PAGE_WIDE_SCOPE);
101
+ nonPageWideScopeDecisions,
102
+ viewScopeDecisions
103
+ } = extractDecisionsByScope(decisionsGroupedByRenderableSchemas.matchedDecisions);
92
104
  return {
93
105
  redirectDecisions: decisionsGroupedByRedirectItemSchema.matchedDecisions,
94
106
  pageWideScopeDecisions,
95
- viewDecisions: nonPageWideScopeDecisions,
96
- nonAutoRenderableDecisions: decisionsGroupedByDomActionSchema.unmatchedDecisions
107
+ viewDecisions: viewScopeDecisions,
108
+ nonAutoRenderableDecisions: decisionsGroupedByRenderableSchemas.unmatchedDecisions.concat(nonPageWideScopeDecisions)
97
109
  };
98
110
  };
99
111
 
@@ -93,7 +93,6 @@ const createPersonalization = ({
93
93
  const fetchDataHandler = createFetchDataHandler({
94
94
  config,
95
95
  responseHandler,
96
- showContainers,
97
96
  hideContainers,
98
97
  mergeQuery
99
98
  });
@@ -105,8 +104,7 @@ const createPersonalization = ({
105
104
  });
106
105
  const viewChangeHandler = createViewChangeHandler({
107
106
  executeCachedViewDecisions,
108
- viewCache,
109
- showContainers
107
+ viewCache
110
108
  });
111
109
  return createComponent({
112
110
  logger,
@@ -115,7 +113,8 @@ const createPersonalization = ({
115
113
  onClickHandler,
116
114
  isAuthoringModeEnabled,
117
115
  mergeQuery,
118
- viewCache
116
+ viewCache,
117
+ showContainers
119
118
  });
120
119
  };
121
120
 
@@ -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.9.0-alpha.1";
14
+ export default "2.9.0-alpha.4";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/alloy",
3
- "version": "2.9.0-alpha.1",
3
+ "version": "2.9.0-alpha.4",
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.9.0-alpha.0",
67
+ "@adobe/alloy": "^2.9.0-alpha.3",
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",