@socket.tech/dl-common 1.0.8 → 1.0.10

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.
@@ -1,2 +1,2 @@
1
- export declare const initDiscord: (webhookUrl_: string, serviceName_: string) => void;
2
- export declare const sendToDiscordWebhook: (title: string, data: object, optionalConfig?: object) => Promise<void>;
1
+ export declare const initDiscord: (webhookUrl_: string, serviceName_: string, discordDebugWebhookUrl_?: string | undefined) => void;
2
+ export declare const sendToDiscordWebhook: (title: string, data: object, optionalConfig?: object, isDebug?: boolean) => Promise<void>;
@@ -4,19 +4,27 @@ exports.sendToDiscordWebhook = exports.initDiscord = void 0;
4
4
  const __1 = require("..");
5
5
  const axios_1 = require("./axios");
6
6
  let discordWebhookUrl;
7
+ let discordDebugWebhookUrl;
7
8
  let serviceName;
8
- const initDiscord = (webhookUrl_, serviceName_) => {
9
+ const initDiscord = (webhookUrl_, serviceName_, discordDebugWebhookUrl_ = undefined) => {
9
10
  discordWebhookUrl = webhookUrl_;
11
+ discordDebugWebhookUrl = discordDebugWebhookUrl_;
10
12
  serviceName = serviceName_;
11
13
  };
12
14
  exports.initDiscord = initDiscord;
13
- const sendToDiscordWebhook = async (title, data, optionalConfig = {}) => {
15
+ const sendToDiscordWebhook = async (title, data, optionalConfig = {}, isDebug = false) => {
14
16
  try {
15
17
  if (!discordWebhookUrl) {
16
18
  throw (0, __1.InternalServerError)("DISCORD_WEBHOOK_URL not provided");
17
19
  }
20
+ if (isDebug && !discordDebugWebhookUrl) {
21
+ console.log("Debug mode enabled but no debug webhook provided");
22
+ }
18
23
  let content = formatMsg(title, data);
19
- await (0, axios_1.axiosPost)(discordWebhookUrl, { content, ...optionalConfig });
24
+ const urlToUse = isDebug && discordDebugWebhookUrl
25
+ ? discordDebugWebhookUrl
26
+ : discordWebhookUrl;
27
+ await (0, axios_1.axiosPost)(urlToUse, { content, ...optionalConfig });
20
28
  }
21
29
  catch (error) {
22
30
  throw error;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@socket.tech/dl-common",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "description": "common utilities for socket data layer.",
@@ -45,13 +45,13 @@
45
45
  "*.{js,css,md}": "prettier --write"
46
46
  },
47
47
  "dependencies": {
48
- "@aws-sdk/client-eventbridge": "^3.449.0",
49
- "@aws-sdk/client-kms": "^3.454.0",
50
- "@aws-sdk/client-s3": "^3.465.0",
51
- "@aws-sdk/client-secrets-manager": "^3.433.0",
52
- "@aws-sdk/client-sqs": "^3.421.0",
48
+ "@aws-sdk/client-eventbridge": "3.449.0",
49
+ "@aws-sdk/client-kms": "3.454.0",
50
+ "@aws-sdk/client-s3": "3.465.0",
51
+ "@aws-sdk/client-secrets-manager": "3.433.0",
52
+ "@aws-sdk/client-sqs": "3.421.0",
53
53
  "@ethersproject/providers": "^5.7.2",
54
- "@smithy/smithy-client": "^3.1.5",
54
+ "@smithy/smithy-client": "3.1.5",
55
55
  "@socket.tech/dl-core": "^2.7.0",
56
56
  "@socket.tech/ll-common": "^0.0.19",
57
57
  "async-redis": "^2.0.0",