@optifye/dashboard-core 4.2.0 → 4.2.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/dist/index.d.mts CHANGED
@@ -211,6 +211,7 @@ interface EndpointsConfig {
211
211
  whatsapp?: string;
212
212
  worstPerformingWorkspaces?: string;
213
213
  agnoApiUrl?: string;
214
+ slackWebhookUrl?: string;
214
215
  }
215
216
  interface DateTimeConfig {
216
217
  defaultTimezone?: string;
@@ -4343,7 +4344,7 @@ interface SupportTicket {
4343
4344
  }
4344
4345
  declare class SlackAPI {
4345
4346
  /**
4346
- * Sends a support ticket notification to Slack via the API route
4347
+ * Sends a support ticket notification directly to Slack webhook
4347
4348
  */
4348
4349
  static sendSupportTicketNotification(ticket: SupportTicket): Promise<void>;
4349
4350
  }
package/dist/index.d.ts CHANGED
@@ -211,6 +211,7 @@ interface EndpointsConfig {
211
211
  whatsapp?: string;
212
212
  worstPerformingWorkspaces?: string;
213
213
  agnoApiUrl?: string;
214
+ slackWebhookUrl?: string;
214
215
  }
215
216
  interface DateTimeConfig {
216
217
  defaultTimezone?: string;
@@ -4343,7 +4344,7 @@ interface SupportTicket {
4343
4344
  }
4344
4345
  declare class SlackAPI {
4345
4346
  /**
4346
- * Sends a support ticket notification to Slack via the API route
4347
+ * Sends a support ticket notification directly to Slack webhook
4347
4348
  */
4348
4349
  static sendSupportTicketNotification(ticket: SupportTicket): Promise<void>;
4349
4350
  }
package/dist/index.js CHANGED
@@ -137,8 +137,10 @@ var DEFAULT_DATE_TIME_CONFIG = {
137
137
  };
138
138
  var DEFAULT_ENDPOINTS_CONFIG = {
139
139
  whatsapp: "/api/send-whatsapp-direct",
140
- agnoApiUrl: process.env.NEXT_PUBLIC_AGNO_URL || "https://optifye-agent-production.up.railway.app"
140
+ agnoApiUrl: process.env.NEXT_PUBLIC_AGNO_URL || "https://optifye-agent-production.up.railway.app",
141
141
  // Default AGNO API URL
142
+ slackWebhookUrl: process.env.NEXT_PUBLIC_SLACK_WEBHOOK_URL || void 0
143
+ // Slack webhook URL from environment
142
144
  };
143
145
  var DEFAULT_THEME_CONFIG = {
144
146
  // Sensible defaults for theme can be added here
@@ -25143,20 +25145,119 @@ var streamProxyConfig = {
25143
25145
  // src/lib/api/slackApi.ts
25144
25146
  var SlackAPI = class {
25145
25147
  /**
25146
- * Sends a support ticket notification to Slack via the API route
25148
+ * Sends a support ticket notification directly to Slack webhook
25147
25149
  */
25148
25150
  static async sendSupportTicketNotification(ticket) {
25149
25151
  try {
25150
- const response = await fetch("/api/slack/support-ticket", {
25152
+ const config = _getDashboardConfigInstance();
25153
+ const endpointsConfig = config.endpoints ?? DEFAULT_ENDPOINTS_CONFIG;
25154
+ const slackWebhookUrl = endpointsConfig.slackWebhookUrl;
25155
+ if (!slackWebhookUrl) {
25156
+ console.log("Slack webhook URL not configured, skipping notification");
25157
+ return;
25158
+ }
25159
+ const timestamp = new Date(ticket.timestamp).toLocaleString("en-US", {
25160
+ dateStyle: "medium",
25161
+ timeStyle: "short",
25162
+ timeZone: "UTC"
25163
+ });
25164
+ const maxDescriptionLength = 300;
25165
+ const description = ticket.description.length > maxDescriptionLength ? `${ticket.description.substring(0, maxDescriptionLength)}...` : ticket.description;
25166
+ const categoryConfig = {
25167
+ general: { emoji: "\u{1F4AC}", color: "#36a64f" },
25168
+ technical: { emoji: "\u{1F527}", color: "#ff6b6b" },
25169
+ feature: { emoji: "\u2728", color: "#4ecdc4" },
25170
+ billing: { emoji: "\u{1F4B3}", color: "#f7b731" }
25171
+ };
25172
+ const priorityConfig = {
25173
+ low: { emoji: "\u{1F7E2}", color: "#36a64f" },
25174
+ normal: { emoji: "\u{1F7E1}", color: "#ffc107" },
25175
+ high: { emoji: "\u{1F7E0}", color: "#ff8c00" },
25176
+ urgent: { emoji: "\u{1F534}", color: "#dc3545" }
25177
+ };
25178
+ const categoryInfo = categoryConfig[ticket.category] || categoryConfig.general;
25179
+ const priorityInfo = priorityConfig[ticket.priority] || priorityConfig.normal;
25180
+ const messageColor = ticket.priority === "high" || ticket.priority === "urgent" ? priorityInfo.color : categoryInfo.color;
25181
+ const slackMessage = {
25182
+ text: `New support ticket from ${ticket.email}`,
25183
+ blocks: [
25184
+ {
25185
+ type: "header",
25186
+ text: {
25187
+ type: "plain_text",
25188
+ text: "\u{1F3AB} New Support Ticket Submitted",
25189
+ emoji: true
25190
+ }
25191
+ },
25192
+ {
25193
+ type: "section",
25194
+ fields: [
25195
+ {
25196
+ type: "mrkdwn",
25197
+ text: `*From:*
25198
+ ${ticket.email}`
25199
+ },
25200
+ {
25201
+ type: "mrkdwn",
25202
+ text: `*Category:*
25203
+ ${categoryInfo.emoji} ${ticket.category.charAt(0).toUpperCase() + ticket.category.slice(1)}`
25204
+ },
25205
+ {
25206
+ type: "mrkdwn",
25207
+ text: `*Priority:*
25208
+ ${priorityInfo.emoji} ${ticket.priority.charAt(0).toUpperCase() + ticket.priority.slice(1)}`
25209
+ },
25210
+ {
25211
+ type: "mrkdwn",
25212
+ text: `*Subject:*
25213
+ ${ticket.subject}`
25214
+ },
25215
+ {
25216
+ type: "mrkdwn",
25217
+ text: `*Submitted:*
25218
+ ${timestamp} UTC`
25219
+ }
25220
+ ]
25221
+ },
25222
+ {
25223
+ type: "section",
25224
+ text: {
25225
+ type: "mrkdwn",
25226
+ text: `*Description:*
25227
+ ${description}`
25228
+ }
25229
+ },
25230
+ {
25231
+ type: "divider"
25232
+ },
25233
+ {
25234
+ type: "context",
25235
+ elements: [
25236
+ {
25237
+ type: "mrkdwn",
25238
+ text: `Category: \`${ticket.category}\` | Priority: ${priorityInfo.emoji} \`${ticket.priority.toUpperCase()}\` | ${ticket.priority === "urgent" ? "\u26A0\uFE0F Requires immediate attention" : "Standard processing"}`
25239
+ }
25240
+ ]
25241
+ }
25242
+ ],
25243
+ attachments: [
25244
+ {
25245
+ color: messageColor,
25246
+ fields: []
25247
+ }
25248
+ ]
25249
+ };
25250
+ const response = await fetch(slackWebhookUrl, {
25151
25251
  method: "POST",
25152
25252
  headers: {
25153
25253
  "Content-Type": "application/json"
25154
25254
  },
25155
- body: JSON.stringify(ticket)
25255
+ body: JSON.stringify(slackMessage)
25156
25256
  });
25157
25257
  if (!response.ok) {
25158
- const errorData = await response.json().catch(() => ({ message: "Unknown error" }));
25159
- throw new Error(errorData.message || `Failed with status: ${response.status}`);
25258
+ const errorText = await response.text();
25259
+ console.error("Slack webhook error:", errorText);
25260
+ throw new Error(`Slack webhook failed with status: ${response.status}`);
25160
25261
  }
25161
25262
  console.log("Support ticket notification sent to Slack successfully");
25162
25263
  } catch (error) {
package/dist/index.mjs CHANGED
@@ -108,8 +108,10 @@ var DEFAULT_DATE_TIME_CONFIG = {
108
108
  };
109
109
  var DEFAULT_ENDPOINTS_CONFIG = {
110
110
  whatsapp: "/api/send-whatsapp-direct",
111
- agnoApiUrl: process.env.NEXT_PUBLIC_AGNO_URL || "https://optifye-agent-production.up.railway.app"
111
+ agnoApiUrl: process.env.NEXT_PUBLIC_AGNO_URL || "https://optifye-agent-production.up.railway.app",
112
112
  // Default AGNO API URL
113
+ slackWebhookUrl: process.env.NEXT_PUBLIC_SLACK_WEBHOOK_URL || void 0
114
+ // Slack webhook URL from environment
113
115
  };
114
116
  var DEFAULT_THEME_CONFIG = {
115
117
  // Sensible defaults for theme can be added here
@@ -25114,20 +25116,119 @@ var streamProxyConfig = {
25114
25116
  // src/lib/api/slackApi.ts
25115
25117
  var SlackAPI = class {
25116
25118
  /**
25117
- * Sends a support ticket notification to Slack via the API route
25119
+ * Sends a support ticket notification directly to Slack webhook
25118
25120
  */
25119
25121
  static async sendSupportTicketNotification(ticket) {
25120
25122
  try {
25121
- const response = await fetch("/api/slack/support-ticket", {
25123
+ const config = _getDashboardConfigInstance();
25124
+ const endpointsConfig = config.endpoints ?? DEFAULT_ENDPOINTS_CONFIG;
25125
+ const slackWebhookUrl = endpointsConfig.slackWebhookUrl;
25126
+ if (!slackWebhookUrl) {
25127
+ console.log("Slack webhook URL not configured, skipping notification");
25128
+ return;
25129
+ }
25130
+ const timestamp = new Date(ticket.timestamp).toLocaleString("en-US", {
25131
+ dateStyle: "medium",
25132
+ timeStyle: "short",
25133
+ timeZone: "UTC"
25134
+ });
25135
+ const maxDescriptionLength = 300;
25136
+ const description = ticket.description.length > maxDescriptionLength ? `${ticket.description.substring(0, maxDescriptionLength)}...` : ticket.description;
25137
+ const categoryConfig = {
25138
+ general: { emoji: "\u{1F4AC}", color: "#36a64f" },
25139
+ technical: { emoji: "\u{1F527}", color: "#ff6b6b" },
25140
+ feature: { emoji: "\u2728", color: "#4ecdc4" },
25141
+ billing: { emoji: "\u{1F4B3}", color: "#f7b731" }
25142
+ };
25143
+ const priorityConfig = {
25144
+ low: { emoji: "\u{1F7E2}", color: "#36a64f" },
25145
+ normal: { emoji: "\u{1F7E1}", color: "#ffc107" },
25146
+ high: { emoji: "\u{1F7E0}", color: "#ff8c00" },
25147
+ urgent: { emoji: "\u{1F534}", color: "#dc3545" }
25148
+ };
25149
+ const categoryInfo = categoryConfig[ticket.category] || categoryConfig.general;
25150
+ const priorityInfo = priorityConfig[ticket.priority] || priorityConfig.normal;
25151
+ const messageColor = ticket.priority === "high" || ticket.priority === "urgent" ? priorityInfo.color : categoryInfo.color;
25152
+ const slackMessage = {
25153
+ text: `New support ticket from ${ticket.email}`,
25154
+ blocks: [
25155
+ {
25156
+ type: "header",
25157
+ text: {
25158
+ type: "plain_text",
25159
+ text: "\u{1F3AB} New Support Ticket Submitted",
25160
+ emoji: true
25161
+ }
25162
+ },
25163
+ {
25164
+ type: "section",
25165
+ fields: [
25166
+ {
25167
+ type: "mrkdwn",
25168
+ text: `*From:*
25169
+ ${ticket.email}`
25170
+ },
25171
+ {
25172
+ type: "mrkdwn",
25173
+ text: `*Category:*
25174
+ ${categoryInfo.emoji} ${ticket.category.charAt(0).toUpperCase() + ticket.category.slice(1)}`
25175
+ },
25176
+ {
25177
+ type: "mrkdwn",
25178
+ text: `*Priority:*
25179
+ ${priorityInfo.emoji} ${ticket.priority.charAt(0).toUpperCase() + ticket.priority.slice(1)}`
25180
+ },
25181
+ {
25182
+ type: "mrkdwn",
25183
+ text: `*Subject:*
25184
+ ${ticket.subject}`
25185
+ },
25186
+ {
25187
+ type: "mrkdwn",
25188
+ text: `*Submitted:*
25189
+ ${timestamp} UTC`
25190
+ }
25191
+ ]
25192
+ },
25193
+ {
25194
+ type: "section",
25195
+ text: {
25196
+ type: "mrkdwn",
25197
+ text: `*Description:*
25198
+ ${description}`
25199
+ }
25200
+ },
25201
+ {
25202
+ type: "divider"
25203
+ },
25204
+ {
25205
+ type: "context",
25206
+ elements: [
25207
+ {
25208
+ type: "mrkdwn",
25209
+ text: `Category: \`${ticket.category}\` | Priority: ${priorityInfo.emoji} \`${ticket.priority.toUpperCase()}\` | ${ticket.priority === "urgent" ? "\u26A0\uFE0F Requires immediate attention" : "Standard processing"}`
25210
+ }
25211
+ ]
25212
+ }
25213
+ ],
25214
+ attachments: [
25215
+ {
25216
+ color: messageColor,
25217
+ fields: []
25218
+ }
25219
+ ]
25220
+ };
25221
+ const response = await fetch(slackWebhookUrl, {
25122
25222
  method: "POST",
25123
25223
  headers: {
25124
25224
  "Content-Type": "application/json"
25125
25225
  },
25126
- body: JSON.stringify(ticket)
25226
+ body: JSON.stringify(slackMessage)
25127
25227
  });
25128
25228
  if (!response.ok) {
25129
- const errorData = await response.json().catch(() => ({ message: "Unknown error" }));
25130
- throw new Error(errorData.message || `Failed with status: ${response.status}`);
25229
+ const errorText = await response.text();
25230
+ console.error("Slack webhook error:", errorText);
25231
+ throw new Error(`Slack webhook failed with status: ${response.status}`);
25131
25232
  }
25132
25233
  console.log("Support ticket notification sent to Slack successfully");
25133
25234
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optifye/dashboard-core",
3
- "version": "4.2.0",
3
+ "version": "4.2.1",
4
4
  "description": "Reusable UI & logic for Optifye dashboard",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",