-
Notifications
You must be signed in to change notification settings - Fork 48
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 propositions option to sendEvent command to make display notifications easier #985
Closed
+445
−215
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8ea3178
Add propositions option and unit tests
jonsnyder 38338e8
Add Top/Bottom page to sandbox
jonsnyder e3b2e7a
Add functional test for sendEvent propositions option
jonsnyder 2ced965
Merge remote-tracking branch 'origin/main' into sendEventPropositions…
jonsnyder File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React, { useEffect } from "react"; | ||
import ContentSecurityPolicy from "./components/ContentSecurityPolicy"; | ||
|
||
export default function TopBottom() { | ||
useEffect(async () => { | ||
let { propositions } = await window.alloy("sendEvent", { | ||
renderDecisions: false, | ||
personalization: { | ||
decisionScopes: ["__view__"] | ||
}, | ||
xdm: { | ||
eventType: "decisioning.propositionFetch" | ||
} | ||
}); | ||
|
||
({ propositions } = await window.alloy("applyPropositions", { | ||
propositions | ||
})); | ||
|
||
await window.alloy("sendEvent", { | ||
xdm: { | ||
eventType: "page-view" | ||
}, | ||
propositions | ||
}); | ||
}, []); | ||
|
||
return ( | ||
<div> | ||
<ContentSecurityPolicy /> | ||
<h1>Top/Bottom Example</h1> | ||
<p> | ||
This page tests rendering of activities using an AJO surface. If you | ||
navigated here from another sandbox view, you will probably need to | ||
refresh your browser because this is how to properly simulate a non-SPA | ||
workflow. | ||
</p> | ||
<div | ||
style={{ border: "1px solid red" }} | ||
className="personalization-container" | ||
> | ||
This is the personalization placeholder. Personalized content has not | ||
been loaded. | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,7 @@ export default ({ | |
renderDecisions, | ||
decisionScopes = [], | ||
personalization = {}, | ||
propositions, | ||
onResponse = noop, | ||
onRequestFailure = noop | ||
}) { | ||
|
@@ -64,6 +65,27 @@ export default ({ | |
logger | ||
}); | ||
|
||
if (propositions && propositions.length > 0) { | ||
const propositionEventType = | ||
event.getEventType() === "decisioning.propositionInteract" || | ||
event.getPropositionEventType() === "interact" | ||
? "interact" | ||
: "display"; | ||
|
||
event.mergeXdm({ | ||
_experience: { | ||
decisioning: { | ||
propositions: propositions.map( | ||
({ id, scope, scopeDetails }) => ({ id, scope, scopeDetails }) | ||
), | ||
propositionEventType: { | ||
[propositionEventType]: 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does the |
||
} | ||
} | ||
} | ||
}); | ||
} | ||
|
||
if (personalizationDetails.shouldFetchData()) { | ||
const decisionsDeferred = defer(); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
test/functional/helpers/constants/configParts/configOverridesAlt.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
test/functional/helpers/constants/configParts/configOverridesMain.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { t } from "testcafe"; | ||
import createNetworkLogger from "../../helpers/networkLogger"; | ||
import { responseStatus } from "../../helpers/assertions/index"; | ||
import createFixture from "../../helpers/createFixture"; | ||
import { | ||
compose, | ||
orgMainConfigMain, | ||
debugEnabled | ||
} from "../../helpers/constants/configParts"; | ||
import { TEST_PAGE as TEST_PAGE_URL } from "../../helpers/constants/url"; | ||
import createAlloyProxy from "../../helpers/createAlloyProxy"; | ||
|
||
const networkLogger = createNetworkLogger(); | ||
const config = compose(orgMainConfigMain, debugEnabled); | ||
|
||
createFixture({ | ||
title: | ||
"C11001566: A display notification is sent when propositions are included in the sendEvent command", | ||
url: `${TEST_PAGE_URL}?test=C11001566`, | ||
requestHooks: [networkLogger.edgeEndpointLogs] | ||
}); | ||
|
||
test.meta({ | ||
ID: "C11001566", | ||
SEVERITY: "P0", | ||
TEST_RUN: "Regression" | ||
}); | ||
|
||
test("Test C11001566: A display notification is sent when propositions are included in the sendEvent command", async () => { | ||
const alloy = createAlloyProxy(); | ||
await alloy.configure(config); | ||
await alloy.sendEvent({ | ||
propositions: [ | ||
{ | ||
id: "C11001566", | ||
scope: "myscope", | ||
scopeDetails: { | ||
type: "test" | ||
} | ||
} | ||
] | ||
}); | ||
|
||
await responseStatus(networkLogger.edgeEndpointLogs.requests, 200); | ||
await t.expect(networkLogger.edgeEndpointLogs.requests.length).eql(1); | ||
|
||
const sendEventRequest = networkLogger.edgeEndpointLogs.requests[0]; | ||
const requestBody = JSON.parse(sendEventRequest.request.body); | ||
await t.expect(requestBody.events[0].xdm._experience.decisioning).eql({ | ||
propositionEventType: { | ||
display: 1 | ||
}, | ||
propositions: [ | ||
{ | ||
id: "C11001566", | ||
scope: "myscope", | ||
scopeDetails: { | ||
type: "test" | ||
} | ||
} | ||
] | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(non-blocking nitpick) Change this to
PropositionEventType.DISPLAY
andPropositionEventType.INTERACT
fromsrc/components/Personalization/constants/propositionEventType.js
.