-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: WebEngage integration #557
base: master
Are you sure you want to change the base?
Conversation
app/server/app.js
Outdated
|
||
export const app = createApp(); | ||
|
||
upstreamQuintypeRoutes(app, {}); | ||
const jsonParser = express.json(); |
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.
unused variable
app/server/handlers/render-layout.js
Outdated
@@ -38,7 +38,7 @@ export async function renderLayout(res, params) { | |||
const placeholderDelay = parseInt( | |||
get(params.store.getState(), ["qt", "config", "publisher-attributes", "placeholder_delay"]) | |||
); | |||
|
|||
const webengageLicenseCode = get(params.store.getState(), ["qt", "config", "webengage-config", "licenseCode"], ""); |
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.
refactor params.store.getState()
into a variable use
const audienceCreationResponse = await ( | ||
await fetch(url, { | ||
method: "POST", | ||
body: JSON.stringify(platform === "push-notifications" ? appRequestPayload : webRequestPayload), |
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.
use function, take it out
const campaignId = get(audienceCreationResponse, ["response", "data", "id"]); | ||
return campaignId; |
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.
const campaignId = get(audienceCreationResponse, ["response", "data", "id"]); | |
return campaignId; | |
return get(audienceCreationResponse, ["response", "data", "id"]); |
title, | ||
description: message || subheadline, | ||
sampling: 100, | ||
icon: `https://afiles.webengage.com/${licenseCode}/97bd14d8-58fe-4303-be6c-9a1c2b99787f.jpg`, |
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.
remove hardcoded icon
}, | ||
{ | ||
sampling: 50, | ||
layoutEId: "~20cc49c5", |
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.
ID
await ( | ||
await fetch(url, { | ||
method: "PUT", | ||
body: JSON.stringify(platform === "push-notifications" ? appPushRequestPayload : webRequestPayload), |
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.
func
// Step 2: Schedule campaign -- WHEN | ||
await scheduleCampaign({ | ||
res, | ||
url: `${BASE_URL}/api/v1/accounts/${licenseCode}/${WEB_PUSH_PLATFORM}/${campaignId}/targetingRule/schedule`, |
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.
use const / func
let targetMapping = []; | ||
const targets = get(webhookContent, "targets", []); | ||
|
||
targetMapping = targets.map((target) => | ||
targetHandlers[target]({ res, webhookContent, cdnName, sketchesHost, eventType }) | ||
); |
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.
let targetMapping = []; | |
const targets = get(webhookContent, "targets", []); | |
targetMapping = targets.map((target) => | |
targetHandlers[target]({ res, webhookContent, cdnName, sketchesHost, eventType }) | |
); | |
const targets = get(webhookContent, "targets", []); | |
const targetMapping = targets.map((target) => | |
targetHandlers[target]({ res, webhookContent, cdnName, sketchesHost, eventType }) | |
); |
await ( | ||
await fetch(url, { method: "POST", body: JSON.stringify(requestPayload), headers: webengageHeaders }) | ||
).json(); |
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.
await ( | |
await fetch(url, { method: "POST", body: JSON.stringify(requestPayload), headers: webengageHeaders }) | |
).json(); | |
const response = await fetch(url, { method: "POST", body: JSON.stringify(requestPayload), headers: webengageHeaders }) | |
await response.json(); |
app/server/app.js
Outdated
import express from "express"; | ||
import bodyParser from "body-parser"; |
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.
can we move these lines to the top. just to keep all external library imports at one place
await ( | ||
await fetch(url, { method: "POST", body: JSON.stringify(requestPayload), headers: webengageHeaders }) | ||
).json(); |
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.
wouldn't it be more readable if we take the fetch response in a variable?
const getUrl = (url, platform, path) => { | ||
return path === "" | ||
? `${url}/${licenseCode}/${platform}` | ||
: path === "conversions" | ||
? `${url}/${licenseCode}/${path}` | ||
: `${url}/${licenseCode}/${platform}/${path}`; | ||
}; |
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.
switch
config/webengage-config.js
Outdated
licenseCode: "11b564a4b", | ||
apiKey: "1f30ed80-2618-46fc-a7dc-116be3984a85", |
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.
not in code
Description
Please include the summary of the change made. Please include the required context here. Please include the issue reference for the fix and the dependencies reference for the change.
Fixes # (issue-reference)
Dependencies # (dependency-issue-reference)
Documentation # (link to the corresponding documentation changes)
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Checklist: