slack-logs 1.2.0 → 1.3.1

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/README.md CHANGED
@@ -38,7 +38,16 @@ Here is a basic example of how to use the Slack Log package to send a message to
38
38
 
39
39
  ```
40
40
  ...
41
- SLACK_WEBHOOK_URL="https://hooks.slack.com/services/******/******/********************"
41
+ # Slack Webhook URL for sending logs and notifications.
42
+ # Replace with your actual webhook URL.
43
+ SLACK_WEBHOOK_URL="https://hooks.slack.com/services/******/******/********************
44
+
45
+
46
+ # Optional field, defaults to "true".
47
+ # Set to "false" to disable Slack logs globally without changing the code.
48
+ ENABLE_SLACK_LOGS=true
49
+ # Note: No need to define this variable unless you want to disable Slack logs.
50
+ # If variable is not defined, it defaults to "true".
42
51
  ...
43
52
  ```
44
53
 
package/dist/index.js CHANGED
@@ -97,8 +97,8 @@ function isValidSlackWebhookUrl() {
97
97
  return SLACK_WEBHOOK_URL.startsWith("https://");
98
98
  }
99
99
  async function axiosCall(payload) {
100
- const DISABLE_SLACK_LOGS = process?.env?.DISABLE_SLACK_LOGS === "false";
101
- if (DISABLE_SLACK_LOGS)
100
+ const ENABLE_SLACK_LOGS = (process?.env?.ENABLE_SLACK_LOGS ?? "").toString() === "true";
101
+ if (ENABLE_SLACK_LOGS)
102
102
  return false;
103
103
  const SLACK_WEBHOOK_URL = process.env.SLACK_WEBHOOK_URL;
104
104
  return await axios_1.default
package/dist/index.ts CHANGED
@@ -52,7 +52,7 @@ export const slack: Slack = {
52
52
  if (!isValidSlackWebhookUrl()) {
53
53
  // SLACK_WEBHOOK_URL is valid
54
54
  console.error(
55
- "🚨 Invalid Slack webhook URL. Kindly check 'SLACK_WEBHOOK_URL' in your .env file! 🚨",
55
+ "🚨 Invalid Slack webhook URL. Kindly check 'SLACK_WEBHOOK_URL' in your .env file! 🚨"
56
56
  );
57
57
  return null;
58
58
  }
@@ -120,10 +120,10 @@ function isValidSlackWebhookUrl(): boolean {
120
120
  }
121
121
 
122
122
  async function axiosCall(payload: any) {
123
- const DISABLE_SLACK_LOGS: boolean =
124
- process?.env?.DISABLE_SLACK_LOGS === "false";
123
+ const ENABLE_SLACK_LOGS: boolean =
124
+ (process?.env?.ENABLE_SLACK_LOGS ?? "").toString() === "true";
125
125
 
126
- if (DISABLE_SLACK_LOGS) return false;
126
+ if (ENABLE_SLACK_LOGS) return false;
127
127
 
128
128
  const SLACK_WEBHOOK_URL = process.env.SLACK_WEBHOOK_URL;
129
129
  return await axios
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slack-logs",
3
- "version": "1.2.0",
3
+ "version": "1.3.1",
4
4
  "description": "slack-logs",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.ts",
package/src/index.ts CHANGED
@@ -52,7 +52,7 @@ export const slack: Slack = {
52
52
  if (!isValidSlackWebhookUrl()) {
53
53
  // SLACK_WEBHOOK_URL is valid
54
54
  console.error(
55
- "🚨 Invalid Slack webhook URL. Kindly check 'SLACK_WEBHOOK_URL' in your .env file! 🚨",
55
+ "🚨 Invalid Slack webhook URL. Kindly check 'SLACK_WEBHOOK_URL' in your .env file! 🚨"
56
56
  );
57
57
  return null;
58
58
  }
@@ -120,10 +120,10 @@ function isValidSlackWebhookUrl(): boolean {
120
120
  }
121
121
 
122
122
  async function axiosCall(payload: any) {
123
- const DISABLE_SLACK_LOGS: boolean =
124
- process?.env?.DISABLE_SLACK_LOGS === "false";
123
+ const ENABLE_SLACK_LOGS: boolean =
124
+ (process?.env?.ENABLE_SLACK_LOGS ?? "").toString() === "true";
125
125
 
126
- if (DISABLE_SLACK_LOGS) return false;
126
+ if (ENABLE_SLACK_LOGS) return false;
127
127
 
128
128
  const SLACK_WEBHOOK_URL = process.env.SLACK_WEBHOOK_URL;
129
129
  return await axios