slack-logs 1.1.2 → 1.1.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/dist/index.js CHANGED
@@ -63,7 +63,7 @@ exports.slack = {
63
63
  type: "divider",
64
64
  });
65
65
  if (objectData?.length) {
66
- objectData.forEach((element) => {
66
+ objectData.forEach(element => {
67
67
  let value = JSON.stringify(element.value);
68
68
  attachmentsBlocks.push({
69
69
  type: "section",
@@ -88,9 +88,7 @@ exports.slack = {
88
88
  };
89
89
  function isValidSlackWebhookUrl() {
90
90
  // Check if SLACK_WEBHOOK_URL is not null or undefined
91
- if (!common_variables_1.SLACK_WEBHOOK_URL ||
92
- common_variables_1.SLACK_WEBHOOK_URL == null ||
93
- typeof common_variables_1.SLACK_WEBHOOK_URL == "undefined") {
91
+ if (!common_variables_1.SLACK_WEBHOOK_URL || common_variables_1.SLACK_WEBHOOK_URL == null || typeof common_variables_1.SLACK_WEBHOOK_URL == "undefined") {
94
92
  return false;
95
93
  }
96
94
  // Check if SLACK_WEBHOOK_URL starts with "https://"
@@ -101,12 +99,12 @@ async function axiosCall(payload) {
101
99
  .post(common_variables_1.SLACK_WEBHOOK_URL, JSON.stringify(payload), {
102
100
  headers: { "Content-Type": "application/json" },
103
101
  })
104
- .then((response) => {
102
+ .then(response => {
105
103
  if (common_variables_1.SLACK_DEBUGGER) {
106
104
  console.log("✅ Log message sent to Slack successfully");
107
105
  }
108
106
  })
109
- .catch((error) => {
110
- console.error("🚨 Error sending log message to Slack:", error);
107
+ .catch(error => {
108
+ console.error("🚨 Error sending log message to Slack: Webhook URL might be updated!");
111
109
  });
112
110
  }
package/dist/index.ts CHANGED
@@ -1,16 +1,9 @@
1
- import {
2
- SLACK_DEBUGGER,
3
- SLACK_WEBHOOK_URL,
4
- } from "./constants/common-variables";
1
+ import { SLACK_DEBUGGER, SLACK_WEBHOOK_URL } from "./constants/common-variables";
5
2
  import axios from "axios";
6
3
 
7
4
  interface Slack {
8
5
  log(label: string, data: any): Promise<null | undefined>;
9
- logBlockMessage(
10
- label: string,
11
- objectData: BlocksInterface[],
12
- error_type?: LogLevel
13
- ): Promise<null | undefined>;
6
+ logBlockMessage(label: string, objectData: BlocksInterface[], error_type?: LogLevel): Promise<null | undefined>;
14
7
  }
15
8
  interface BlocksInterface {
16
9
  title: string;
@@ -36,9 +29,7 @@ export const slack: Slack = {
36
29
  const messageData = JSON.stringify(data);
37
30
  if (!isValidSlackWebhookUrl()) {
38
31
  // SLACK_WEBHOOK_URL is valid
39
- console.error(
40
- "🚨 Invalid Slack webhook URL. Kindly check 'SLACK_WEBHOOK_URL' in your .env file! 🚨"
41
- );
32
+ console.error("🚨 Invalid Slack webhook URL. Kindly check 'SLACK_WEBHOOK_URL' in your .env file! 🚨");
42
33
  return null;
43
34
  }
44
35
 
@@ -48,16 +39,10 @@ export const slack: Slack = {
48
39
  };
49
40
  await axiosCall(payload);
50
41
  },
51
- async logBlockMessage(
52
- label: string,
53
- objectData: BlocksInterface[],
54
- error_type: LogLevel = LogLevel.DEFAULT
55
- ) {
42
+ async logBlockMessage(label: string, objectData: BlocksInterface[], error_type: LogLevel = LogLevel.DEFAULT) {
56
43
  if (!isValidSlackWebhookUrl()) {
57
44
  // SLACK_WEBHOOK_URL is valid
58
- console.error(
59
- "🚨 Invalid Slack webhook URL. Kindly check 'SLACK_WEBHOOK_URL' in your .env file! 🚨"
60
- );
45
+ console.error("🚨 Invalid Slack webhook URL. Kindly check 'SLACK_WEBHOOK_URL' in your .env file! 🚨");
61
46
  return null;
62
47
  }
63
48
  console.log(error_type);
@@ -83,7 +68,7 @@ export const slack: Slack = {
83
68
  });
84
69
 
85
70
  if (objectData?.length) {
86
- objectData.forEach((element) => {
71
+ objectData.forEach(element => {
87
72
  let value = JSON.stringify(element.value);
88
73
  attachmentsBlocks.push({
89
74
  type: "section",
@@ -110,11 +95,7 @@ export const slack: Slack = {
110
95
 
111
96
  function isValidSlackWebhookUrl(): boolean {
112
97
  // Check if SLACK_WEBHOOK_URL is not null or undefined
113
- if (
114
- !SLACK_WEBHOOK_URL ||
115
- SLACK_WEBHOOK_URL == null ||
116
- typeof SLACK_WEBHOOK_URL == "undefined"
117
- ) {
98
+ if (!SLACK_WEBHOOK_URL || SLACK_WEBHOOK_URL == null || typeof SLACK_WEBHOOK_URL == "undefined") {
118
99
  return false;
119
100
  }
120
101
 
@@ -127,12 +108,12 @@ async function axiosCall(payload: any) {
127
108
  .post(SLACK_WEBHOOK_URL as string, JSON.stringify(payload), {
128
109
  headers: { "Content-Type": "application/json" },
129
110
  })
130
- .then((response) => {
111
+ .then(response => {
131
112
  if (SLACK_DEBUGGER) {
132
113
  console.log("✅ Log message sent to Slack successfully");
133
114
  }
134
115
  })
135
- .catch((error) => {
136
- console.error("🚨 Error sending log message to Slack:", error);
116
+ .catch(error => {
117
+ console.error("🚨 Error sending log message to Slack: Webhook URL might be updated!");
137
118
  });
138
119
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slack-logs",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "slack-logs",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.ts",
package/src/index.ts CHANGED
@@ -1,16 +1,9 @@
1
- import {
2
- SLACK_DEBUGGER,
3
- SLACK_WEBHOOK_URL,
4
- } from "./constants/common-variables";
1
+ import { SLACK_DEBUGGER, SLACK_WEBHOOK_URL } from "./constants/common-variables";
5
2
  import axios from "axios";
6
3
 
7
4
  interface Slack {
8
5
  log(label: string, data: any): Promise<null | undefined>;
9
- logBlockMessage(
10
- label: string,
11
- objectData: BlocksInterface[],
12
- error_type?: LogLevel
13
- ): Promise<null | undefined>;
6
+ logBlockMessage(label: string, objectData: BlocksInterface[], error_type?: LogLevel): Promise<null | undefined>;
14
7
  }
15
8
  interface BlocksInterface {
16
9
  title: string;
@@ -36,9 +29,7 @@ export const slack: Slack = {
36
29
  const messageData = JSON.stringify(data);
37
30
  if (!isValidSlackWebhookUrl()) {
38
31
  // SLACK_WEBHOOK_URL is valid
39
- console.error(
40
- "🚨 Invalid Slack webhook URL. Kindly check 'SLACK_WEBHOOK_URL' in your .env file! 🚨"
41
- );
32
+ console.error("🚨 Invalid Slack webhook URL. Kindly check 'SLACK_WEBHOOK_URL' in your .env file! 🚨");
42
33
  return null;
43
34
  }
44
35
 
@@ -48,16 +39,10 @@ export const slack: Slack = {
48
39
  };
49
40
  await axiosCall(payload);
50
41
  },
51
- async logBlockMessage(
52
- label: string,
53
- objectData: BlocksInterface[],
54
- error_type: LogLevel = LogLevel.DEFAULT
55
- ) {
42
+ async logBlockMessage(label: string, objectData: BlocksInterface[], error_type: LogLevel = LogLevel.DEFAULT) {
56
43
  if (!isValidSlackWebhookUrl()) {
57
44
  // SLACK_WEBHOOK_URL is valid
58
- console.error(
59
- "🚨 Invalid Slack webhook URL. Kindly check 'SLACK_WEBHOOK_URL' in your .env file! 🚨"
60
- );
45
+ console.error("🚨 Invalid Slack webhook URL. Kindly check 'SLACK_WEBHOOK_URL' in your .env file! 🚨");
61
46
  return null;
62
47
  }
63
48
  console.log(error_type);
@@ -83,7 +68,7 @@ export const slack: Slack = {
83
68
  });
84
69
 
85
70
  if (objectData?.length) {
86
- objectData.forEach((element) => {
71
+ objectData.forEach(element => {
87
72
  let value = JSON.stringify(element.value);
88
73
  attachmentsBlocks.push({
89
74
  type: "section",
@@ -110,11 +95,7 @@ export const slack: Slack = {
110
95
 
111
96
  function isValidSlackWebhookUrl(): boolean {
112
97
  // Check if SLACK_WEBHOOK_URL is not null or undefined
113
- if (
114
- !SLACK_WEBHOOK_URL ||
115
- SLACK_WEBHOOK_URL == null ||
116
- typeof SLACK_WEBHOOK_URL == "undefined"
117
- ) {
98
+ if (!SLACK_WEBHOOK_URL || SLACK_WEBHOOK_URL == null || typeof SLACK_WEBHOOK_URL == "undefined") {
118
99
  return false;
119
100
  }
120
101
 
@@ -127,12 +108,12 @@ async function axiosCall(payload: any) {
127
108
  .post(SLACK_WEBHOOK_URL as string, JSON.stringify(payload), {
128
109
  headers: { "Content-Type": "application/json" },
129
110
  })
130
- .then((response) => {
111
+ .then(response => {
131
112
  if (SLACK_DEBUGGER) {
132
113
  console.log("✅ Log message sent to Slack successfully");
133
114
  }
134
115
  })
135
- .catch((error) => {
136
- console.error("🚨 Error sending log message to Slack:", error);
116
+ .catch(error => {
117
+ console.error("🚨 Error sending log message to Slack: Webhook URL might be updated!");
137
118
  });
138
119
  }