@product7/feedback-sdk 1.3.3 → 1.3.5
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/feedback-sdk.js +2441 -3240
- package/dist/feedback-sdk.js.map +1 -1
- package/dist/feedback-sdk.min.js +1 -1
- package/dist/feedback-sdk.min.js.map +1 -1
- package/package.json +1 -1
- package/src/api/services/MessengerService.js +76 -0
- package/src/core/BaseAPIService.js +4 -0
- package/src/index.js +2 -3
- package/src/styles/base.js +27 -52
- package/src/styles/changelog.js +152 -269
- package/src/styles/components.js +489 -0
- package/src/styles/design-tokens.js +104 -0
- package/src/styles/feedback.js +59 -369
- package/src/styles/messenger-core.js +390 -0
- package/src/styles/messenger-features.js +347 -0
- package/src/styles/messenger-help.js +298 -0
- package/src/styles/messenger-themes.js +500 -0
- package/src/styles/messenger-views.js +618 -0
- package/src/styles/messenger.js +558 -0
- package/src/styles/styles.js +24 -2
- package/src/styles/surveys.js +354 -0
- package/src/widgets/BaseWidget.js +25 -58
- package/src/widgets/ButtonWidget.js +3 -18
- package/src/widgets/ChangelogWidget.js +7 -48
- package/src/widgets/InlineWidget.js +16 -13
- package/src/widgets/MessengerWidget.js +37 -51
- package/src/widgets/SurveyWidget.js +42 -146
- package/src/widgets/TabWidget.js +2 -22
- package/src/widgets/messenger/MessengerState.js +49 -46
- package/src/widgets/messenger/components/MessengerLauncher.js +10 -5
- package/src/widgets/messenger/components/MessengerPanel.js +5 -27
- package/src/widgets/messenger/components/NavigationTabs.js +5 -14
- package/src/widgets/messenger/views/ChangelogView.js +13 -14
- package/src/widgets/messenger/views/ChatView.js +43 -36
- package/src/widgets/messenger/views/ConversationsView.js +16 -21
- package/src/widgets/messenger/views/HelpView.js +10 -10
- package/src/widgets/messenger/views/HomeView.js +11 -16
- package/src/widgets/messenger/views/PreChatFormView.js +18 -30
- package/src/styles/messengerStyles.js +0 -2328
package/package.json
CHANGED
|
@@ -194,4 +194,80 @@ export class MessengerService {
|
|
|
194
194
|
}
|
|
195
195
|
);
|
|
196
196
|
}
|
|
197
|
+
|
|
198
|
+
async getMessages(conversationId, options = {}) {
|
|
199
|
+
await this.api._ensureSession();
|
|
200
|
+
|
|
201
|
+
if (this.api.mock) {
|
|
202
|
+
await delay(200);
|
|
203
|
+
return {
|
|
204
|
+
status: true,
|
|
205
|
+
data: MOCK_MESSAGES[conversationId] || [],
|
|
206
|
+
meta: { total: 0, page: 1, limit: 50 },
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const params = { ...options };
|
|
211
|
+
const endpoint = this.api._getEndpointWithParams(
|
|
212
|
+
`/widget/messenger/conversations/${conversationId}/messages`,
|
|
213
|
+
params
|
|
214
|
+
);
|
|
215
|
+
return this.api._makeRequest(endpoint, {
|
|
216
|
+
method: 'GET',
|
|
217
|
+
headers: { Authorization: `Bearer ${this.api.sessionToken}` },
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
async identifyContact(data) {
|
|
222
|
+
await this.api._ensureSession();
|
|
223
|
+
|
|
224
|
+
if (this.api.mock) {
|
|
225
|
+
await delay(300);
|
|
226
|
+
return {
|
|
227
|
+
status: true,
|
|
228
|
+
data: {
|
|
229
|
+
contact_id: 'mock_contact_' + Date.now(),
|
|
230
|
+
email: data.email,
|
|
231
|
+
name: data.name || '',
|
|
232
|
+
is_new: true,
|
|
233
|
+
},
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return this.api._makeRequest('/widget/messenger/identify', {
|
|
238
|
+
method: 'POST',
|
|
239
|
+
headers: {
|
|
240
|
+
'Content-Type': 'application/json',
|
|
241
|
+
Authorization: `Bearer ${this.api.sessionToken}`,
|
|
242
|
+
},
|
|
243
|
+
body: JSON.stringify({
|
|
244
|
+
email: data.email,
|
|
245
|
+
name: data.name || '',
|
|
246
|
+
phone: data.phone || '',
|
|
247
|
+
company: data.company || '',
|
|
248
|
+
avatar_url: data.avatar_url || '',
|
|
249
|
+
metadata: data.metadata || {},
|
|
250
|
+
}),
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
async sendTypingIndicator(conversationId, isTyping) {
|
|
255
|
+
await this.api._ensureSession();
|
|
256
|
+
|
|
257
|
+
if (this.api.mock) {
|
|
258
|
+
return { status: true };
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return this.api._makeRequest(
|
|
262
|
+
`/widget/messenger/conversations/${conversationId}/typing`,
|
|
263
|
+
{
|
|
264
|
+
method: 'POST',
|
|
265
|
+
headers: {
|
|
266
|
+
'Content-Type': 'application/json',
|
|
267
|
+
Authorization: `Bearer ${this.api.sessionToken}`,
|
|
268
|
+
},
|
|
269
|
+
body: JSON.stringify({ is_typing: isTyping }),
|
|
270
|
+
}
|
|
271
|
+
);
|
|
272
|
+
}
|
|
197
273
|
}
|
|
@@ -25,6 +25,10 @@ export class BaseAPIService {
|
|
|
25
25
|
base: 'https://staging.api.product7.io/api/v1',
|
|
26
26
|
withWorkspace: (ws) => `https://${ws}.staging.api.product7.io/api/v1`,
|
|
27
27
|
},
|
|
28
|
+
localstack: {
|
|
29
|
+
base: 'http://localhost:1323/api/v1',
|
|
30
|
+
withWorkspace: (ws) => `http://${ws}.localhost:1323/api/v1`,
|
|
31
|
+
},
|
|
28
32
|
};
|
|
29
33
|
|
|
30
34
|
const envConfig = ENV_URLS[this.env] || ENV_URLS.production;
|
package/src/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { APIService } from './core/APIService.js';
|
|
2
2
|
import { EventBus } from './core/EventBus.js';
|
|
3
3
|
import { FeedbackSDK } from './core/FeedbackSDK.js';
|
|
4
|
-
import { MESSENGER_STYLES } from './styles/messengerStyles.js';
|
|
5
4
|
import { CSS_STYLES } from './styles/styles.js';
|
|
6
5
|
import {
|
|
7
6
|
APIError,
|
|
@@ -27,7 +26,7 @@ function injectStyles() {
|
|
|
27
26
|
) {
|
|
28
27
|
const style = document.createElement('style');
|
|
29
28
|
style.id = 'feedback-sdk-styles';
|
|
30
|
-
style.textContent = CSS_STYLES
|
|
29
|
+
style.textContent = CSS_STYLES;
|
|
31
30
|
document.head.appendChild(style);
|
|
32
31
|
}
|
|
33
32
|
}
|
|
@@ -195,4 +194,4 @@ export {
|
|
|
195
194
|
ValidationError,
|
|
196
195
|
WidgetError,
|
|
197
196
|
WidgetFactory,
|
|
198
|
-
};
|
|
197
|
+
};
|
package/src/styles/base.js
CHANGED
|
@@ -1,75 +1,50 @@
|
|
|
1
1
|
export const baseStyles = `
|
|
2
|
-
.feedback-widget
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
z-index: 999999;
|
|
2
|
+
.feedback-widget,
|
|
3
|
+
.messenger-widget,
|
|
4
|
+
.changelog-widget,
|
|
5
|
+
.feedback-survey {
|
|
7
6
|
box-sizing: border-box;
|
|
7
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', Oxygen, Ubuntu, Cantarell, sans-serif;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
.feedback-widget *,
|
|
11
11
|
.feedback-widget *::before,
|
|
12
|
-
.feedback-widget *::after
|
|
12
|
+
.feedback-widget *::after,
|
|
13
|
+
.messenger-widget *,
|
|
14
|
+
.messenger-widget *::before,
|
|
15
|
+
.messenger-widget *::after,
|
|
16
|
+
.changelog-widget *,
|
|
17
|
+
.changelog-widget *::before,
|
|
18
|
+
.changelog-widget *::after,
|
|
19
|
+
.feedback-survey *,
|
|
20
|
+
.feedback-survey *::before,
|
|
21
|
+
.feedback-survey *::after {
|
|
13
22
|
box-sizing: border-box;
|
|
14
23
|
}
|
|
15
24
|
|
|
16
|
-
/* Animations */
|
|
17
|
-
@keyframes fadeIn {
|
|
18
|
-
from { opacity: 0; }
|
|
19
|
-
to { opacity: 1; }
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
@keyframes slideInRight {
|
|
23
|
-
from {
|
|
24
|
-
transform: translateX(400px);
|
|
25
|
-
opacity: 0;
|
|
26
|
-
}
|
|
27
|
-
to {
|
|
28
|
-
transform: translateX(0);
|
|
29
|
-
opacity: 1;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
@keyframes confettiFall {
|
|
34
|
-
0% {
|
|
35
|
-
opacity: 1;
|
|
36
|
-
transform: translateY(0) rotate(0deg) scale(1);
|
|
37
|
-
}
|
|
38
|
-
10% {
|
|
39
|
-
opacity: 1;
|
|
40
|
-
}
|
|
41
|
-
100% {
|
|
42
|
-
opacity: 0;
|
|
43
|
-
transform: translateY(100vh) rotate(720deg) scale(0.5);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
@keyframes changelogSpin {
|
|
48
|
-
to {
|
|
49
|
-
transform: rotate(360deg);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/* Accessibility */
|
|
54
25
|
@media (prefers-reduced-motion: reduce) {
|
|
55
|
-
|
|
26
|
+
.feedback-widget *,
|
|
27
|
+
.messenger-widget *,
|
|
28
|
+
.changelog-widget *,
|
|
29
|
+
.feedback-survey * {
|
|
56
30
|
transition: none !important;
|
|
57
31
|
animation: none !important;
|
|
58
32
|
}
|
|
59
33
|
}
|
|
60
34
|
|
|
61
|
-
/* Print */
|
|
62
35
|
@media print {
|
|
63
36
|
.feedback-widget,
|
|
64
37
|
.feedback-panel,
|
|
65
|
-
.
|
|
66
|
-
.
|
|
38
|
+
.sdk-modal-backdrop,
|
|
39
|
+
.sdk-notification,
|
|
67
40
|
.changelog-widget,
|
|
68
41
|
.changelog-modal,
|
|
69
|
-
.
|
|
70
|
-
.
|
|
71
|
-
.
|
|
42
|
+
.messenger-widget,
|
|
43
|
+
.messenger-launcher,
|
|
44
|
+
.messenger-panel,
|
|
45
|
+
.feedback-survey,
|
|
46
|
+
.feedback-survey-backdrop {
|
|
72
47
|
display: none !important;
|
|
73
48
|
}
|
|
74
49
|
}
|
|
75
|
-
`;
|
|
50
|
+
`;
|