Skip to content

Commit

Permalink
Merge branch 'main' into media
Browse files Browse the repository at this point in the history
  • Loading branch information
Nina Ciocanu committed Dec 14, 2023
2 parents 59a4330 + 74f69ba commit ffc2b14
Show file tree
Hide file tree
Showing 49 changed files with 595 additions and 125 deletions.
70 changes: 70 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Contributing

Welcome to the home of the AEP Web SDK! We appreciate your interest in contributing and are excited to collaborate.

The following guidelines will help ensure a smooth contribution process.

Our guidelines vary depending on the type of contribution: New Feature, Enhancement, or Bug Fix.


## Contributor license agreement

All third-party contributions to this project must be accompanied by a signed contributor
license agreement. This gives Adobe permission to redistribute your contributions
as part of the project. [Sign our CLA](http://opensource.adobe.com/cla.html). You
only need to submit an Adobe CLA one time, so if you have submitted one previously,
you are good to go!


## Bug Fix Process

Submit bug fixes via pull requests, to be reviewed by the AEP Web SDK's Core team.

1. Create a pull request.
2. Describe the bug, and provide steps to reproduce it. (More details on the PR process below)


## New Feature Process

New feature contributions start with a Concept Approval (CA) / Proposal document.

- Internal Contributors: Create a Wiki page and engage with the AEP Web SDK's Product team to discuss your proposal.
- External Contributors: Create a GitHub issue detailing your feature and assign the ticket to https://github.com/jfkhoury.
- No need for detailed architectural insights at this stage.


#### Post Approval

1. Add a thorough architecture and design proposal to a technical document.
- Seek assistance from the AEP Web SDK Engineering team for design input if necessary.
- This document will be shared with Adobe's documentation writers, so ensure it's detailed.
2. Share your CA and technical documents with the AEP Web SDK engineering team for further discussion and approval.
- A work session will be scheduled for a kickoff discussion. (Joe to set up)
3. Upon design approval, proceed with development. The technical document will be shared with the documentation team for public documentation preparation.


## Pull Request Approval Process

We strive to review all pull requests promptly and may suggest improvements or alternatives.

Include in your pull request:


- Break down your PR into manageable commits and add a descriptive PR title and thorough description, including screenshots if applicable.
- Ensure code adheres to our formatting and usage standards (`npm run format` and `npm run lint`)
- Testing:
- Detail your test cases comprehensively. PRs lacking tests will not be reviewed.
- Include unit and functional tests.
- Test your feature in the [Sandbox](https://github.com/adobe/alloy/wiki/Running-the-sandbox-locally-over-HTTPS-on-Mac-OS).
- Make sure the PR merges cleanly with the latest main.
- Obtain 3 approvals from the Core Web SDK team to have your PR approved.
- If a consensus isn’t reached regarding any code concern, Joe will provide the final say.
- We encourage and enjoy open minded, deep discussions on this team. Try your best to propose a design that the whole team agrees with.


## Ownership

While contributors are not expected to maintain the feature post-contribution, for a smooth handover, we require:

- Detailed technical documents explaining the feature and architecture.
- Engage in discussions with the AEP Web SDK core team to ensure full understanding and approval of the design and code.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ Alloy is the code name for the Adobe Experience Platform Web SDK. It allows for

For documentation on how to use Alloy, please see the [user documentation](https://experienceleague.adobe.com/docs/experience-platform/edge/home.html).

For documentation on how to contribute to Alloy, please see the [developer documentation](https://github.com/adobe/alloy/wiki).

## Contribution

Check out the [contribution guidelines](CONTRIBUTING.md) for quick start information, and head over to the [developer documentation](https://github.com/adobe/alloy/wiki) to understand the architecture and structure of the library.
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.19.0-beta.14",
"version": "2.19.1",
"description": "Adobe Experience Platform Web SDK",
"main": "libEs5/index.js",
"module": "libEs6/index.js",
Expand Down Expand Up @@ -70,7 +70,7 @@
"uuid": "^3.3.2"
},
"devDependencies": {
"@adobe/alloy": "^2.19.0-beta.14",
"@adobe/alloy": "^2.19.1",
"@babel/cli": "^7.12.8",
"@babel/core": "^7.2.2",
"@babel/plugin-proposal-object-rest-spread": "^7.3.2",
Expand Down
48 changes: 43 additions & 5 deletions sandbox/src/components/InAppMessagesDemo/InAppMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import React, { useEffect, useState } from "react";
import ContentSecurityPolicy from "../ContentSecurityPolicy";
import "./InAppMessagesStyle.css";

const configKey = localStorage.getItem("iam-configKey") || "stage";
const configKey =
localStorage.getItem("iam-configKey") || "aemonacpprodcampaign";

const config = {
cjmProdNld2: {
Expand Down Expand Up @@ -53,14 +54,32 @@ if (alloyInstance !== window.alloy) {
edgeDomain,
thirdPartyCookiesEnabled: false,
targetMigrationEnabled: false,
personalizationStorageEnabled: true,
debugEnabled: true
});
}

const CUSTOM_TRAIT_KEY = "iam-customtrait-key";
const CUSTOM_TRAIT_VALUE = "iam-customtrait-value";

export default function InAppMessages() {
const [sentEvent, setSentEvent] = useState(false);
const [customTraitKey, setCustomTraitKey] = useState("");
const [customTraitValue, setCustomTraitValue] = useState("");
const [customTraitKey, setCustomTraitKeyInternal] = useState(
localStorage.getItem(CUSTOM_TRAIT_KEY) || ""
);
const [customTraitValue, setCustomTraitValueInternal] = useState(
localStorage.getItem(CUSTOM_TRAIT_VALUE) || ""
);

const setCustomTraitKey = value => {
setCustomTraitKeyInternal(value);
localStorage.setItem(CUSTOM_TRAIT_KEY, value);
};

const setCustomTraitValue = value => {
setCustomTraitValueInternal(value);
localStorage.setItem(CUSTOM_TRAIT_VALUE, value);
};

useEffect(() => {
const unsubscribePromise = alloyInstance("subscribeRulesetItems", {
Expand Down Expand Up @@ -93,8 +112,24 @@ export default function InAppMessages() {

alloyInstance("sendEvent", {
renderDecisions: true,
personalization: { surfaces: ["#hello"], decisionContext: context }
}).then(() => setSentEvent(true));
type: "decisioning.propositionFetch",
personalization: {
surfaces: ["#hello"],
decisionContext: context,
sendDisplayEvent: false
}
}).then(() => {
setSentEvent(true);
});
};

const sendDisplayEvents = () => {
alloyInstance("sendEvent", {
renderDecisions: false,
personalization: {
includeRenderedPropositions: true
}
});
};

const deleteAllCookies = () => {
Expand Down Expand Up @@ -154,6 +189,9 @@ export default function InAppMessages() {
</span>
</div>
<button onClick={() => renderDecisions()}>sendEvent</button>
<button onClick={() => sendDisplayEvents()} disabled={!sentEvent}>
send display events
</button>
<button onClick={() => renderDecisions(true)} disabled={!sentEvent}>
evaluateRulesets
</button>
Expand Down
15 changes: 12 additions & 3 deletions src/components/DecisioningEngine/createApplyResponse.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,20 @@ OF ANY KIND, either express or implied. See the License for the specific languag
governing permissions and limitations under the License.
*/
export default lifecycle => {
return ({ viewName, renderDecisions = false, propositions = [] }) => {
return ({
renderDecisions = false,
propositions = [],
event,
personalization
}) => {
if (propositions.length > 0 && lifecycle) {
lifecycle.onDecision({ renderDecisions, viewName, propositions });
lifecycle.onDecision({
renderDecisions,
propositions,
event,
personalization
});
}

return { propositions };
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@ export default (payload, eventRegistry, decisionHistory) => {
)
.map(consequenceAdapter)
.map(item => {
const {
firstTimestamp: qualifiedDate
} = decisionHistory.recordQualified(activityId);
const { firstTimestamp: qualifiedDate } =
decisionHistory.recordQualified(activityId) || {};

return {
...item,
Expand Down
11 changes: 10 additions & 1 deletion src/components/DecisioningEngine/createEventRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ import {
createSaveStorage,
getExpirationDate,
getActivityId,
hasExperienceData
hasExperienceData,
getDecisionProvider
} from "./utils";
import { EVENT_TYPE_TRUE } from "../../constants/eventType";
import { ADOBE_JOURNEY_OPTIMIZER } from "../../constants/decisionProvider";

const STORAGE_KEY = "events";
const MAX_EVENT_RECORDS = 1000;
Expand Down Expand Up @@ -66,6 +68,10 @@ export default ({ storage }) => {
setStorage(storage);

const addEvent = (event, eventType, eventId, action) => {
if (!eventType || !eventId) {
return undefined;
}

if (!events[eventType]) {
events[eventType] = {};
}
Expand Down Expand Up @@ -125,6 +131,9 @@ export default ({ storage }) => {
.filter(validPropositionEventType)
.forEach(propositionEventType => {
propositions.forEach(proposition => {
if (getDecisionProvider(proposition) !== ADOBE_JOURNEY_OPTIMIZER) {
return;
}
addEvent(
{},
propositionEventType,
Expand Down
12 changes: 8 additions & 4 deletions src/components/DecisioningEngine/createOnResponseHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ export default ({
decisionProvider,
applyResponse,
event,
personalization,
decisionContext
}) => {
const context = {
...flattenObject(event.getContent()),
...decisionContext
};
const viewName = event.getViewName();

return ({ response }) => {
decisionProvider.addPayloads(
Expand All @@ -32,11 +32,15 @@ export default ({

// only evaluate events that include a personalization query
if (!event.hasQuery()) {
return;
return { propositions: [] };
}

const propositions = decisionProvider.evaluate(context);

applyResponse({ viewName, renderDecisions, propositions });
return applyResponse({
renderDecisions,
propositions,
event,
personalization
});
};
};
5 changes: 5 additions & 0 deletions src/components/DecisioningEngine/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
} from "./constants";
import createEvaluateRulesetsCommand from "./createEvaluateRulesetsCommand";
import { clearLocalStorage, createInMemoryStorage } from "./utils";
import { objectOf, boolean } from "../../utils/validation";

const createDecisioningEngine = ({
config,
Expand Down Expand Up @@ -84,6 +85,7 @@ const createDecisioningEngine = ({
decisionProvider,
applyResponse,
event,
personalization,
decisionContext: contextProvider.getContext({
[CONTEXT_KEY.TYPE]: CONTEXT_EVENT_TYPE.EDGE,
[CONTEXT_KEY.SOURCE]: CONTEXT_EVENT_SOURCE.REQUEST,
Expand Down Expand Up @@ -117,4 +119,7 @@ const createDecisioningEngine = ({
};

createDecisioningEngine.namespace = "DecisioningEngine";
createDecisioningEngine.configValidators = objectOf({
personalizationStorageEnabled: boolean().default(false)
});
export default createDecisioningEngine;
6 changes: 6 additions & 0 deletions src/components/DecisioningEngine/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,9 @@ export const hasExperienceData = xdm => {

return true;
};

export const getDecisionProvider = proposition => {
const { scopeDetails = {} } = proposition;
const { decisionProvider } = scopeDetails;
return decisionProvider;
};
Loading

0 comments on commit ffc2b14

Please sign in to comment.