@go-mailer/jarvis 3.1.3 → 3.1.5

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/index.js CHANGED
@@ -3,5 +3,6 @@ const FeatureFlag = require('./lib/flag')
3
3
  const QueryBuilder = require('./lib/query')
4
4
  const HTTP = require('./lib/middlewares/http')
5
5
  const Authenticator = require('./lib/middlewares/auth')
6
+ const AutomationConstants = require('./lib/constants/automation')
6
7
  const { RequestLogger, ProcessLogger } = require('./lib/middlewares/logger')
7
- module.exports = { RequestLogger, ProcessLogger, Authenticator, EnvVar, FeatureFlag, HTTP, QueryBuilder }
8
+ module.exports = { RequestLogger, ProcessLogger, Authenticator, AutomationConstants, EnvVar, FeatureFlag, HTTP, QueryBuilder }
@@ -0,0 +1,13 @@
1
+ module.exports = {
2
+ EVENT_CLICKED_LINK: 'clicked_link',
3
+ EVENT_NEW_CONTACT: 'new_contact',
4
+ EVENT_OPENED_CAMPAIGN: 'opened_campaign',
5
+ EVENT_OPENED_TRANSACTIONAL: 'opened_transactional',
6
+ EVENT_SUBSCRIPTION: 'left_audience',
7
+ EVENT_UNSUBSCRIPTION: 'left_audience',
8
+
9
+ //
10
+ EFFECT_SEND_TRANSACTIONAL: 'send_transactional_email',
11
+ EFFECT_SUBSCRIBE: 'add_to_audience',
12
+ EFFECT_UNSUBSCRIBE: 'remove_from_audience'
13
+ }
@@ -8,6 +8,11 @@ const { Logtail } = require("@logtail/node");
8
8
  const LOGTAIL_SECRET = Env.fetch("LOGTAIL_SECRET", true);
9
9
  const logtail = new Logtail(LOGTAIL_SECRET);
10
10
 
11
+ function hashLogData (log = {}) {
12
+ const hashed = JSON.stringify(log).replace(/\w+@/gi, '************')
13
+ return JSON.parse(hashed)
14
+ }
15
+
11
16
  function RequestLogger() {
12
17
  const app_name = Env.fetch("APP_NAME", true);
13
18
  return (request, response, next) => {
@@ -54,9 +59,9 @@ function RequestLogger() {
54
59
  let error = payload ? payload.error : statusMessage;
55
60
  if (error) {
56
61
  log.error = error;
57
- logtail.error(pathname, log);
62
+ logtail.error(pathname, hashLogData(log));
58
63
  } else {
59
- logtail.info(pathname, log);
64
+ logtail.info(pathname, hashLogData(log));
60
65
  }
61
66
 
62
67
  logtail.flush();
@@ -72,25 +77,25 @@ class ProcessLogger {
72
77
  }
73
78
 
74
79
  error(error, method = "unspecified_method", params = {}) {
75
- logtail.error(`${this.service}:${method}:${error.message}`, {
80
+ logtail.error(`${this.service}:${method}:${error.message}`, hashLogData({
76
81
  app_name: Env.fetch("APP_NAME", true),
77
82
  type: "process",
78
83
  message: error.message,
79
84
  trace: error.stack,
80
85
  params,
81
- });
86
+ }));
82
87
  logtail.flush();
83
88
  }
84
89
 
85
90
  info(info, method = "unspecified_method", params = {}) {
86
91
  const message_str = `${this.service}:${method}:${info}`;
87
92
  console.log(message_str);
88
- logtail.info(message_str, {
93
+ logtail.info(message_str, hashLogData({
89
94
  app_name: Env.fetch("APP_NAME", true),
90
95
  type: "process",
91
96
  message: info,
92
97
  params,
93
- });
98
+ }));
94
99
  logtail.flush();
95
100
  }
96
101
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-mailer/jarvis",
3
- "version": "3.1.3",
3
+ "version": "3.1.5",
4
4
  "main": "index.js",
5
5
  "repository": "git@github.com:go-mailer-ltd/jarvis-node.git",
6
6
  "author": "Nathan Oguntuberu <nateoguns.work@gmail.com>",