NTP-15943 | conflict resolved
This commit is contained in:
@@ -3,7 +3,31 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## 1.0.90 (2024-12-22)
|
||||
## 1.0.92 (2024-12-24)
|
||||
|
||||
**Note:** Version bump only for package @universal-call-sdk/adapter-ameyo
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## 1.0.91 (2024-12-23)
|
||||
|
||||
**Note:** Version bump only for package @universal-call-sdk/adapter-ameyo
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## 1.0.86 (2024-12-18)
|
||||
|
||||
**Note:** Version bump only for package @universal-call-sdk/adapter-ameyo
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## 1.0.85 (2024-12-17)
|
||||
|
||||
**Note:** Version bump only for package @universal-call-sdk/adapter-ameyo
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ import {
|
||||
} from "./assets/js/sip5ml.service.ts";
|
||||
import registerEventProcessor from "./eventsProcessor.ts";
|
||||
import MetricsProcessor from "@universal-call-sdk/common/lib/utils/metricsProcessor.ts";
|
||||
import ClickStreamProcessor from "@universal-call-sdk/common/lib/utils/clickStreamProcessor.ts";
|
||||
|
||||
class AmeyoAdapter implements IAdapter {
|
||||
private callbacks: {
|
||||
@@ -44,7 +45,7 @@ class AmeyoAdapter implements IAdapter {
|
||||
onAgentsForCallTransfer: (data: GenericObject) => void
|
||||
onCallTransferStatus: (data: GenericObject) => void;
|
||||
};
|
||||
private currentCallState: string;
|
||||
private currentCallState: CALL_STATES;
|
||||
private eventListenerUrl: string;
|
||||
private baseUrl: string;
|
||||
private sessionId: string;
|
||||
@@ -54,13 +55,8 @@ class AmeyoAdapter implements IAdapter {
|
||||
private currentCallMetadata: GenericObject;
|
||||
private sipAccountInfo: GenericObject;
|
||||
private isAgentAvailable: boolean;
|
||||
private isMetricsEnabled : boolean
|
||||
private metricFlowName: string
|
||||
private metricMetadata: GenericObject
|
||||
private metricProcessor: any
|
||||
private metricUrl: string
|
||||
private metricTransporter: ((metricData: GenericObject)=>void ) | undefined
|
||||
|
||||
private clickStreamProcessor: ClickStreamProcessor ;
|
||||
private metricProcessor: MetricsProcessor;
|
||||
constructor(options: AmeyoInitializationOptions) {
|
||||
|
||||
if(document.readyState === 'loading') {
|
||||
@@ -100,26 +96,19 @@ class AmeyoAdapter implements IAdapter {
|
||||
this.sipAccountInfo = {};
|
||||
this.currentCallMetadata = {};
|
||||
this.isAgentAvailable = false;
|
||||
this.isMetricsEnabled = options?.isMetricEnabled || false;
|
||||
this.metricFlowName = options?.metricFlowName || '';
|
||||
this.metricMetadata = options?.metricMetadata || {}
|
||||
this.metricUrl = options?.metricUrl || ''
|
||||
if(options?.metricTransporter) {
|
||||
this.metricTransporter = options?.metricTransporter || undefined
|
||||
}
|
||||
this.clickStreamProcessor = {} as ClickStreamProcessor;
|
||||
this.metricProcessor={} as MetricsProcessor;
|
||||
window.BASE_AMEYO_URL = this.baseUrl;
|
||||
window.AMEYO_LOGIN_URL = options.loginUrl
|
||||
|
||||
}
|
||||
|
||||
init() {
|
||||
init(metricProcessor: MetricsProcessor, clickStreamProcessor: ClickStreamProcessor) {
|
||||
window.addEventListener('message', this._registerMessageListener);
|
||||
this._initializeAmeyo();
|
||||
if(this.isMetricsEnabled) {
|
||||
this.metricProcessor = new MetricsProcessor(this.metricUrl, this.metricFlowName, this.metricTransporter);
|
||||
|
||||
}
|
||||
this.metricProcessor?.pushCounterMetric({metricName: 'initSdk', flow: "sdk_init_count", metaData: this.metricMetadata})
|
||||
this.metricProcessor = metricProcessor;
|
||||
this.clickStreamProcessor = clickStreamProcessor;
|
||||
this.metricProcessor?.pushCounterMetric({metricName: 'initSdk', flow: "sdk_init_count"})
|
||||
}
|
||||
|
||||
|
||||
@@ -130,7 +119,7 @@ class AmeyoAdapter implements IAdapter {
|
||||
loadCredentials({accountName, userName, domain, password});
|
||||
loadCallOptions();
|
||||
sipRegister({domain: domainOnly, port});
|
||||
this.metricProcessor?.pushCounterMetric({metricName: 'sipStackInitialised',flow: 'ameyo-sip-stack_init_count', metaData: this.metricMetadata})
|
||||
this.metricProcessor?.pushCounterMetric({metricName: 'sipStackInitialised',flow: 'ameyo-sip-stack_init_count'})
|
||||
|
||||
|
||||
}
|
||||
@@ -140,25 +129,30 @@ class AmeyoAdapter implements IAdapter {
|
||||
|
||||
}
|
||||
|
||||
|
||||
_getElementFromDomById = (elementId: string): HTMLElement | null => {
|
||||
return document.getElementById(elementId);
|
||||
};
|
||||
|
||||
_onListenForCorsBypassResponse = (payload: GenericObject) => {
|
||||
if(payload?.data?.requestKey !== RequestKeys.AMEYO_HEARTBEAT) {
|
||||
if(payload?.data?.requestKey !== RequestKeys.AMEYO_HEARTBEAT && !payload?.data?.err) {
|
||||
this.metricProcessor?.pushCounterMetric({
|
||||
metricName: `ameyo-api-call-count`,
|
||||
metaData: this.metricMetadata,
|
||||
flow: 'api-call-count',
|
||||
subFlow: payload?.data?.requestKey
|
||||
})
|
||||
this.metricProcessor?.pushHistogramMetric({
|
||||
metricName: `ameyo-api-latency-${payload?.data?.requestKey}`,
|
||||
metaData: this.metricMetadata,
|
||||
flow: 'api-latency',
|
||||
subFlow: payload?.data?.requestKey,
|
||||
value: payload?.data?.time
|
||||
value: payload?.data?.time/1000 || 0 //converting to seconds
|
||||
})
|
||||
}
|
||||
|
||||
if(payload?.data?.err) {
|
||||
this.metricProcessor?.pushCounterMetric({metricName: `ameyo-api-err-count`, metaData: this.metricMetadata, flow: 'api-error-count', subFlow: payload?.data?.requestKey})
|
||||
this.clickStreamProcessor?.sendClickStreamEvent({type: 'api-error', data: payload?.data?.err})
|
||||
this.metricProcessor?.pushCounterMetric({metricName: `ameyo-api-err-count`, flow: 'api-error-count', subFlow: payload?.data?.requestKey})
|
||||
this.clickStreamProcessor?.sendClickStreamEvent({type: 'api-error', err: payload?.data?.err})
|
||||
}
|
||||
|
||||
if (payload?.data?.requestKey === RequestKeys.AMEYO_LOGIN) {
|
||||
@@ -220,12 +214,11 @@ class AmeyoAdapter implements IAdapter {
|
||||
}
|
||||
|
||||
_registerMessageListener = async ({data}: GenericObject) => {
|
||||
if(data?.type !== MessagingType.SET_RESPONSE_WITHOUT_CORS) {
|
||||
this.metricProcessor?.pushCounterMetric({
|
||||
if(data?.type !== MessagingType.SET_RESPONSE_WITHOUT_CORS && data?.type !== MessagingType.GET_RESPONSE_WITHOUT_CORS) {
|
||||
this.metricProcessor.pushCounterMetric({
|
||||
metricName: `ameyo-events-count`,
|
||||
metaData: this.metricMetadata,
|
||||
flow: 'api-events-count',
|
||||
subFlow: data?.type
|
||||
subFlow:`universal-call-sdk-${data?.type}`
|
||||
})
|
||||
}
|
||||
|
||||
@@ -247,6 +240,8 @@ class AmeyoAdapter implements IAdapter {
|
||||
this.currentCallState = CALL_STATES.CALL_DISCONNECTED;
|
||||
ameyoHangupUser(this.sessionId, this.currentCallMetadata?.userCRTObjectId);
|
||||
this.currentCallMetadata = {...this.currentCallMetadata, ...data?.data}
|
||||
(this._getElementFromDomById("beep") as HTMLAudioElement)?.play();
|
||||
|
||||
}
|
||||
if (data?.type === MessagingType.ON_AMEYO_AGENT_ON_BREAK) {
|
||||
this.isAgentAvailable = false;
|
||||
@@ -449,6 +444,10 @@ class AmeyoAdapter implements IAdapter {
|
||||
id: 'dtmfTone',
|
||||
src: 'https://public-assets.np.navi-gi.in/jarvis/dtmf.wav',
|
||||
});
|
||||
createElement("audio", {
|
||||
id: "beep",
|
||||
src: "https://public-assets.np.navi-gi.in/jarvis/beep.wav",
|
||||
});
|
||||
const onSipSetupReadyEvent = new CustomEvent('onSipSetupReady', {
|
||||
detail: {message: 'Custom page loaded event triggered'}
|
||||
});
|
||||
|
||||
@@ -39,6 +39,7 @@ export type AmeyoInitializationOptions = {
|
||||
metricMetadata ?:GenericObject,
|
||||
metricUrl ?:string,
|
||||
metricTransporter ?:(metricPayload: GenericObject)=>void
|
||||
clickStreamTransporter ?:(clickStreamPayload: GenericObject)=>void
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@universal-call-sdk/adapter-ameyo",
|
||||
"version": "1.0.90",
|
||||
"version": "1.0.92",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
@@ -9,7 +9,7 @@
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@universal-call-sdk/common": "^1.0.41"
|
||||
"@universal-call-sdk/common": "^1.0.43"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.11.1",
|
||||
|
||||
@@ -3,7 +3,31 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## 1.0.41 (2024-12-22)
|
||||
## 1.0.43 (2024-12-24)
|
||||
|
||||
**Note:** Version bump only for package @universal-call-sdk/common
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## 1.0.42 (2024-12-23)
|
||||
|
||||
**Note:** Version bump only for package @universal-call-sdk/common
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## 1.0.39 (2024-12-18)
|
||||
|
||||
**Note:** Version bump only for package @universal-call-sdk/common
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## 1.0.38 (2024-12-17)
|
||||
|
||||
**Note:** Version bump only for package @universal-call-sdk/common
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import GenericObject from "../types/GenericObject.ts";
|
||||
import MetricsProcessor from "../utils/metricsProcessor.ts";
|
||||
import ClickStreamProcessor from "../utils/clickStreamProcessor.ts";
|
||||
import {CALL_STATES} from "@universal-call-sdk/adapter-ameyo/lib/types.ts";
|
||||
|
||||
class IAdapter {
|
||||
registerOnCallIncoming(callback: (callState: GenericObject)=>void) {callback({})}
|
||||
@@ -18,11 +21,14 @@ class IAdapter {
|
||||
setOnBreak() {}
|
||||
setAvailable() {}
|
||||
|
||||
init() {}
|
||||
|
||||
//@ts-expect-error these values will be used by adapters not by interface
|
||||
init(metricProcessor: (MetricsProcessor) | undefined, clickStreamProcessor: (ClickStreamProcessor)| undefined) {
|
||||
}
|
||||
|
||||
getAgentAvailability(): boolean {return false}
|
||||
|
||||
getLatestCallState() {return {}}
|
||||
getLatestCallState(): CALL_STATES {return CALL_STATES.IDLE}
|
||||
getAvailableAgentsForCallTransfer() {}
|
||||
transferCallToAgent(data: GenericObject) {console.log("transfer call", data)}
|
||||
}
|
||||
|
||||
@@ -13,12 +13,10 @@ export type MetricPayload = {
|
||||
value: number | string;
|
||||
group: string;
|
||||
subFlow?: string;
|
||||
metaData?: Record<string, any>;
|
||||
}
|
||||
|
||||
export type CounterMetricPayload = {
|
||||
metricName: string;
|
||||
metaData?: Record<string, any>;
|
||||
flow: string;
|
||||
subFlow?: string;
|
||||
|
||||
@@ -29,7 +27,6 @@ export type HistogramMetricPayload = {
|
||||
metricName: string;
|
||||
value: number | string;
|
||||
subFlow?: string;
|
||||
metaData?: Record<string, any>;
|
||||
flow: string;
|
||||
}
|
||||
|
||||
@@ -37,7 +34,6 @@ export type GaugeMetricPayload = {
|
||||
metricName: string;
|
||||
value: number | string;
|
||||
subFlow?: string;
|
||||
metaData?: Record<string, any>;
|
||||
flow: string;
|
||||
metadata: GenericObject
|
||||
}
|
||||
|
||||
19
packages/common/lib/utils/clickStreamProcessor.ts
Normal file
19
packages/common/lib/utils/clickStreamProcessor.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import GenericObject from "../types/GenericObject.ts";
|
||||
|
||||
class ClickStreamProcessor{
|
||||
private clickStreamProcessor: ((payload: GenericObject)=>void) | undefined
|
||||
|
||||
constructor(clickStreamProcessor: ((payload: GenericObject)=>void) | undefined) {
|
||||
this.clickStreamProcessor = clickStreamProcessor;
|
||||
}
|
||||
|
||||
sendClickStreamEvent(payload: GenericObject) {
|
||||
if(this.clickStreamProcessor){
|
||||
this.clickStreamProcessor(payload)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export default ClickStreamProcessor;
|
||||
@@ -16,12 +16,10 @@ class MetricsProcessor {
|
||||
|
||||
_sendMetricToMetricServer(payload: {
|
||||
metricType: MetricType;
|
||||
metadata: any;
|
||||
metricName: string;
|
||||
subFlow?: any;
|
||||
value?: number | string
|
||||
flow?: string
|
||||
Metadata?:GenericObject
|
||||
}) {
|
||||
if(!this.isMetricEnabled) {
|
||||
return;
|
||||
@@ -36,10 +34,9 @@ class MetricsProcessor {
|
||||
body: JSON.stringify(finalPayload)
|
||||
})
|
||||
}
|
||||
pushCounterMetric({metricName, flow, metaData, subFlow}: CounterMetricPayload ) {
|
||||
pushCounterMetric({metricName, flow, subFlow}: CounterMetricPayload ) {
|
||||
this._sendMetricToMetricServer({
|
||||
flow: flow,
|
||||
metadata: metaData,
|
||||
metricType: MetricType.COUNTER,
|
||||
subFlow:subFlow,
|
||||
metricName,
|
||||
@@ -47,10 +44,9 @@ class MetricsProcessor {
|
||||
})
|
||||
}
|
||||
|
||||
pushHistogramMetric({metricName, value, flow, metaData, subFlow}: HistogramMetricPayload) {
|
||||
pushHistogramMetric({metricName, value, flow, subFlow}: HistogramMetricPayload) {
|
||||
this._sendMetricToMetricServer({
|
||||
flow: flow,
|
||||
metadata: metaData,
|
||||
metricType: MetricType.HISTOGRAM,
|
||||
subFlow: subFlow,
|
||||
metricName,
|
||||
@@ -59,10 +55,9 @@ class MetricsProcessor {
|
||||
})
|
||||
}
|
||||
|
||||
pushGaugeMetric({metricName, value, flow, metaData, subFlow}: GaugeMetricPayload) {
|
||||
pushGaugeMetric({metricName, value, flow, subFlow}: GaugeMetricPayload) {
|
||||
this._sendMetricToMetricServer({
|
||||
flow: flow,
|
||||
metadata: metaData,
|
||||
metricType: MetricType.GAUGE,
|
||||
subFlow: subFlow,
|
||||
metricName,
|
||||
|
||||
3
packages/common/lib/utils/noop.ts
Normal file
3
packages/common/lib/utils/noop.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
const noop = () => {};
|
||||
|
||||
export default noop;
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@universal-call-sdk/common",
|
||||
"version": "1.0.41",
|
||||
"version": "1.0.43",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -3,7 +3,31 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## 1.0.46 (2024-12-22)
|
||||
## 1.0.48 (2024-12-24)
|
||||
|
||||
**Note:** Version bump only for package @universal-call-sdk/core
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## 1.0.47 (2024-12-23)
|
||||
|
||||
**Note:** Version bump only for package @universal-call-sdk/core
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## 1.0.44 (2024-12-18)
|
||||
|
||||
**Note:** Version bump only for package @universal-call-sdk/core
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## 1.0.43 (2024-12-17)
|
||||
|
||||
**Note:** Version bump only for package @universal-call-sdk/core
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import {useEffect, useReducer} from 'react';
|
||||
import {GenericObject, StateType} from "./types.ts";
|
||||
import IAdapter from "@universal-call-sdk/common/lib/Interfaces/IAdapter.ts";
|
||||
import MetricsProcessor from "@universal-call-sdk/common/lib/utils/metricsProcessor.ts";
|
||||
import ClickStreamProcessor from "@universal-call-sdk/common/lib/utils/clickStreamProcessor.ts";
|
||||
import noop from "@universal-call-sdk/common/lib/utils/noop.ts";
|
||||
import {CALL_STATES} from "@universal-call-sdk/adapter-ameyo/lib/types.ts";
|
||||
|
||||
|
||||
enum actionTypes {
|
||||
@@ -72,9 +76,18 @@ const initialState: StateType = {
|
||||
|
||||
let adapter: IAdapter;
|
||||
|
||||
function UseCallSdk({AdapterClass, adapterOptions}: {
|
||||
function UseCallSdk({AdapterClass, adapterOptions, metricsConfig, clickStreamConfig}: {
|
||||
AdapterClass: new (adapterOptions: IAdapter) => IAdapter,
|
||||
adapterOptions: IAdapter
|
||||
adapterOptions: IAdapter,
|
||||
metricsConfig?: {
|
||||
isMetricEnabled: boolean,
|
||||
metricFlowName: string,
|
||||
metricUrl: string,
|
||||
metricTransporter: (metricPayload: GenericObject) => void
|
||||
},
|
||||
clickStreamConfig?: {
|
||||
clickStreamTransporter: (clickStreamPayload: GenericObject) => void
|
||||
}
|
||||
}) {
|
||||
useEffect(() => {
|
||||
adapter = new AdapterClass(adapterOptions);
|
||||
@@ -141,7 +154,16 @@ function UseCallSdk({AdapterClass, adapterOptions}: {
|
||||
}
|
||||
|
||||
function initialize() {
|
||||
adapter.init();
|
||||
let metricProcessor;
|
||||
let clickStreamProcessor;
|
||||
if(metricsConfig && metricsConfig?.isMetricEnabled) {
|
||||
metricProcessor = new MetricsProcessor(metricsConfig?.metricUrl || '', metricsConfig?.metricFlowName || '', metricsConfig?.metricTransporter || noop);
|
||||
|
||||
}
|
||||
if(clickStreamConfig?.clickStreamTransporter) {
|
||||
clickStreamProcessor = new ClickStreamProcessor(clickStreamConfig?.clickStreamTransporter || noop);
|
||||
}
|
||||
adapter.init(metricProcessor, clickStreamProcessor);
|
||||
}
|
||||
|
||||
function setOnBreak() {
|
||||
@@ -157,7 +179,7 @@ function UseCallSdk({AdapterClass, adapterOptions}: {
|
||||
return adapter.getAgentAvailability();
|
||||
}
|
||||
|
||||
function getLatestCallState(): GenericObject {
|
||||
function getLatestCallState(): CALL_STATES {
|
||||
return adapter.getLatestCallState();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@universal-call-sdk/core",
|
||||
"version": "1.0.46",
|
||||
"version": "1.0.48",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
Reference in New Issue
Block a user