@quintype/framework 7.18.2-webengage.2 → 7.18.2-webengage.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/server/routes.js +25 -3
package/package.json
CHANGED
package/server/routes.js
CHANGED
|
@@ -28,6 +28,7 @@ const bodyParser = require("body-parser");
|
|
|
28
28
|
const get = require("lodash/get");
|
|
29
29
|
const { URL } = require("url");
|
|
30
30
|
const prerender = require("@quintype/prerender-node");
|
|
31
|
+
const request = require("request-promise");
|
|
31
32
|
|
|
32
33
|
/**
|
|
33
34
|
* *upstreamQuintypeRoutes* connects various routes directly to the upstream API server.
|
|
@@ -333,6 +334,8 @@ exports.isomorphicRoutes = function isomorphicRoutes(
|
|
|
333
334
|
sMaxAge = 900,
|
|
334
335
|
appLoadingPlaceholder = "",
|
|
335
336
|
fcmServerKey = "",
|
|
337
|
+
webengageLicenseCode,
|
|
338
|
+
webengageApiKey,
|
|
336
339
|
}
|
|
337
340
|
) {
|
|
338
341
|
const withConfig = withConfigPartial(getClient, logError, publisherConfig, configWrapper);
|
|
@@ -427,9 +430,28 @@ exports.isomorphicRoutes = function isomorphicRoutes(
|
|
|
427
430
|
|
|
428
431
|
app.post("/register-fcm-topic", bodyParser.json(), withConfig(registerFCMTopic, { publisherConfig, fcmServerKey }));
|
|
429
432
|
|
|
430
|
-
app.post("/webengage-api", bodyParser.json(), (req, res) => {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
+
app.post("/webengage-api", bodyParser.json(), async (req, res) => {
|
|
434
|
+
const { headline, subheadline, slug } = req.body;
|
|
435
|
+
console.log("hit /webengage-api", webengageLicenseCode, webengageApiKey, headline, subheadline, slug);
|
|
436
|
+
const url = `https://api.webengage.com/v2/accounts/${webengageLicenseCode}/business/save-event`;
|
|
437
|
+
try {
|
|
438
|
+
await request({
|
|
439
|
+
uri: url,
|
|
440
|
+
method: "POST",
|
|
441
|
+
headers: {
|
|
442
|
+
Authorization: `Bearer ${webengageApiKey}`,
|
|
443
|
+
"content-type": "application/json",
|
|
444
|
+
},
|
|
445
|
+
body: { eventName: "Story Created", eventData: { app: "malibu" } },
|
|
446
|
+
json: true,
|
|
447
|
+
});
|
|
448
|
+
res.status(200).send("webengage event triggered successfully");
|
|
449
|
+
return;
|
|
450
|
+
} catch (error) {
|
|
451
|
+
console.log("The error is -->", error);
|
|
452
|
+
res.status(500).send("webengage event Failed");
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
433
455
|
});
|
|
434
456
|
|
|
435
457
|
if (manifestFn) {
|