mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 13:26:08 +00:00
fix chat estracture
This commit is contained in:
@@ -4,10 +4,6 @@
|
|||||||
"name": "gabinete-digital-fo",
|
"name": "gabinete-digital-fo",
|
||||||
"path": "."
|
"path": "."
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "oo",
|
|
||||||
"path": "../../../Downloads/oo"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "socket-server",
|
"name": "socket-server",
|
||||||
"path": "../socket-server"
|
"path": "../socket-server"
|
||||||
|
|||||||
@@ -106,6 +106,16 @@ import { typingReducer } from './module/chat/data/data-source/userTyping/user-ty
|
|||||||
import { FirebaseX } from '@ionic-native/firebase-x/ngx'; */
|
import { FirebaseX } from '@ionic-native/firebase-x/ngx'; */
|
||||||
//import { FCM } from 'cordova-plugin-fcm-with-dependecy-updated/ionic/ngx';
|
//import { FCM } from 'cordova-plugin-fcm-with-dependecy-updated/ionic/ngx';
|
||||||
|
|
||||||
|
|
||||||
|
// import { WebTracerProvider } from '@opentelemetry/web';
|
||||||
|
// import { SimpleSpanProcessor } from '@opentelemetry/tracing';
|
||||||
|
// import { ConsoleSpanExporter } from '@opentelemetry/tracing';
|
||||||
|
|
||||||
|
|
||||||
|
// const provider = new WebTracerProvider();
|
||||||
|
// provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
|
||||||
|
// provider.register();
|
||||||
|
|
||||||
Sentry.init(
|
Sentry.init(
|
||||||
{
|
{
|
||||||
dsn: 'https://5b345a3ae70b4e4da463da65881b4aaa@o4504340905525248.ingest.sentry.io/4504345615794176',
|
dsn: 'https://5b345a3ae70b4e4da463da65881b4aaa@o4504340905525248.ingest.sentry.io/4504345615794176',
|
||||||
|
|||||||
@@ -2,18 +2,18 @@ import { TableRoom } from "../../../data-source/room/rooom-local-data-source.ser
|
|||||||
import { RoomListItemOutPutDTO, RoomListOutPutDTO } from "../../../dto/room/roomListOutputDTO";
|
import { RoomListItemOutPutDTO, RoomListOutPutDTO } from "../../../dto/room/roomListOutputDTO";
|
||||||
|
|
||||||
export function roomListDetermineChanges(serverRooms: RoomListItemOutPutDTO[], localRooms: TableRoom[]) {
|
export function roomListDetermineChanges(serverRooms: RoomListItemOutPutDTO[], localRooms: TableRoom[]) {
|
||||||
const serverRoomMap = new Map(serverRooms.map(room => [room.id, room]));
|
const serverRoomMap = new Map(serverRooms.map(room => [room.chatRoom.id, room]));
|
||||||
const localRoomMap = new Map(localRooms.map(room => [room.id, room]));
|
const localRoomMap = new Map(localRooms.map(room => [room.id, room]));
|
||||||
|
|
||||||
const roomsToInsert = serverRooms.filter(room => !localRoomMap.has(room.id));
|
const roomsToInsert = serverRooms.filter(room => !localRoomMap.has(room.chatRoom.id));
|
||||||
const roomsToUpdate = serverRooms.filter(room => {
|
const roomsToUpdate = serverRooms.filter(room => {
|
||||||
const localRoom = localRoomMap.get(room.id);
|
const localRoom = localRoomMap.get(room.chatRoom.id);
|
||||||
return localRoom && (
|
return localRoom && (
|
||||||
room.roomName !== localRoom.roomName ||
|
room.chatRoom.roomName !== localRoom.roomName ||
|
||||||
room.createdBy.wxUserId !== localRoom.createdBy.wxUserId ||
|
room.chatRoom.createdBy.wxUserId !== localRoom.createdBy.wxUserId ||
|
||||||
room.createdAt !== localRoom.createdAt ||
|
room.chatRoom.createdAt !== localRoom.createdAt ||
|
||||||
room.expirationDate !== localRoom.expirationDate ||
|
room.chatRoom.expirationDate !== localRoom.expirationDate ||
|
||||||
room.roomType !== localRoom.roomType
|
room.chatRoom.roomType !== localRoom.roomType
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
const roomsToDelete = localRooms.filter(room => !serverRoomMap.has(room.id));
|
const roomsToDelete = localRooms.filter(room => !serverRoomMap.has(room.id));
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export class MessageAsyncService {
|
|||||||
filter((message: any) => {
|
filter((message: any) => {
|
||||||
return !message?.requestId?.startsWith(InstanceId) && message?.requestId
|
return !message?.requestId?.startsWith(InstanceId) && message?.requestId
|
||||||
})
|
})
|
||||||
).subscribe(async (message: any) => {
|
).subscribe(async (message) => {
|
||||||
|
|
||||||
console.log('message async ', message)
|
console.log('message async ', message)
|
||||||
|
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ export class MessageLocalDataSourceService {
|
|||||||
|
|
||||||
async getLastMessageByRoomId(roomId: string): Promise<Result<undefined|TableMessage, any>> {
|
async getLastMessageByRoomId(roomId: string): Promise<Result<undefined|TableMessage, any>> {
|
||||||
try {
|
try {
|
||||||
|
console.log({roomId})
|
||||||
const lastMessage = await messageDataSource.message
|
const lastMessage = await messageDataSource.message
|
||||||
.where('roomId')
|
.where('roomId')
|
||||||
.equals(roomId)
|
.equals(roomId)
|
||||||
@@ -107,7 +108,7 @@ export class MessageLocalDataSourceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// @ValidateSchema(tableSchema)
|
// @ValidateSchema(tableSchema)
|
||||||
async createMessage(data: MessageInputDTO) {
|
async createMessage(data: MessageInputDTO) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -179,6 +179,10 @@ export class RoomLocalDataSourceService {
|
|||||||
return await roomDataSource.room.toArray()
|
return await roomDataSource.room.toArray()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getMemberLive(data: {roomId, wxUserId}) {
|
||||||
|
const $roomIdUserId = data.roomId + data.wxUserId
|
||||||
|
return liveQuery(() => roomDataSource.memberList.get($roomIdUserId)) as any;
|
||||||
|
}
|
||||||
|
|
||||||
getItemsLive(): Observable<RoomListOutPutDTO[]> {
|
getItemsLive(): Observable<RoomListOutPutDTO[]> {
|
||||||
return liveQuery(() => roomDataSource.room.toArray()) as any;
|
return liveQuery(() => roomDataSource.room.toArray()) as any;
|
||||||
|
|||||||
+6
-2
@@ -11,8 +11,12 @@ export class UserTypingLiveDataSourceService {
|
|||||||
private SignalRLiveDataSourceService: SignalRService
|
private SignalRLiveDataSourceService: SignalRService
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
sendTyping(roomId) {
|
sendTyping(roomId, ) {
|
||||||
return this.SignalRLiveDataSourceService.sendTyping({roomId, UserName:SessionStore.user.FullName})
|
return this.SignalRLiveDataSourceService.sendTyping({
|
||||||
|
roomId,
|
||||||
|
UserName:SessionStore.user.FullName,
|
||||||
|
userId:SessionStore.user.UserId
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ const MemberSchema = z.object({
|
|||||||
id: z.string(),
|
id: z.string(),
|
||||||
user: UserSchema,
|
user: UserSchema,
|
||||||
joinAt: z.string(),
|
joinAt: z.string(),
|
||||||
|
isAdmin: z.boolean()
|
||||||
});
|
});
|
||||||
|
|
||||||
export const RoomByIdOutputDTOSchema = z.object({
|
export const RoomByIdOutputDTOSchema = z.object({
|
||||||
@@ -27,6 +28,5 @@ export const RoomByIdOutputDTOSchema = z.object({
|
|||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
export type RoomByIdMemberItemOutputDTO = z.infer<typeof MemberSchema>
|
export type RoomByIdMemberItemOutputDTO = z.infer<typeof MemberSchema>
|
||||||
export type RoomByIdOutputDTO = z.infer<typeof RoomByIdOutputDTOSchema>
|
export type RoomByIdOutputDTO = z.infer<typeof RoomByIdOutputDTOSchema>
|
||||||
@@ -8,12 +8,16 @@ const CreatedBySchema = z.object({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const RoomListItemOutPutDTOSchema = z.object({
|
const RoomListItemOutPutDTOSchema = z.object({
|
||||||
id: z.string(),
|
|
||||||
roomName: z.string(),
|
chatRoom: z.object({
|
||||||
createdBy: CreatedBySchema,
|
id: z.string(),
|
||||||
createdAt: z.string(),
|
roomName: z.string(),
|
||||||
expirationDate: z.string().nullable(), // api check
|
createdBy: CreatedBySchema,
|
||||||
roomType: z.number()
|
createdAt: z.string(),
|
||||||
|
expirationDate: z.string().nullable(), // api check
|
||||||
|
roomType: z.number()
|
||||||
|
}),
|
||||||
|
joinAt: z.string()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ export class MessageRepositoryService {
|
|||||||
|
|
||||||
data['requestId'] = InstanceId +'@'+ uuidv4();
|
data['requestId'] = InstanceId +'@'+ uuidv4();
|
||||||
|
|
||||||
const localActionResult = await this.messageLocalDataSourceService.sendMessage(data)
|
const localActionResult = await this.messageLocalDataSourceService.sendMessage({...data})
|
||||||
|
console.log('create message', data)
|
||||||
|
|
||||||
// this.messageLiveDataSourceService.sendMessage({
|
// this.messageLiveDataSourceService.sendMessage({
|
||||||
// type: 'sendMessage',
|
// type: 'sendMessage',
|
||||||
@@ -63,17 +64,20 @@ export class MessageRepositoryService {
|
|||||||
delete sendMessageResult.value.sender
|
delete sendMessageResult.value.sender
|
||||||
}
|
}
|
||||||
|
|
||||||
let clone: TableMessage = {
|
// let clone: TableMessage = {
|
||||||
...sendMessageResult.value,
|
// ...sendMessageResult.value,
|
||||||
messageId: sendMessageResult.value.id,
|
// messageId: sendMessageResult.value.id,
|
||||||
id : localActionResult.value
|
// id : localActionResult.value
|
||||||
}
|
// }
|
||||||
|
|
||||||
return this.messageLocalDataSourceService.update({...clone, sending: false})
|
// console.log({clone})
|
||||||
|
console.log('update message')
|
||||||
|
//return this.messageLocalDataSourceService.update({...clone, sending: false})
|
||||||
|
return ok(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return this.messageLocalDataSourceService.update({sending: false})
|
// return this.messageLocalDataSourceService.update({sending: false})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,7 +86,7 @@ export class MessageRepositoryService {
|
|||||||
if(result.isOk()) {
|
if(result.isOk()) {
|
||||||
if(result.value) {
|
if(result.value) {
|
||||||
|
|
||||||
return await this.messageLiveSignalRDataSourceService.sendReadAt({roomId, memberId: SessionStore.user.UserId, chatMessageId: result.value.messageId})
|
// return await this.messageLiveSignalRDataSourceService.sendReadAt({roomId, memberId: SessionStore.user.UserId, chatMessageId: result.value.messageId})
|
||||||
}
|
}
|
||||||
return ok(true)
|
return ok(true)
|
||||||
}
|
}
|
||||||
@@ -116,6 +120,14 @@ export class MessageRepositoryService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sendTyping(roomId) {
|
sendTyping(roomId) {
|
||||||
return this.messageLiveSignalRDataSourceService.sendTyping({roomId, UserName:SessionStore.user.FullName})
|
return this.messageLiveSignalRDataSourceService.sendTyping({
|
||||||
|
roomId,
|
||||||
|
UserName:SessionStore.user.FullName,
|
||||||
|
userId: SessionStore.user.UserId
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
getMemberByLive({roomId, userId}) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ export class RoomRepositoryService {
|
|||||||
// },
|
// },
|
||||||
// }
|
// }
|
||||||
|
|
||||||
this.roomLocalDataSourceService.createRoom(roomData)
|
this.roomLocalDataSourceService.createRoom(roomData.chatRoom)
|
||||||
}
|
}
|
||||||
|
|
||||||
for( const roomData of roomsToUpdate) {
|
for( const roomData of roomsToUpdate) {
|
||||||
@@ -78,7 +78,7 @@ export class RoomRepositoryService {
|
|||||||
// },
|
// },
|
||||||
// }
|
// }
|
||||||
|
|
||||||
this.roomLocalDataSourceService.updateRoom(roomData)
|
this.roomLocalDataSourceService.updateRoom(roomData.chatRoom)
|
||||||
}
|
}
|
||||||
|
|
||||||
for( const roomData of roomsToDelete) {
|
for( const roomData of roomsToDelete) {
|
||||||
@@ -105,15 +105,15 @@ export class RoomRepositoryService {
|
|||||||
|
|
||||||
if(result.isOk()) {
|
if(result.isOk()) {
|
||||||
const localList = await this.roomLocalDataSourceService.getRoomList()
|
const localList = await this.roomLocalDataSourceService.getRoomList()
|
||||||
const { roomsToDelete, roomsToInsert, roomsToUpdate } = roomListDetermineChanges([result.value.data], localList)
|
// const { roomsToDelete, roomsToInsert, roomsToUpdate } = roomListDetermineChanges([result.value.data], localList)
|
||||||
|
|
||||||
for( const roomData of roomsToUpdate) {
|
// for( const roomData of roomsToUpdate) {
|
||||||
if(!roomData.createdBy?.wxUserId) {
|
// if(!roomData.chatRoom.createdBy?.wxUserId) {
|
||||||
delete roomData.createdBy;
|
// delete roomData.chatRoom.createdBy;
|
||||||
}
|
// }
|
||||||
|
|
||||||
this.roomLocalDataSourceService.updateRoom(roomData)
|
// this.roomLocalDataSourceService.updateRoom(roomData.chatRoom)
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,10 +127,13 @@ export class RoomRepositoryService {
|
|||||||
if(result.isOk()) {
|
if(result.isOk()) {
|
||||||
|
|
||||||
const localListRoom = await this.roomLocalDataSourceService.getRoomList()
|
const localListRoom = await this.roomLocalDataSourceService.getRoomList()
|
||||||
const { roomsToDelete, roomsToInsert, roomsToUpdate } = roomListDetermineChanges([result.value.data], localListRoom)
|
const object = {
|
||||||
|
chatRoom: result.value.data
|
||||||
|
}
|
||||||
|
const { roomsToDelete, roomsToInsert, roomsToUpdate } = roomListDetermineChanges([object], localListRoom)
|
||||||
|
|
||||||
for( const roomData of roomsToUpdate) {
|
for( const roomData of roomsToUpdate) {
|
||||||
this.roomLocalDataSourceService.updateRoom(roomData)
|
this.roomLocalDataSourceService.updateRoom(roomData.chatRoom)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================
|
// ============================
|
||||||
|
|||||||
@@ -88,8 +88,8 @@ export class SignalRService {
|
|||||||
this.establishConnection()
|
this.establishConnection()
|
||||||
}
|
}
|
||||||
|
|
||||||
async sendTyping({roomId, UserName}) {
|
async sendTyping({roomId, UserName, userId}) {
|
||||||
return await this.connection.typing({ roomId, UserName})
|
return await this.connection.typing({ roomId, UserName, userId})
|
||||||
}
|
}
|
||||||
|
|
||||||
async sendReadAt({ roomId, memberId, chatMessageId}) {
|
async sendReadAt({ roomId, memberId, chatMessageId}) {
|
||||||
|
|||||||
@@ -108,14 +108,20 @@ export class SignalRConnection {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async typing(data: Object & { roomId, UserName}):Promise<Result<any, any>> {
|
public async typing(data: Object & { roomId, UserName, userId }):Promise<Result<any, any>> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|
||||||
const requestId = uuidv4()
|
const requestId = uuidv4()
|
||||||
if(this.connectionStateSubject.value == true) {
|
if(this.connectionStateSubject.value == true) {
|
||||||
|
console.log('send typing', data)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.hubConnection.invoke("Typing", {userName: data.UserName, roomId: data.roomId, requestId} as any)
|
this.hubConnection.invoke("Typing", {
|
||||||
|
userName: data.UserName,
|
||||||
|
roomId: data.roomId,
|
||||||
|
userId: data.userId +'',
|
||||||
|
requestId
|
||||||
|
} as any)
|
||||||
|
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import { metrics } from '@opentelemetry/api';
|
import { metrics } from '@opentelemetry/api';
|
||||||
import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http';
|
import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http';
|
||||||
import { MeterProvider, PeriodicExportingMetricReader } from '@opentelemetry/sdk-metrics';
|
import { MeterProvider, PeriodicExportingMetricReader } from '@opentelemetry/sdk-metrics';
|
||||||
|
import { Subject } from 'rxjs';
|
||||||
|
import { throttleTime } from 'rxjs/operators';
|
||||||
import { environment } from 'src/environments/environment';
|
import { environment } from 'src/environments/environment';
|
||||||
|
|
||||||
// Initialize OpenTelemetry metrics
|
// Initialize OpenTelemetry metrics
|
||||||
@@ -10,15 +12,28 @@ metrics.setGlobalMeterProvider(meterProvider);
|
|||||||
if (window.location.protocol !== 'https:' && environment.apiURL != 'https://gdqas-api.oapr.gov.ao/api/') {
|
if (window.location.protocol !== 'https:' && environment.apiURL != 'https://gdqas-api.oapr.gov.ao/api/') {
|
||||||
const metricReader = new PeriodicExportingMetricReader({
|
const metricReader = new PeriodicExportingMetricReader({
|
||||||
exporter: new OTLPMetricExporter({
|
exporter: new OTLPMetricExporter({
|
||||||
url: 'http://5-180-182-151.cloud-xip.com:4318/v1/metrics',
|
url: 'https://5-180-182-151.cloud-xip.com:85/collector2/v1/metrics',
|
||||||
// headers: {
|
// headers: {
|
||||||
// 'Authorization': 'Basic ' + btoa('tabteste@006:tabteste@006'),
|
// 'Authorization': 'Basic ' + btoa('tabteste@006:tabteste@006'),
|
||||||
// }
|
// }
|
||||||
}),
|
}),
|
||||||
exportIntervalMillis: 3000,
|
exportIntervalMillis: 30000,
|
||||||
});
|
});
|
||||||
|
|
||||||
meterProvider.addMetricReader(metricReader);
|
meterProvider.addMetricReader(metricReader);
|
||||||
|
|
||||||
|
const subject = new Subject()
|
||||||
|
|
||||||
|
subject
|
||||||
|
.pipe(
|
||||||
|
throttleTime(5000) // 5000 milliseconds = 5 seconds
|
||||||
|
)
|
||||||
|
.subscribe(() => {
|
||||||
|
metricReader.forceFlush().then(() => {
|
||||||
|
console.log('Metrics exported');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
export const meter = meterProvider.getMeter('example-exporter-collector');
|
export const meter = meterProvider.getMeter('example-exporter-collector');
|
||||||
export const RequestCounter = meter.createCounter('post_requests', {
|
export const RequestCounter = meter.createCounter('post_requests', {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { WebTracerProvider } from '@opentelemetry/sdk-trace-web';
|
|||||||
import { ZipkinExporter } from '@opentelemetry/exporter-zipkin';
|
import { ZipkinExporter } from '@opentelemetry/exporter-zipkin';
|
||||||
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'
|
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'
|
||||||
import { Resource } from '@opentelemetry/resources';
|
import { Resource } from '@opentelemetry/resources';
|
||||||
|
import { OTLPTraceExporter } from '@opentelemetry/exporter-otlp-http';
|
||||||
import { context, trace, propagation } from '@opentelemetry/api';
|
import { context, trace, propagation } from '@opentelemetry/api';
|
||||||
|
|
||||||
function createProvider(serviceName) {
|
function createProvider(serviceName) {
|
||||||
@@ -35,7 +36,6 @@ export const OpentelemetryInterceptorProvider = createProvider('FO-interceptor')
|
|||||||
export const OpentelemetryPublicationProvider = createProvider('FO-publication-service');
|
export const OpentelemetryPublicationProvider = createProvider('FO-publication-service');
|
||||||
export const OpentelemetryLogging = createProvider('logging');
|
export const OpentelemetryLogging = createProvider('logging');
|
||||||
|
|
||||||
|
|
||||||
const tracerInstance = OpentelemetryAgendaProvider.getTracer('example-tracer-hole', '111', {})
|
const tracerInstance = OpentelemetryAgendaProvider.getTracer('example-tracer-hole', '111', {})
|
||||||
|
|
||||||
|
|
||||||
@@ -84,4 +84,4 @@ function childSpanExample(parentContext) {
|
|||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
parentSpanExample()
|
// parentSpanExample()
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ import { environment } from 'src/environments/environment';
|
|||||||
import { UseCaseCounter } from './matrix';
|
import { UseCaseCounter } from './matrix';
|
||||||
import { openTelemetryLogging } from './logging';
|
import { openTelemetryLogging } from './logging';
|
||||||
// import { context, propagation } from '@opentelemetry/api';
|
// import { context, propagation } from '@opentelemetry/api';
|
||||||
|
import {
|
||||||
|
SpanStatus, SpanStatusCode
|
||||||
|
} from '@opentelemetry/api';
|
||||||
const tracerInstance = OpentelemetryAgendaProvider.getTracer('example-tracer-hole', '111', {})
|
const tracerInstance = OpentelemetryAgendaProvider.getTracer('example-tracer-hole', '111', {})
|
||||||
const tracerNotificationInstance = OpentelemetryNotificationProvider.getTracer('example-tracer-hole', '111', {})
|
const tracerNotificationInstance = OpentelemetryNotificationProvider.getTracer('example-tracer-hole', '111', {})
|
||||||
// const logger: ILoggerAdapter = new ColoredLoggerService()
|
// const logger: ILoggerAdapter = new ColoredLoggerService()
|
||||||
@@ -53,15 +55,16 @@ const createTracingInstance = ({bugPrint, name, module, autoFinish}): TracingTyp
|
|||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
event: {},
|
event: {},
|
||||||
tags: {}
|
tags: {},
|
||||||
|
status: {} as any,
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
const returnObject = {
|
||||||
span: span as any,
|
span: span as any,
|
||||||
tracer: tracerInstance,
|
tracer: tracerInstance,
|
||||||
tracerId: requestId,
|
tracerId: requestId,
|
||||||
attributes: SemanticAttributes,
|
attributes: SemanticAttributes,
|
||||||
setStatus: (status: any) => {
|
setStatus: (status: SpanStatus) => {
|
||||||
span.setStatus(status);
|
span.setStatus(status);
|
||||||
},
|
},
|
||||||
addEvent: (context: string, message?: any, obj?: any) => {
|
addEvent: (context: string, message?: any, obj?: any) => {
|
||||||
@@ -79,7 +82,7 @@ const createTracingInstance = ({bugPrint, name, module, autoFinish}): TracingTyp
|
|||||||
span.setAttribute(key, value);
|
span.setAttribute(key, value);
|
||||||
|
|
||||||
if(key =='outcome' && value == 'failed') {
|
if(key =='outcome' && value == 'failed') {
|
||||||
span.setAttribute('error', 'true')
|
returnObject.hasError('error')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
log(message: string, data: Object) {
|
log(message: string, data: Object) {
|
||||||
@@ -110,18 +113,25 @@ const createTracingInstance = ({bugPrint, name, module, autoFinish}): TracingTyp
|
|||||||
finish: () => {
|
finish: () => {
|
||||||
if(environment.apiURL != 'https://gdqas-api.oapr.gov.ao/api/') {
|
if(environment.apiURL != 'https://gdqas-api.oapr.gov.ao/api/') {
|
||||||
span.end();
|
span.end();
|
||||||
UseCaseCounter.add(1, {user: SessionStore?.user?.FullName, outcome:data.tags['outcome'], usecase: name})
|
UseCaseCounter.add(1, {user: SessionStore?.user?.FullName, outcome:data.tags['outcome'] || data.status?.code , usecase: name})
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bugPrint && data.tags['outcome'] == 'failed') {
|
if(bugPrint && (data.tags['outcome'] == 'failed' || data.status?.code == SpanStatusCode.ERROR)) {
|
||||||
console.error(name, data)
|
console.error(name, data)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
bugFlag:() => {},
|
hasError:(message: string) => {
|
||||||
|
if(data.status?.code != SpanStatusCode.ERROR) {
|
||||||
|
data.status = {code: SpanStatusCode.ERROR, message}
|
||||||
|
span.setStatus({code: SpanStatusCode.ERROR, message})
|
||||||
|
span.setAttribute('outcome','failed')
|
||||||
|
}
|
||||||
|
},
|
||||||
createSpan: (name, parent?: any) => {
|
createSpan: (name, parent?: any) => {
|
||||||
return tracerInstance.startSpan(name, { root: false }, parent) as Span;
|
return tracerInstance.startSpan(name, { root: false }, parent) as Span;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return returnObject
|
||||||
}
|
}
|
||||||
|
|
||||||
export function XTracerAsync({ name, bugPrint, module = null, autoFinish = true, daley =0 }) {
|
export function XTracerAsync({ name, bugPrint, module = null, autoFinish = true, daley =0 }) {
|
||||||
@@ -221,7 +231,7 @@ export type TracingType = {
|
|||||||
getAttribute: (key: string) => string;
|
getAttribute: (key: string) => string;
|
||||||
LocalLogEvent: (name: string, attributesOrStartTime: any, obj?:any) => void;
|
LocalLogEvent: (name: string, attributesOrStartTime: any, obj?:any) => void;
|
||||||
finish: () => void;
|
finish: () => void;
|
||||||
bugFlag:() => void;
|
hasError:(message: string) => void;
|
||||||
createSpan:(name, parent?: any) => Span;
|
createSpan:(name, parent?: any) => Span;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -153,6 +153,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges): void {
|
ngOnChanges(changes: SimpleChanges): void {
|
||||||
|
console.log('change ¬!!')
|
||||||
this.roomData$ = this.roomRepositoryService.getItemByIdLive(this.roomId)
|
this.roomData$ = this.roomRepositoryService.getItemByIdLive(this.roomId)
|
||||||
this.roomMessage$ = this.messageRepositoryService.getItemsLive(this.roomId)
|
this.roomMessage$ = this.messageRepositoryService.getItemsLive(this.roomId)
|
||||||
this.roomMembers$ = this.roomRepositoryService.getRoomMemberByIdLive(this.roomId) as any
|
this.roomMembers$ = this.roomRepositoryService.getRoomMemberByIdLive(this.roomId) as any
|
||||||
@@ -179,9 +180,10 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
this.scrollToBottomClicked()
|
this.scrollToBottomClicked()
|
||||||
}, 200)
|
}, 200)
|
||||||
|
|
||||||
this.messageRepositoryService.sendReadAt({roomId: this.roomId}).then((e) => {
|
console.log('new message==============')
|
||||||
console.log(e)
|
// this.messageRepositoryService.sendReadAt({roomId: this.roomId}).then((e) => {
|
||||||
})
|
// console.log(e)
|
||||||
|
// })
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user