@quintype/framework 7.18.2-webengage.7 → 7.18.2-webengage.9

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/framework",
3
- "version": "7.18.2-webengage.7",
3
+ "version": "7.18.2-webengage.9",
4
4
  "description": "Libraries to help build Quintype Node.js apps",
5
5
  "main": "index.js",
6
6
  "engines": {
@@ -1,10 +1,9 @@
1
+ const get = require("lodash/get");
1
2
  const request = require("request-promise");
2
3
 
3
- exports.webengageApi = async function webengageApi(req, res) {
4
- const webengageLicenseCode = "311c5229";
5
- const webengageApiKey = "2d5cb58e-7160-4f2a-b423-0c0d8007dd9c";
4
+ exports.webengageApi = async function webengageApi(req, res, next, { webengageApiKey, webengageLicenseCode }) {
5
+ const eventName = get(req, ["body", "v1", "event", "name"], "");
6
6
  let eventData = {};
7
- const eventName = req.body.v1.event.name;
8
7
 
9
8
  switch (eventName) {
10
9
  case "story-publish":
@@ -18,9 +17,7 @@ exports.webengageApi = async function webengageApi(req, res) {
18
17
  default:
19
18
  break;
20
19
  }
21
-
22
- console.log("hit /webengage-api by syncing ---->", eventName, eventData);
23
- const url = `https://api.webengage.com/v1/accounts/${webengageLicenseCode}/events`;
20
+ const url = `https://api.webengage.com/v2/accounts/${webengageLicenseCode}/business/save-event`;
24
21
  try {
25
22
  await request({
26
23
  uri: url,
@@ -29,7 +26,7 @@ exports.webengageApi = async function webengageApi(req, res) {
29
26
  Authorization: `Bearer ${webengageApiKey}`,
30
27
  "content-type": "application/json",
31
28
  },
32
- body: { eventName: eventName, eventData: { eventData }, userId: eventName },
29
+ body: { eventName: eventName, eventData: { eventData } },
33
30
  json: true,
34
31
  });
35
32
  res.status(200).send("webengage event triggered successfully");
package/server/routes.js CHANGED
@@ -430,7 +430,7 @@ 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(), webengageApi);
433
+ app.post("/webengage-api", bodyParser.json(), withConfig(webengageApi, { webengageLicenseCode, webengageApiKey }));
434
434
 
435
435
  if (manifestFn) {
436
436
  app.get("/manifest.json", withConfig(handleManifest, { manifestFn, logError }));