Enhance eBay extension logging and account management features
- Added detailed logging for various actions in the background script and content script to improve debugging capabilities. - Updated the account management flow to include the last updated timestamp and sales data. - Refined the parsing logic to ensure accurate extraction of seller statistics from eBay profiles. - Improved error handling in the parsing process to provide more informative responses in case of failures.
This commit is contained in:
@@ -102,15 +102,14 @@ export const AccountsPage = () => {
|
||||
// Shop-Name und account_sells können auch leer sein (optional)
|
||||
updatePayload.account_shop_name = parsedData.shopName || null;
|
||||
updatePayload.account_sells = parsedData.stats?.itemsSold ?? null;
|
||||
|
||||
// #region agent log
|
||||
fetch('http://127.0.0.1:7242/ingest/246fe132-ecc5-435f-bd9c-fe5e8e26089d',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'AccountsPage.jsx:93',message:'handleRefreshAccount: update payload',data:{payload:updatePayload},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'A'})}).catch(()=>{});
|
||||
// #endregion
|
||||
|
||||
// account_status wird weggelassen (wie beim Erstellen)
|
||||
// Grund: Schema-Konflikt - Enum-Feld akzeptiert weder String noch Array im Update
|
||||
// TODO: Schema in Appwrite prüfen und korrigieren, dann account_status wieder hinzufügen
|
||||
|
||||
// Setze account_updated_at auf aktuelle Zeit
|
||||
updatePayload.account_updated_at = new Date().toISOString();
|
||||
|
||||
await updateManagedAccount(accountId, updatePayload);
|
||||
|
||||
// Accounts-Liste neu laden (in-place Update)
|
||||
@@ -206,9 +205,6 @@ export const AccountsPage = () => {
|
||||
|
||||
// Payload aus parsedData zusammenstellen
|
||||
const accountSellsValue = parsedData.stats?.itemsSold ?? null;
|
||||
// #region agent log
|
||||
fetch('http://127.0.0.1:7242/ingest/246fe132-ecc5-435f-bd9c-fe5e8e26089d',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'AccountsPage.jsx:193',message:'handleFormSubmit: parsedData before save',data:{hasStats:!!parsedData.stats,itemsSold:parsedData.stats?.itemsSold,accountSellsValue},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});
|
||||
// #endregion
|
||||
const newAccount = await createManagedAccount(authUser.$id, {
|
||||
account_url: formData.account_url.trim(),
|
||||
account_platform_account_id: parsedData.sellerId,
|
||||
@@ -247,7 +243,7 @@ export const AccountsPage = () => {
|
||||
"Platform Account ID",
|
||||
"Market",
|
||||
"Account URL",
|
||||
"Status",
|
||||
"Sales",
|
||||
"Last Scan",
|
||||
...(showAdvanced ? ["Owner User ID"] : []),
|
||||
"Action",
|
||||
@@ -310,12 +306,15 @@ export const AccountsPage = () => {
|
||||
);
|
||||
}
|
||||
|
||||
if (col === "Status") {
|
||||
return row.account_status || "-";
|
||||
if (col === "Sales") {
|
||||
const sales = row.account_sells;
|
||||
if (sales === null || sales === undefined) return "-";
|
||||
// Format number with thousand separators
|
||||
return new Intl.NumberFormat("de-DE").format(sales);
|
||||
}
|
||||
|
||||
if (col === "Last Scan") {
|
||||
const lastScan = row.account_last_scan_at;
|
||||
const lastScan = row.account_updated_at;
|
||||
if (!lastScan) return "-";
|
||||
try {
|
||||
const date = new Date(lastScan);
|
||||
@@ -400,9 +399,9 @@ export const AccountsPage = () => {
|
||||
</div>
|
||||
<div>
|
||||
<span className="font-medium text-[var(--text)]">
|
||||
Status (Auto)
|
||||
Sales (Auto)
|
||||
</span>
|
||||
: Wird automatisch auf "active" gesetzt. Du musst nichts eingeben.
|
||||
: Anzahl der verkauften Artikel wird automatisch aus dem eBay-Profil gelesen.
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-4 rounded-lg border border-[var(--line)] bg-white/2 p-3 text-xs text-[var(--muted)]">
|
||||
@@ -602,16 +601,16 @@ export const AccountsPage = () => {
|
||||
|
||||
<div>
|
||||
<label className="mb-1.5 block text-xs font-medium text-[var(--muted)]">
|
||||
Status (Auto)
|
||||
Sales (Auto)
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
value={parsedData.status}
|
||||
value={parsedData.stats?.itemsSold ? new Intl.NumberFormat("de-DE").format(parsedData.stats.itemsSold) : "-"}
|
||||
readOnly
|
||||
className="w-full rounded-lg border border-neutral-200 bg-white px-3 py-2 text-sm text-[var(--text)] opacity-75 dark:bg-neutral-900 dark:border-neutral-700"
|
||||
/>
|
||||
<p className="mt-1 text-xs text-[var(--muted)]">
|
||||
Interner Status. Normalerweise "active".
|
||||
Gesamtzahl der verkauften Artikel.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -163,6 +163,10 @@ async function getExtensionId() {
|
||||
* @throws {Error} - "Extension not available" oder andere Fehler
|
||||
*/
|
||||
async function parseViaExtension(url) {
|
||||
// #region agent log
|
||||
fetch('http://127.0.0.1:7242/ingest/246fe132-ecc5-435f-bd9c-fe5e8e26089d',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'ebayParserService.js:165',message:'parseViaExtension: entry',data:{url,hasChrome:typeof chrome!=='undefined',hasRuntime:typeof chrome!=='undefined'&&!!chrome.runtime},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});
|
||||
// #endregion
|
||||
|
||||
// Validierung
|
||||
if (!url || typeof url !== 'string') {
|
||||
throw new Error("Invalid URL");
|
||||
@@ -174,6 +178,10 @@ async function parseViaExtension(url) {
|
||||
try {
|
||||
const extensionId = await getExtensionId();
|
||||
|
||||
// #region agent log
|
||||
fetch('http://127.0.0.1:7242/ingest/246fe132-ecc5-435f-bd9c-fe5e8e26089d',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'ebayParserService.js:175',message:'parseViaExtension: got extension ID',data:{extensionId,url},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});
|
||||
// #endregion
|
||||
|
||||
// Versuche chrome.runtime.sendMessage (mit oder ohne Extension-ID)
|
||||
return new Promise((resolve, reject) => {
|
||||
const message = {
|
||||
@@ -181,6 +189,10 @@ async function parseViaExtension(url) {
|
||||
url: url
|
||||
};
|
||||
|
||||
// #region agent log
|
||||
fetch('http://127.0.0.1:7242/ingest/246fe132-ecc5-435f-bd9c-fe5e8e26089d',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'ebayParserService.js:178',message:'parseViaExtension: sending message',data:{extensionId,url},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});
|
||||
// #endregion
|
||||
|
||||
// SendMessage-Callback
|
||||
const sendMessageCallback = (response) => {
|
||||
// Check for Chrome runtime errors
|
||||
@@ -203,10 +215,13 @@ async function parseViaExtension(url) {
|
||||
stats: response.data.stats || {}
|
||||
};
|
||||
// #region agent log
|
||||
fetch('http://127.0.0.1:7242/ingest/246fe132-ecc5-435f-bd9c-fe5e8e26089d',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'ebayParserService.js:160',message:'parseViaExtension: response data from extension',data:{hasStats:!!response.data.stats,itemsSold:response.data.stats?.itemsSold,stats:response.data.stats},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});
|
||||
fetch('http://127.0.0.1:7242/ingest/246fe132-ecc5-435f-bd9c-fe5e8e26089d',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'ebayParserService.js:196',message:'parseViaExtension: response success',data:{hasStats:!!response.data.stats,itemsSold:response.data.stats?.itemsSold,stats:response.data.stats},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});
|
||||
// #endregion
|
||||
resolve(data);
|
||||
} else {
|
||||
// #region agent log
|
||||
fetch('http://127.0.0.1:7242/ingest/246fe132-ecc5-435f-bd9c-fe5e8e26089d',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'ebayParserService.js:210',message:'parseViaExtension: response failed',data:{error:response?.error,hasResponse:!!response,ok:response?.ok},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});
|
||||
// #endregion
|
||||
reject(new Error(response?.error || "Extension parsing failed"));
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user