@vezlo/assistant-chat 1.4.0 → 1.5.0
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/lib/api/analytics.d.ts +26 -0
- package/lib/api/analytics.js +26 -0
- package/lib/api/index.d.ts +1 -0
- package/lib/api/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Analytics API Service
|
|
3
|
+
* Handles fetching company analytics data
|
|
4
|
+
*/
|
|
5
|
+
export interface CompanyAnalyticsResponse {
|
|
6
|
+
conversations: {
|
|
7
|
+
total: number;
|
|
8
|
+
open: number;
|
|
9
|
+
closed: number;
|
|
10
|
+
};
|
|
11
|
+
users: {
|
|
12
|
+
total_active_users: number;
|
|
13
|
+
};
|
|
14
|
+
messages: {
|
|
15
|
+
total: number;
|
|
16
|
+
user_messages_total: number;
|
|
17
|
+
assistant_messages_total: number;
|
|
18
|
+
agent_messages_total: number;
|
|
19
|
+
};
|
|
20
|
+
feedback: {
|
|
21
|
+
total: number;
|
|
22
|
+
likes: number;
|
|
23
|
+
dislikes: number;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export declare function getCompanyAnalytics(token: string, apiUrl?: string): Promise<CompanyAnalyticsResponse>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Analytics API Service
|
|
3
|
+
* Handles fetching company analytics data
|
|
4
|
+
*/
|
|
5
|
+
const DEFAULT_API_BASE_URL = import.meta.env.VITE_ASSISTANT_SERVER_URL || 'http://localhost:3000';
|
|
6
|
+
const parseErrorMessage = async (response) => {
|
|
7
|
+
const data = await response.json().catch(() => ({}));
|
|
8
|
+
return (data.error ||
|
|
9
|
+
data.message ||
|
|
10
|
+
'Unexpected server error');
|
|
11
|
+
};
|
|
12
|
+
export async function getCompanyAnalytics(token, apiUrl) {
|
|
13
|
+
const API_BASE_URL = apiUrl || DEFAULT_API_BASE_URL;
|
|
14
|
+
const response = await fetch(`${API_BASE_URL}/api/company/analytics`, {
|
|
15
|
+
method: 'GET',
|
|
16
|
+
headers: {
|
|
17
|
+
Accept: 'application/json',
|
|
18
|
+
Authorization: `Bearer ${token}`,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
if (!response.ok) {
|
|
22
|
+
const message = await parseErrorMessage(response);
|
|
23
|
+
throw new Error(message);
|
|
24
|
+
}
|
|
25
|
+
return (await response.json());
|
|
26
|
+
}
|
package/lib/api/index.d.ts
CHANGED
package/lib/api/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vezlo/assistant-chat",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "React component library for AI-powered chat widgets with RAG knowledge base integration, realtime updates, and human agent support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|