NTP-26126 | adapter sanity (#34)

* NTP-26126 | adapter sanity

* NTP-26126 | package bump

* Publish

 - @universal-call-sdk/adapter-ameyo@1.1.23
 - @universal-call-sdk/common@1.1.16
 - @universal-call-sdk/core@1.1.14

* NTP-26126 | added more events

* NTP-26126 | adapter sanity

* NTP-26126v | metric processor

* NTP-26126 | package bump

* Publish

 - @universal-call-sdk/adapter-ameyo@1.1.33
 - @universal-call-sdk/common@1.1.18
 - @universal-call-sdk/core@1.1.15

---------

Co-authored-by: varnit goyal <github.cicd@navi.com>
This commit is contained in:
Varnit Goyal
2025-01-18 02:24:00 +05:30
committed by GitHub
parent 4010a13060
commit 91f1deede6
10 changed files with 94 additions and 24 deletions

View File

@@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## 1.1.33 (2025-01-17)
**Note:** Version bump only for package @universal-call-sdk/adapter-ameyo
## 1.1.23 (2025-01-16)
**Note:** Version bump only for package @universal-call-sdk/adapter-ameyo
## 1.1.15 (2025-01-16)
**Note:** Version bump only for package @universal-call-sdk/adapter-ameyo

View File

@@ -6,6 +6,9 @@ import {v4 as uuid} from 'uuid';
export const loginInAmeyo = (userId: string, password: string) => {
console.log('loginInAmeyo', userId, password);
if(!userId || !password) {
return
}
return getResponseWithoutCors({
url: `${window.BASE_AMEYO_URL}/ameyorestapi/userLogin/login`,
method: 'POST',

View File

@@ -2,6 +2,8 @@ import {MessagingType} from "./assets/js/ajaxClient.ts";
import {CallStatus, PushType, CallState} from "./types.ts";
import {parseQuerystring} from "@universal-call-sdk/common/lib/utils/parsingUtils.ts";
import messagingType from "../types/MessagingType.ts";
import metricsProcessor from "@universal-call-sdk/common/lib/utils/metricsProcessor.ts";
import MetricsProcessor from "@universal-call-sdk/common/lib/utils/metricsProcessor.ts";
class CallStateManager {
private state: CallState = {
@@ -15,6 +17,7 @@ class CallStateManager {
private readonly MAX_CONNECTION_ATTEMPTS = 3;
private connectionTimeout: ReturnType<typeof setTimeout> | null = null;
private metricProcessor : metricsProcessor = {} as metricsProcessor
public sendConnectedMessage() {
const customerInfo = this.state.customerInfo;
@@ -35,6 +38,7 @@ class CallStateManager {
}
}
private setConnectionTimeout() {
this.clearConnectionTimeout();
this.connectionTimeout = setTimeout(() => {
@@ -94,6 +98,10 @@ class CallStateManager {
type: MessagingType.ON_AMEYO_CALL_INCOMING,
data: this.state.customerInfo
});
this?.metricProcessor?.pushCounterMetric({
metricName: 'ringing_event_counter',
flow: "ringing_event_counter"
});
break;
case 'hungup':
this.handleCallDisconnect();
@@ -126,6 +134,10 @@ class CallStateManager {
const parsedQuery = parseQuerystring(crmURL);
const userCRTObjectId = parsedQuery?.userCrtObjectId?.replaceAll('%40', '@');
this?.metricProcessor?.pushCounterMetric({
metricName: 'notify_push_event_counter',
flow: "notify_push_event_counter"
});
this.state.customerInfo = {
...this.state.customerInfo,
@@ -184,6 +196,10 @@ class CallStateManager {
};
this.clearConnectionTimeout();
}
public setMetricProcessor(metricProcessor: MetricsProcessor) {
this.metricProcessor = metricProcessor
}
}
export const callStateManager = new CallStateManager();

View File

@@ -120,6 +120,7 @@ class AmeyoAdapter implements IAdapter {
this.initializeAmeyo();
this.metricProcessor = metricProcessor;
this.clickStreamProcessor = clickStreamProcessor;
callStateManager.setMetricProcessor(metricProcessor)
this.metricProcessor?.pushCounterMetric({
metricName: 'initSdk',
flow: "sdk_init_count"

View File

@@ -1,6 +1,6 @@
{
"name": "@universal-call-sdk/adapter-ameyo",
"version": "1.1.15",
"version": "1.1.33",
"type": "module",
"scripts": {
"dev": "vite",
@@ -9,7 +9,7 @@
"preview": "vite preview"
},
"dependencies": {
"@universal-call-sdk/common": "^1.1.13",
"@universal-call-sdk/common": "^1.1.18",
"uuid": "^11.0.3"
},
"devDependencies": {

View File

@@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## 1.1.18 (2025-01-17)
**Note:** Version bump only for package @universal-call-sdk/common
## 1.1.16 (2025-01-16)
**Note:** Version bump only for package @universal-call-sdk/common
## 1.1.13 (2025-01-16)
**Note:** Version bump only for package @universal-call-sdk/common

View File

@@ -1,6 +1,6 @@
{
"name": "@universal-call-sdk/common",
"version": "1.1.13",
"version": "1.1.18",
"type": "module",
"scripts": {
"dev": "vite",

View File

@@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## 1.1.15 (2025-01-17)
**Note:** Version bump only for package @universal-call-sdk/core
## 1.1.14 (2025-01-16)
**Note:** Version bump only for package @universal-call-sdk/core
## 1.1.12 (2025-01-16)
**Note:** Version bump only for package @universal-call-sdk/core

View File

@@ -74,7 +74,7 @@ const initialState: StateType = {
callStartTime: Date.now(),
}
let adapter: IAdapter;
let adapter: IAdapter
function UseCallSdk({AdapterClass, adapterOptions, metricsConfig, clickStreamConfig}: {
AdapterClass: new (adapterOptions: IAdapter) => IAdapter,
@@ -90,71 +90,73 @@ function UseCallSdk({AdapterClass, adapterOptions, metricsConfig, clickStreamCon
}
}) {
useEffect(() => {
if(adapterOptions) {
adapter = new AdapterClass(adapterOptions);
}
}, [adapterOptions]);
// @ts-expect-error sdfsf
const [callState] = useReducer<any>(reducer, initialState,()=> initialState);
function registerOnCallIncoming(callback : (callState: GenericObject)=>void) {
//dispatch({type: actionTypes.CALL_INCOMING, payload: {}})
adapter.registerOnCallIncoming(callback);
adapter?.registerOnCallIncoming(callback);
}
function registerOnCallConnected(callback : (callState: GenericObject)=>void) {
adapter.registerOnCallConnected(callback);
adapter?.registerOnCallConnected(callback);
}
function registerOnCallDisconnected(callback : (callState: GenericObject)=>void) {
adapter.registerOnCallDisconnected(callback);
adapter?.registerOnCallDisconnected(callback);
}
function registerOnAdapterReady(callback : ()=> void) {
adapter.registerOnAdapterReady(callback);
adapter?.registerOnAdapterReady(callback);
}
function registerOnAgentAvailabilityChange(callback : (isAgentAvailable: boolean, reason: string) => void) {
adapter.registerOnAgentAvailabilityChange(callback);
adapter?.registerOnAgentAvailabilityChange(callback);
}
function registerOnForcedLogoutListener(callback:()=>void) {
adapter.registerOnForcedLogoutListener(callback);
adapter?.registerOnForcedLogoutListener(callback);
}
function registerOnAgentsForCallTransfer(callback: (data: GenericObject) => void) {
adapter.registerOnAgentsForCallTransfer(callback);
adapter?.registerOnAgentsForCallTransfer(callback);
}
function registerOnCallTransferStatus(callback: (data: GenericObject) => void) {
adapter.registerOnCallTransferStatus(callback);
adapter?.registerOnCallTransferStatus(callback);
}
function registerOnLoginFailedListener(callback:()=>void) {
adapter.registerOnLoginFailedListener(callback);
adapter?.registerOnLoginFailedListener(callback);
}
function acceptCall() {
adapter.acceptCall();
adapter?.acceptCall();
}
function rejectCall() {
adapter.rejectCall();
adapter?.rejectCall();
}
function disposeCall() {
adapter.disposeCall();
adapter?.disposeCall();
}
function muteCall() {
adapter.muteCall();
adapter?.muteCall();
}
function unmuteCall() {
adapter.unmuteCall();
adapter?.unmuteCall();
}
function logOut() {
adapter.logOut();
adapter?.logOut();
}
function initialize() {
@@ -167,15 +169,15 @@ function UseCallSdk({AdapterClass, adapterOptions, metricsConfig, clickStreamCon
if(clickStreamConfig?.clickStreamTransporter) {
clickStreamProcessor = new ClickStreamProcessor(clickStreamConfig?.clickStreamTransporter || noop);
}
adapter.init(metricProcessor, clickStreamProcessor);
adapter?.init(metricProcessor, clickStreamProcessor);
}
function setOnBreak() {
adapter.setOnBreak();
adapter?.setOnBreak();
}
function setAvailable() {
adapter.setAvailable();
adapter?.setAvailable();
}
function getAgentAvailability(): boolean {

View File

@@ -1,6 +1,6 @@
{
"name": "@universal-call-sdk/core",
"version": "1.1.12",
"version": "1.1.15",
"type": "module",
"scripts": {
"dev": "vite",