From ac49ce3cc56b5c8602e5d22e9fd3a4fcf4fdab05 Mon Sep 17 00:00:00 2001 From: devlikepro Date: Wed, 2 Jul 2025 14:16:40 +0700 Subject: [PATCH] [core] trace --- src/api/server.debug.controller.ts | 10 +++++----- src/core/abc/session.abc.ts | 4 ++-- src/core/engines/webjs/session.webjs.core.ts | 6 +++--- src/structures/server.debug.dto.ts | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/api/server.debug.controller.ts b/src/api/server.debug.controller.ts index 0679bc61..fde6429e 100644 --- a/src/api/server.debug.controller.ts +++ b/src/api/server.debug.controller.ts @@ -18,7 +18,7 @@ import { WorkingSessionParam, } from '@waha/nestjs/params/SessionApiParam'; import { WAHAValidationPipe } from '@waha/nestjs/pipes/WAHAValidationPipe'; -import { BrowserTracingQuery } from '@waha/structures/server.debug.dto'; +import { BrowserTraceQuery } from '@waha/structures/server.debug.dto'; import { createReadStream } from 'fs'; @ApiSecurity('api_key') @@ -54,21 +54,21 @@ export class ServerDebugController { }); } - @Get('browser/tracing/:session') + @Get('browser/trace/:session') @ApiOperation({ summary: 'Collect and get a trace.json for Chrome DevTools ', description: 'Uses https://pptr.dev/api/puppeteer.tracing', }) @SessionApiParam @UsePipes(new WAHAValidationPipe()) - async browserTracing( + async browserTrace( @WorkingSessionParam session: WhatsappSession, - @Query() query: BrowserTracingQuery, + @Query() query: BrowserTraceQuery, ) { if (!this.enabled) { throw new NotFoundException('WAHA_DEBUG_MODE is disabled'); } - const filepath = await session.browserTracing(query); + const filepath = await session.browserTrace(query); const stream = createReadStream(filepath); const filename = `trace - ${session.name} - ${new Date()}.json`; return new StreamableFile(stream, { diff --git a/src/core/abc/session.abc.ts b/src/core/abc/session.abc.ts index cfb4e3f5..578f39cd 100644 --- a/src/core/abc/session.abc.ts +++ b/src/core/abc/session.abc.ts @@ -30,7 +30,7 @@ import { Label, LabelDTO, LabelID } from '@waha/structures/labels.dto'; import { LidToPhoneNumber } from '@waha/structures/lids.dto'; import { PaginationParams } from '@waha/structures/pagination.dto'; import { MessageSource, WAMessage } from '@waha/structures/responses.dto'; -import { BrowserTracingQuery } from '@waha/structures/server.debug.dto'; +import { BrowserTraceQuery } from '@waha/structures/server.debug.dto'; import { DefaultMap } from '@waha/utils/DefaultMap'; import { generatePrefixedId } from '@waha/utils/ids'; import { LoggerBuilder } from '@waha/utils/logging'; @@ -350,7 +350,7 @@ export abstract class WhatsappSession { * START - Methods for API */ - public browserTracing(query: BrowserTracingQuery): Promise { + public browserTrace(query: BrowserTraceQuery): Promise { throw new NotImplementedByEngineError(); } diff --git a/src/core/engines/webjs/session.webjs.core.ts b/src/core/engines/webjs/session.webjs.core.ts index 9af7c8f5..dca521da 100644 --- a/src/core/engines/webjs/session.webjs.core.ts +++ b/src/core/engines/webjs/session.webjs.core.ts @@ -106,7 +106,7 @@ import { WAHAPresenceData, } from '@waha/structures/presence.dto'; import { WAMessage, WAMessageReaction } from '@waha/structures/responses.dto'; -import { BrowserTracingQuery } from '@waha/structures/server.debug.dto'; +import { BrowserTraceQuery } from '@waha/structures/server.debug.dto'; import { MeInfo } from '@waha/structures/sessions.dto'; import { StatusRequest, TextStatus } from '@waha/structures/status.dto'; import { @@ -522,10 +522,10 @@ export class WhatsappSessionWebJSCore extends WhatsappSession { /** * START - Methods for API */ - public async browserTracing(query: BrowserTracingQuery): Promise { + public async browserTrace(query: BrowserTraceQuery): Promise { const tmpdir = new TmpDir( this.logger, - `waha-browser-tracing-${this.name}`, + `waha-browser-trace-${this.name}`, (10 * query.seconds + 120) * 1000, ); const page = this.whatsapp.pupPage; diff --git a/src/structures/server.debug.dto.ts b/src/structures/server.debug.dto.ts index ac847e7a..628cb340 100644 --- a/src/structures/server.debug.dto.ts +++ b/src/structures/server.debug.dto.ts @@ -2,7 +2,7 @@ import { ApiProperty } from '@nestjs/swagger'; import { Transform, Type } from 'class-transformer'; import { IsArray, IsNumber, IsOptional, IsString } from 'class-validator'; -export class BrowserTracingQuery { +export class BrowserTraceQuery { @Type(() => Number) @IsNumber() @ApiProperty({