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

feat: WebEngage integration #557

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open

Conversation

VeenaYemmiganur
Copy link
Contributor

@VeenaYemmiganur VeenaYemmiganur commented Nov 3, 2023

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.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

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

  • Test Case A
  • Test Case B

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@VeenaYemmiganur VeenaYemmiganur changed the title New we integration feat: WE integration Nov 17, 2023
@VeenaYemmiganur VeenaYemmiganur changed the title feat: WE integration feat: WebEngage integration Nov 17, 2023

export const app = createApp();

upstreamQuintypeRoutes(app, {});
const jsonParser = express.json();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused variable

@@ -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"], "");
Copy link
Contributor

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),
Copy link
Contributor

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

Comment on lines 34 to 35
const campaignId = get(audienceCreationResponse, ["response", "data", "id"]);
return campaignId;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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`,
Copy link
Contributor

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",
Copy link
Contributor

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),
Copy link
Contributor

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`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use const / func

Comment on lines 134 to 139
let targetMapping = [];
const targets = get(webhookContent, "targets", []);

targetMapping = targets.map((target) =>
targetHandlers[target]({ res, webhookContent, cdnName, sketchesHost, eventType })
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 })
);

views/js/service-worker.ejs Show resolved Hide resolved
Comment on lines 34 to 36
await (
await fetch(url, { method: "POST", body: JSON.stringify(requestPayload), headers: webengageHeaders })
).json();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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();

Comment on lines 18 to 19
import express from "express";
import bodyParser from "body-parser";
Copy link
Contributor

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

Comment on lines 23 to 25
await (
await fetch(url, { method: "POST", body: JSON.stringify(requestPayload), headers: webengageHeaders })
).json();
Copy link
Contributor

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?

Comment on lines 20 to 26
const getUrl = (url, platform, path) => {
return path === ""
? `${url}/${licenseCode}/${platform}`
: path === "conversions"
? `${url}/${licenseCode}/${path}`
: `${url}/${licenseCode}/${platform}/${path}`;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switch

Comment on lines 3 to 4
licenseCode: "11b564a4b",
apiKey: "1f30ed80-2618-46fc-a7dc-116be3984a85",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not in code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants