NTP-27557 | Clickstream error handling
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
||||
AmeyoInitializationOptions,
|
||||
CALL_STATES, CallbackFunctions,
|
||||
CallTransferData,
|
||||
ErrorType,
|
||||
SipAccountInfo,
|
||||
StateType
|
||||
} from "./types";
|
||||
@@ -158,14 +159,13 @@ class AmeyoAdapter implements IAdapter {
|
||||
await this.handleCampaignSelection();
|
||||
} catch (error) {
|
||||
console.error("Error during Ameyo initialization:", error);
|
||||
this.handleError(ErrorType.INITIALIZATION_ERROR, error);
|
||||
}
|
||||
};
|
||||
|
||||
private handleMessage = async ({data}: MessageEvent): Promise<void> => {
|
||||
try {
|
||||
if (this.shouldTrackMetrics(data.type)) {
|
||||
this.trackEventMetrics(data.type);
|
||||
}
|
||||
this.trackEventMetrics(data.type);
|
||||
|
||||
switch (data.type) {
|
||||
case MessagingType.ON_AMEYO_CALL_INCOMING:
|
||||
@@ -194,11 +194,6 @@ class AmeyoAdapter implements IAdapter {
|
||||
}
|
||||
};
|
||||
|
||||
private shouldTrackMetrics(messageType: string): boolean {
|
||||
return messageType !== MessagingType.SET_RESPONSE_WITHOUT_CORS &&
|
||||
messageType !== MessagingType.GET_RESPONSE_WITHOUT_CORS;
|
||||
}
|
||||
|
||||
private trackEventMetrics(messageType: string): void {
|
||||
this.metricProcessor?.pushCounterMetric({
|
||||
metricName: `ameyo-events-count`,
|
||||
@@ -232,6 +227,7 @@ class AmeyoAdapter implements IAdapter {
|
||||
subFlow: payload?.data?.requestKey,
|
||||
value: payload?.data?.time / 1000 || 0
|
||||
});
|
||||
this.handleError(payload?.data?.requestKey, payload?.data?.err);
|
||||
} else {
|
||||
this.metricProcessor?.pushCounterMetric({
|
||||
metricName: 'ameyo-api-err-count',
|
||||
|
||||
@@ -51,13 +51,6 @@ declare global {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export enum MessagingType {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
export type SipAccountInfo = {
|
||||
accountName: string,
|
||||
userName: string,
|
||||
@@ -120,3 +113,9 @@ export interface EventData {
|
||||
pushType: PushType;
|
||||
data: any;
|
||||
}
|
||||
|
||||
export enum ErrorType {
|
||||
SIP_INIT_ERROR = 'SIP_INIT_ERROR',
|
||||
MESSAGE_HANDLING_ERROR = 'MESSAGE_HANDLING_ERROR',
|
||||
INITIALIZATION_ERROR = 'INITIALIZATION_ERROR',
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user