call-control-sdk 6.5.1-uat.5 → 6.5.1-uat.6
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.js +34 -300
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -300
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -253,7 +253,7 @@ var SDKStateManager = class {
|
|
|
253
253
|
});
|
|
254
254
|
}
|
|
255
255
|
} catch (error) {
|
|
256
|
-
console.warn("Failed to load SDK state
|
|
256
|
+
console.warn("Failed to load SDK state:", error);
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
259
|
saveToStorage() {
|
|
@@ -277,7 +277,7 @@ var SDKStateManager = class {
|
|
|
277
277
|
};
|
|
278
278
|
localStorage.setItem(this.STORAGE_KEY, JSON.stringify(persistentState));
|
|
279
279
|
} catch (error) {
|
|
280
|
-
console.warn("Failed to save SDK state
|
|
280
|
+
console.warn("Failed to save SDK state:", error);
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
283
|
notifyListeners() {
|
|
@@ -411,7 +411,6 @@ var SDKStateManager = class {
|
|
|
411
411
|
setConferenceLine(line) {
|
|
412
412
|
var _a2;
|
|
413
413
|
if (!this.state.conferenceLine || !Array.isArray(this.state.conferenceLine)) {
|
|
414
|
-
console.warn("Conference line data corrupted, resetting to initial state");
|
|
415
414
|
this.state.conferenceLine = this.getInitialState().conferenceLine;
|
|
416
415
|
}
|
|
417
416
|
const conferenceLineData = (_a2 = this.state.conferenceLine) == null ? void 0 : _a2.map((each) => {
|
|
@@ -486,19 +485,7 @@ var SDKStateManager = class {
|
|
|
486
485
|
this.state = this.getInitialState();
|
|
487
486
|
this.notifyListeners();
|
|
488
487
|
} catch (error) {
|
|
489
|
-
console.warn("Failed to clear
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
debugStorage() {
|
|
493
|
-
try {
|
|
494
|
-
const stored = localStorage.getItem(this.STORAGE_KEY);
|
|
495
|
-
console.log("Current localStorage data:", stored);
|
|
496
|
-
if (stored) {
|
|
497
|
-
console.log("Parsed localStorage data:", JSON.parse(stored));
|
|
498
|
-
}
|
|
499
|
-
console.log("Current state:", this.state);
|
|
500
|
-
} catch (error) {
|
|
501
|
-
console.error("Error debugging storage:", error);
|
|
488
|
+
console.warn("Failed to clear:", error);
|
|
502
489
|
}
|
|
503
490
|
}
|
|
504
491
|
getConferenceLines() {
|
|
@@ -513,23 +500,17 @@ var EventTrackerSDK = class {
|
|
|
513
500
|
__publicField(this, "config", null);
|
|
514
501
|
__publicField(this, "ticketId", null);
|
|
515
502
|
__publicField(this, "baseUrl", "");
|
|
516
|
-
__publicField(this, "eventQueue", []);
|
|
517
|
-
// private isOnline: boolean = true;
|
|
518
|
-
// private retryQueue: Array<() => Promise<void>> = [];
|
|
519
503
|
__publicField(this, "flushTimer", null);
|
|
520
504
|
}
|
|
521
505
|
async init(config) {
|
|
522
506
|
this.config = __spreadValues({
|
|
523
|
-
autoTrack: true,
|
|
524
507
|
retryAttempts: 3,
|
|
525
508
|
queueSize: 100,
|
|
526
509
|
flushInterval: 5e3
|
|
527
510
|
}, config);
|
|
528
511
|
this.baseUrl = config.baseUrl || (typeof window !== "undefined" ? window.location.origin : "");
|
|
529
|
-
this.setupNetworkDetection();
|
|
530
512
|
const ticket = await this.createTicket();
|
|
531
513
|
this.startPeriodicFlush();
|
|
532
|
-
console.log("EventTracker SDK initialized successfully");
|
|
533
514
|
return ticket;
|
|
534
515
|
}
|
|
535
516
|
isInitialized() {
|
|
@@ -563,104 +544,11 @@ var EventTrackerSDK = class {
|
|
|
563
544
|
}
|
|
564
545
|
const data = await response.json();
|
|
565
546
|
this.ticketId = data.ticketId;
|
|
566
|
-
if (this.config.autoTrack) {
|
|
567
|
-
this.setupAutoTracking();
|
|
568
|
-
}
|
|
569
547
|
return data;
|
|
570
548
|
} catch (error) {
|
|
571
|
-
console.error("EventTracker initialization failed:", error);
|
|
572
549
|
throw error;
|
|
573
550
|
}
|
|
574
551
|
}
|
|
575
|
-
async logEvent(eventType, eventData) {
|
|
576
|
-
if (!this.config || !this.ticketId) {
|
|
577
|
-
console.warn("EventTracker not initialized, skipping event:", eventType);
|
|
578
|
-
return;
|
|
579
|
-
}
|
|
580
|
-
const event = {
|
|
581
|
-
eventType,
|
|
582
|
-
eventData,
|
|
583
|
-
timestamp: Date.now()
|
|
584
|
-
};
|
|
585
|
-
this.eventQueue.push(event);
|
|
586
|
-
if (this.eventQueue.length > (this.config.queueSize || 100)) {
|
|
587
|
-
this.eventQueue.shift();
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
// private async sendEvent(event: {
|
|
591
|
-
// eventType: string;
|
|
592
|
-
// eventData?: EventData;
|
|
593
|
-
// timestamp: number;
|
|
594
|
-
// }): Promise<void> {
|
|
595
|
-
// if (!this.config || !this.ticketId) return;
|
|
596
|
-
// try {
|
|
597
|
-
// const response = await this.makeRequest("/api/v1/et/event", {
|
|
598
|
-
// method: "POST",
|
|
599
|
-
// headers: {
|
|
600
|
-
// "Content-Type": "application/json",
|
|
601
|
-
// "X-API-Key": this.config.apiKey,
|
|
602
|
-
// },
|
|
603
|
-
// body: JSON.stringify({
|
|
604
|
-
// ticketId: this.ticketId,
|
|
605
|
-
// eventType: event.eventType,
|
|
606
|
-
// eventData: event.eventData,
|
|
607
|
-
// }),
|
|
608
|
-
// });
|
|
609
|
-
// if (!response.ok) {
|
|
610
|
-
// throw new Error(`Failed to log event: ${response.status} ${response.statusText}`);
|
|
611
|
-
// }
|
|
612
|
-
// const index = this.eventQueue.findIndex((e) => e.timestamp === event.timestamp);
|
|
613
|
-
// if (index > -1) {
|
|
614
|
-
// this.eventQueue.splice(index, 1);
|
|
615
|
-
// }
|
|
616
|
-
// } catch (error) {
|
|
617
|
-
// console.error("Event logging failed:", error);
|
|
618
|
-
// // this.retryQueue.push(() => this.sendEvent(event));
|
|
619
|
-
// }
|
|
620
|
-
// }
|
|
621
|
-
// async closeTicket(): Promise<void> {
|
|
622
|
-
// if (!this.config || !this.ticketId) {
|
|
623
|
-
// throw new Error("EventTracker not initialized");
|
|
624
|
-
// }
|
|
625
|
-
// await this.flush();
|
|
626
|
-
// try {
|
|
627
|
-
// const response = await this.makeRequest("/api/v1/et/close", {
|
|
628
|
-
// method: "POST",
|
|
629
|
-
// headers: {
|
|
630
|
-
// "Content-Type": "application/json",
|
|
631
|
-
// "X-API-Key": this.config.apiKey,
|
|
632
|
-
// },
|
|
633
|
-
// body: JSON.stringify({
|
|
634
|
-
// ticketId: this.ticketId,
|
|
635
|
-
// }),
|
|
636
|
-
// });
|
|
637
|
-
// if (!response.ok) {
|
|
638
|
-
// throw new Error(`Failed to close ticket: ${response.status} ${response.statusText}`);
|
|
639
|
-
// }
|
|
640
|
-
// this.ticketId = null;
|
|
641
|
-
// this.stopPeriodicFlush();
|
|
642
|
-
// console.log("Ticket closed successfully");
|
|
643
|
-
// } catch (error) {
|
|
644
|
-
// console.error("Ticket close failed:", error);
|
|
645
|
-
// throw error;
|
|
646
|
-
// }
|
|
647
|
-
// }
|
|
648
|
-
// async flush(): Promise<void> {
|
|
649
|
-
// if (!this.isOnline || this.eventQueue.length === 0) return;
|
|
650
|
-
// // const eventsToFlush = [...this.eventQueue];
|
|
651
|
-
// // for (const event of eventsToFlush) {
|
|
652
|
-
// // await this.sendEvent(event);
|
|
653
|
-
// // }
|
|
654
|
-
// const retryItems = [...this.retryQueue];
|
|
655
|
-
// this.retryQueue = [];
|
|
656
|
-
// for (const retryFn of retryItems) {
|
|
657
|
-
// try {
|
|
658
|
-
// await retryFn();
|
|
659
|
-
// } catch (error) {
|
|
660
|
-
// console.error("Retry failed:", error);
|
|
661
|
-
// }
|
|
662
|
-
// }
|
|
663
|
-
// }
|
|
664
552
|
async makeRequest(url, options) {
|
|
665
553
|
var _a2;
|
|
666
554
|
const fullUrl = `${this.baseUrl}${url}`;
|
|
@@ -679,156 +567,11 @@ var EventTrackerSDK = class {
|
|
|
679
567
|
}
|
|
680
568
|
throw new Error("Max retries exceeded");
|
|
681
569
|
}
|
|
682
|
-
setupAutoTracking() {
|
|
683
|
-
var _a2;
|
|
684
|
-
if (typeof window === "undefined" || !((_a2 = this.config) == null ? void 0 : _a2.autoTrack)) return;
|
|
685
|
-
const autoTrackConfig = this.config.autoTrack === true ? {} : this.config.autoTrack;
|
|
686
|
-
if (autoTrackConfig.pageVisits !== false) {
|
|
687
|
-
this.logEvent("pageVisit", {
|
|
688
|
-
url: window.location.href,
|
|
689
|
-
title: document.title,
|
|
690
|
-
referrer: document.referrer,
|
|
691
|
-
userAgent: navigator.userAgent,
|
|
692
|
-
viewport: {
|
|
693
|
-
width: window.innerWidth,
|
|
694
|
-
height: window.innerHeight
|
|
695
|
-
},
|
|
696
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
697
|
-
}).catch((error) => console.warn("Failed to track page visit:", error));
|
|
698
|
-
}
|
|
699
|
-
if (autoTrackConfig.clicks !== false) {
|
|
700
|
-
document.addEventListener("click", (event) => {
|
|
701
|
-
var _a3;
|
|
702
|
-
const target = event.target;
|
|
703
|
-
if (target.tagName === "BUTTON" || target.tagName === "A" || target.onclick || target.getAttribute("role") === "button" || target instanceof HTMLButtonElement && target.type === "button") {
|
|
704
|
-
this.logEvent("click", {
|
|
705
|
-
element: target.tagName,
|
|
706
|
-
text: (_a3 = target.textContent) == null ? void 0 : _a3.trim().substring(0, 100),
|
|
707
|
-
href: target.getAttribute("href"),
|
|
708
|
-
id: target.id,
|
|
709
|
-
className: target.className,
|
|
710
|
-
role: target.getAttribute("role"),
|
|
711
|
-
position: {
|
|
712
|
-
x: event.clientX,
|
|
713
|
-
y: event.clientY
|
|
714
|
-
},
|
|
715
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
716
|
-
}).catch((error) => console.warn("Failed to track click:", error));
|
|
717
|
-
}
|
|
718
|
-
});
|
|
719
|
-
}
|
|
720
|
-
if (autoTrackConfig.forms !== false) {
|
|
721
|
-
document.addEventListener("submit", (event) => {
|
|
722
|
-
const target = event.target;
|
|
723
|
-
const formData = new FormData(target);
|
|
724
|
-
const formFields = {};
|
|
725
|
-
formData.forEach((value, key) => {
|
|
726
|
-
formFields[key] = value.toString();
|
|
727
|
-
});
|
|
728
|
-
this.logEvent("formSubmission", {
|
|
729
|
-
formId: target.id,
|
|
730
|
-
action: target.action,
|
|
731
|
-
method: target.method,
|
|
732
|
-
fields: Object.keys(formFields),
|
|
733
|
-
fieldCount: Object.keys(formFields).length,
|
|
734
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
735
|
-
}).catch((error) => console.warn("Failed to track form submission:", error));
|
|
736
|
-
});
|
|
737
|
-
}
|
|
738
|
-
if (autoTrackConfig.inputs !== false) {
|
|
739
|
-
let inputTimer;
|
|
740
|
-
document.addEventListener("input", (event) => {
|
|
741
|
-
const target = event.target;
|
|
742
|
-
if (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.tagName === "SELECT") {
|
|
743
|
-
clearTimeout(inputTimer);
|
|
744
|
-
inputTimer = setTimeout(() => {
|
|
745
|
-
var _a3;
|
|
746
|
-
this.logEvent("fieldChange", {
|
|
747
|
-
element: target.tagName,
|
|
748
|
-
type: target.getAttribute("type"),
|
|
749
|
-
name: target.getAttribute("name"),
|
|
750
|
-
id: target.id,
|
|
751
|
-
valueLength: ((_a3 = target.value) == null ? void 0 : _a3.length) || 0,
|
|
752
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
753
|
-
}).catch((error) => console.warn("Failed to track field change:", error));
|
|
754
|
-
}, 1e3);
|
|
755
|
-
}
|
|
756
|
-
});
|
|
757
|
-
}
|
|
758
|
-
const sessionStartTime = Date.now();
|
|
759
|
-
window.addEventListener("beforeunload", () => {
|
|
760
|
-
const sessionDuration = Date.now() - sessionStartTime;
|
|
761
|
-
this.logEvent("pageUnload", {
|
|
762
|
-
url: window.location.href,
|
|
763
|
-
sessionDuration,
|
|
764
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
765
|
-
});
|
|
766
|
-
});
|
|
767
|
-
if (autoTrackConfig.visibility !== false) {
|
|
768
|
-
document.addEventListener("visibilitychange", () => {
|
|
769
|
-
this.logEvent("visibilityChange", {
|
|
770
|
-
hidden: document.hidden,
|
|
771
|
-
visibilityState: document.visibilityState,
|
|
772
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
773
|
-
});
|
|
774
|
-
});
|
|
775
|
-
}
|
|
776
|
-
if (autoTrackConfig.errors !== false) {
|
|
777
|
-
window.addEventListener("error", (event) => {
|
|
778
|
-
this.logEvent("jsError", {
|
|
779
|
-
message: event.message,
|
|
780
|
-
filename: event.filename,
|
|
781
|
-
lineno: event.lineno,
|
|
782
|
-
colno: event.colno,
|
|
783
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
784
|
-
});
|
|
785
|
-
});
|
|
786
|
-
window.addEventListener("unhandledrejection", (event) => {
|
|
787
|
-
var _a3;
|
|
788
|
-
this.logEvent("unhandledRejection", {
|
|
789
|
-
reason: (_a3 = event.reason) == null ? void 0 : _a3.toString(),
|
|
790
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
791
|
-
});
|
|
792
|
-
});
|
|
793
|
-
}
|
|
794
|
-
if (autoTrackConfig.performance !== false && typeof window.performance !== "undefined" && window.performance.navigation) {
|
|
795
|
-
window.addEventListener("load", () => {
|
|
796
|
-
setTimeout(() => {
|
|
797
|
-
const navigation = window.performance.navigation;
|
|
798
|
-
const timing = window.performance.timing;
|
|
799
|
-
this.logEvent("performanceMetrics", {
|
|
800
|
-
navigationTime: timing.navigationStart,
|
|
801
|
-
loadTime: timing.loadEventEnd - timing.navigationStart,
|
|
802
|
-
domReady: timing.domContentLoadedEventEnd - timing.navigationStart,
|
|
803
|
-
renderTime: timing.loadEventEnd - timing.domContentLoadedEventEnd,
|
|
804
|
-
navigationType: navigation.type,
|
|
805
|
-
redirectCount: navigation.redirectCount,
|
|
806
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
807
|
-
});
|
|
808
|
-
}, 1e3);
|
|
809
|
-
});
|
|
810
|
-
}
|
|
811
|
-
}
|
|
812
|
-
setupNetworkDetection() {
|
|
813
|
-
if (typeof window === "undefined") return;
|
|
814
|
-
window.addEventListener("online", () => {
|
|
815
|
-
console.log("EventTracker: Back online, flushing queued events");
|
|
816
|
-
});
|
|
817
|
-
window.addEventListener("offline", () => {
|
|
818
|
-
console.log("EventTracker: Offline, queueing events");
|
|
819
|
-
});
|
|
820
|
-
}
|
|
821
570
|
startPeriodicFlush() {
|
|
822
571
|
if (this.flushTimer) {
|
|
823
572
|
clearInterval(this.flushTimer);
|
|
824
573
|
}
|
|
825
574
|
}
|
|
826
|
-
// private stopPeriodicFlush(): void {
|
|
827
|
-
// if (this.flushTimer) {
|
|
828
|
-
// clearInterval(this.flushTimer);
|
|
829
|
-
// this.flushTimer = null;
|
|
830
|
-
// }
|
|
831
|
-
// }
|
|
832
575
|
};
|
|
833
576
|
var eventTracker = new EventTrackerSDK();
|
|
834
577
|
if (typeof window !== "undefined") {
|
|
@@ -877,12 +620,6 @@ function createAxiosInstance() {
|
|
|
877
620
|
);
|
|
878
621
|
instance.interceptors.response.use(
|
|
879
622
|
(response) => {
|
|
880
|
-
var _a3;
|
|
881
|
-
const endTime = (/* @__PURE__ */ new Date()).getTime();
|
|
882
|
-
const startTime = (_a3 = response.config.metadata) == null ? void 0 : _a3.startTime;
|
|
883
|
-
if (startTime) {
|
|
884
|
-
console.log(`Request to ${response.config.url} took ${endTime - startTime}ms`);
|
|
885
|
-
}
|
|
886
623
|
return response;
|
|
887
624
|
},
|
|
888
625
|
async (error) => {
|
|
@@ -1601,17 +1338,11 @@ var ConferenceTableRow = ({ each }) => {
|
|
|
1601
1338
|
const [holdOrUnHold] = usePostRequest({
|
|
1602
1339
|
onSuccess: () => {
|
|
1603
1340
|
sdkStateManager.setHolding(!state.isHolding);
|
|
1604
|
-
},
|
|
1605
|
-
onError: (error) => {
|
|
1606
|
-
console.log("\u274C Hold operation error:", error);
|
|
1607
1341
|
}
|
|
1608
1342
|
});
|
|
1609
1343
|
const [muteOrUnMute] = usePostRequest({
|
|
1610
1344
|
onSuccess: () => {
|
|
1611
1345
|
sdkStateManager.setMuted(!state.isMuted);
|
|
1612
|
-
},
|
|
1613
|
-
onError: (error) => {
|
|
1614
|
-
console.log("\u274C Mute operation error:", error);
|
|
1615
1346
|
}
|
|
1616
1347
|
});
|
|
1617
1348
|
const handleHoldToggle = () => {
|
|
@@ -2542,7 +2273,6 @@ function EndCallDispositionDialog({ open, setOpen, onSubmitDisposition }) {
|
|
|
2542
2273
|
(0, import_react10.useEffect)(() => {
|
|
2543
2274
|
getDispositions(END_POINT.DISPOSITIONS);
|
|
2544
2275
|
}, []);
|
|
2545
|
-
console.log("dispositionsData", formData);
|
|
2546
2276
|
const dispositionsOptions = (0, import_react10.useMemo)(() => {
|
|
2547
2277
|
var _a3, _b2;
|
|
2548
2278
|
return ((_b2 = (_a3 = data == null ? void 0 : data.data) == null ? void 0 : _a3.data) == null ? void 0 : _b2.map((item) => ({
|
|
@@ -2919,7 +2649,7 @@ async function loadAudioAsBlob() {
|
|
|
2919
2649
|
audioBlobUrl = URL.createObjectURL(blob);
|
|
2920
2650
|
return audioBlobUrl;
|
|
2921
2651
|
} catch (error) {
|
|
2922
|
-
console.
|
|
2652
|
+
console.error("Could not create blob URL, using direct URL:", error);
|
|
2923
2653
|
return import_incoming.default;
|
|
2924
2654
|
}
|
|
2925
2655
|
}
|
|
@@ -2958,15 +2688,11 @@ async function createAudioElement() {
|
|
|
2958
2688
|
};
|
|
2959
2689
|
let loaded = await tryLoadAudio(audioUrl);
|
|
2960
2690
|
if (!loaded && audioUrl !== import_incoming.default) {
|
|
2961
|
-
console.log("Primary URL failed, trying original import URL:", import_incoming.default);
|
|
2962
2691
|
loaded = await tryLoadAudio(import_incoming.default);
|
|
2963
2692
|
if (loaded) {
|
|
2964
2693
|
audioUrl = import_incoming.default;
|
|
2965
2694
|
}
|
|
2966
2695
|
}
|
|
2967
|
-
if (!loaded) {
|
|
2968
|
-
console.error("Failed to load audio with all methods. URL:", audioUrl);
|
|
2969
|
-
}
|
|
2970
2696
|
return audio;
|
|
2971
2697
|
}
|
|
2972
2698
|
function cleanupAudioResources() {
|
|
@@ -3088,6 +2814,7 @@ function CallControls({ onDataChange }) {
|
|
|
3088
2814
|
const [processList, setProcessList] = (0, import_react11.useState)(null);
|
|
3089
2815
|
const [phoneNumber, setPhoneNumber] = (0, import_react11.useState)("");
|
|
3090
2816
|
const [callDuration, setCallDuration] = (0, import_react11.useState)(0);
|
|
2817
|
+
const [callWrapuptime, setCallWrapuptime] = (0, import_react11.useState)(null);
|
|
3091
2818
|
const { position, isDragging, dragRef, handleMouseDown, handleTouchStart } = useDraggable(
|
|
3092
2819
|
state.controlPanelPosition,
|
|
3093
2820
|
(newPosition) => sdkStateManager.setControlPanelPosition(newPosition)
|
|
@@ -3111,17 +2838,11 @@ function CallControls({ onDataChange }) {
|
|
|
3111
2838
|
const [holdOrUnHold, { isLoading: holdOrUnHoldLoading }] = usePostRequest({
|
|
3112
2839
|
onSuccess: () => {
|
|
3113
2840
|
sdkStateManager.setHolding(!state.isHolding);
|
|
3114
|
-
},
|
|
3115
|
-
onError: (error) => {
|
|
3116
|
-
console.log("\u274C Hold operation error:", error);
|
|
3117
2841
|
}
|
|
3118
2842
|
});
|
|
3119
2843
|
const [muteOrUnMute, { isLoading: muteOrUnMuteLoading }] = usePostRequest({
|
|
3120
2844
|
onSuccess: () => {
|
|
3121
2845
|
sdkStateManager.setMuted(!state.isMuted);
|
|
3122
|
-
},
|
|
3123
|
-
onError: (error) => {
|
|
3124
|
-
console.log("\u274C Mute operation error:", error);
|
|
3125
2846
|
}
|
|
3126
2847
|
});
|
|
3127
2848
|
const [readyAgentStatus, { isLoading: agentReadyLoading }] = usePostRequest();
|
|
@@ -3293,6 +3014,7 @@ function CallControls({ onDataChange }) {
|
|
|
3293
3014
|
}, []);
|
|
3294
3015
|
(0, import_react11.useEffect)(() => {
|
|
3295
3016
|
let interval;
|
|
3017
|
+
let wrapUpinterval;
|
|
3296
3018
|
if (state.callData.status && state.callData.status === "ONCALL") {
|
|
3297
3019
|
interval = setInterval(() => {
|
|
3298
3020
|
const elapsed = Math.floor((Date.now() - state.callStartTime) / 1e3);
|
|
@@ -3301,8 +3023,28 @@ function CallControls({ onDataChange }) {
|
|
|
3301
3023
|
} else {
|
|
3302
3024
|
setCallDuration(0);
|
|
3303
3025
|
}
|
|
3026
|
+
if (state.callData.status && state.callData.status === "WRAPUP" && callWrapuptime !== null) {
|
|
3027
|
+
wrapUpinterval = setInterval(() => {
|
|
3028
|
+
setCallWrapuptime((prevTime) => {
|
|
3029
|
+
if (prevTime === null || prevTime <= 1) {
|
|
3030
|
+
clearInterval(wrapUpinterval);
|
|
3031
|
+
handleEndCall({
|
|
3032
|
+
disposition: { label: "Resolved", value: "RES" },
|
|
3033
|
+
followUp: { label: "No", value: "N" },
|
|
3034
|
+
callbackDate: "",
|
|
3035
|
+
callbackHrs: "",
|
|
3036
|
+
callbackMins: "",
|
|
3037
|
+
selected_break: false
|
|
3038
|
+
});
|
|
3039
|
+
return null;
|
|
3040
|
+
}
|
|
3041
|
+
return prevTime - 1;
|
|
3042
|
+
});
|
|
3043
|
+
}, 1e3);
|
|
3044
|
+
}
|
|
3304
3045
|
return () => {
|
|
3305
3046
|
if (interval) clearInterval(interval);
|
|
3047
|
+
if (wrapUpinterval) clearInterval(wrapUpinterval);
|
|
3306
3048
|
};
|
|
3307
3049
|
}, [state.callData.status]);
|
|
3308
3050
|
(0, import_react11.useEffect)(() => {
|
|
@@ -3353,13 +3095,10 @@ function CallControls({ onDataChange }) {
|
|
|
3353
3095
|
}).catch((err) => {
|
|
3354
3096
|
showToast(err.response.data.message, "error");
|
|
3355
3097
|
});
|
|
3356
|
-
} else {
|
|
3357
|
-
console.log("No agentId available, skipping API call");
|
|
3358
3098
|
}
|
|
3359
3099
|
}, [state.agentId]);
|
|
3360
3100
|
const connectWebSocket = () => {
|
|
3361
3101
|
if (!state.agentId) {
|
|
3362
|
-
console.log("No agentId available, cannot connect WebSocket");
|
|
3363
3102
|
return;
|
|
3364
3103
|
}
|
|
3365
3104
|
if (reconnectTimeoutRef.current) {
|
|
@@ -3378,7 +3117,6 @@ function CallControls({ onDataChange }) {
|
|
|
3378
3117
|
if (webSocketRef.current && webSocketRef.current.readyState === WebSocket.OPEN) {
|
|
3379
3118
|
try {
|
|
3380
3119
|
webSocketRef.current.send(JSON.stringify({ type: "ping" }));
|
|
3381
|
-
console.log("\u{1F4E1} WebSocket ping sent");
|
|
3382
3120
|
} catch (error) {
|
|
3383
3121
|
console.error("Failed to send ping:", error);
|
|
3384
3122
|
}
|
|
@@ -3386,14 +3124,14 @@ function CallControls({ onDataChange }) {
|
|
|
3386
3124
|
}, 3e4);
|
|
3387
3125
|
};
|
|
3388
3126
|
webSocketRef.current.onmessage = (event) => {
|
|
3127
|
+
var _a3, _b2, _c2;
|
|
3389
3128
|
try {
|
|
3390
3129
|
const data = JSON.parse(event.data);
|
|
3391
3130
|
if (data.type === "pong") {
|
|
3392
|
-
console.log("\u{1F4E1} WebSocket pong received");
|
|
3393
3131
|
return;
|
|
3394
3132
|
}
|
|
3395
|
-
const rls = localStorage.getItem("call-control-sdk-state");
|
|
3396
|
-
const confrence = getCombineConfrenceData(
|
|
3133
|
+
const rls = JSON.parse((_a3 = localStorage.getItem("call-control-sdk-state")) != null ? _a3 : "{}");
|
|
3134
|
+
const confrence = getCombineConfrenceData(rls, data);
|
|
3397
3135
|
sdkStateManager.updateCallData(data);
|
|
3398
3136
|
sdkStateManager.updateConferenceData([...confrence]);
|
|
3399
3137
|
if ((data.status === "RINGING" || data.status === "DIALING") && (data == null ? void 0 : data.mode) !== "manual") {
|
|
@@ -3463,6 +3201,7 @@ function CallControls({ onDataChange }) {
|
|
|
3463
3201
|
}
|
|
3464
3202
|
if (data.status === "ONCALL") {
|
|
3465
3203
|
sdkStateManager.startCall();
|
|
3204
|
+
setCallWrapuptime((_c2 = (_b2 = rls == null ? void 0 : rls.sdkConfig) == null ? void 0 : _b2.auto_wrapup_time) != null ? _c2 : null);
|
|
3466
3205
|
if (!showIframe) {
|
|
3467
3206
|
setShowIframe(true);
|
|
3468
3207
|
}
|
|
@@ -3471,11 +3210,10 @@ function CallControls({ onDataChange }) {
|
|
|
3471
3210
|
sdkStateManager.endCall();
|
|
3472
3211
|
}
|
|
3473
3212
|
} catch (e) {
|
|
3474
|
-
console.
|
|
3213
|
+
console.error("\u{1F4E8} Raw message:", event.data);
|
|
3475
3214
|
}
|
|
3476
3215
|
};
|
|
3477
3216
|
webSocketRef.current.onclose = (event) => {
|
|
3478
|
-
console.log("\u{1F50C} WebSocket connection closed", event.code, event.reason);
|
|
3479
3217
|
if (pingIntervalRef.current) {
|
|
3480
3218
|
clearInterval(pingIntervalRef.current);
|
|
3481
3219
|
pingIntervalRef.current = null;
|
|
@@ -3486,14 +3224,13 @@ function CallControls({ onDataChange }) {
|
|
|
3486
3224
|
baseReconnectDelay * Math.pow(2, reconnectAttemptsRef.current - 1),
|
|
3487
3225
|
maxReconnectDelay
|
|
3488
3226
|
);
|
|
3489
|
-
console.
|
|
3227
|
+
console.warn(
|
|
3490
3228
|
`\u{1F504} Attempting to reconnect WebSocket (attempt ${reconnectAttemptsRef.current}/${maxReconnectAttempts}) in ${delay}ms`
|
|
3491
3229
|
);
|
|
3492
3230
|
reconnectTimeoutRef.current = setTimeout(() => {
|
|
3493
3231
|
connectWebSocket();
|
|
3494
3232
|
}, delay);
|
|
3495
3233
|
} else if (reconnectAttemptsRef.current >= maxReconnectAttempts) {
|
|
3496
|
-
console.error("\u274C Maximum reconnection attempts reached. Please refresh the page.");
|
|
3497
3234
|
showToast("WebSocket connection failed. Please refresh the page.", "error");
|
|
3498
3235
|
}
|
|
3499
3236
|
};
|
|
@@ -3501,7 +3238,6 @@ function CallControls({ onDataChange }) {
|
|
|
3501
3238
|
console.error("\u274C WebSocket error:", error);
|
|
3502
3239
|
};
|
|
3503
3240
|
} catch (error) {
|
|
3504
|
-
console.error("\u274C Failed to create WebSocket:", error);
|
|
3505
3241
|
if (reconnectAttemptsRef.current < maxReconnectAttempts) {
|
|
3506
3242
|
reconnectAttemptsRef.current += 1;
|
|
3507
3243
|
const delay = Math.min(
|
|
@@ -3654,7 +3390,7 @@ function CallControls({ onDataChange }) {
|
|
|
3654
3390
|
fontWeight: "600",
|
|
3655
3391
|
cursor: "pointer"
|
|
3656
3392
|
},
|
|
3657
|
-
children: formatDuration(callDuration)
|
|
3393
|
+
children: state.callData.status === "WRAPUP" && callWrapuptime !== null ? formatDuration(callWrapuptime) : formatDuration(callDuration)
|
|
3658
3394
|
}
|
|
3659
3395
|
) }),
|
|
3660
3396
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
@@ -4204,7 +3940,7 @@ async function initSDK({
|
|
|
4204
3940
|
baseUrl: BASE_URL
|
|
4205
3941
|
});
|
|
4206
3942
|
if (initResult) {
|
|
4207
|
-
console.
|
|
3943
|
+
console.info("SDK initialized successfully");
|
|
4208
3944
|
sdkStateManager.initialize(
|
|
4209
3945
|
apiKey.trim(),
|
|
4210
3946
|
tenantId.trim(),
|
|
@@ -4213,14 +3949,12 @@ async function initSDK({
|
|
|
4213
3949
|
initResult
|
|
4214
3950
|
);
|
|
4215
3951
|
} else {
|
|
4216
|
-
console.error("SDK initialization failed: Event tracker initialization returned false");
|
|
4217
3952
|
sdkStateManager.setInitCheck();
|
|
4218
3953
|
throw new Error(
|
|
4219
3954
|
"SDK initialization failed: Unable to establish connection with the CTI system"
|
|
4220
3955
|
);
|
|
4221
3956
|
}
|
|
4222
3957
|
} catch (error) {
|
|
4223
|
-
console.error("SDK initialization error:", error);
|
|
4224
3958
|
sdkStateManager.setInitCheck();
|
|
4225
3959
|
if (error instanceof Error) {
|
|
4226
3960
|
throw error;
|