XWX-AI Claude Opus 4.6 commited on
Commit
b4075c9
·
1 Parent(s): b89c431

feat: add messageCount parameter to PDF generation logging

Browse files

Logs total message count (user + AI) sent from plugin for telemetry.
Backward compatible with old plugin versions that don't send this field.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. server.js +4 -4
server.js CHANGED
@@ -132,7 +132,7 @@ app.get('/', (req, res) => {
132
  app.post('/api/generate_pdf', async (req, res) => {
133
  const startTime = Date.now();
134
  const envText = isTest ? '【测试环境】' : '【生产环境】';
135
- const { platform, exportCount, language, exportPdf, exportMd, exportTxt, exportDocx, exportJson, exportClipboard, exportNotion, extensionVersion, imageCount, totalImageSizeMB, isPro } = req.body;
136
 
137
  // PRO status with text emphasis (no ANSI colors for Docker compatibility)
138
  const userTag = isPro ? '★★★PRO★★★' : '◆FREE◆';
@@ -156,7 +156,7 @@ app.post('/api/generate_pdf', async (req, res) => {
156
  `---------------[PDF-GEN] ${envText} ${userTag} 收到请求 | 平台: ${platformStr} | 版本: ${versionStr} | 语言: ${langStr}`
157
  );
158
  console.log(
159
- ` 导出: ${exportCount ?? '-'}次 | 格式: ${fmtStr} | 图片: ${imageCount ?? '-'}张 (${totalImageSizeMB ?? '-'}MB)`
160
  );
161
  console.log(`---------------`);
162
 
@@ -164,7 +164,7 @@ app.post('/api/generate_pdf', async (req, res) => {
164
  let browser = null;
165
 
166
  try {
167
- const { html, showWatermark, imageCount, totalImageSizeMB, codeTheme, textOnlySizeMB } = req.body;
168
  if (!html) {
169
  return res.status(400).json({ error: 'Missing html content' });
170
  }
@@ -199,7 +199,7 @@ app.post('/api/generate_pdf', async (req, res) => {
199
  // 如果前端未提供(旧版本插件),回退到总大小(向后兼容)
200
  const effectiveSizeMB = textOnlySizeMB != null ? textOnlySizeMB : htmlSizeMBNum;
201
 
202
- console.log(`[PDF-GEN] [${getElapsed()}] 解析请求完成: HTML ${htmlSizeMB} MB (纯文本=${effectiveSizeMB.toFixed(2)} MB), 图片 ${imgCount} 张 (${imgSizeMB} MB)`);
203
 
204
  // HTML 大小硬性上限:超过 10 MB 时 Chromium PDF 引擎会崩溃
205
  // 使用纯文本大小判断(扣除 base64 图片),与前端保持一致
 
132
  app.post('/api/generate_pdf', async (req, res) => {
133
  const startTime = Date.now();
134
  const envText = isTest ? '【测试环境】' : '【生产环境】';
135
+ const { platform, exportCount, language, exportPdf, exportMd, exportTxt, exportDocx, exportJson, exportClipboard, exportNotion, extensionVersion, imageCount, totalImageSizeMB, messageCount, isPro } = req.body;
136
 
137
  // PRO status with text emphasis (no ANSI colors for Docker compatibility)
138
  const userTag = isPro ? '★★★PRO★★★' : '◆FREE◆';
 
156
  `---------------[PDF-GEN] ${envText} ${userTag} 收到请求 | 平台: ${platformStr} | 版本: ${versionStr} | 语言: ${langStr}`
157
  );
158
  console.log(
159
+ ` 导出: ${exportCount ?? '-'}次 | 格式: ${fmtStr} | 消息: ${messageCount ?? '-'}条 | 图片: ${imageCount ?? '-'}张 (${totalImageSizeMB ?? '-'}MB)`
160
  );
161
  console.log(`---------------`);
162
 
 
164
  let browser = null;
165
 
166
  try {
167
+ const { html, showWatermark, imageCount, totalImageSizeMB, messageCount, codeTheme, textOnlySizeMB } = req.body;
168
  if (!html) {
169
  return res.status(400).json({ error: 'Missing html content' });
170
  }
 
199
  // 如果前端未提供(旧版本插件),回退到总大小(向后兼容)
200
  const effectiveSizeMB = textOnlySizeMB != null ? textOnlySizeMB : htmlSizeMBNum;
201
 
202
+ console.log(`[PDF-GEN] [${getElapsed()}] 解析请求完成: HTML ${htmlSizeMB} MB (纯文本=${effectiveSizeMB.toFixed(2)} MB), 消息 ${messageCount || 0} 条, 图片 ${imgCount} 张 (${imgSizeMB} MB)`);
203
 
204
  // HTML 大小硬性上限:超过 10 MB 时 Chromium PDF 引擎会崩溃
205
  // 使用纯文本大小判断(扣除 base64 图片),与前端保持一致