@quintype/framework 7.18.2-webengage.3 → 7.18.2-webengage.4

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/server/routes.js +28 -24
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/framework",
3
- "version": "7.18.2-webengage.3",
3
+ "version": "7.18.2-webengage.4",
4
4
  "description": "Libraries to help build Quintype Node.js apps",
5
5
  "main": "index.js",
6
6
  "engines": {
package/server/routes.js CHANGED
@@ -312,7 +312,6 @@ exports.isomorphicRoutes = function isomorphicRoutes(
312
312
  handleNotFound = true,
313
313
  redirectRootLevelStories = false,
314
314
  mobileApiEnabled = true,
315
- feEnabled = true,
316
315
  mobileConfigFields = {},
317
316
  templateOptions = false,
318
317
  lightPages = false,
@@ -334,6 +333,7 @@ exports.isomorphicRoutes = function isomorphicRoutes(
334
333
  sMaxAge = 900,
335
334
  appLoadingPlaceholder = "",
336
335
  fcmServerKey = "",
336
+ enableWebengage = false,
337
337
  webengageLicenseCode,
338
338
  webengageApiKey,
339
339
  }
@@ -430,29 +430,33 @@ exports.isomorphicRoutes = function isomorphicRoutes(
430
430
 
431
431
  app.post("/register-fcm-topic", bodyParser.json(), withConfig(registerFCMTopic, { publisherConfig, fcmServerKey }));
432
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
- }
455
- });
433
+ if (enableWebengage) {
434
+ app.post("/webengage-api", bodyParser.json(), async (req, res) => {
435
+ const eventName = req.body.v1.event.name;
436
+ const { headline, subheadline, slug } = req.body;
437
+ console.log("hit /webengage-api", webengageLicenseCode, webengageApiKey, headline, subheadline, slug, eventName);
438
+ const url = `https://api.webengage.com/v2/accounts/${webengageLicenseCode}/business/save-event`;
439
+ try {
440
+ await request({
441
+ uri: url,
442
+ method: "POST",
443
+ headers: {
444
+ Authorization: `Bearer ${webengageApiKey}`,
445
+ "content-type": "application/json",
446
+ },
447
+ body: { eventName: "Story Created", eventData: { app: "malibu" } },
448
+ json: true,
449
+ });
450
+ console.log("inside the try block before return", eventName);
451
+ res.status(200).send("webengage event triggered successfully");
452
+ return;
453
+ } catch (error) {
454
+ console.log("The error is -->", error);
455
+ res.status(500).send("webengage event Failed");
456
+ return;
457
+ }
458
+ });
459
+ }
456
460
 
457
461
  if (manifestFn) {
458
462
  app.get("/manifest.json", withConfig(handleManifest, { manifestFn, logError }));