Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DO NOT MERGE!!! All changes from last release for Nina #1042

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
22d1d81
WIP add handlers for each kind of activity
jonsnyder Feb 6, 2023
efe6c16
Finalize personalization handlers
jonsnyder Feb 21, 2023
6c33b2d
Merge remote-tracking branch 'origin/main' into personalizationRefactor
jonsnyder Aug 2, 2023
3aeff9d
Add component tests with support for fetch, viewChange, and apply
jonsnyder Aug 15, 2023
63cdfb0
Refactor handlePropositions to render
jonsnyder Aug 17, 2023
4c337ec
Remove unused files
jonsnyder Aug 18, 2023
f648376
fix some tests
jonsnyder Aug 18, 2023
1cc8e88
Update all unit tests
jonsnyder Aug 21, 2023
520a0c8
Fix functional tests, and fix issues found when running functional tests
jonsnyder Aug 22, 2023
8a97a0b
Remove fetch related features, only including refactor and combining …
jonsnyder Aug 23, 2023
76038af
Add unit tests for new handler files
jonsnyder Aug 29, 2023
443745b
Revert "Remove fetch related features, only including refactor and co…
jonsnyder Aug 29, 2023
aa0474a
Save display notifications and send them at the bottom of page hit
jonsnyder Aug 29, 2023
0ca03c8
Fix default value for sendDisplayNotifications
jonsnyder Aug 31, 2023
9a9835d
Add viewName option to applyPropositions
jonsnyder Aug 31, 2023
daea723
Add showContainers call after rendering in fetch data handler
jonsnyder Sep 1, 2023
09e1a19
Merge branch 'combineNotifications' into topAndBottom2
jonsnyder Sep 7, 2023
3fbc4d9
TNT-48367 Make SPA view names lowercase (#1027)
XDex Sep 13, 2023
8c56124
Change proposition to be immutable. Render based on schema. Group by …
jonsnyder Sep 14, 2023
e9b5acf
Remove unused code, fix unit tests for personalization handlers
jonsnyder Sep 14, 2023
9b664c0
Add license header
jonsnyder Sep 14, 2023
50dba9c
Fix bugs found running functional tests
jonsnyder Sep 14, 2023
a8dd78f
Merge remote-tracking branch 'origin/main' into topAndBottom2
jonsnyder Sep 14, 2023
ca33032
Update scope lowercase logic to only apply to the view cache.
jonsnyder Sep 20, 2023
0bf960d
Merge pull request #1036 from adobe/topAndBottom2
jonsnyder Sep 21, 2023
b3ab160
[skip ci] 2.19.0-beta.0
Sep 21, 2023
1960692
[skip ci] update self devDependency to 2.19.0-beta.0
Sep 21, 2023
5b29072
Call show containers immediately after we start rendering. Do not wai…
jonsnyder Sep 22, 2023
2e08077
Add unit test for showing containers at the right time
jonsnyder Sep 22, 2023
bda7033
Fix empty view change issues
jonsnyder Sep 23, 2023
300cf11
Merge remote-tracking branch 'origin/fixShowContainersTiming' into to…
jonsnyder Sep 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adobe/alloy",
"version": "2.18.0",
"version": "2.19.0-beta.0",
"description": "Adobe Experience Platform Web SDK",
"main": "libEs5/index.js",
"module": "libEs6/index.js",
Expand Down Expand Up @@ -66,7 +66,7 @@
"uuid": "^3.3.2"
},
"devDependencies": {
"@adobe/alloy": "^2.18.0",
"@adobe/alloy": "^2.19.0-beta.0",
"@babel/cli": "^7.12.8",
"@babel/core": "^7.2.2",
"@babel/plugin-proposal-object-rest-spread": "^7.3.2",
Expand Down
1 change: 1 addition & 0 deletions rollup.test.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ if (argv.reporters && argv.reporters.split(",").includes("coverage")) {

module.exports = {
output: {
sourcemap: true,
format: "iife",
// Allow non-IE browsers and IE11
// document.documentMode was added in IE8, and is specific to IE.
Expand Down
6 changes: 4 additions & 2 deletions src/components/DataCollector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,17 @@ const createDataCollector = ({ eventManager, logger }) => {
const {
renderDecisions = false,
responseHeaders = {},
responseBody = { handle: [] }
responseBody = { handle: [] },
personalization
} = options;

const event = eventManager.createEvent();

return eventManager.applyResponse(event, {
renderDecisions,
responseHeaders,
responseBody
responseBody,
personalization
});
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/components/DataCollector/validateApplyResponse.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ export default ({ options }) => {
payload: anything().required()
})
).required()
}).required()
}).required(),
personalization: objectOf({
sendDisplayNotifications: boolean().default(true)
}).default({ sendDisplayNotifications: true })
}).noUnknownFields();

return validator(options);
Expand Down
6 changes: 4 additions & 2 deletions src/components/DataCollector/validateUserEventOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ export default ({ options }) => {
decisionScopes: arrayOf(string()).uniqueItems(),
personalization: objectOf({
decisionScopes: arrayOf(string()).uniqueItems(),
surfaces: arrayOf(string()).uniqueItems()
}),
surfaces: arrayOf(string()).uniqueItems(),
sendDisplayNotifications: boolean().default(true),
includePendingDisplayNotifications: boolean().default(false)
}).default({ sendDisplayNotifications: true }),
datasetId: string(),
mergeId: string(),
edgeConfigOverrides: validateConfigOverride
Expand Down
50 changes: 34 additions & 16 deletions src/components/Personalization/createApplyPropositions.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ OF ANY KIND, either express or implied. See the License for the specific languag
governing permissions and limitations under the License.
*/

