rohit-chat-widget 1.0.62 → 1.0.64
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/components/ChatWidget/ChatWidget.d.ts.map +1 -1
- package/lib/components/ChatWidget/ChatWidget.js +9 -12
- package/lib/components/ChatWidget/ChatWidget.js.map +1 -1
- package/lib/config/sentry.d.ts.map +1 -1
- package/lib/config/sentry.js +29 -1
- package/lib/config/sentry.js.map +1 -1
- package/lib/hooks/useChatInit.d.ts.map +1 -1
- package/lib/hooks/useChatInit.js +5 -7
- package/lib/hooks/useChatInit.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.esm.js +273 -56
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/services/acs/acsClient.d.ts.map +1 -1
- package/lib/services/acs/acsClient.js +69 -18
- package/lib/services/acs/acsClient.js.map +1 -1
- package/lib/services/api/backendApi.d.ts +38 -38
- package/lib/services/api/backendApi.d.ts.map +1 -1
- package/lib/services/api/backendApi.js +32 -11
- package/lib/services/api/backendApi.js.map +1 -1
- package/lib/services/chatService.d.ts.map +1 -1
- package/lib/services/chatService.js +5 -7
- package/lib/services/chatService.js.map +1 -1
- package/lib/src/components/ChatWidget/ChatWidget.d.ts.map +1 -1
- package/lib/src/config/sentry.d.ts.map +1 -1
- package/lib/src/hooks/useChatInit.d.ts.map +1 -1
- package/lib/src/index.d.ts +1 -0
- package/lib/src/index.d.ts.map +1 -1
- package/lib/src/services/acs/acsClient.d.ts.map +1 -1
- package/lib/src/services/api/backendApi.d.ts +38 -38
- package/lib/src/services/api/backendApi.d.ts.map +1 -1
- package/lib/src/services/chatService.d.ts.map +1 -1
- package/lib/src/store/index.d.ts +8 -8
- package/lib/src/store/store.d.ts +8 -8
- package/lib/src/store/store.d.ts.map +1 -1
- package/lib/src/utils/errorHandler.d.ts +65 -0
- package/lib/src/utils/errorHandler.d.ts.map +1 -0
- package/lib/store/index.d.ts +8 -8
- package/lib/store/store.d.ts +8 -8
- package/lib/store/store.d.ts.map +1 -1
- package/lib/store/store.js +18 -1
- package/lib/store/store.js.map +1 -1
- package/lib/utils/errorHandler.d.ts +65 -0
- package/lib/utils/errorHandler.d.ts.map +1 -0
- package/lib/utils/errorHandler.js +112 -0
- package/lib/utils/errorHandler.js.map +1 -0
- package/package.json +2 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatWidget.d.ts","sourceRoot":"","sources":["../../../src/components/ChatWidget/ChatWidget.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAQzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"ChatWidget.d.ts","sourceRoot":"","sources":["../../../src/components/ChatWidget/ChatWidget.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAQzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAKjD,MAAM,WAAW,eAAe;IAE9B,UAAU,EAAE,mBAAmB,CAAC;IAGhC,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IAGvB,SAAS,EAAE,cAAc,EAAE,CAAC;IAC5B,QAAQ,EAAE,OAAO,CAAC;CACnB;AA2FD,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA8BhD,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -10,6 +10,7 @@ import { ChatHeader } from '../ChatHeader';
|
|
|
10
10
|
import { useChatInit } from '../../hooks';
|
|
11
11
|
import { ErrorBoundary } from '../ErrorBoundary';
|
|
12
12
|
import { ErrorDisplay } from '../ErrorDisplay';
|
|
13
|
+
import { ErrorHandler } from '../../utils/errorHandler';
|
|
13
14
|
const InnerChatWidget = ({ initParams, primaryColor, secondaryColor, menuItems, showMenu }) => {
|
|
14
15
|
const { isInitializing, error, initializeChat } = useChatInit();
|
|
15
16
|
// Apply primary color to CSS custom properties
|
|
@@ -30,13 +31,11 @@ const InnerChatWidget = ({ initParams, primaryColor, secondaryColor, menuItems,
|
|
|
30
31
|
const result = await initializeChat(initParams);
|
|
31
32
|
if (!result.success && result.error) {
|
|
32
33
|
console.error('Chat initialization failed:', result.error);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
action: 'initializeChat'
|
|
37
|
-
},
|
|
34
|
+
ErrorHandler.capture(new Error(`Chat initialization failed: ${result.error}`), {
|
|
35
|
+
component: 'ChatWidget',
|
|
36
|
+
action: 'initializeChat',
|
|
38
37
|
extra: {
|
|
39
|
-
initParams: { ...initParams, apiKey: '[REDACTED]' },
|
|
38
|
+
initParams: { ...initParams, apiKey: '[REDACTED]' },
|
|
40
39
|
result
|
|
41
40
|
}
|
|
42
41
|
});
|
|
@@ -45,13 +44,11 @@ const InnerChatWidget = ({ initParams, primaryColor, secondaryColor, menuItems,
|
|
|
45
44
|
catch (error) {
|
|
46
45
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
47
46
|
console.error('Error during chat initialization:', errorMessage);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
action: 'initializeChat'
|
|
52
|
-
},
|
|
47
|
+
ErrorHandler.capture(error, {
|
|
48
|
+
component: 'ChatWidget',
|
|
49
|
+
action: 'initializeChat',
|
|
53
50
|
extra: {
|
|
54
|
-
initParams: { ...initParams, apiKey: '[REDACTED]' },
|
|
51
|
+
initParams: { ...initParams, apiKey: '[REDACTED]' },
|
|
55
52
|
errorMessage
|
|
56
53
|
}
|
|
57
54
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatWidget.js","sourceRoot":"","sources":["../../../src/components/ChatWidget/ChatWidget.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,MAAM,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"ChatWidget.js","sourceRoot":"","sources":["../../../src/components/ChatWidget/ChatWidget.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,MAAM,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,C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O,MAAM,gBAAgB,QAAO,
|
|
1
|
+
{"version":3,"file":"sentry.d.ts","sourceRoot":"","sources":["../../src/config/sentry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC;;;GAGG;AACH,eAAO,MAAM,gBAAgB,QAAO,IAuDnC,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
package/lib/config/sentry.js
CHANGED
|
@@ -6,7 +6,7 @@ import * as Sentry from '@sentry/react';
|
|
|
6
6
|
export const initializeSentry = () => {
|
|
7
7
|
try {
|
|
8
8
|
Sentry.init({
|
|
9
|
-
dsn: '
|
|
9
|
+
dsn: '',
|
|
10
10
|
// Setting this option to true will send default PII data to Sentry.
|
|
11
11
|
// For example, automatic IP address collection on events
|
|
12
12
|
sendDefaultPii: true,
|
|
@@ -24,6 +24,34 @@ export const initializeSentry = () => {
|
|
|
24
24
|
replaysSessionSampleRate: 0.1, // 10% of sessions
|
|
25
25
|
replaysOnErrorSampleRate: 1.0, // 100% of sessions with errors
|
|
26
26
|
});
|
|
27
|
+
// Global error handlers for unhandled exceptions
|
|
28
|
+
window.addEventListener('error', (event) => {
|
|
29
|
+
Sentry.captureException(event.error, {
|
|
30
|
+
tags: {
|
|
31
|
+
component: 'global',
|
|
32
|
+
type: 'javascript_error'
|
|
33
|
+
},
|
|
34
|
+
extra: {
|
|
35
|
+
message: event.message,
|
|
36
|
+
filename: event.filename,
|
|
37
|
+
lineno: event.lineno,
|
|
38
|
+
colno: event.colno
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
// Global handler for unhandled promise rejections
|
|
43
|
+
window.addEventListener('unhandledrejection', (event) => {
|
|
44
|
+
Sentry.captureException(event.reason, {
|
|
45
|
+
tags: {
|
|
46
|
+
component: 'global',
|
|
47
|
+
type: 'unhandled_promise_rejection'
|
|
48
|
+
},
|
|
49
|
+
extra: {
|
|
50
|
+
reason: event.reason,
|
|
51
|
+
promise: event.promise
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|
|
27
55
|
}
|
|
28
56
|
catch (error) {
|
|
29
57
|
console.error('Failed to initialize Sentry:', error);
|
package/lib/config/sentry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sentry.js","sourceRoot":"","sources":["../../src/config/sentry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAS,EAAE;IACzC,IAAI,CAAC;QACH,MAAM,CAAC,IAAI,CAAC;YACV,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"sentry.js","sourceRoot":"","sources":["../../src/config/sentry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAS,EAAE;IACzC,IAAI,CAAC;QACH,MAAM,CAAC,IAAI,CAAC;YACV,GAAG,EAAE,EAAE;YACP,oEAAoE;YACpE,yDAAyD;YACzD,cAAc,EAAE,IAAI;YACpB,yFAAyF;YACzF,kDAAkD;YAClD,gBAAgB,EAAE,GAAG;YACrB,sCAAsC;YACtC,YAAY,EAAE;gBACZ,MAAM,CAAC,iBAAiB,CAAC;oBACvB,WAAW,EAAE,KAAK;oBAClB,aAAa,EAAE,KAAK;iBACrB,CAAC;aACH;YACD,6BAA6B;YAC7B,wBAAwB,EAAE,GAAG,EAAE,kBAAkB;YACjD,wBAAwB,EAAE,GAAG,EAAE,+BAA+B;SAC/D,CAAC,CAAC;QAEH,iDAAiD;QACjD,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YACzC,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,KAAK,EAAE;gBACnC,IAAI,EAAE;oBACJ,SAAS,EAAE,QAAQ;oBACnB,IAAI,EAAE,kBAAkB;iBACzB;gBACD,KAAK,EAAE;oBACL,OAAO,EAAE,KAAK,CAAC,OAAO;oBACtB,QAAQ,EAAE,KAAK,CAAC,QAAQ;oBACxB,MAAM,EAAE,KAAK,CAAC,MAAM;oBACpB,KAAK,EAAE,KAAK,CAAC,KAAK;iBACnB;aACF,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,kDAAkD;QAClD,MAAM,CAAC,gBAAgB,CAAC,oBAAoB,EAAE,CAAC,KAAK,EAAE,EAAE;YACtD,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,MAAM,EAAE;gBACpC,IAAI,EAAE;oBACJ,SAAS,EAAE,QAAQ;oBACnB,IAAI,EAAE,6BAA6B;iBACpC;gBACD,KAAK,EAAE;oBACL,MAAM,EAAE,KAAK,CAAC,MAAM;oBACpB,OAAO,EAAE,KAAK,CAAC,OAAO;iBACvB;aACF,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IAEL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,KAAK,CAAC,CAAC;IACvD,CAAC;AACH,CAAC,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChatInit.d.ts","sourceRoot":"","sources":["../../src/hooks/useChatInit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useChatInit.d.ts","sourceRoot":"","sources":["../../src/hooks/useChatInit.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEnD,MAAM,WAAW,iBAAiB;IAC9B,cAAc,EAAE,OAAO,CAAC;IACxB,aAAa,EAAE,OAAO,CAAC;IACvB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAErB,cAAc,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/F,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChF,YAAY,EAAE,MAAM,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClE,SAAS,EAAE,MAAM,IAAI,CAAC;CACzB;AAED,eAAO,MAAM,WAAW,QAAO,iBA0E9B,CAAA"}
|
package/lib/hooks/useChatInit.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
2
|
import { useSelector, useDispatch } from 'react-redux';
|
|
3
|
-
import
|
|
3
|
+
import { ErrorHandler } from '@/utils/errorHandler';
|
|
4
4
|
import { chatService } from '@/services/chatService';
|
|
5
5
|
import { selectIsInitializing, selectError, clearThreadInfo } from '@/store';
|
|
6
6
|
import { selectIsInitialized, setIsInitialized, startInitialization, finishInitialization, resetMessages } from '@/store/slices/messagesSlice';
|
|
@@ -29,13 +29,11 @@ export const useChatInit = () => {
|
|
|
29
29
|
}
|
|
30
30
|
catch (error) {
|
|
31
31
|
console.error('Chat initialization failed:', error);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
action: 'initializeChat'
|
|
36
|
-
},
|
|
32
|
+
ErrorHandler.capture(error, {
|
|
33
|
+
component: 'useChatInit',
|
|
34
|
+
action: 'initializeChat',
|
|
37
35
|
extra: {
|
|
38
|
-
params: { ...params, apiKey: '[REDACTED]' }
|
|
36
|
+
params: { ...params, apiKey: '[REDACTED]' }
|
|
39
37
|
}
|
|
40
38
|
});
|
|
41
39
|
dispatch(setIsInitialized(false));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChatInit.js","sourceRoot":"","sources":["../../src/hooks/useChatInit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"useChatInit.js","sourceRoot":"","sources":["../../src/hooks/useChatInit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAgB,eAAe,EAAE,MAAM,SAAS,CAAC;AAC3F,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAc/I,MAAM,CAAC,MAAM,WAAW,GAAG,GAAsB,EAAE;IAC/C,MAAM,aAAa,GAAG,WAAW,CAAC,mBAAmB,CAAC,CAAC;IACvD,MAAM,cAAc,GAAG,WAAW,CAAC,oBAAoB,CAAC,CAAC;IACzD,MAAM,KAAK,GAAG,WAAW,CAAC,WAAW,CAAC,CAAC;IACvC,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAE/B;;OAEG;IACH,MAAM,cAAc,GAAG,WAAW,CAAC,KAAK,EAAE,MAA2B,EAAiD,EAAE;QACpH,IAAI,CAAC;YACD,QAAQ,CAAC,eAAe,EAAE,CAAC,CAAC;YAC5B,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC;YAC1B,QAAQ,CAAC,mBAAmB,EAAE,CAAC,CAAC;YAChC,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;YACxD,IAAI,MAAM,CAAC,OAAO,EAAE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AAa;QACb,KAAK;QAEL,UAAU;QACV,cAAc;QACd,WAAW;QACX,YAAY;QACZ,SAAS;KACZ,CAAC;AACN,CAAC,CAAA"}
|
package/lib/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from './components';
|
|
|
4
4
|
export type { ChatWidgetProps } from './components/ChatWidget/ChatWidget';
|
|
5
5
|
export type { InitiateChatRequest, InitiateChatResponse } from './config/api';
|
|
6
6
|
export * from './utils';
|
|
7
|
+
export { ErrorHandler } from './utils/errorHandler';
|
|
7
8
|
export * from './hooks';
|
|
8
9
|
export * from './services';
|
|
9
10
|
export { store, useAppDispatch, useAppSelector } from './store';
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,qBAAqB,CAAC;AAO7B,OAAO,EAAE,UAAU,IAAI,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAGhE,cAAc,cAAc,CAAC;AAG7B,YAAY,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAC1E,YAAY,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAG9E,cAAc,SAAS,CAAC;AAGxB,cAAc,SAAS,CAAC;AAGxB,cAAc,YAAY,CAAC;AAG3B,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAChE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGtD,YAAY,EAAE,OAAO,IAAI,YAAY,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC3F,YAAY,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,QAAQ,EACR,UAAU,EACV,aAAa,EACb,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,EACX,uBAAuB,EACvB,mBAAmB,EACpB,MAAM,8BAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,qBAAqB,CAAC;AAO7B,OAAO,EAAE,UAAU,IAAI,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAGhE,cAAc,cAAc,CAAC;AAG7B,YAAY,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAC1E,YAAY,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAG9E,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,cAAc,SAAS,CAAC;AAGxB,cAAc,YAAY,CAAC;AAG3B,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAChE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGtD,YAAY,EAAE,OAAO,IAAI,YAAY,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC3F,YAAY,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,QAAQ,EACR,UAAU,EACV,aAAa,EACb,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,EACX,uBAAuB,EACvB,mBAAmB,EACpB,MAAM,8BAA8B,CAAC"}
|
package/lib/index.esm.js
CHANGED
|
@@ -22349,7 +22349,7 @@ let ErrorBoundary$1 = class ErrorBoundary extends React.Component {
|
|
|
22349
22349
|
const initializeSentry = () => {
|
|
22350
22350
|
try {
|
|
22351
22351
|
init({
|
|
22352
|
-
dsn: '
|
|
22352
|
+
dsn: '',
|
|
22353
22353
|
// Setting this option to true will send default PII data to Sentry.
|
|
22354
22354
|
// For example, automatic IP address collection on events
|
|
22355
22355
|
sendDefaultPii: true,
|
|
@@ -22367,6 +22367,34 @@ const initializeSentry = () => {
|
|
|
22367
22367
|
replaysSessionSampleRate: 0.1, // 10% of sessions
|
|
22368
22368
|
replaysOnErrorSampleRate: 1.0, // 100% of sessions with errors
|
|
22369
22369
|
});
|
|
22370
|
+
// Global error handlers for unhandled exceptions
|
|
22371
|
+
window.addEventListener('error', (event) => {
|
|
22372
|
+
captureException(event.error, {
|
|
22373
|
+
tags: {
|
|
22374
|
+
component: 'global',
|
|
22375
|
+
type: 'javascript_error'
|
|
22376
|
+
},
|
|
22377
|
+
extra: {
|
|
22378
|
+
message: event.message,
|
|
22379
|
+
filename: event.filename,
|
|
22380
|
+
lineno: event.lineno,
|
|
22381
|
+
colno: event.colno
|
|
22382
|
+
}
|
|
22383
|
+
});
|
|
22384
|
+
});
|
|
22385
|
+
// Global handler for unhandled promise rejections
|
|
22386
|
+
window.addEventListener('unhandledrejection', (event) => {
|
|
22387
|
+
captureException(event.reason, {
|
|
22388
|
+
tags: {
|
|
22389
|
+
component: 'global',
|
|
22390
|
+
type: 'unhandled_promise_rejection'
|
|
22391
|
+
},
|
|
22392
|
+
extra: {
|
|
22393
|
+
reason: event.reason,
|
|
22394
|
+
promise: event.promise
|
|
22395
|
+
}
|
|
22396
|
+
});
|
|
22397
|
+
});
|
|
22370
22398
|
}
|
|
22371
22399
|
catch (error) {
|
|
22372
22400
|
console.error('Failed to initialize Sentry:', error);
|
|
@@ -25723,6 +25751,117 @@ function handleThunkCaseReducerDefinition({
|
|
|
25723
25751
|
function noop() {
|
|
25724
25752
|
}
|
|
25725
25753
|
|
|
25754
|
+
/**
|
|
25755
|
+
* Centralized error handling utility for the chat widget
|
|
25756
|
+
* All errors should be reported through this utility for consistent tracking
|
|
25757
|
+
*/
|
|
25758
|
+
class ErrorHandler {
|
|
25759
|
+
/**
|
|
25760
|
+
* Capture and report an error to Sentry with context
|
|
25761
|
+
*/
|
|
25762
|
+
static capture(error, context) {
|
|
25763
|
+
error instanceof Error ? error.message : 'Unknown error';
|
|
25764
|
+
console.error(`[${context.component}] ${context.action || 'Unknown'}:`, error);
|
|
25765
|
+
captureException(error, {
|
|
25766
|
+
tags: {
|
|
25767
|
+
component: context.component,
|
|
25768
|
+
action: context.action || 'unknown',
|
|
25769
|
+
...context.tags
|
|
25770
|
+
},
|
|
25771
|
+
extra: {
|
|
25772
|
+
...context.extra,
|
|
25773
|
+
timestamp: new Date().toISOString(),
|
|
25774
|
+
userAgent: navigator.userAgent,
|
|
25775
|
+
url: window.location.href
|
|
25776
|
+
}
|
|
25777
|
+
});
|
|
25778
|
+
}
|
|
25779
|
+
/**
|
|
25780
|
+
* Wrap an async function with error handling
|
|
25781
|
+
*/
|
|
25782
|
+
static async wrapAsync(fn, context) {
|
|
25783
|
+
try {
|
|
25784
|
+
return await fn();
|
|
25785
|
+
}
|
|
25786
|
+
catch (error) {
|
|
25787
|
+
this.capture(error, context);
|
|
25788
|
+
throw error;
|
|
25789
|
+
}
|
|
25790
|
+
}
|
|
25791
|
+
/**
|
|
25792
|
+
* Wrap a sync function with error handling
|
|
25793
|
+
*/
|
|
25794
|
+
static wrapSync(fn, context) {
|
|
25795
|
+
try {
|
|
25796
|
+
return fn();
|
|
25797
|
+
}
|
|
25798
|
+
catch (error) {
|
|
25799
|
+
this.capture(error, context);
|
|
25800
|
+
throw error;
|
|
25801
|
+
}
|
|
25802
|
+
}
|
|
25803
|
+
/**
|
|
25804
|
+
* Handle API errors specifically
|
|
25805
|
+
*/
|
|
25806
|
+
static captureApiError(error, context) {
|
|
25807
|
+
this.capture(error, {
|
|
25808
|
+
component: 'api',
|
|
25809
|
+
action: 'request_failed',
|
|
25810
|
+
extra: {
|
|
25811
|
+
endpoint: context.endpoint,
|
|
25812
|
+
method: context.method || 'GET',
|
|
25813
|
+
statusCode: context.statusCode,
|
|
25814
|
+
...context.extra
|
|
25815
|
+
},
|
|
25816
|
+
tags: {
|
|
25817
|
+
type: 'api_error'
|
|
25818
|
+
}
|
|
25819
|
+
});
|
|
25820
|
+
}
|
|
25821
|
+
/**
|
|
25822
|
+
* Handle ACS (Azure Communication Services) errors
|
|
25823
|
+
*/
|
|
25824
|
+
static captureAcsError(error, context) {
|
|
25825
|
+
this.capture(error, {
|
|
25826
|
+
component: 'acs',
|
|
25827
|
+
action: context.operation,
|
|
25828
|
+
extra: {
|
|
25829
|
+
threadId: context.threadId,
|
|
25830
|
+
...context.extra
|
|
25831
|
+
},
|
|
25832
|
+
tags: {
|
|
25833
|
+
type: 'acs_error'
|
|
25834
|
+
}
|
|
25835
|
+
});
|
|
25836
|
+
}
|
|
25837
|
+
/**
|
|
25838
|
+
* Handle Redux errors
|
|
25839
|
+
*/
|
|
25840
|
+
static captureReduxError(error, context) {
|
|
25841
|
+
this.capture(error, {
|
|
25842
|
+
component: 'redux',
|
|
25843
|
+
action: context.action,
|
|
25844
|
+
extra: context.extra,
|
|
25845
|
+
tags: {
|
|
25846
|
+
type: 'redux_error'
|
|
25847
|
+
}
|
|
25848
|
+
});
|
|
25849
|
+
}
|
|
25850
|
+
/**
|
|
25851
|
+
* Handle component errors
|
|
25852
|
+
*/
|
|
25853
|
+
static captureComponentError(error, context) {
|
|
25854
|
+
this.capture(error, {
|
|
25855
|
+
component: context.componentName,
|
|
25856
|
+
action: 'render_error',
|
|
25857
|
+
extra: context.extra,
|
|
25858
|
+
tags: {
|
|
25859
|
+
type: 'component_error'
|
|
25860
|
+
}
|
|
25861
|
+
});
|
|
25862
|
+
}
|
|
25863
|
+
}
|
|
25864
|
+
|
|
25726
25865
|
const initialState$2 = {
|
|
25727
25866
|
threadId: null,
|
|
25728
25867
|
threadType: null,
|
|
@@ -29309,19 +29448,39 @@ const updateApiConfig = (baseUrl, apiKey) => {
|
|
|
29309
29448
|
globalConfig.apiKey = apiKey;
|
|
29310
29449
|
};
|
|
29311
29450
|
const getApiConfig = () => globalConfig;
|
|
29451
|
+
const customBaseQuery = fetchBaseQuery({
|
|
29452
|
+
baseUrl: '',
|
|
29453
|
+
prepareHeaders: (headers, { endpoint, getState }) => {
|
|
29454
|
+
headers.set('Content-Type', 'application/json');
|
|
29455
|
+
headers.set('Accept', 'application/json');
|
|
29456
|
+
if (globalConfig.apiKey) {
|
|
29457
|
+
headers.set("api_secret_key", globalConfig.apiKey);
|
|
29458
|
+
}
|
|
29459
|
+
return headers;
|
|
29460
|
+
}
|
|
29461
|
+
});
|
|
29462
|
+
// Enhanced base query with error handling
|
|
29463
|
+
const baseQueryWithErrorHandling = async (args, api, extraOptions) => {
|
|
29464
|
+
const result = await customBaseQuery(args, api, extraOptions);
|
|
29465
|
+
if (result.error) {
|
|
29466
|
+
// Capture API errors with ErrorHandler
|
|
29467
|
+
ErrorHandler.captureApiError(result.error, {
|
|
29468
|
+
endpoint: args.url || args,
|
|
29469
|
+
method: args.method || 'GET',
|
|
29470
|
+
statusCode: result.error.status,
|
|
29471
|
+
extra: {
|
|
29472
|
+
error: result.error,
|
|
29473
|
+
args,
|
|
29474
|
+
baseUrl: globalConfig.baseUrl,
|
|
29475
|
+
hasApiKey: !!globalConfig.apiKey
|
|
29476
|
+
}
|
|
29477
|
+
});
|
|
29478
|
+
}
|
|
29479
|
+
return result;
|
|
29480
|
+
};
|
|
29312
29481
|
const backendApi = createApi({
|
|
29313
29482
|
reducerPath: 'backendApi',
|
|
29314
|
-
baseQuery:
|
|
29315
|
-
baseUrl: '',
|
|
29316
|
-
prepareHeaders: (headers, { endpoint, getState }) => {
|
|
29317
|
-
headers.set('Content-Type', 'application/json');
|
|
29318
|
-
headers.set('Accept', 'application/json');
|
|
29319
|
-
if (globalConfig.apiKey) {
|
|
29320
|
-
headers.set("api_secret_key", globalConfig.apiKey);
|
|
29321
|
-
}
|
|
29322
|
-
return headers;
|
|
29323
|
-
}
|
|
29324
|
-
}),
|
|
29483
|
+
baseQuery: baseQueryWithErrorHandling,
|
|
29325
29484
|
endpoints: (builder) => ({
|
|
29326
29485
|
initiateChat: builder.mutation({
|
|
29327
29486
|
query: (body) => ({
|
|
@@ -29369,6 +29528,22 @@ const { useInitiateChatMutation, useSendMessageMutation, useGetMessagesQuery, us
|
|
|
29369
29528
|
// Export API reducer for store integration
|
|
29370
29529
|
var backendApi$1 = backendApi.reducer;
|
|
29371
29530
|
|
|
29531
|
+
// Redux middleware to capture errors
|
|
29532
|
+
const errorMiddleware = (store) => (next) => (action) => {
|
|
29533
|
+
try {
|
|
29534
|
+
return next(action);
|
|
29535
|
+
}
|
|
29536
|
+
catch (error) {
|
|
29537
|
+
ErrorHandler.captureReduxError(error, {
|
|
29538
|
+
action: action.type,
|
|
29539
|
+
extra: {
|
|
29540
|
+
action,
|
|
29541
|
+
state: store.getState()
|
|
29542
|
+
}
|
|
29543
|
+
});
|
|
29544
|
+
throw error;
|
|
29545
|
+
}
|
|
29546
|
+
};
|
|
29372
29547
|
const store = configureStore({
|
|
29373
29548
|
reducer: {
|
|
29374
29549
|
thread: threadReducer,
|
|
@@ -29380,7 +29555,7 @@ const store = configureStore({
|
|
|
29380
29555
|
ignoredActions: ['messages/addNewMessage'],
|
|
29381
29556
|
ignoredPaths: ['messages.messages.createdOn', 'messages.messages.updatedOn'],
|
|
29382
29557
|
},
|
|
29383
|
-
}).concat(backendApi.middleware),
|
|
29558
|
+
}).concat(backendApi.middleware).concat(errorMiddleware),
|
|
29384
29559
|
});
|
|
29385
29560
|
|
|
29386
29561
|
// Pre-typed hooks for components (Typescript infers types automatically)
|
|
@@ -42535,12 +42710,21 @@ class acsClientService {
|
|
|
42535
42710
|
}
|
|
42536
42711
|
//Initialize the ACS client with token and endpoint
|
|
42537
42712
|
async initializeClient(acsAccessToken) {
|
|
42538
|
-
|
|
42539
|
-
|
|
42540
|
-
|
|
42541
|
-
|
|
42542
|
-
|
|
42543
|
-
|
|
42713
|
+
return ErrorHandler.wrapAsync(async () => {
|
|
42714
|
+
// Create ACS Token Credential
|
|
42715
|
+
this.tokenCredential = new AzureCommunicationTokenCredential(acsAccessToken);
|
|
42716
|
+
// Create Chat Client
|
|
42717
|
+
this.chatClient = new ChatClient(APP_CONSTANTS.ACS_ENDPOINT, this.tokenCredential);
|
|
42718
|
+
await this.chatClient.startRealtimeNotifications();
|
|
42719
|
+
return { success: true };
|
|
42720
|
+
}, {
|
|
42721
|
+
component: 'acsClientService',
|
|
42722
|
+
action: 'initializeClient',
|
|
42723
|
+
extra: {
|
|
42724
|
+
acsEndpoint: APP_CONSTANTS.ACS_ENDPOINT,
|
|
42725
|
+
hasToken: !!acsAccessToken
|
|
42726
|
+
}
|
|
42727
|
+
});
|
|
42544
42728
|
}
|
|
42545
42729
|
// Get Chat Thread Client for a specific thread
|
|
42546
42730
|
getChatThreadClient(threadId) {
|
|
@@ -42552,17 +42736,22 @@ class acsClientService {
|
|
|
42552
42736
|
}
|
|
42553
42737
|
// Send message to thread
|
|
42554
42738
|
async sendMessage(threadId, content) {
|
|
42555
|
-
|
|
42739
|
+
return ErrorHandler.wrapAsync(async () => {
|
|
42556
42740
|
if (!this.chatThreadClient) {
|
|
42557
42741
|
this.getChatThreadClient(threadId);
|
|
42558
42742
|
}
|
|
42559
42743
|
const sendMessageResult = await this.chatThreadClient.sendMessage({ content, type: 'text' });
|
|
42560
42744
|
return { success: true, messageId: sendMessageResult.id };
|
|
42561
|
-
}
|
|
42562
|
-
|
|
42563
|
-
|
|
42564
|
-
|
|
42565
|
-
|
|
42745
|
+
}, {
|
|
42746
|
+
component: 'acsClientService',
|
|
42747
|
+
action: 'sendMessage',
|
|
42748
|
+
extra: {
|
|
42749
|
+
threadId,
|
|
42750
|
+
contentLength: content.length,
|
|
42751
|
+
hasChatClient: !!this.chatClient,
|
|
42752
|
+
hasChatThreadClient: !!this.chatThreadClient
|
|
42753
|
+
}
|
|
42754
|
+
});
|
|
42566
42755
|
}
|
|
42567
42756
|
// Get messages for specific page using continuation token
|
|
42568
42757
|
async getMessagesForPage(threadId, continuationToken, hasExistingMessages = false) {
|
|
@@ -42601,18 +42790,54 @@ class acsClientService {
|
|
|
42601
42790
|
}
|
|
42602
42791
|
catch (error) {
|
|
42603
42792
|
console.error('An error occured while getting messages for page:', error);
|
|
42793
|
+
ErrorHandler.capture(error, {
|
|
42794
|
+
component: 'acsClientService',
|
|
42795
|
+
action: 'getMessagesForPage',
|
|
42796
|
+
extra: {
|
|
42797
|
+
threadId,
|
|
42798
|
+
continuationToken,
|
|
42799
|
+
hasExistingMessages,
|
|
42800
|
+
hasChatClient: !!this.chatClient,
|
|
42801
|
+
hasChatThreadClient: !!this.chatThreadClient
|
|
42802
|
+
}
|
|
42803
|
+
});
|
|
42604
42804
|
return { success: false, error };
|
|
42605
42805
|
}
|
|
42606
42806
|
}
|
|
42607
42807
|
// Set up real-time message listeners
|
|
42608
42808
|
setupMessageListeners(onMessageReceived) {
|
|
42609
|
-
|
|
42610
|
-
|
|
42809
|
+
try {
|
|
42810
|
+
if (!this.chatClient) {
|
|
42811
|
+
throw new Error('Chat client not initialized');
|
|
42812
|
+
}
|
|
42813
|
+
// Listen for new messages
|
|
42814
|
+
this.chatClient.on('chatMessageReceived', (e) => {
|
|
42815
|
+
try {
|
|
42816
|
+
onMessageReceived(e);
|
|
42817
|
+
}
|
|
42818
|
+
catch (error) {
|
|
42819
|
+
console.error('Error in message listener:', error);
|
|
42820
|
+
ErrorHandler.capture(error, {
|
|
42821
|
+
component: 'acsClientService',
|
|
42822
|
+
action: 'messageListener',
|
|
42823
|
+
extra: {
|
|
42824
|
+
event: e
|
|
42825
|
+
}
|
|
42826
|
+
});
|
|
42827
|
+
}
|
|
42828
|
+
});
|
|
42829
|
+
}
|
|
42830
|
+
catch (error) {
|
|
42831
|
+
console.error('Error setting up message listeners:', error);
|
|
42832
|
+
ErrorHandler.capture(error, {
|
|
42833
|
+
component: 'acsClientService',
|
|
42834
|
+
action: 'setupMessageListeners',
|
|
42835
|
+
extra: {
|
|
42836
|
+
hasChatClient: !!this.chatClient
|
|
42837
|
+
}
|
|
42838
|
+
});
|
|
42839
|
+
throw error;
|
|
42611
42840
|
}
|
|
42612
|
-
// Listen for new messages
|
|
42613
|
-
this.chatClient.on('chatMessageReceived', (e) => {
|
|
42614
|
-
onMessageReceived(e);
|
|
42615
|
-
});
|
|
42616
42841
|
}
|
|
42617
42842
|
// Dispose client
|
|
42618
42843
|
dispose() {
|
|
@@ -42664,13 +42889,11 @@ class ChatService {
|
|
|
42664
42889
|
catch (error) {
|
|
42665
42890
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
42666
42891
|
console.error('Chat initialization failed:', error);
|
|
42667
|
-
|
|
42668
|
-
|
|
42669
|
-
|
|
42670
|
-
action: 'initializeChat'
|
|
42671
|
-
},
|
|
42892
|
+
ErrorHandler.capture(error, {
|
|
42893
|
+
component: 'ChatService',
|
|
42894
|
+
action: 'initializeChat',
|
|
42672
42895
|
extra: {
|
|
42673
|
-
params: { ...params, apiKey: '[REDACTED]' },
|
|
42896
|
+
params: { ...params, apiKey: '[REDACTED]' },
|
|
42674
42897
|
errorMessage
|
|
42675
42898
|
}
|
|
42676
42899
|
});
|
|
@@ -42890,13 +43113,11 @@ const useChatInit = () => {
|
|
|
42890
43113
|
}
|
|
42891
43114
|
catch (error) {
|
|
42892
43115
|
console.error('Chat initialization failed:', error);
|
|
42893
|
-
|
|
42894
|
-
|
|
42895
|
-
|
|
42896
|
-
action: 'initializeChat'
|
|
42897
|
-
},
|
|
43116
|
+
ErrorHandler.capture(error, {
|
|
43117
|
+
component: 'useChatInit',
|
|
43118
|
+
action: 'initializeChat',
|
|
42898
43119
|
extra: {
|
|
42899
|
-
params: { ...params, apiKey: '[REDACTED]' }
|
|
43120
|
+
params: { ...params, apiKey: '[REDACTED]' }
|
|
42900
43121
|
}
|
|
42901
43122
|
});
|
|
42902
43123
|
dispatch(setIsInitialized(false));
|
|
@@ -43509,13 +43730,11 @@ const InnerChatWidget = ({ initParams, primaryColor, secondaryColor, menuItems,
|
|
|
43509
43730
|
const result = await initializeChat(initParams);
|
|
43510
43731
|
if (!result.success && result.error) {
|
|
43511
43732
|
console.error('Chat initialization failed:', result.error);
|
|
43512
|
-
|
|
43513
|
-
|
|
43514
|
-
|
|
43515
|
-
action: 'initializeChat'
|
|
43516
|
-
},
|
|
43733
|
+
ErrorHandler.capture(new Error(`Chat initialization failed: ${result.error}`), {
|
|
43734
|
+
component: 'ChatWidget',
|
|
43735
|
+
action: 'initializeChat',
|
|
43517
43736
|
extra: {
|
|
43518
|
-
initParams: { ...initParams, apiKey: '[REDACTED]' },
|
|
43737
|
+
initParams: { ...initParams, apiKey: '[REDACTED]' },
|
|
43519
43738
|
result
|
|
43520
43739
|
}
|
|
43521
43740
|
});
|
|
@@ -43524,13 +43743,11 @@ const InnerChatWidget = ({ initParams, primaryColor, secondaryColor, menuItems,
|
|
|
43524
43743
|
catch (error) {
|
|
43525
43744
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
43526
43745
|
console.error('Error during chat initialization:', errorMessage);
|
|
43527
|
-
|
|
43528
|
-
|
|
43529
|
-
|
|
43530
|
-
action: 'initializeChat'
|
|
43531
|
-
},
|
|
43746
|
+
ErrorHandler.capture(error, {
|
|
43747
|
+
component: 'ChatWidget',
|
|
43748
|
+
action: 'initializeChat',
|
|
43532
43749
|
extra: {
|
|
43533
|
-
initParams: { ...initParams, apiKey: '[REDACTED]' },
|
|
43750
|
+
initParams: { ...initParams, apiKey: '[REDACTED]' },
|
|
43534
43751
|
errorMessage
|
|
43535
43752
|
}
|
|
43536
43753
|
});
|
|
@@ -43703,5 +43920,5 @@ const applyDefaultTheme = () => {
|
|
|
43703
43920
|
// Import styles automatically
|
|
43704
43921
|
initializeSentry();
|
|
43705
43922
|
|
|
43706
|
-
export { ChatContainer, ChatHeader, ChatService, ChatWidget, DropdownMenu, ErrorBoundary, ErrorDisplay, LoadingIndicator, MenuItem, MessageBubble, MessageInput, MessageList, StyleManager, acsClientService, addNewMessage, applyDefaultTheme, backendApi, backendApi$1 as backendApiReducer, chatService, clearError, ChatWidget as default, defaultTheme, finishInitialization, formatDate, formatTime, getApiConfig, getRelativeTime, isValidUUID, resetMessages, sanitizeInput, selectContinuationToken, selectError, selectIsInitialized, selectIsInitializing, selectIsLoadingPage, selectMessages, setContinuationToken, setError, setIsInitialized, setPageMessages, startInitialization, startLoadingPage, store, useAppDispatch, useAppSelector, useChatInit, useGetMessagesQuery, useInitiateChatMutation, useLazyGetMessagesQuery, useSendMessageMutation, validateEmail, validateMessage };
|
|
43923
|
+
export { ChatContainer, ChatHeader, ChatService, ChatWidget, DropdownMenu, ErrorBoundary, ErrorDisplay, ErrorHandler, LoadingIndicator, MenuItem, MessageBubble, MessageInput, MessageList, StyleManager, acsClientService, addNewMessage, applyDefaultTheme, backendApi, backendApi$1 as backendApiReducer, chatService, clearError, ChatWidget as default, defaultTheme, finishInitialization, formatDate, formatTime, getApiConfig, getRelativeTime, isValidUUID, resetMessages, sanitizeInput, selectContinuationToken, selectError, selectIsInitialized, selectIsInitializing, selectIsLoadingPage, selectMessages, setContinuationToken, setError, setIsInitialized, setPageMessages, startInitialization, startLoadingPage, store, useAppDispatch, useAppSelector, useChatInit, useGetMessagesQuery, useInitiateChatMutation, useLazyGetMessagesQuery, useSendMessageMutation, validateEmail, validateMessage };
|
|
43707
43924
|
//# sourceMappingURL=index.esm.js.map
|