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

Only set journey keys, dont reset. Add two types of example, simple a… #153

Merged
merged 1 commit into from
Apr 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 17 additions & 1 deletion injection/injection.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
<html>
<head><title>Session Injection</title></head>
<head>
<title>Session Injection</title>
<script>
function showExample(type) {
document.getElementById("payload").value =
document.getElementById(type+"Example").value;
return false;
}
</script>
</head>
<body>
<form method="POST">
</br/>
<% if (obj.notice) { %>
<h2 id="notice"><%- notice %></h2>
<% } %>
<h3>Session Injection JSON:</h3>
<div>
<a href="javascript: showExample('simple')">Show Simple Example</a>
<textarea id="simpleExample" style="display: none"><%- simpleExample %></textarea>
|
<a href="javascript: showExample('full')">Show Full Example</a>
<textarea id="fullExample" style="display: none"><%- fullExample %></textarea>
</div>
<textarea id="payload" name="payload" rows="20" cols="80"><%- payload %></textarea><br/><br/>
<input type="submit"/>
</form>
Expand Down
14 changes: 12 additions & 2 deletions injection/session-injection.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ const DEFAULTS = {
enumeratedDistribution: null
};

const SIMPLE_EXAMPLE = {
'featureFlags': {
'flag': true
},
'journeyKeys': {
'key': 'name'
}
};

const EXAMPLE = {
'journeyName': 'name',
'journeyKeys': {
Expand Down Expand Up @@ -98,7 +107,6 @@ class SessionInjection {
setJourneyKeys(req, journeyKeys) {
debug('setJourneyKeys', journeyKeys);
if (journeyKeys) {
req.journeyModel.reset();
req.journeyModel.set(journeyKeys);
}
}
Expand Down Expand Up @@ -233,7 +241,9 @@ class SessionInjection {

middlewareRender(req, res, next) {
if (req.accepts('html')) {
res.locals.payload = toJSON(res.locals.payload || EXAMPLE);
res.locals.fullExample = toJSON(EXAMPLE);
res.locals.simpleExample = toJSON(SIMPLE_EXAMPLE);
res.locals.payload = toJSON(res.locals.payload || SIMPLE_EXAMPLE);
res.locals.journeyKeys = toJSON(res.locals.journeyKeys);
res.locals.featureFlags = toJSON(res.locals.featureFlags);
res.locals.enumeratedDistribution = toJSON(res.locals.enumeratedDistribution);
Expand Down
Loading