@zauru-sdk/components 6.21.1 → 6.22.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/CHANGELOG.md +24 -0
- package/package.json +3 -3
- package/src/Chatwoot/Chat.tsx +28 -31
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,30 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [6.22.0](https://github.com/intuitiva/zauru-typescript-sdk/compare/@zauru-sdk/components@6.21.2...@zauru-sdk/components@6.22.0) (2026-11-10)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* require Chatwoot HMAC hash before identifying the visitor ([cd1f7fb](https://github.com/intuitiva/zauru-typescript-sdk/commit/cd1f7fbb6f4f7cade64aeec4f91b9b186a1fb492))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* enviar description y atributos de conversación a Chatwoot ([2420e66](https://github.com/intuitiva/zauru-typescript-sdk/commit/2420e66572323a8c841855448f67c6099b4c7c7c))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [6.21.2](https://github.com/intuitiva/zauru-typescript-sdk/compare/@zauru-sdk/components@6.21.1...@zauru-sdk/components@6.21.2) (2026-11-10)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @zauru-sdk/components
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
6
30
|
## [6.21.1](https://github.com/intuitiva/zauru-typescript-sdk/compare/@zauru-sdk/components@6.21.0...@zauru-sdk/components@6.21.1) (2026-11-10)
|
|
7
31
|
|
|
8
32
|
**Note:** Version bump only for package @zauru-sdk/components
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zauru-sdk/components",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.22.0",
|
|
4
4
|
"description": "Componentes reutilizables en las WebApps de Zauru.",
|
|
5
5
|
"main": "./dist/esm/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@zauru-sdk/icons": "^6.2.0",
|
|
51
51
|
"@zauru-sdk/redux": "^6.8.13",
|
|
52
52
|
"@zauru-sdk/types": "^6.37.1",
|
|
53
|
-
"@zauru-sdk/utils": "^6.
|
|
53
|
+
"@zauru-sdk/utils": "^6.34.0",
|
|
54
54
|
"browser-image-compression": "^2.0.2",
|
|
55
55
|
"framer-motion": "^12.0.0",
|
|
56
56
|
"jsonwebtoken": "^9.0.2",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"styled-components": "^5.3.5",
|
|
64
64
|
"zod": "^3.23.8"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "64db5b7f3deb29757e8abf57fe3e3f873011e5a6"
|
|
67
67
|
}
|
package/src/Chatwoot/Chat.tsx
CHANGED
|
@@ -4,8 +4,7 @@ const SCRIPT_ID = "chatwoot-sdk";
|
|
|
4
4
|
const DEFAULT_BASE_URL = "https://soporte.zauru.com";
|
|
5
5
|
|
|
6
6
|
const canUseDOM = (): boolean =>
|
|
7
|
-
typeof window !== "undefined" &&
|
|
8
|
-
Boolean(window.document?.createElement);
|
|
7
|
+
typeof window !== "undefined" && Boolean(window.document?.createElement);
|
|
9
8
|
|
|
10
9
|
export type ChatwootUser = {
|
|
11
10
|
identifier: string;
|
|
@@ -13,10 +12,15 @@ export type ChatwootUser = {
|
|
|
13
12
|
name?: string;
|
|
14
13
|
companyName?: string;
|
|
15
14
|
avatarUrl?: string;
|
|
15
|
+
description?: string;
|
|
16
16
|
customAttributes?: Record<
|
|
17
17
|
string,
|
|
18
18
|
string | number | boolean | null | undefined
|
|
19
19
|
>;
|
|
20
|
+
conversationAttributes?: Record<
|
|
21
|
+
string,
|
|
22
|
+
string | number | boolean | null | undefined
|
|
23
|
+
>;
|
|
20
24
|
};
|
|
21
25
|
|
|
22
26
|
export type ChatwootWidgetProps = {
|
|
@@ -36,6 +40,7 @@ type ChatwootSdk = {
|
|
|
36
40
|
type ChatwootApi = {
|
|
37
41
|
setUser: (identifier: string, user: Record<string, unknown>) => void;
|
|
38
42
|
setCustomAttributes: (attrs: Record<string, unknown>) => void;
|
|
43
|
+
setConversationCustomAttributes?: (attrs: Record<string, unknown>) => void;
|
|
39
44
|
setLocale?: (locale: string) => void;
|
|
40
45
|
reset: () => void;
|
|
41
46
|
};
|
|
@@ -75,7 +80,8 @@ function identifyUser(
|
|
|
75
80
|
if (user.email) payload.email = user.email;
|
|
76
81
|
if (user.name) payload.name = user.name;
|
|
77
82
|
if (user.companyName) payload.company_name = user.companyName;
|
|
78
|
-
if (user.
|
|
83
|
+
if (user.description) payload.description = user.description;
|
|
84
|
+
if (user.avatarUrl?.startsWith("http")) payload.avatar_url = user.avatarUrl;
|
|
79
85
|
if (identifierHash) payload.identifier_hash = identifierHash;
|
|
80
86
|
|
|
81
87
|
$chatwoot.setUser(user.identifier, payload);
|
|
@@ -85,19 +91,12 @@ function identifyUser(
|
|
|
85
91
|
$chatwoot.setCustomAttributes(custom);
|
|
86
92
|
}
|
|
87
93
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const doc = getChatwootWindow()?.document;
|
|
93
|
-
if (!doc) return;
|
|
94
|
+
const conversation = compactAttributes(user.conversationAttributes);
|
|
95
|
+
if (Object.keys(conversation).length > 0) {
|
|
96
|
+
$chatwoot.setConversationCustomAttributes?.(conversation);
|
|
97
|
+
}
|
|
94
98
|
|
|
95
|
-
|
|
96
|
-
doc
|
|
97
|
-
.querySelectorAll(
|
|
98
|
-
`script[src*="${baseUrl}/packs/js/sdk.js"], iframe#chatwoot_live_chat_widget, .woot-widget-holder, .woot-widget-bubble`,
|
|
99
|
-
)
|
|
100
|
-
.forEach((el) => el.remove());
|
|
99
|
+
$chatwoot.setLocale?.(locale);
|
|
101
100
|
}
|
|
102
101
|
|
|
103
102
|
export function resetChatwoot(): void {
|
|
@@ -124,13 +123,17 @@ export function ChatwootWidget({
|
|
|
124
123
|
const name = user.name;
|
|
125
124
|
const companyName = user.companyName;
|
|
126
125
|
const avatarUrl = user.avatarUrl;
|
|
126
|
+
const description = user.description;
|
|
127
127
|
const customAttributesKey = JSON.stringify(
|
|
128
128
|
compactAttributes(user.customAttributes),
|
|
129
129
|
);
|
|
130
|
+
const conversationAttributesKey = JSON.stringify(
|
|
131
|
+
compactAttributes(user.conversationAttributes),
|
|
132
|
+
);
|
|
130
133
|
|
|
131
134
|
useEffect(() => {
|
|
132
135
|
const w = getChatwootWindow();
|
|
133
|
-
if (!w || !websiteToken || !identifier) return;
|
|
136
|
+
if (!w || !websiteToken || !identifier || !identifierHash) return;
|
|
134
137
|
|
|
135
138
|
w.chatwootSettings = {
|
|
136
139
|
hideMessageBubble: false,
|
|
@@ -149,9 +152,13 @@ export function ChatwootWidget({
|
|
|
149
152
|
name,
|
|
150
153
|
companyName,
|
|
151
154
|
avatarUrl,
|
|
155
|
+
description,
|
|
152
156
|
customAttributes: JSON.parse(
|
|
153
157
|
customAttributesKey,
|
|
154
158
|
) as ChatwootUser["customAttributes"],
|
|
159
|
+
conversationAttributes: JSON.parse(
|
|
160
|
+
conversationAttributesKey,
|
|
161
|
+
) as ChatwootUser["conversationAttributes"],
|
|
155
162
|
},
|
|
156
163
|
identifierHash,
|
|
157
164
|
locale,
|
|
@@ -160,12 +167,12 @@ export function ChatwootWidget({
|
|
|
160
167
|
|
|
161
168
|
w.addEventListener("chatwoot:ready", onReady);
|
|
162
169
|
|
|
163
|
-
const existing = w.document.getElementById(SCRIPT_ID)
|
|
164
|
-
| HTMLScriptElement
|
|
165
|
-
| null;
|
|
170
|
+
const existing = w.document.getElementById(SCRIPT_ID);
|
|
166
171
|
|
|
167
172
|
if (w.$chatwoot) {
|
|
168
173
|
onReady();
|
|
174
|
+
} else if (w.chatwootSDK) {
|
|
175
|
+
w.chatwootSDK.run({ websiteToken, baseUrl });
|
|
169
176
|
} else if (!existing) {
|
|
170
177
|
const script = w.document.createElement("script");
|
|
171
178
|
script.id = SCRIPT_ID;
|
|
@@ -190,24 +197,14 @@ export function ChatwootWidget({
|
|
|
190
197
|
name,
|
|
191
198
|
companyName,
|
|
192
199
|
avatarUrl,
|
|
200
|
+
description,
|
|
193
201
|
customAttributesKey,
|
|
202
|
+
conversationAttributesKey,
|
|
194
203
|
locale,
|
|
195
204
|
position,
|
|
196
205
|
darkMode,
|
|
197
206
|
]);
|
|
198
207
|
|
|
199
|
-
useEffect(() => {
|
|
200
|
-
return () => {
|
|
201
|
-
resetChatwoot();
|
|
202
|
-
removeWidgetDom(baseUrl);
|
|
203
|
-
const w = getChatwootWindow();
|
|
204
|
-
if (w) {
|
|
205
|
-
delete w.chatwootSDK;
|
|
206
|
-
delete w.$chatwoot;
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
}, [baseUrl]);
|
|
210
|
-
|
|
211
208
|
return null;
|
|
212
209
|
}
|
|
213
210
|
|