import composePersonalizationResultingObject from "./utils/composePersonalizationResultingObject";
import { isNonEmptyArray, isObject } from "../../utils";
import { isNonEmptyArray, isObject, defer } from "../../utils";
import { DOM_ACTION, HTML_CONTENT_ITEM } from "./constants/schema";
import PAGE_WIDE_SCOPE from "../../constants/pageWideScope";
import { EMPTY_PROPOSITIONS } from "./validateApplyPropositionsOptions";

export const SUPPORTED_SCHEMAS = [DOM_ACTION, HTML_CONTENT_ITEM];
const SUPPORTED_SCHEMAS = [DOM_ACTION, HTML_CONTENT_ITEM];

export default ({ executeDecisions }) => {
export default ({
processPropositions,
createProposition,
pendingDisplayNotifications,
viewCache
}) => {
const filterItemsPredicate = item =>
SUPPORTED_SCHEMAS.indexOf(item.schema) > -1;

Expand Down Expand Up @@ -71,20 +74,35 @@ export default ({ executeDecisions }) => {
.filter(proposition => isNonEmptyArray(proposition.items));
};

const applyPropositions = ({ propositions, metadata }) => {
return ({ propositions = [], metadata = {}, viewName }) => {
// We need to immediately call concat so that subsequent sendEvent
// calls will wait for applyPropositions to complete before executing.
const displayNotificationsDeferred = defer();
pendingDisplayNotifications.concat(displayNotificationsDeferred.promise);

const propositionsToExecute = preparePropositions({
propositions,
metadata
});
return executeDecisions(propositionsToExecute).then(() => {
return composePersonalizationResultingObject(propositionsToExecute, true);
});
};
}).map(proposition => createProposition(proposition));

return Promise.resolve()
.then(() => {
if (viewName) {
return viewCache.getView(viewName);
}
return [];
})
.then(additionalPropositions => {
const { render, returnedPropositions } = processPropositions([
...propositionsToExecute,
...additionalPropositions
]);

render().then(displayNotificationsDeferred.resolve);

return ({ propositions, metadata = {} }) => {
if (isNonEmptyArray(propositions)) {
return applyPropositions({ propositions, metadata });
}
return Promise.resolve(EMPTY_PROPOSITIONS);
return {
propositions: returnedPropositions
};
});
};
};
77 changes: 0 additions & 77 deletions src/components/Personalization/createAutoRenderingHandler.js

This file was deleted.

55 changes: 38 additions & 17 deletions src/components/Personalization/createComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ OF ANY KIND, either express or implied. See the License for the specific languag
governing permissions and limitations under the License.
*/

import { noop, defer } from "../../utils";
import { noop, flatMap } from "../../utils";
import createPersonalizationDetails from "./createPersonalizationDetails";
import { AUTHORING_ENABLED } from "./constants/loggerMessage";
import validateApplyPropositionsOptions from "./validateApplyPropositionsOptions";
import { PropositionEventType } from "./constants/propositionEventType";

export default ({
getPageLocation,
Expand All @@ -26,7 +27,9 @@ export default ({
viewCache,
showContainers,
applyPropositions,
setTargetMigration
setTargetMigration,
mergeDecisionsMeta,
pendingDisplayNotifications
}) => {
return {
lifecycle: {
Expand All @@ -51,7 +54,7 @@ export default ({

// If we are in authoring mode we disable personalization
mergeQuery(event, { enabled: false });
return;
return Promise.resolve();
}

const personalizationDetails = createPersonalizationDetails({
Expand All @@ -60,33 +63,51 @@ export default ({
decisionScopes,
personalization,
event,
viewCache,
isCacheInitialized: viewCache.isInitialized(),
logger
});

const decisionsMetaPromises = [];
if (personalizationDetails.shouldAddPendingDisplayNotifications()) {
decisionsMetaPromises.push(pendingDisplayNotifications.clear());
}

if (personalizationDetails.shouldFetchData()) {
const decisionsDeferred = defer();
const cacheUpdate = viewCache.createCacheUpdate(
personalizationDetails.getViewName()
);
onRequestFailure(() => cacheUpdate.cancel());

viewCache.storeViews(decisionsDeferred.promise);
onRequestFailure(() => decisionsDeferred.reject());
fetchDataHandler({
decisionsDeferred,
cacheUpdate,
personalizationDetails,
event,
onResponse
});
return;
} else if (personalizationDetails.shouldUseCachedData()) {
// eslint-disable-next-line consistent-return
decisionsMetaPromises.push(
viewChangeHandler({
personalizationDetails,
event,
onResponse,
onRequestFailure
})
);
}

if (personalizationDetails.shouldUseCachedData()) {
// eslint-disable-next-line consistent-return
return viewChangeHandler({
personalizationDetails,
// This promise.all waits for both the pending display notifications to be resolved
// (i.e. the top of page call to finish rendering) and the view change handler to
// finish rendering anything for this view.
return Promise.all(decisionsMetaPromises).then(decisionsMetas => {
// We only want to call mergeDecisionsMeta once, but we can get the propositions
// from two places: the pending display notifications and the view change handler.
mergeDecisionsMeta(
event,
onResponse,
onRequestFailure
});
}
flatMap(decisionsMetas, dms => dms),
PropositionEventType.DISPLAY
);
});
},
onClick({ event, clickedElement }) {
onClickHandler({ event, clickedElement });
Expand Down
Loading
Loading