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

Added support for rendering in-app messages from Adobe Journey Optimizer #1029

Merged
merged 101 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from 84 commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
936ed32
messaging action modules
jasonwaters Apr 10, 2023
5a5b61b
banner test
jasonwaters Apr 11, 2023
bc28a58
modal test
jasonwaters Apr 11, 2023
f19788b
decisioning engine component
jasonwaters Apr 13, 2023
ffcc6dd
fix test
jasonwaters Apr 17, 2023
9d4662e
removed modulesProvider and refactored it into actionsProvider with a…
jasonwaters Apr 18, 2023
078198f
Merge branch 'in-browser-messages' into render-messages
jasonwaters Apr 19, 2023
c7f7746
license headers
jasonwaters Apr 19, 2023
417de7e
Merge branch 'in-browser-messages' into decisioning-engine
jasonwaters Apr 19, 2023
fc01df2
license headers
jasonwaters Apr 19, 2023
b496b1b
Merge branch 'render-messages' into in-browser-messages-temp
jasonwaters Apr 24, 2023
95dd975
Merge branch 'decisioning-engine' into in-browser-messages-temp
jasonwaters Apr 24, 2023
e52ba88
introduced context provider for managing context
jasonwaters Apr 26, 2023
571a5b6
license header
jasonwaters Apr 26, 2023
62a8daf
introduced context provider for managing context
jasonwaters Apr 26, 2023
395c2a6
license header
jasonwaters Apr 26, 2023
c3f2ed5
message feed POC
jasonwaters Apr 28, 2023
13a7668
added some tests.
jasonwaters May 2, 2023
10b501a
Merge branch 'main' into decisioning-engine
jasonwaters May 2, 2023
0c8f472
Merge branch 'main' into in-browser-messages-feed-poc
jasonwaters May 2, 2023
c29587e
Merge branch 'main' into render-messages
jasonwaters May 2, 2023
f3ffb3b
track display/interact events and save to storage
jasonwaters May 2, 2023
a664d89
Merge branch 'decisioning-engine' into in-browser-messages-feed-poc
jasonwaters May 2, 2023
cdb7fb7
limit event storage
jasonwaters May 2, 2023
cf95253
Merge branch 'decisioning-engine' into in-browser-messages-feed-poc
jasonwaters May 2, 2023
8ec3aed
store decision history as object
jasonwaters May 4, 2023
772dff9
decisioning.qualifiedItem event
jasonwaters May 4, 2023
8447c99
refactor event registry a little
jasonwaters May 4, 2023
788722c
provide collect function to messaging actions
jasonwaters May 5, 2023
4c5d3c3
fix package-lock.json
jasonwaters May 5, 2023
14d7130
fix debounce test
jasonwaters May 5, 2023
00a2ff3
Merge branch 'render-messages' into in-browser-messages-feed-poc
jasonwaters May 8, 2023
c3bb389
Merge branch 'decisioning-engine' into in-browser-messages-feed-poc
jasonwaters May 8, 2023
b35e475
Merge branch 'in-browser-messages' into decisioning-engine
jasonwaters May 8, 2023
6992aa5
Merge branch 'in-browser-messages' into render-messages
jasonwaters May 8, 2023
dd8e2dd
applyResponse initialized once
jasonwaters May 9, 2023
a4e280a
CJM-45417-globalDecisionContext (#986)
shandilya3 May 22, 2023
5d6f5fa
Merge pull request #979 from adobe/decisioning-engine
jasonwaters May 22, 2023
dd5b6de
Merge branch 'in-browser-messages' into render-messages
jasonwaters May 22, 2023
95aabf7
Merge pull request #976 from adobe/render-messages
jasonwaters May 22, 2023
918bc02
don't flatten events on context
jasonwaters May 22, 2023
ace9baf
Merge branch 'in-browser-messages' into in-browser-messages-feed-poc
jasonwaters May 22, 2023
8d4914f
Merge branch 'main' into in-browser-messages
jasonwaters May 22, 2023
c34a0b7
Merge branch 'in-browser-messages' into in-browser-messages-feed-poc
jasonwaters May 22, 2023
f710292
[CJM-48525]Renamed renderDecision command to evaluateRulesets (#994)
shandilya3 Jun 1, 2023
e2ac6f5
added consequence adapter and refactored iframe display code
jasonwaters Jul 27, 2023
32a432d
license
jasonwaters Jul 27, 2023
86c742b
[CJM-48522]Purge historical events post retention period (#997)
shandilya3 Aug 2, 2023
0f01322
defensively check for ruleset items
jasonwaters Aug 7, 2023
7137deb
Merge branch 'in-browser-messages' into in-browser-messages-feed-poc
jasonwaters Aug 18, 2023
f0b9c69
update to schema based actions
jasonwaters Aug 23, 2023
52f44b1
update schemas
jasonwaters Aug 25, 2023
04cb535
Merge branch 'in-browser-messages' into consequenceAdapter
jasonwaters Aug 25, 2023
303d992
rename json-ruleset-item to ruleset-item
jasonwaters Aug 25, 2023
b375023
Merge branch 'main' into consequenceAdapter
jasonwaters Aug 25, 2023
599a676
rename in-app message schema
jasonwaters Aug 28, 2023
d3f749c
Dismiss Messages & url click (#1024)
shandilya3 Aug 29, 2023
2507b8e
Merge branch 'main' into in-browser-messages
jasonwaters Aug 29, 2023
7050af9
Merge branch 'in-browser-messages' into consequenceAdapter
jasonwaters Aug 29, 2023
0fef6ec
Merge branch 'main' into in-browser-messages-feed-poc
jasonwaters Aug 29, 2023
65bdcdd
Merge branch 'in-browser-messages' into in-browser-messages-feed-poc
jasonwaters Aug 29, 2023
3fe4b65
rename qualified event to decisioning.propositionQualified
jasonwaters Aug 29, 2023
e852f18
fix test
jasonwaters Aug 29, 2023
fcef6ac
subscribeRulesetItems command
jasonwaters Aug 29, 2023
8c037cf
license
jasonwaters Aug 29, 2023
e5863d6
Merge pull request #1026 from adobe/in-browser-messages-feed-poc
jasonwaters Aug 29, 2023
050f7b6
remove IAM types, add message feed actions modules
jasonwaters Aug 30, 2023
da2de83
license
jasonwaters Aug 30, 2023
8d485b9
ensure schema based ruleset consequences
jasonwaters Aug 31, 2023
8447ce9
message feed sandbox (#1028)
shandilya3 Sep 6, 2023
d6fdfca
support "Send data to platform" trigger (#1030)
jasonwaters Sep 7, 2023
211a477
[CJM-46521] Send interact events when in-app messages are clicked (#1…
jasonwaters Sep 11, 2023
ee9948a
evaluateRulesetsCommand (#1033)
jasonwaters Sep 11, 2023
3faee3e
Merge branch 'combineNotifications' into in-browser-messages-merge
jasonwaters Sep 12, 2023
d3291c8
Merge branch 'topAndBottom2' into in-browser-messages-merge
jasonwaters Sep 14, 2023
544cfb3
functional tests (#1034)
shandilya3 Sep 15, 2023
6149e5a
Merge pull request #1037 from adobe/in-browser-messages-merge
jasonwaters Sep 15, 2023
a3f09ae
web parameters support (#1035)
shandilya3 Sep 22, 2023
8da8294
Merge branch 'main' into in-browser-messages
jasonwaters Sep 22, 2023
0add1a2
support "~timestampu" and "~timestampz" (#1044)
shandilya3 Sep 26, 2023
0cec5f1
In browser messages e2e (#1045)
jasonwaters Oct 10, 2023
4a2ae69
resolve config warning on iam demo page
jasonwaters Oct 10, 2023
f4f3305
support manual triggers
jasonwaters Oct 10, 2023
8021d1c
remove surface designation on IAM sandbox demo
jasonwaters Oct 11, 2023
bd77c84
clear cookies when switching demo environment
jasonwaters Oct 12, 2023
e64e9f9
Historical events fix (#1051)
shandilya3 Oct 12, 2023
6a83ade
fix for click through (#1054)
jasonwaters Oct 18, 2023
f738fcd
Merge branch 'main' into in-browser-messages
jasonwaters Oct 18, 2023
da6857b
Code Review Fixes (#1052)
shandilya3 Oct 18, 2023
a4654c8
IAM: support multiple subscriptions (#1059)
jasonwaters Oct 25, 2023
f2a3b70
rename mobile events
jasonwaters Oct 25, 2023
2d11af7
Merge branch 'main' into in-browser-messages
jasonwaters Oct 25, 2023
121c8c2
Consent & local storage config flag (#1064)
shandilya3 Oct 25, 2023
b5a39e0
remove message-feed (#1065)
jasonwaters Oct 25, 2023
1829b46
Move decisionContext within personalization (#1068)
jasonwaters Oct 26, 2023
f9e5d66
few test (#1067)
shandilya3 Oct 26, 2023
fdd8f0f
code review fix (#1069)
shandilya3 Oct 26, 2023
d740196
Merge branch 'main' into in-browser-messages
jasonwaters Oct 27, 2023
899ec90
some fixes (#1071)
jasonwaters Oct 27, 2023
382b3da
remove ALLOY from constants
jasonwaters Oct 27, 2023
b8829e5
Merge branch 'in-browser-messages' of github.com:adobe/alloy into in-…
jasonwaters Oct 27, 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
42 changes: 42 additions & 0 deletions package-lock.json

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

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"format": "prettier --write \"*.{html,js}\" \"{sandbox,src,test,scripts}/**/*.{html,js}\"",
"test": "npm run test:unit && npm run test:scripts && npm run test:functional",
"test:unit": "karma start --single-run",
"testdebug": "karma start --browsers=Chrome --single-run=false --debug",
shandilya3 marked this conversation as resolved.
Show resolved Hide resolved
"test:unit:watch": "karma start",
"test:unit:saucelabs:local": "karma start karma.saucelabs.conf.js --single-run",
"test:unit:coverage": "karma start --single-run --reporters spec,coverage",
Expand Down Expand Up @@ -58,11 +59,14 @@
}
],
"dependencies": {
"@adobe/aep-rules-engine": "^2.0.1",
"@adobe/reactor-cookie": "^1.0.0",
"@adobe/reactor-load-script": "^1.1.1",
"@adobe/reactor-object-assign": "^1.0.0",
"@adobe/reactor-query-string": "^1.0.0",
"css.escape": "^1.5.1",
"js-cookie": "2.2.1",
"parse-uri": "^1.0.7",
jasonwaters marked this conversation as resolved.
Show resolved Hide resolved
"uuid": "^3.3.2"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion sandbox/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
!function(n,o){o.forEach(function(o){n[o]||((n.__alloyNS=n.__alloyNS||
[]).push(o),n[o]=function(){var u=arguments;return new Promise(
function(i,l){n[o].q.push([i,l,u])})},n[o].q=[])})}
(window,["alloy", "organizationTwo", "cjmProd"]);
(window,["alloy", "organizationTwo", "cjmProd", 'iamAlloy']);
</script>

<script nonce="%REACT_APP_NONCE%">
Expand Down
10 changes: 10 additions & 0 deletions sandbox/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import PersonalizationFormBased from "./PersonalizationFormBased";
import Identity from "./Identity";
import AlloyVersion from "./components/AlloyVersion";
import ConfigOverrides from "./ConfigOverrides.jsx";
import InAppMessages from "./components/InAppMessagesDemo/InAppMessages";
import MessageFeed from "./components/MessageFeedDemo/MessageFeed";

const BasicExample = () => {
return (
Expand Down Expand Up @@ -96,6 +98,12 @@ const BasicExample = () => {
<li>
<a href="/configOverrides">Config Overrides</a>
</li>
<li>
<Link to="/inAppMessages">In-app Messages</Link>
</li>
<li>
<Link to="/messageFeed">Message Feed</Link>
</li>
</ul>
<hr />

Expand Down Expand Up @@ -125,6 +133,8 @@ const BasicExample = () => {
<Route path="/redirectedNewPage" component={RedirectedNewPage} />
<Route path="/identity" component={Identity} />
<Route path="/configOverrides" component={ConfigOverrides} />
<Route path="/inAppMessages" component={InAppMessages} />
<Route path="/messageFeed" component={MessageFeed} />
</div>
</Router>
<AlloyVersion />
Expand Down
2 changes: 1 addition & 1 deletion sandbox/src/components/ContentSecurityPolicy.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function ContentSecurityPolicy() {
http-equiv="Content-Security-Policy"
// cdn.tt.omtrdc.net is necessary for Target VEC to function properly.
// *.sc.omtrdc.net is necessary for Analytics Data Insertion API to function properly
content={`default-src 'self';
content={`default-src 'self' blob:;
shandilya3 marked this conversation as resolved.
Show resolved Hide resolved
script-src 'self' 'nonce-${process.env.REACT_APP_NONCE}' cdn.jsdelivr.net assets.adobedtm.com cdn.tt.omtrdc.net;
style-src 'self' 'unsafe-inline';
img-src * data:;
Expand Down
204 changes: 204 additions & 0 deletions sandbox/src/components/InAppMessagesDemo/InAppMessages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
/* eslint-disable no-bitwise, no-console */
import React, { useState } from "react";
import ContentSecurityPolicy from "../ContentSecurityPolicy";
import "./InAppMessagesStyle.css";

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

const config = {
cjmProdNld2: {
name: "CJM Prod NLD2 – Prod (NLD2)",
alloyInstance: window.alloy,
datastreamId: "7a19c434-6648-48d3-948f-ba0258505d98",
orgId: "4DA0571C5FDC4BF70A495FC2@AdobeOrg",
surface: "mobileapp://com.adobe.iamTutorialiOS",
carterworks marked this conversation as resolved.
Show resolved Hide resolved
decisionContext: {
"~type": "com.adobe.eventType.generic.track",
"~source": "com.adobe.eventSource.requestContent",
state: "",
"~state.com.adobe.module.lifecycle/lifecyclecontextdata.dayofweek": 1
},
edgeDomain: "edge.adobedc.net",
activeCampaigns: [
"https://experience.adobe.com/#/@cjmprodnld2/sname:prod/journey-optimizer/campaigns/summary/59bfdc09-03b9-4cd5-9ab8-5c2a045b0b2e"
]
},
aemonacpprodcampaign: {
name: "AEM Assets Departmental - Campaign – Prod (VA7)",
alloyInstance: window.iamAlloy,
datastreamId: "8cefc5ca-1c2a-479f-88f2-3d42cc302514",
orgId: "906E3A095DC834230A495FD6@AdobeOrg",
surface: "mobileapp://com.adobe.aguaAppIos",
decisionContext: {},
edgeDomain: "edge.adobedc.net",
activeCampaigns: [
"https://experience.adobe.com/#/@aemonacpprodcampaign/sname:prod/journey-optimizer/campaigns/summary/8bb52c05-d381-4d8b-a67a-95f345776322"
]
},
stage: {
name: "CJM Stage - AJO Web (VA7)",
alloyInstance: window.iamAlloy,
datastreamId: "15525167-fd4e-4511-b9e0-02119485784f",
orgId: "745F37C35E4B776E0A49421B@AdobeOrg",
surface: "web://localhost:3000/inAppMessages",
decisionContext: {},
edgeDomain: "edge-int.adobedc.net"
}
};

const {
datastreamId,
orgId,
surface,
decisionContext,
edgeDomain,
alloyInstance
} = config[configKey];

if (alloyInstance !== window.alloy) {
alloyInstance("configure", {
datastreamId,
orgId,
edgeDomain,
thirdPartyCookiesEnabled: false,
targetMigrationEnabled: false,
debugEnabled: true
});
}

alloyInstance("subscribeRulesetItems", {
surfaces: [surface],
callback: result => {
console.log("subscribeRulesetItems", result);
}
});

const uuidv4 = () => {
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
(
c ^
(crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))
).toString(16)
);
};

const getInAppPayload = async payload => {
const res = await fetch(
`https://${edgeDomain}/ee/or2/v1/interact?configId=${datastreamId}&requestId=${uuidv4()}`,
{
method: "POST",
body: JSON.stringify(payload)
}
);
return res.json();
};

const fetchMobilePayload = () =>
getInAppPayload({
events: [
{
query: {
personalization: {
surfaces: [surface]
}
},
xdm: {
timestamp: new Date().toISOString(),
implementationDetails: {
name: "https://ns.adobe.com/experience/mobilesdk/ios",
version: "3.7.4+1.5.0",
environment: "app"
jasonwaters marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
]
});

export default function InAppMessages() {
const [sentEvent, setSentEvent] = useState(false);
const [customTraitKey, setCustomTraitKey] = useState("");
const [customTraitValue, setCustomTraitValue] = useState("");

const renderDecisions = (useEvaluateRulesetsCommand = false) => {
const context = { ...decisionContext };

if (customTraitKey.length !== 0 && customTraitValue.length !== 0) {
context[customTraitKey] = customTraitValue;
}

if (useEvaluateRulesetsCommand) {
alloyInstance("evaluateRulesets", {
renderDecisions: true,
decisionContext: context
});
return;
}

if (surface.startsWith("mobileapp://")) {
fetchMobilePayload().then(response => {
alloyInstance("applyResponse", {
renderDecisions: true,
decisionContext: context,
responseBody: response
}).then(() => setSentEvent(true));
});
} else {
alloyInstance("sendEvent", {
renderDecisions: true,
decisionContext: context
}).then(() => setSentEvent(true));
}
};

const setNewCofigEnv = value => {
localStorage.setItem("iam-configKey", value);
window.location.reload();
};

return (
<div>
<ContentSecurityPolicy />
<h1>In App Messages For Web</h1>
<div>
<label htmlFor="cars">Environment:</label>
<select
id="configEnv"
name="configEnv"
onChange={evt => setNewCofigEnv(evt.target.value)}
defaultValue={configKey}
>
{Object.keys(config).map(conf => (
<option key={conf} value={conf}>
{config[conf].name}
</option>
))}
</select>
<div style={{ marginBottom: "20px" }}>
<h3>Custom Trait</h3>
<span style={{ marginRight: "20px" }}>
<label htmlFor="input-custom-trait-key">Key</label>
<input
id="input-custom-trait-key"
type="text"
value={customTraitKey}
onChange={evt => setCustomTraitKey(evt.target.value)}
/>
</span>
<span style={{ marginRight: "20px" }}>
<label htmlFor="input-custom-trait-value">Value</label>
<input
id="input-custom-trait-value"
type="text"
value={customTraitValue}
onChange={evt => setCustomTraitValue(evt.target.value)}
/>
</span>
</div>
<button onClick={() => renderDecisions()}>sendEvent</button>
<button onClick={() => renderDecisions(true)} disabled={!sentEvent}>
evaluateRulesets
</button>
</div>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.custom-heading {
color: red;
font-size: 25px;
}
.element-spacing {
margin-right: 10px;
}
shandilya3 marked this conversation as resolved.
Show resolved Hide resolved
15 changes: 15 additions & 0 deletions sandbox/src/components/MessageFeedDemo/MessageFeed.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* Card.css */
.pretty-card {
color: black;
border: 1px solid #ccc;
border-radius: 8px;
padding: 16px;
margin: 16px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
background-color: lightblue;
transition: transform 0.2s;
}

.pretty-card:hover {
transform: scale(1.05);
}
Loading