Skip to content

Commit

Permalink
export types CallSummary, ClientSummary, ClientIssue
Browse files Browse the repository at this point in the history
  • Loading branch information
balazskreith committed Apr 4, 2024
1 parent 8d68012 commit 54e9928
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@observertc/observer-js",
"version": "0.40.13",
"version": "0.40.14",
"description": "Server Side NodeJS Library for processing ObserveRTC Samples",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
10 changes: 1 addition & 9 deletions src/ObservedClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,10 @@ import { isValidUuid } from './common/utils';
import { createClientLeftEventReport } from './common/callEventReports';
import { CallEventType } from './common/CallEventType';
import { ObservedSfu } from './ObservedSfu';
import { ClientIssue } from './monitors/CallSummary';

const logger = createLogger('ObservedClient');

export interface ClientIssue {
severity: 'critical' | 'major' | 'minor';
timestamp: number;
description?: string;
peerConnectionId?: string,
trackId?: string,
attachments?: Record<string, unknown>,
}

export type ObservedClientModel= {
clientId: string;
mediaUnitId: string;
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export type { ObservedClient, ObservedClientModel } from './ObservedClient';
export type { ObservedPeerConnection, ObservedPeerConnectionModel, ObservedPeerConnectionEvents } from './ObservedPeerConnection';
export type { ObservedInboundTrack, ObservedInboundTrackModel, ObservedInboundTrackEvents } from './ObservedInboundTrack';
export type { ObservedOutboundTrack, ObservedOutboundTrackModel, ObservedOutboundTrackEvents } from './ObservedOutboundTrack';

export type { CallSummary, ClientSummary, ClientIssue } from './monitors/CallSummary';
export type { ObserverSinkContext } from './common/types';

import { Observer, ObserverConfig } from './Observer';
Expand Down
11 changes: 10 additions & 1 deletion src/monitors/CallSummary.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { ClientIssue } from '../ObservedClient';
export interface ClientIssue {
severity: 'critical' | 'major' | 'minor';
timestamp: number;
description?: string;
peerConnectionId?: string,
trackId?: string,
attachments?: Record<string, unknown>,
}

export interface ClientSummary {
clientId: string;
Expand All @@ -23,5 +30,7 @@ export interface CallSummary {
started: number;
durationInMs: number;
maxNumberOfParticipants: number;
numberOfIssues: number;
highestSeverity?: ClientIssue['severity'],
clients: ClientSummary[];
}
16 changes: 8 additions & 8 deletions src/monitors/CallSummaryMonitor.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { EventEmitter } from 'events';
import { CallSummary, ClientSummary } from './CallSummary';
import { CallSummary, ClientIssue, ClientSummary } from './CallSummary';
import { ObservedCall } from '../ObservedCall';
import { ClientIssue, ObservedClient } from '../ObservedClient';
import { ObservedClient } from '../ObservedClient';
import { ObservedOutboundTrack } from '../ObservedOutboundTrack';
import { ObservedPeerConnection } from '../ObservedPeerConnection';

Expand Down Expand Up @@ -35,7 +35,7 @@ export class CallSummaryMonitor extends EventEmitter {
public addCall(call: ObservedCall) {
if (this.closed) return;

let callSummary = this._summaries.get(call.callId);
let callSummary: CallSummary | undefined = this._summaries.get(call.callId);

if (!callSummary) {
callSummary = {
Expand All @@ -45,6 +45,7 @@ export class CallSummaryMonitor extends EventEmitter {
clients: [],
durationInMs: 0,
maxNumberOfParticipants: 0,
numberOfIssues: 0,
started: call.created,
};
this._summaries.set(call.callId, callSummary);
Expand Down Expand Up @@ -91,16 +92,15 @@ export class CallSummaryMonitor extends EventEmitter {
};

const onIssue = (issue: ClientIssue) => {
++callSummary.numberOfIssues;
clientSummary.issues.push(issue);

};

const onUserMediaError = (error: string) => {
if (!this.config.detectUserMediaIssues) return;

// maybe the client also sned this issue, in which case the timestamp can be more accurate
const alreadyDetected = clientSummary.issues.find((issue) => issue.severity === 'critical' && issue.description === error);

!alreadyDetected && clientSummary.issues.push({
client.addIssue({
severity: 'critical',
timestamp: Date.now(),
description: error,
Expand Down Expand Up @@ -145,7 +145,7 @@ export class CallSummaryMonitor extends EventEmitter {
const onQualityLimitationChanged = (reason: string) => {
if (!this.config.detectMediaTrackQualityLimitationIssues) return;

clientSummary.issues.push({
track.peerConnection.client.addIssue({
severity: 'minor',
timestamp: Date.now(),
description: reason,
Expand Down

0 comments on commit 54e9928

Please sign in to comment.